PostgreSQL Source Code  git master
int8.c File Reference
#include "postgres.h"
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include "common/int.h"
#include "funcapi.h"
#include "libpq/pqformat.h"
#include "nodes/nodeFuncs.h"
#include "nodes/supportnodes.h"
#include "optimizer/optimizer.h"
#include "utils/builtins.h"
Include dependency graph for int8.c:

Go to the source code of this file.

Data Structures

struct  generate_series_fctx
 

Functions

Datum int8in (PG_FUNCTION_ARGS)
 
Datum int8out (PG_FUNCTION_ARGS)
 
Datum int8recv (PG_FUNCTION_ARGS)
 
Datum int8send (PG_FUNCTION_ARGS)
 
Datum int8eq (PG_FUNCTION_ARGS)
 
Datum int8ne (PG_FUNCTION_ARGS)
 
Datum int8lt (PG_FUNCTION_ARGS)
 
Datum int8gt (PG_FUNCTION_ARGS)
 
Datum int8le (PG_FUNCTION_ARGS)
 
Datum int8ge (PG_FUNCTION_ARGS)
 
Datum int84eq (PG_FUNCTION_ARGS)
 
Datum int84ne (PG_FUNCTION_ARGS)
 
Datum int84lt (PG_FUNCTION_ARGS)
 
Datum int84gt (PG_FUNCTION_ARGS)
 
Datum int84le (PG_FUNCTION_ARGS)
 
Datum int84ge (PG_FUNCTION_ARGS)
 
Datum int48eq (PG_FUNCTION_ARGS)
 
Datum int48ne (PG_FUNCTION_ARGS)
 
Datum int48lt (PG_FUNCTION_ARGS)
 
Datum int48gt (PG_FUNCTION_ARGS)
 
Datum int48le (PG_FUNCTION_ARGS)
 
Datum int48ge (PG_FUNCTION_ARGS)
 
Datum int82eq (PG_FUNCTION_ARGS)
 
Datum int82ne (PG_FUNCTION_ARGS)
 
Datum int82lt (PG_FUNCTION_ARGS)
 
Datum int82gt (PG_FUNCTION_ARGS)
 
Datum int82le (PG_FUNCTION_ARGS)
 
Datum int82ge (PG_FUNCTION_ARGS)
 
Datum int28eq (PG_FUNCTION_ARGS)
 
Datum int28ne (PG_FUNCTION_ARGS)
 
Datum int28lt (PG_FUNCTION_ARGS)
 
Datum int28gt (PG_FUNCTION_ARGS)
 
Datum int28le (PG_FUNCTION_ARGS)
 
Datum int28ge (PG_FUNCTION_ARGS)
 
Datum in_range_int8_int8 (PG_FUNCTION_ARGS)
 
Datum int8um (PG_FUNCTION_ARGS)
 
Datum int8up (PG_FUNCTION_ARGS)
 
Datum int8pl (PG_FUNCTION_ARGS)
 
Datum int8mi (PG_FUNCTION_ARGS)
 
Datum int8mul (PG_FUNCTION_ARGS)
 
Datum int8div (PG_FUNCTION_ARGS)
 
Datum int8abs (PG_FUNCTION_ARGS)
 
Datum int8mod (PG_FUNCTION_ARGS)
 
static int64 int8gcd_internal (int64 arg1, int64 arg2)
 
Datum int8gcd (PG_FUNCTION_ARGS)
 
Datum int8lcm (PG_FUNCTION_ARGS)
 
Datum int8inc (PG_FUNCTION_ARGS)
 
Datum int8dec (PG_FUNCTION_ARGS)
 
Datum int8inc_any (PG_FUNCTION_ARGS)
 
Datum int8inc_float8_float8 (PG_FUNCTION_ARGS)
 
Datum int8dec_any (PG_FUNCTION_ARGS)
 
Datum int8inc_support (PG_FUNCTION_ARGS)
 
Datum int8larger (PG_FUNCTION_ARGS)
 
Datum int8smaller (PG_FUNCTION_ARGS)
 
Datum int84pl (PG_FUNCTION_ARGS)
 
Datum int84mi (PG_FUNCTION_ARGS)
 
Datum int84mul (PG_FUNCTION_ARGS)
 
Datum int84div (PG_FUNCTION_ARGS)
 
Datum int48pl (PG_FUNCTION_ARGS)
 
Datum int48mi (PG_FUNCTION_ARGS)
 
Datum int48mul (PG_FUNCTION_ARGS)
 
Datum int48div (PG_FUNCTION_ARGS)
 
Datum int82pl (PG_FUNCTION_ARGS)
 
Datum int82mi (PG_FUNCTION_ARGS)
 
Datum int82mul (PG_FUNCTION_ARGS)
 
Datum int82div (PG_FUNCTION_ARGS)
 
Datum int28pl (PG_FUNCTION_ARGS)
 
Datum int28mi (PG_FUNCTION_ARGS)
 
Datum int28mul (PG_FUNCTION_ARGS)
 
Datum int28div (PG_FUNCTION_ARGS)
 
Datum int8and (PG_FUNCTION_ARGS)
 
Datum int8or (PG_FUNCTION_ARGS)
 
Datum int8xor (PG_FUNCTION_ARGS)
 
Datum int8not (PG_FUNCTION_ARGS)
 
Datum int8shl (PG_FUNCTION_ARGS)
 
Datum int8shr (PG_FUNCTION_ARGS)
 
Datum int48 (PG_FUNCTION_ARGS)
 
Datum int84 (PG_FUNCTION_ARGS)
 
Datum int28 (PG_FUNCTION_ARGS)
 
Datum int82 (PG_FUNCTION_ARGS)
 
Datum i8tod (PG_FUNCTION_ARGS)
 
Datum dtoi8 (PG_FUNCTION_ARGS)
 
Datum i8tof (PG_FUNCTION_ARGS)
 
Datum ftoi8 (PG_FUNCTION_ARGS)
 
Datum i8tooid (PG_FUNCTION_ARGS)
 
Datum oidtoi8 (PG_FUNCTION_ARGS)
 
Datum generate_series_int8 (PG_FUNCTION_ARGS)
 
Datum generate_series_step_int8 (PG_FUNCTION_ARGS)
 
Datum generate_series_int8_support (PG_FUNCTION_ARGS)
 

Function Documentation

◆ dtoi8()

Datum dtoi8 ( PG_FUNCTION_ARGS  )

Definition at line 1297 of file int8.c.

1298 {
1299  float8 num = PG_GETARG_FLOAT8(0);
1300 
1301  /*
1302  * Get rid of any fractional part in the input. This is so we don't fail
1303  * on just-out-of-range values that would round into range. Note
1304  * assumption that rint() will pass through a NaN or Inf unchanged.
1305  */
1306  num = rint(num);
1307 
1308  /* Range check */
1309  if (unlikely(isnan(num) || !FLOAT8_FITS_IN_INT64(num)))
1310  ereport(ERROR,
1311  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1312  errmsg("bigint out of range")));
1313 
1314  PG_RETURN_INT64((int64) num);
1315 }
int64_t int64
Definition: c.h:482
double float8
Definition: c.h:584
#define FLOAT8_FITS_IN_INT64(num)
Definition: c.h:1046
#define unlikely(x)
Definition: c.h:330
int errcode(int sqlerrcode)
Definition: elog.c:853
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
#define PG_GETARG_FLOAT8(n)
Definition: fmgr.h:282
#define PG_RETURN_INT64(x)
Definition: fmgr.h:368

References ereport, errcode(), errmsg(), ERROR, FLOAT8_FITS_IN_INT64, PG_GETARG_FLOAT8, PG_RETURN_INT64, and unlikely.

Referenced by int8_to_char().

◆ ftoi8()

Datum ftoi8 ( PG_FUNCTION_ARGS  )

Definition at line 1332 of file int8.c.

1333 {
1334  float4 num = PG_GETARG_FLOAT4(0);
1335 
1336  /*
1337  * Get rid of any fractional part in the input. This is so we don't fail
1338  * on just-out-of-range values that would round into range. Note
1339  * assumption that rint() will pass through a NaN or Inf unchanged.
1340  */
1341  num = rint(num);
1342 
1343  /* Range check */
1344  if (unlikely(isnan(num) || !FLOAT4_FITS_IN_INT64(num)))
1345  ereport(ERROR,
1346  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1347  errmsg("bigint out of range")));
1348 
1349  PG_RETURN_INT64((int64) num);
1350 }
#define FLOAT4_FITS_IN_INT64(num)
Definition: c.h:1040
float float4
Definition: c.h:583
#define PG_GETARG_FLOAT4(n)
Definition: fmgr.h:281

References ereport, errcode(), errmsg(), ERROR, FLOAT4_FITS_IN_INT64, PG_GETARG_FLOAT4, PG_RETURN_INT64, and unlikely.

◆ generate_series_int8()

Datum generate_series_int8 ( PG_FUNCTION_ARGS  )

Definition at line 1377 of file int8.c.

1378 {
1379  return generate_series_step_int8(fcinfo);
1380 }
Datum generate_series_step_int8(PG_FUNCTION_ARGS)
Definition: int8.c:1383

References generate_series_step_int8().

◆ generate_series_int8_support()

Datum generate_series_int8_support ( PG_FUNCTION_ARGS  )

Definition at line 1459 of file int8.c.

1460 {
1461  Node *rawreq = (Node *) PG_GETARG_POINTER(0);
1462  Node *ret = NULL;
1463 
1464  if (IsA(rawreq, SupportRequestRows))
1465  {
1466  /* Try to estimate the number of rows returned */
1467  SupportRequestRows *req = (SupportRequestRows *) rawreq;
1468 
1469  if (is_funcclause(req->node)) /* be paranoid */
1470  {
1471  List *args = ((FuncExpr *) req->node)->args;
1472  Node *arg1,
1473  *arg2,
1474  *arg3;
1475 
1476  /* We can use estimated argument values here */
1478  arg2 = estimate_expression_value(req->root, lsecond(args));
1479  if (list_length(args) >= 3)
1480  arg3 = estimate_expression_value(req->root, lthird(args));
1481  else
1482  arg3 = NULL;
1483 
1484  /*
1485  * If any argument is constant NULL, we can safely assume that
1486  * zero rows are returned. Otherwise, if they're all non-NULL
1487  * constants, we can calculate the number of rows that will be
1488  * returned. Use double arithmetic to avoid overflow hazards.
1489  */
1490  if ((IsA(arg1, Const) &&
1491  ((Const *) arg1)->constisnull) ||
1492  (IsA(arg2, Const) &&
1493  ((Const *) arg2)->constisnull) ||
1494  (arg3 != NULL && IsA(arg3, Const) &&
1495  ((Const *) arg3)->constisnull))
1496  {
1497  req->rows = 0;
1498  ret = (Node *) req;
1499  }
1500  else if (IsA(arg1, Const) &&
1501  IsA(arg2, Const) &&
1502  (arg3 == NULL || IsA(arg3, Const)))
1503  {
1504  double start,
1505  finish,
1506  step;
1507 
1508  start = DatumGetInt64(((Const *) arg1)->constvalue);
1509  finish = DatumGetInt64(((Const *) arg2)->constvalue);
1510  step = arg3 ? DatumGetInt64(((Const *) arg3)->constvalue) : 1;
1511 
1512  /* This equation works for either sign of step */
1513  if (step != 0)
1514  {
1515  req->rows = floor((finish - start + step) / step);
1516  ret = (Node *) req;
1517  }
1518  }
1519  }
1520  }
1521 
1522  PG_RETURN_POINTER(ret);
1523 }
Node * estimate_expression_value(PlannerInfo *root, Node *node)
Definition: clauses.c:2394
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:276
#define PG_RETURN_POINTER(x)
Definition: fmgr.h:361
return str start
static bool is_funcclause(const void *clause)
Definition: nodeFuncs.h:69
#define IsA(nodeptr, _type_)
Definition: nodes.h:158
static int list_length(const List *l)
Definition: pg_list.h:152
#define lthird(l)
Definition: pg_list.h:188
#define linitial(l)
Definition: pg_list.h:178
#define lsecond(l)
Definition: pg_list.h:183
static int64 DatumGetInt64(Datum X)
Definition: postgres.h:385
Definition: pg_list.h:54
Definition: nodes.h:129
struct PlannerInfo * root
Definition: supportnodes.h:163

References generate_unaccent_rules::args, DatumGetInt64(), estimate_expression_value(), is_funcclause(), IsA, linitial, list_length(), lsecond, lthird, SupportRequestRows::node, PG_GETARG_POINTER, PG_RETURN_POINTER, SupportRequestRows::root, SupportRequestRows::rows, and start.

◆ generate_series_step_int8()

Datum generate_series_step_int8 ( PG_FUNCTION_ARGS  )

Definition at line 1383 of file int8.c.

1384 {
1385  FuncCallContext *funcctx;
1386  generate_series_fctx *fctx;
1387  int64 result;
1388  MemoryContext oldcontext;
1389 
1390  /* stuff done only on the first call of the function */
1391  if (SRF_IS_FIRSTCALL())
1392  {
1394  int64 finish = PG_GETARG_INT64(1);
1395  int64 step = 1;
1396 
1397  /* see if we were given an explicit step size */
1398  if (PG_NARGS() == 3)
1399  step = PG_GETARG_INT64(2);
1400  if (step == 0)
1401  ereport(ERROR,
1402  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1403  errmsg("step size cannot equal zero")));
1404 
1405  /* create a function context for cross-call persistence */
1406  funcctx = SRF_FIRSTCALL_INIT();
1407 
1408  /*
1409  * switch to memory context appropriate for multiple function calls
1410  */
1411  oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
1412 
1413  /* allocate memory for user context */
1414  fctx = (generate_series_fctx *) palloc(sizeof(generate_series_fctx));
1415 
1416  /*
1417  * Use fctx to keep state from call to call. Seed current with the
1418  * original start value
1419  */
1420  fctx->current = start;
1421  fctx->finish = finish;
1422  fctx->step = step;
1423 
1424  funcctx->user_fctx = fctx;
1425  MemoryContextSwitchTo(oldcontext);
1426  }
1427 
1428  /* stuff done on every call of the function */
1429  funcctx = SRF_PERCALL_SETUP();
1430 
1431  /*
1432  * get the saved state and use current as the result for this iteration
1433  */
1434  fctx = funcctx->user_fctx;
1435  result = fctx->current;
1436 
1437  if ((fctx->step > 0 && fctx->current <= fctx->finish) ||
1438  (fctx->step < 0 && fctx->current >= fctx->finish))
1439  {
1440  /*
1441  * Increment current in preparation for next iteration. If next-value
1442  * computation overflows, this is the final result.
1443  */
1444  if (pg_add_s64_overflow(fctx->current, fctx->step, &fctx->current))
1445  fctx->step = 0;
1446 
1447  /* do when there is more left to send */
1448  SRF_RETURN_NEXT(funcctx, Int64GetDatum(result));
1449  }
1450  else
1451  /* do when there is no more left */
1452  SRF_RETURN_DONE(funcctx);
1453 }
Datum Int64GetDatum(int64 X)
Definition: fmgr.c:1807
#define PG_NARGS()
Definition: fmgr.h:203
#define PG_GETARG_INT64(n)
Definition: fmgr.h:283
#define SRF_IS_FIRSTCALL()
Definition: funcapi.h:304
#define SRF_PERCALL_SETUP()
Definition: funcapi.h:308
#define SRF_RETURN_NEXT(_funcctx, _result)
Definition: funcapi.h:310
#define SRF_FIRSTCALL_INIT()
Definition: funcapi.h:306
#define SRF_RETURN_DONE(_funcctx)
Definition: funcapi.h:328
static bool pg_add_s64_overflow(int64 a, int64 b, int64 *result)
Definition: int.h:203
void * palloc(Size size)
Definition: mcxt.c:1317
MemoryContextSwitchTo(old_ctx)
void * user_fctx
Definition: funcapi.h:82
MemoryContext multi_call_memory_ctx
Definition: funcapi.h:101
int32 current
Definition: int.c:49
int32 finish
Definition: int.c:50

References generate_series_fctx::current, ereport, errcode(), errmsg(), ERROR, generate_series_fctx::finish, Int64GetDatum(), MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, palloc(), pg_add_s64_overflow(), PG_GETARG_INT64, PG_NARGS, SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, start, generate_series_fctx::step, and FuncCallContext::user_fctx.

Referenced by generate_series_int8().

◆ i8tod()

Datum i8tod ( PG_FUNCTION_ARGS  )

Definition at line 1283 of file int8.c.

1284 {
1285  int64 arg = PG_GETARG_INT64(0);
1286  float8 result;
1287 
1288  result = arg;
1289 
1290  PG_RETURN_FLOAT8(result);
1291 }
#define PG_RETURN_FLOAT8(x)
Definition: fmgr.h:367
void * arg

References arg, PG_GETARG_INT64, and PG_RETURN_FLOAT8.

◆ i8tof()

Datum i8tof ( PG_FUNCTION_ARGS  )

Definition at line 1318 of file int8.c.

1319 {
1320  int64 arg = PG_GETARG_INT64(0);
1321  float4 result;
1322 
1323  result = arg;
1324 
1325  PG_RETURN_FLOAT4(result);
1326 }
#define PG_RETURN_FLOAT4(x)
Definition: fmgr.h:366

References arg, PG_GETARG_INT64, and PG_RETURN_FLOAT4.

◆ i8tooid()

Datum i8tooid ( PG_FUNCTION_ARGS  )

Definition at line 1353 of file int8.c.

1354 {
1355  int64 arg = PG_GETARG_INT64(0);
1356 
1357  if (unlikely(arg < 0) || unlikely(arg > PG_UINT32_MAX))
1358  ereport(ERROR,
1359  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1360  errmsg("OID out of range")));
1361 
1362  PG_RETURN_OID((Oid) arg);
1363 }
#define PG_UINT32_MAX
Definition: c.h:544
#define PG_RETURN_OID(x)
Definition: fmgr.h:360
unsigned int Oid
Definition: postgres_ext.h:31

References arg, ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT64, PG_RETURN_OID, PG_UINT32_MAX, and unlikely.

◆ in_range_int8_int8()

Datum in_range_int8_int8 ( PG_FUNCTION_ARGS  )

Definition at line 401 of file int8.c.

402 {
404  int64 base = PG_GETARG_INT64(1);
405  int64 offset = PG_GETARG_INT64(2);
406  bool sub = PG_GETARG_BOOL(3);
407  bool less = PG_GETARG_BOOL(4);
408  int64 sum;
409 
410  if (offset < 0)
411  ereport(ERROR,
412  (errcode(ERRCODE_INVALID_PRECEDING_OR_FOLLOWING_SIZE),
413  errmsg("invalid preceding or following size in window function")));
414 
415  if (sub)
416  offset = -offset; /* cannot overflow */
417 
418  if (unlikely(pg_add_s64_overflow(base, offset, &sum)))
419  {
420  /*
421  * If sub is false, the true sum is surely more than val, so correct
422  * answer is the same as "less". If sub is true, the true sum is
423  * surely less than val, so the answer is "!less".
424  */
425  PG_RETURN_BOOL(sub ? !less : less);
426  }
427 
428  if (less)
429  PG_RETURN_BOOL(val <= sum);
430  else
431  PG_RETURN_BOOL(val >= sum);
432 }
#define PG_GETARG_BOOL(n)
Definition: fmgr.h:274
#define PG_RETURN_BOOL(x)
Definition: fmgr.h:359
long val
Definition: informix.c:689

References ereport, errcode(), errmsg(), ERROR, pg_add_s64_overflow(), PG_GETARG_BOOL, PG_GETARG_INT64, PG_RETURN_BOOL, unlikely, and val.

◆ int28()

Datum int28 ( PG_FUNCTION_ARGS  )

Definition at line 1262 of file int8.c.

1263 {
1264  int16 arg = PG_GETARG_INT16(0);
1265 
1267 }
int16_t int16
Definition: c.h:480
#define PG_GETARG_INT16(n)
Definition: fmgr.h:271

References arg, PG_GETARG_INT16, and PG_RETURN_INT64.

◆ int28div()

Datum int28div ( PG_FUNCTION_ARGS  )

Definition at line 1155 of file int8.c.

1156 {
1157  int16 arg1 = PG_GETARG_INT16(0);
1158  int64 arg2 = PG_GETARG_INT64(1);
1159 
1160  if (unlikely(arg2 == 0))
1161  {
1162  ereport(ERROR,
1163  (errcode(ERRCODE_DIVISION_BY_ZERO),
1164  errmsg("division by zero")));
1165  /* ensure compiler realizes we mustn't reach the division (gcc bug) */
1166  PG_RETURN_NULL();
1167  }
1168 
1169  /* No overflow is possible */
1170  PG_RETURN_INT64((int64) arg1 / arg2);
1171 }
#define PG_RETURN_NULL()
Definition: fmgr.h:345

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT16, PG_GETARG_INT64, PG_RETURN_INT64, PG_RETURN_NULL, and unlikely.

◆ int28eq()

Datum int28eq ( PG_FUNCTION_ARGS  )

Definition at line 341 of file int8.c.

342 {
343  int16 val1 = PG_GETARG_INT16(0);
344  int64 val2 = PG_GETARG_INT64(1);
345 
346  PG_RETURN_BOOL(val1 == val2);
347 }

References PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int28ge()

Datum int28ge ( PG_FUNCTION_ARGS  )

Definition at line 386 of file int8.c.

387 {
388  int16 val1 = PG_GETARG_INT16(0);
389  int64 val2 = PG_GETARG_INT64(1);
390 
391  PG_RETURN_BOOL(val1 >= val2);
392 }

References PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int28gt()

Datum int28gt ( PG_FUNCTION_ARGS  )

Definition at line 368 of file int8.c.

369 {
370  int16 val1 = PG_GETARG_INT16(0);
371  int64 val2 = PG_GETARG_INT64(1);
372 
373  PG_RETURN_BOOL(val1 > val2);
374 }

References PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int28le()

Datum int28le ( PG_FUNCTION_ARGS  )

Definition at line 377 of file int8.c.

378 {
379  int16 val1 = PG_GETARG_INT16(0);
380  int64 val2 = PG_GETARG_INT64(1);
381 
382  PG_RETURN_BOOL(val1 <= val2);
383 }

References PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int28lt()

Datum int28lt ( PG_FUNCTION_ARGS  )

Definition at line 359 of file int8.c.

360 {
361  int16 val1 = PG_GETARG_INT16(0);
362  int64 val2 = PG_GETARG_INT64(1);
363 
364  PG_RETURN_BOOL(val1 < val2);
365 }

References PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int28mi()

Datum int28mi ( PG_FUNCTION_ARGS  )

Definition at line 1127 of file int8.c.

1128 {
1129  int16 arg1 = PG_GETARG_INT16(0);
1130  int64 arg2 = PG_GETARG_INT64(1);
1131  int64 result;
1132 
1133  if (unlikely(pg_sub_s64_overflow((int64) arg1, arg2, &result)))
1134  ereport(ERROR,
1135  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1136  errmsg("bigint out of range")));
1137  PG_RETURN_INT64(result);
1138 }
static bool pg_sub_s64_overflow(int64 a, int64 b, int64 *result)
Definition: int.h:230

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT16, PG_GETARG_INT64, PG_RETURN_INT64, pg_sub_s64_overflow(), and unlikely.

◆ int28mul()

Datum int28mul ( PG_FUNCTION_ARGS  )

Definition at line 1141 of file int8.c.

1142 {
1143  int16 arg1 = PG_GETARG_INT16(0);
1144  int64 arg2 = PG_GETARG_INT64(1);
1145  int64 result;
1146 
1147  if (unlikely(pg_mul_s64_overflow((int64) arg1, arg2, &result)))
1148  ereport(ERROR,
1149  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1150  errmsg("bigint out of range")));
1151  PG_RETURN_INT64(result);
1152 }
static bool pg_mul_s64_overflow(int64 a, int64 b, int64 *result)
Definition: int.h:261

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT16, PG_GETARG_INT64, pg_mul_s64_overflow(), PG_RETURN_INT64, and unlikely.

◆ int28ne()

Datum int28ne ( PG_FUNCTION_ARGS  )

Definition at line 350 of file int8.c.

351 {
352  int16 val1 = PG_GETARG_INT16(0);
353  int64 val2 = PG_GETARG_INT64(1);
354 
355  PG_RETURN_BOOL(val1 != val2);
356 }

References PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int28pl()

Datum int28pl ( PG_FUNCTION_ARGS  )

Definition at line 1113 of file int8.c.

1114 {
1115  int16 arg1 = PG_GETARG_INT16(0);
1116  int64 arg2 = PG_GETARG_INT64(1);
1117  int64 result;
1118 
1119  if (unlikely(pg_add_s64_overflow((int64) arg1, arg2, &result)))
1120  ereport(ERROR,
1121  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1122  errmsg("bigint out of range")));
1123  PG_RETURN_INT64(result);
1124 }

References ereport, errcode(), errmsg(), ERROR, pg_add_s64_overflow(), PG_GETARG_INT16, PG_GETARG_INT64, PG_RETURN_INT64, and unlikely.

◆ int48()

Datum int48 ( PG_FUNCTION_ARGS  )

Definition at line 1241 of file int8.c.

1242 {
1243  int32 arg = PG_GETARG_INT32(0);
1244 
1246 }
int32_t int32
Definition: c.h:481
#define PG_GETARG_INT32(n)
Definition: fmgr.h:269

References arg, PG_GETARG_INT32, and PG_RETURN_INT64.

◆ int48div()

Datum int48div ( PG_FUNCTION_ARGS  )

Definition at line 1013 of file int8.c.

1014 {
1015  int32 arg1 = PG_GETARG_INT32(0);
1016  int64 arg2 = PG_GETARG_INT64(1);
1017 
1018  if (unlikely(arg2 == 0))
1019  {
1020  ereport(ERROR,
1021  (errcode(ERRCODE_DIVISION_BY_ZERO),
1022  errmsg("division by zero")));
1023  /* ensure compiler realizes we mustn't reach the division (gcc bug) */
1024  PG_RETURN_NULL();
1025  }
1026 
1027  /* No overflow is possible */
1028  PG_RETURN_INT64((int64) arg1 / arg2);
1029 }

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT32, PG_GETARG_INT64, PG_RETURN_INT64, PG_RETURN_NULL, and unlikely.

◆ int48eq()

Datum int48eq ( PG_FUNCTION_ARGS  )

Definition at line 227 of file int8.c.

228 {
229  int32 val1 = PG_GETARG_INT32(0);
230  int64 val2 = PG_GETARG_INT64(1);
231 
232  PG_RETURN_BOOL(val1 == val2);
233 }

References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int48ge()

Datum int48ge ( PG_FUNCTION_ARGS  )

Definition at line 272 of file int8.c.

273 {
274  int32 val1 = PG_GETARG_INT32(0);
275  int64 val2 = PG_GETARG_INT64(1);
276 
277  PG_RETURN_BOOL(val1 >= val2);
278 }

References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int48gt()

Datum int48gt ( PG_FUNCTION_ARGS  )

Definition at line 254 of file int8.c.

255 {
256  int32 val1 = PG_GETARG_INT32(0);
257  int64 val2 = PG_GETARG_INT64(1);
258 
259  PG_RETURN_BOOL(val1 > val2);
260 }

References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int48le()

Datum int48le ( PG_FUNCTION_ARGS  )

Definition at line 263 of file int8.c.

264 {
265  int32 val1 = PG_GETARG_INT32(0);
266  int64 val2 = PG_GETARG_INT64(1);
267 
268  PG_RETURN_BOOL(val1 <= val2);
269 }

References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int48lt()

Datum int48lt ( PG_FUNCTION_ARGS  )

Definition at line 245 of file int8.c.

246 {
247  int32 val1 = PG_GETARG_INT32(0);
248  int64 val2 = PG_GETARG_INT64(1);
249 
250  PG_RETURN_BOOL(val1 < val2);
251 }

References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int48mi()

Datum int48mi ( PG_FUNCTION_ARGS  )

Definition at line 985 of file int8.c.

986 {
987  int32 arg1 = PG_GETARG_INT32(0);
988  int64 arg2 = PG_GETARG_INT64(1);
989  int64 result;
990 
991  if (unlikely(pg_sub_s64_overflow((int64) arg1, arg2, &result)))
992  ereport(ERROR,
993  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
994  errmsg("bigint out of range")));
995  PG_RETURN_INT64(result);
996 }

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT32, PG_GETARG_INT64, PG_RETURN_INT64, pg_sub_s64_overflow(), and unlikely.

◆ int48mul()

Datum int48mul ( PG_FUNCTION_ARGS  )

Definition at line 999 of file int8.c.

1000 {
1001  int32 arg1 = PG_GETARG_INT32(0);
1002  int64 arg2 = PG_GETARG_INT64(1);
1003  int64 result;
1004 
1005  if (unlikely(pg_mul_s64_overflow((int64) arg1, arg2, &result)))
1006  ereport(ERROR,
1007  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1008  errmsg("bigint out of range")));
1009  PG_RETURN_INT64(result);
1010 }

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT32, PG_GETARG_INT64, pg_mul_s64_overflow(), PG_RETURN_INT64, and unlikely.

◆ int48ne()

Datum int48ne ( PG_FUNCTION_ARGS  )

Definition at line 236 of file int8.c.

237 {
238  int32 val1 = PG_GETARG_INT32(0);
239  int64 val2 = PG_GETARG_INT64(1);
240 
241  PG_RETURN_BOOL(val1 != val2);
242 }

References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int48pl()

Datum int48pl ( PG_FUNCTION_ARGS  )

Definition at line 971 of file int8.c.

972 {
973  int32 arg1 = PG_GETARG_INT32(0);
974  int64 arg2 = PG_GETARG_INT64(1);
975  int64 result;
976 
977  if (unlikely(pg_add_s64_overflow((int64) arg1, arg2, &result)))
978  ereport(ERROR,
979  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
980  errmsg("bigint out of range")));
981  PG_RETURN_INT64(result);
982 }

References ereport, errcode(), errmsg(), ERROR, pg_add_s64_overflow(), PG_GETARG_INT32, PG_GETARG_INT64, PG_RETURN_INT64, and unlikely.

◆ int82()

Datum int82 ( PG_FUNCTION_ARGS  )

Definition at line 1270 of file int8.c.

1271 {
1272  int64 arg = PG_GETARG_INT64(0);
1273 
1275  ereport(ERROR,
1276  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1277  errmsg("smallint out of range")));
1278 
1280 }
#define PG_INT16_MIN
Definition: c.h:539
#define PG_INT16_MAX
Definition: c.h:540
#define PG_RETURN_INT16(x)
Definition: fmgr.h:356

References arg, ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT64, PG_INT16_MAX, PG_INT16_MIN, PG_RETURN_INT16, and unlikely.

◆ int82div()

Datum int82div ( PG_FUNCTION_ARGS  )

Definition at line 1074 of file int8.c.

1075 {
1076  int64 arg1 = PG_GETARG_INT64(0);
1077  int16 arg2 = PG_GETARG_INT16(1);
1078  int64 result;
1079 
1080  if (unlikely(arg2 == 0))
1081  {
1082  ereport(ERROR,
1083  (errcode(ERRCODE_DIVISION_BY_ZERO),
1084  errmsg("division by zero")));
1085  /* ensure compiler realizes we mustn't reach the division (gcc bug) */
1086  PG_RETURN_NULL();
1087  }
1088 
1089  /*
1090  * INT64_MIN / -1 is problematic, since the result can't be represented on
1091  * a two's-complement machine. Some machines produce INT64_MIN, some
1092  * produce zero, some throw an exception. We can dodge the problem by
1093  * recognizing that division by -1 is the same as negation.
1094  */
1095  if (arg2 == -1)
1096  {
1097  if (unlikely(arg1 == PG_INT64_MIN))
1098  ereport(ERROR,
1099  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1100  errmsg("bigint out of range")));
1101  result = -arg1;
1102  PG_RETURN_INT64(result);
1103  }
1104 
1105  /* No overflow is possible */
1106 
1107  result = arg1 / arg2;
1108 
1109  PG_RETURN_INT64(result);
1110 }
#define PG_INT64_MIN
Definition: c.h:545

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT16, PG_GETARG_INT64, PG_INT64_MIN, PG_RETURN_INT64, PG_RETURN_NULL, and unlikely.

◆ int82eq()

Datum int82eq ( PG_FUNCTION_ARGS  )

Definition at line 284 of file int8.c.

285 {
286  int64 val1 = PG_GETARG_INT64(0);
287  int16 val2 = PG_GETARG_INT16(1);
288 
289  PG_RETURN_BOOL(val1 == val2);
290 }

References PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int82ge()

Datum int82ge ( PG_FUNCTION_ARGS  )

Definition at line 329 of file int8.c.

330 {
331  int64 val1 = PG_GETARG_INT64(0);
332  int16 val2 = PG_GETARG_INT16(1);
333 
334  PG_RETURN_BOOL(val1 >= val2);
335 }

References PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int82gt()

Datum int82gt ( PG_FUNCTION_ARGS  )

Definition at line 311 of file int8.c.

312 {
313  int64 val1 = PG_GETARG_INT64(0);
314  int16 val2 = PG_GETARG_INT16(1);
315 
316  PG_RETURN_BOOL(val1 > val2);
317 }

References PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int82le()

Datum int82le ( PG_FUNCTION_ARGS  )

Definition at line 320 of file int8.c.

321 {
322  int64 val1 = PG_GETARG_INT64(0);
323  int16 val2 = PG_GETARG_INT16(1);
324 
325  PG_RETURN_BOOL(val1 <= val2);
326 }

References PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int82lt()

Datum int82lt ( PG_FUNCTION_ARGS  )

Definition at line 302 of file int8.c.

303 {
304  int64 val1 = PG_GETARG_INT64(0);
305  int16 val2 = PG_GETARG_INT16(1);
306 
307  PG_RETURN_BOOL(val1 < val2);
308 }

References PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int82mi()

Datum int82mi ( PG_FUNCTION_ARGS  )

Definition at line 1046 of file int8.c.

1047 {
1048  int64 arg1 = PG_GETARG_INT64(0);
1049  int16 arg2 = PG_GETARG_INT16(1);
1050  int64 result;
1051 
1052  if (unlikely(pg_sub_s64_overflow(arg1, (int64) arg2, &result)))
1053  ereport(ERROR,
1054  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1055  errmsg("bigint out of range")));
1056  PG_RETURN_INT64(result);
1057 }

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT16, PG_GETARG_INT64, PG_RETURN_INT64, pg_sub_s64_overflow(), and unlikely.

◆ int82mul()

Datum int82mul ( PG_FUNCTION_ARGS  )

Definition at line 1060 of file int8.c.

1061 {
1062  int64 arg1 = PG_GETARG_INT64(0);
1063  int16 arg2 = PG_GETARG_INT16(1);
1064  int64 result;
1065 
1066  if (unlikely(pg_mul_s64_overflow(arg1, (int64) arg2, &result)))
1067  ereport(ERROR,
1068  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1069  errmsg("bigint out of range")));
1070  PG_RETURN_INT64(result);
1071 }

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT16, PG_GETARG_INT64, pg_mul_s64_overflow(), PG_RETURN_INT64, and unlikely.

◆ int82ne()

Datum int82ne ( PG_FUNCTION_ARGS  )

Definition at line 293 of file int8.c.

294 {
295  int64 val1 = PG_GETARG_INT64(0);
296  int16 val2 = PG_GETARG_INT16(1);
297 
298  PG_RETURN_BOOL(val1 != val2);
299 }

References PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int82pl()

Datum int82pl ( PG_FUNCTION_ARGS  )

Definition at line 1032 of file int8.c.

1033 {
1034  int64 arg1 = PG_GETARG_INT64(0);
1035  int16 arg2 = PG_GETARG_INT16(1);
1036  int64 result;
1037 
1038  if (unlikely(pg_add_s64_overflow(arg1, (int64) arg2, &result)))
1039  ereport(ERROR,
1040  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1041  errmsg("bigint out of range")));
1042  PG_RETURN_INT64(result);
1043 }

References ereport, errcode(), errmsg(), ERROR, pg_add_s64_overflow(), PG_GETARG_INT16, PG_GETARG_INT64, PG_RETURN_INT64, and unlikely.

◆ int84()

Datum int84 ( PG_FUNCTION_ARGS  )

Definition at line 1249 of file int8.c.

1250 {
1251  int64 arg = PG_GETARG_INT64(0);
1252 
1254  ereport(ERROR,
1255  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
1256  errmsg("integer out of range")));
1257 
1259 }
#define PG_INT32_MAX
Definition: c.h:543
#define PG_INT32_MIN
Definition: c.h:542
#define PG_RETURN_INT32(x)
Definition: fmgr.h:354

References arg, ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT64, PG_INT32_MAX, PG_INT32_MIN, PG_RETURN_INT32, and unlikely.

◆ int84div()

Datum int84div ( PG_FUNCTION_ARGS  )

Definition at line 932 of file int8.c.

933 {
934  int64 arg1 = PG_GETARG_INT64(0);
935  int32 arg2 = PG_GETARG_INT32(1);
936  int64 result;
937 
938  if (arg2 == 0)
939  {
940  ereport(ERROR,
941  (errcode(ERRCODE_DIVISION_BY_ZERO),
942  errmsg("division by zero")));
943  /* ensure compiler realizes we mustn't reach the division (gcc bug) */
944  PG_RETURN_NULL();
945  }
946 
947  /*
948  * INT64_MIN / -1 is problematic, since the result can't be represented on
949  * a two's-complement machine. Some machines produce INT64_MIN, some
950  * produce zero, some throw an exception. We can dodge the problem by
951  * recognizing that division by -1 is the same as negation.
952  */
953  if (arg2 == -1)
954  {
955  if (unlikely(arg1 == PG_INT64_MIN))
956  ereport(ERROR,
957  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
958  errmsg("bigint out of range")));
959  result = -arg1;
960  PG_RETURN_INT64(result);
961  }
962 
963  /* No overflow is possible */
964 
965  result = arg1 / arg2;
966 
967  PG_RETURN_INT64(result);
968 }

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT32, PG_GETARG_INT64, PG_INT64_MIN, PG_RETURN_INT64, PG_RETURN_NULL, and unlikely.

◆ int84eq()

Datum int84eq ( PG_FUNCTION_ARGS  )

Definition at line 170 of file int8.c.

171 {
172  int64 val1 = PG_GETARG_INT64(0);
173  int32 val2 = PG_GETARG_INT32(1);
174 
175  PG_RETURN_BOOL(val1 == val2);
176 }

References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int84ge()

Datum int84ge ( PG_FUNCTION_ARGS  )

Definition at line 215 of file int8.c.

216 {
217  int64 val1 = PG_GETARG_INT64(0);
218  int32 val2 = PG_GETARG_INT32(1);
219 
220  PG_RETURN_BOOL(val1 >= val2);
221 }

References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int84gt()

Datum int84gt ( PG_FUNCTION_ARGS  )

Definition at line 197 of file int8.c.

198 {
199  int64 val1 = PG_GETARG_INT64(0);
200  int32 val2 = PG_GETARG_INT32(1);
201 
202  PG_RETURN_BOOL(val1 > val2);
203 }

References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int84le()

Datum int84le ( PG_FUNCTION_ARGS  )

Definition at line 206 of file int8.c.

207 {
208  int64 val1 = PG_GETARG_INT64(0);
209  int32 val2 = PG_GETARG_INT32(1);
210 
211  PG_RETURN_BOOL(val1 <= val2);
212 }

References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int84lt()

Datum int84lt ( PG_FUNCTION_ARGS  )

Definition at line 188 of file int8.c.

189 {
190  int64 val1 = PG_GETARG_INT64(0);
191  int32 val2 = PG_GETARG_INT32(1);
192 
193  PG_RETURN_BOOL(val1 < val2);
194 }

References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int84mi()

Datum int84mi ( PG_FUNCTION_ARGS  )

Definition at line 904 of file int8.c.

905 {
906  int64 arg1 = PG_GETARG_INT64(0);
907  int32 arg2 = PG_GETARG_INT32(1);
908  int64 result;
909 
910  if (unlikely(pg_sub_s64_overflow(arg1, (int64) arg2, &result)))
911  ereport(ERROR,
912  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
913  errmsg("bigint out of range")));
914  PG_RETURN_INT64(result);
915 }

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT32, PG_GETARG_INT64, PG_RETURN_INT64, pg_sub_s64_overflow(), and unlikely.

◆ int84mul()

Datum int84mul ( PG_FUNCTION_ARGS  )

Definition at line 918 of file int8.c.

919 {
920  int64 arg1 = PG_GETARG_INT64(0);
921  int32 arg2 = PG_GETARG_INT32(1);
922  int64 result;
923 
924  if (unlikely(pg_mul_s64_overflow(arg1, (int64) arg2, &result)))
925  ereport(ERROR,
926  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
927  errmsg("bigint out of range")));
928  PG_RETURN_INT64(result);
929 }

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT32, PG_GETARG_INT64, pg_mul_s64_overflow(), PG_RETURN_INT64, and unlikely.

◆ int84ne()

Datum int84ne ( PG_FUNCTION_ARGS  )

Definition at line 179 of file int8.c.

180 {
181  int64 val1 = PG_GETARG_INT64(0);
182  int32 val2 = PG_GETARG_INT32(1);
183 
184  PG_RETURN_BOOL(val1 != val2);
185 }

References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int84pl()

Datum int84pl ( PG_FUNCTION_ARGS  )

Definition at line 890 of file int8.c.

891 {
892  int64 arg1 = PG_GETARG_INT64(0);
893  int32 arg2 = PG_GETARG_INT32(1);
894  int64 result;
895 
896  if (unlikely(pg_add_s64_overflow(arg1, (int64) arg2, &result)))
897  ereport(ERROR,
898  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
899  errmsg("bigint out of range")));
900  PG_RETURN_INT64(result);
901 }

References ereport, errcode(), errmsg(), ERROR, pg_add_s64_overflow(), PG_GETARG_INT32, PG_GETARG_INT64, PG_RETURN_INT64, and unlikely.

◆ int8abs()

Datum int8abs ( PG_FUNCTION_ARGS  )

Definition at line 546 of file int8.c.

547 {
548  int64 arg1 = PG_GETARG_INT64(0);
549  int64 result;
550 
551  if (unlikely(arg1 == PG_INT64_MIN))
552  ereport(ERROR,
553  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
554  errmsg("bigint out of range")));
555  result = (arg1 < 0) ? -arg1 : arg1;
556  PG_RETURN_INT64(result);
557 }

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT64, PG_INT64_MIN, PG_RETURN_INT64, and unlikely.

◆ int8and()

Datum int8and ( PG_FUNCTION_ARGS  )

Definition at line 1184 of file int8.c.

1185 {
1186  int64 arg1 = PG_GETARG_INT64(0);
1187  int64 arg2 = PG_GETARG_INT64(1);
1188 
1189  PG_RETURN_INT64(arg1 & arg2);
1190 }

References PG_GETARG_INT64, and PG_RETURN_INT64.

◆ int8dec()

Datum int8dec ( PG_FUNCTION_ARGS  )

Definition at line 757 of file int8.c.

758 {
759  /*
760  * When int8 is pass-by-reference, we provide this special case to avoid
761  * palloc overhead for COUNT(): when called as an aggregate, we know that
762  * the argument is modifiable local storage, so just update it in-place.
763  * (If int8 is pass-by-value, then of course this is useless as well as
764  * incorrect, so just ifdef it out.)
765  */
766 #ifndef USE_FLOAT8_BYVAL /* controls int8 too */
767  if (AggCheckCallContext(fcinfo, NULL))
768  {
769  int64 *arg = (int64 *) PG_GETARG_POINTER(0);
770 
771  if (unlikely(pg_sub_s64_overflow(*arg, 1, arg)))
772  ereport(ERROR,
773  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
774  errmsg("bigint out of range")));
776  }
777  else
778 #endif
779  {
780  /* Not called as an aggregate, so just do it the dumb way */
782  int64 result;
783 
784  if (unlikely(pg_sub_s64_overflow(arg, 1, &result)))
785  ereport(ERROR,
786  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
787  errmsg("bigint out of range")));
788 
789  PG_RETURN_INT64(result);
790  }
791 }
int AggCheckCallContext(FunctionCallInfo fcinfo, MemoryContext *aggcontext)
Definition: nodeAgg.c:4510

References AggCheckCallContext(), arg, ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT64, PG_GETARG_POINTER, PG_RETURN_INT64, PG_RETURN_POINTER, pg_sub_s64_overflow(), and unlikely.

Referenced by int8dec_any().

◆ int8dec_any()

Datum int8dec_any ( PG_FUNCTION_ARGS  )

Definition at line 816 of file int8.c.

817 {
818  return int8dec(fcinfo);
819 }
Datum int8dec(PG_FUNCTION_ARGS)
Definition: int8.c:757

References int8dec().

◆ int8div()

Datum int8div ( PG_FUNCTION_ARGS  )

Definition at line 504 of file int8.c.

505 {
506  int64 arg1 = PG_GETARG_INT64(0);
507  int64 arg2 = PG_GETARG_INT64(1);
508  int64 result;
509 
510  if (arg2 == 0)
511  {
512  ereport(ERROR,
513  (errcode(ERRCODE_DIVISION_BY_ZERO),
514  errmsg("division by zero")));
515  /* ensure compiler realizes we mustn't reach the division (gcc bug) */
516  PG_RETURN_NULL();
517  }
518 
519  /*
520  * INT64_MIN / -1 is problematic, since the result can't be represented on
521  * a two's-complement machine. Some machines produce INT64_MIN, some
522  * produce zero, some throw an exception. We can dodge the problem by
523  * recognizing that division by -1 is the same as negation.
524  */
525  if (arg2 == -1)
526  {
527  if (unlikely(arg1 == PG_INT64_MIN))
528  ereport(ERROR,
529  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
530  errmsg("bigint out of range")));
531  result = -arg1;
532  PG_RETURN_INT64(result);
533  }
534 
535  /* No overflow is possible */
536 
537  result = arg1 / arg2;
538 
539  PG_RETURN_INT64(result);
540 }

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT64, PG_INT64_MIN, PG_RETURN_INT64, PG_RETURN_NULL, and unlikely.

◆ int8eq()

Datum int8eq ( PG_FUNCTION_ARGS  )

Definition at line 113 of file int8.c.

114 {
115  int64 val1 = PG_GETARG_INT64(0);
116  int64 val2 = PG_GETARG_INT64(1);
117 
118  PG_RETURN_BOOL(val1 == val2);
119 }

References PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int8gcd()

Datum int8gcd ( PG_FUNCTION_ARGS  )

Definition at line 667 of file int8.c.

668 {
669  int64 arg1 = PG_GETARG_INT64(0);
670  int64 arg2 = PG_GETARG_INT64(1);
671  int64 result;
672 
673  result = int8gcd_internal(arg1, arg2);
674 
675  PG_RETURN_INT64(result);
676 }
static int64 int8gcd_internal(int64 arg1, int64 arg2)
Definition: int8.c:606

References int8gcd_internal(), PG_GETARG_INT64, and PG_RETURN_INT64.

◆ int8gcd_internal()

static int64 int8gcd_internal ( int64  arg1,
int64  arg2 
)
static

Definition at line 606 of file int8.c.

607 {
608  int64 swap;
609  int64 a1,
610  a2;
611 
612  /*
613  * Put the greater absolute value in arg1.
614  *
615  * This would happen automatically in the loop below, but avoids an
616  * expensive modulo operation, and simplifies the special-case handling
617  * for INT64_MIN below.
618  *
619  * We do this in negative space in order to handle INT64_MIN.
620  */
621  a1 = (arg1 < 0) ? arg1 : -arg1;
622  a2 = (arg2 < 0) ? arg2 : -arg2;
623  if (a1 > a2)
624  {
625  swap = arg1;
626  arg1 = arg2;
627  arg2 = swap;
628  }
629 
630  /* Special care needs to be taken with INT64_MIN. See comments above. */
631  if (arg1 == PG_INT64_MIN)
632  {
633  if (arg2 == 0 || arg2 == PG_INT64_MIN)
634  ereport(ERROR,
635  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
636  errmsg("bigint out of range")));
637 
638  /*
639  * Some machines throw a floating-point exception for INT64_MIN % -1,
640  * which is a bit silly since the correct answer is perfectly
641  * well-defined, namely zero. Guard against this and just return the
642  * result, gcd(INT64_MIN, -1) = 1.
643  */
644  if (arg2 == -1)
645  return 1;
646  }
647 
648  /* Use the Euclidean algorithm to find the GCD */
649  while (arg2 != 0)
650  {
651  swap = arg2;
652  arg2 = arg1 % arg2;
653  arg1 = swap;
654  }
655 
656  /*
657  * Make sure the result is positive. (We know we don't have INT64_MIN
658  * anymore).
659  */
660  if (arg1 < 0)
661  arg1 = -arg1;
662 
663  return arg1;
664 }
static const FormData_pg_attribute a1
Definition: heap.c:142
static const FormData_pg_attribute a2
Definition: heap.c:156

References a1, a2, ereport, errcode(), errmsg(), ERROR, and PG_INT64_MIN.

Referenced by int8gcd(), and int8lcm().

◆ int8ge()

Datum int8ge ( PG_FUNCTION_ARGS  )

Definition at line 158 of file int8.c.

159 {
160  int64 val1 = PG_GETARG_INT64(0);
161  int64 val2 = PG_GETARG_INT64(1);
162 
163  PG_RETURN_BOOL(val1 >= val2);
164 }

References PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int8gt()

Datum int8gt ( PG_FUNCTION_ARGS  )

Definition at line 140 of file int8.c.

141 {
142  int64 val1 = PG_GETARG_INT64(0);
143  int64 val2 = PG_GETARG_INT64(1);
144 
145  PG_RETURN_BOOL(val1 > val2);
146 }

References PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int8in()

Datum int8in ( PG_FUNCTION_ARGS  )

Definition at line 50 of file int8.c.

51 {
52  char *num = PG_GETARG_CSTRING(0);
53 
54  PG_RETURN_INT64(pg_strtoint64_safe(num, fcinfo->context));
55 }
#define PG_GETARG_CSTRING(n)
Definition: fmgr.h:277
int64 pg_strtoint64_safe(const char *s, Node *escontext)
Definition: numutils.c:650

References PG_GETARG_CSTRING, PG_RETURN_INT64, and pg_strtoint64_safe().

Referenced by defGetInt64(), and executeItemOptUnwrapTarget().

◆ int8inc()

Datum int8inc ( PG_FUNCTION_ARGS  )

Definition at line 719 of file int8.c.

720 {
721  /*
722  * When int8 is pass-by-reference, we provide this special case to avoid
723  * palloc overhead for COUNT(): when called as an aggregate, we know that
724  * the argument is modifiable local storage, so just update it in-place.
725  * (If int8 is pass-by-value, then of course this is useless as well as
726  * incorrect, so just ifdef it out.)
727  */
728 #ifndef USE_FLOAT8_BYVAL /* controls int8 too */
729  if (AggCheckCallContext(fcinfo, NULL))
730  {
731  int64 *arg = (int64 *) PG_GETARG_POINTER(0);
732 
733  if (unlikely(pg_add_s64_overflow(*arg, 1, arg)))
734  ereport(ERROR,
735  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
736  errmsg("bigint out of range")));
737 
739  }
740  else
741 #endif
742  {
743  /* Not called as an aggregate, so just do it the dumb way */
745  int64 result;
746 
747  if (unlikely(pg_add_s64_overflow(arg, 1, &result)))
748  ereport(ERROR,
749  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
750  errmsg("bigint out of range")));
751 
752  PG_RETURN_INT64(result);
753  }
754 }

References AggCheckCallContext(), arg, ereport, errcode(), errmsg(), ERROR, pg_add_s64_overflow(), PG_GETARG_INT64, PG_GETARG_POINTER, PG_RETURN_INT64, PG_RETURN_POINTER, and unlikely.

Referenced by int8inc_any(), and int8inc_float8_float8().

◆ int8inc_any()

Datum int8inc_any ( PG_FUNCTION_ARGS  )

Definition at line 804 of file int8.c.

805 {
806  return int8inc(fcinfo);
807 }
Datum int8inc(PG_FUNCTION_ARGS)
Definition: int8.c:719

References int8inc().

◆ int8inc_float8_float8()

Datum int8inc_float8_float8 ( PG_FUNCTION_ARGS  )

Definition at line 810 of file int8.c.

811 {
812  return int8inc(fcinfo);
813 }

References int8inc().

◆ int8inc_support()

Datum int8inc_support ( PG_FUNCTION_ARGS  )

Definition at line 826 of file int8.c.

827 {
828  Node *rawreq = (Node *) PG_GETARG_POINTER(0);
829 
830  if (IsA(rawreq, SupportRequestWFuncMonotonic))
831  {
834  int frameOptions = req->window_clause->frameOptions;
835 
836  /* No ORDER BY clause then all rows are peers */
837  if (req->window_clause->orderClause == NIL)
838  monotonic = MONOTONICFUNC_BOTH;
839  else
840  {
841  /*
842  * Otherwise take into account the frame options. When the frame
843  * bound is the start of the window then the resulting value can
844  * never decrease, therefore is monotonically increasing
845  */
846  if (frameOptions & FRAMEOPTION_START_UNBOUNDED_PRECEDING)
847  monotonic |= MONOTONICFUNC_INCREASING;
848 
849  /*
850  * Likewise, if the frame bound is the end of the window then the
851  * resulting value can never decrease.
852  */
853  if (frameOptions & FRAMEOPTION_END_UNBOUNDED_FOLLOWING)
854  monotonic |= MONOTONICFUNC_DECREASING;
855  }
856 
857  req->monotonic = monotonic;
858  PG_RETURN_POINTER(req);
859  }
860 
861  PG_RETURN_POINTER(NULL);
862 }
#define FRAMEOPTION_START_UNBOUNDED_PRECEDING
Definition: parsenodes.h:588
#define FRAMEOPTION_END_UNBOUNDED_FOLLOWING
Definition: parsenodes.h:591
#define NIL
Definition: pg_list.h:68
MonotonicFunction
Definition: plannodes.h:1587
@ MONOTONICFUNC_NONE
Definition: plannodes.h:1588
@ MONOTONICFUNC_DECREASING
Definition: plannodes.h:1590
@ MONOTONICFUNC_INCREASING
Definition: plannodes.h:1589
@ MONOTONICFUNC_BOTH
Definition: plannodes.h:1591
struct WindowClause * window_clause
Definition: supportnodes.h:296
MonotonicFunction monotonic
Definition: supportnodes.h:299
List * orderClause
Definition: parsenodes.h:1545

References FRAMEOPTION_END_UNBOUNDED_FOLLOWING, FRAMEOPTION_START_UNBOUNDED_PRECEDING, WindowClause::frameOptions, IsA, SupportRequestWFuncMonotonic::monotonic, MONOTONICFUNC_BOTH, MONOTONICFUNC_DECREASING, MONOTONICFUNC_INCREASING, MONOTONICFUNC_NONE, NIL, WindowClause::orderClause, PG_GETARG_POINTER, PG_RETURN_POINTER, and SupportRequestWFuncMonotonic::window_clause.

◆ int8larger()

Datum int8larger ( PG_FUNCTION_ARGS  )

Definition at line 866 of file int8.c.

867 {
868  int64 arg1 = PG_GETARG_INT64(0);
869  int64 arg2 = PG_GETARG_INT64(1);
870  int64 result;
871 
872  result = ((arg1 > arg2) ? arg1 : arg2);
873 
874  PG_RETURN_INT64(result);
875 }

References PG_GETARG_INT64, and PG_RETURN_INT64.

◆ int8lcm()

Datum int8lcm ( PG_FUNCTION_ARGS  )

Definition at line 682 of file int8.c.

683 {
684  int64 arg1 = PG_GETARG_INT64(0);
685  int64 arg2 = PG_GETARG_INT64(1);
686  int64 gcd;
687  int64 result;
688 
689  /*
690  * Handle lcm(x, 0) = lcm(0, x) = 0 as a special case. This prevents a
691  * division-by-zero error below when x is zero, and an overflow error from
692  * the GCD computation when x = INT64_MIN.
693  */
694  if (arg1 == 0 || arg2 == 0)
695  PG_RETURN_INT64(0);
696 
697  /* lcm(x, y) = abs(x / gcd(x, y) * y) */
698  gcd = int8gcd_internal(arg1, arg2);
699  arg1 = arg1 / gcd;
700 
701  if (unlikely(pg_mul_s64_overflow(arg1, arg2, &result)))
702  ereport(ERROR,
703  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
704  errmsg("bigint out of range")));
705 
706  /* If the result is INT64_MIN, it cannot be represented. */
707  if (unlikely(result == PG_INT64_MIN))
708  ereport(ERROR,
709  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
710  errmsg("bigint out of range")));
711 
712  if (result < 0)
713  result = -result;
714 
715  PG_RETURN_INT64(result);
716 }
static uint32 gcd(uint32 a, uint32 b)

References ereport, errcode(), errmsg(), ERROR, gcd(), int8gcd_internal(), PG_GETARG_INT64, PG_INT64_MIN, pg_mul_s64_overflow(), PG_RETURN_INT64, and unlikely.

◆ int8le()

Datum int8le ( PG_FUNCTION_ARGS  )

Definition at line 149 of file int8.c.

150 {
151  int64 val1 = PG_GETARG_INT64(0);
152  int64 val2 = PG_GETARG_INT64(1);
153 
154  PG_RETURN_BOOL(val1 <= val2);
155 }

References PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int8lt()

Datum int8lt ( PG_FUNCTION_ARGS  )

Definition at line 131 of file int8.c.

132 {
133  int64 val1 = PG_GETARG_INT64(0);
134  int64 val2 = PG_GETARG_INT64(1);
135 
136  PG_RETURN_BOOL(val1 < val2);
137 }

References PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int8mi()

Datum int8mi ( PG_FUNCTION_ARGS  )

Definition at line 476 of file int8.c.

477 {
478  int64 arg1 = PG_GETARG_INT64(0);
479  int64 arg2 = PG_GETARG_INT64(1);
480  int64 result;
481 
482  if (unlikely(pg_sub_s64_overflow(arg1, arg2, &result)))
483  ereport(ERROR,
484  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
485  errmsg("bigint out of range")));
486  PG_RETURN_INT64(result);
487 }

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT64, PG_RETURN_INT64, pg_sub_s64_overflow(), and unlikely.

◆ int8mod()

Datum int8mod ( PG_FUNCTION_ARGS  )

Definition at line 563 of file int8.c.

564 {
565  int64 arg1 = PG_GETARG_INT64(0);
566  int64 arg2 = PG_GETARG_INT64(1);
567 
568  if (unlikely(arg2 == 0))
569  {
570  ereport(ERROR,
571  (errcode(ERRCODE_DIVISION_BY_ZERO),
572  errmsg("division by zero")));
573  /* ensure compiler realizes we mustn't reach the division (gcc bug) */
574  PG_RETURN_NULL();
575  }
576 
577  /*
578  * Some machines throw a floating-point exception for INT64_MIN % -1,
579  * which is a bit silly since the correct answer is perfectly
580  * well-defined, namely zero.
581  */
582  if (arg2 == -1)
583  PG_RETURN_INT64(0);
584 
585  /* No overflow is possible */
586 
587  PG_RETURN_INT64(arg1 % arg2);
588 }

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT64, PG_RETURN_INT64, PG_RETURN_NULL, and unlikely.

◆ int8mul()

Datum int8mul ( PG_FUNCTION_ARGS  )

Definition at line 490 of file int8.c.

491 {
492  int64 arg1 = PG_GETARG_INT64(0);
493  int64 arg2 = PG_GETARG_INT64(1);
494  int64 result;
495 
496  if (unlikely(pg_mul_s64_overflow(arg1, arg2, &result)))
497  ereport(ERROR,
498  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
499  errmsg("bigint out of range")));
500  PG_RETURN_INT64(result);
501 }

References ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT64, pg_mul_s64_overflow(), PG_RETURN_INT64, and unlikely.

Referenced by int4_cash(), int8_cash(), and int8_to_char().

◆ int8ne()

Datum int8ne ( PG_FUNCTION_ARGS  )

Definition at line 122 of file int8.c.

123 {
124  int64 val1 = PG_GETARG_INT64(0);
125  int64 val2 = PG_GETARG_INT64(1);
126 
127  PG_RETURN_BOOL(val1 != val2);
128 }

References PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int8not()

Datum int8not ( PG_FUNCTION_ARGS  )

Definition at line 1211 of file int8.c.

1212 {
1213  int64 arg1 = PG_GETARG_INT64(0);
1214 
1215  PG_RETURN_INT64(~arg1);
1216 }

References PG_GETARG_INT64, and PG_RETURN_INT64.

◆ int8or()

Datum int8or ( PG_FUNCTION_ARGS  )

Definition at line 1193 of file int8.c.

1194 {
1195  int64 arg1 = PG_GETARG_INT64(0);
1196  int64 arg2 = PG_GETARG_INT64(1);
1197 
1198  PG_RETURN_INT64(arg1 | arg2);
1199 }

References PG_GETARG_INT64, and PG_RETURN_INT64.

◆ int8out()

Datum int8out ( PG_FUNCTION_ARGS  )

Definition at line 61 of file int8.c.

62 {
64  char buf[MAXINT8LEN + 1];
65  char *result;
66  int len;
67 
68  len = pg_lltoa(val, buf) + 1;
69 
70  /*
71  * Since the length is already known, we do a manual palloc() and memcpy()
72  * to avoid the strlen() call that would otherwise be done in pstrdup().
73  */
74  result = palloc(len);
75  memcpy(result, buf, len);
76  PG_RETURN_CSTRING(result);
77 }
#define MAXINT8LEN
Definition: builtins.h:22
#define PG_RETURN_CSTRING(x)
Definition: fmgr.h:362
int pg_lltoa(int64 value, char *a)
Definition: numutils.c:1227
const void size_t len
static char * buf
Definition: pg_test_fsync.c:72

References buf, len, MAXINT8LEN, palloc(), PG_GETARG_INT64, pg_lltoa(), PG_RETURN_CSTRING, and val.

Referenced by int8_to_char().

◆ int8pl()

Datum int8pl ( PG_FUNCTION_ARGS  )

Definition at line 462 of file int8.c.

463 {
464  int64 arg1 = PG_GETARG_INT64(0);
465  int64 arg2 = PG_GETARG_INT64(1);
466  int64 result;
467 
468  if (unlikely(pg_add_s64_overflow(arg1, arg2, &result)))
469  ereport(ERROR,
470  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
471  errmsg("bigint out of range")));
472  PG_RETURN_INT64(result);
473 }

References ereport, errcode(), errmsg(), ERROR, pg_add_s64_overflow(), PG_GETARG_INT64, PG_RETURN_INT64, and unlikely.

◆ int8recv()

Datum int8recv ( PG_FUNCTION_ARGS  )

Definition at line 83 of file int8.c.

84 {
86 
88 }
int64 pq_getmsgint64(StringInfo msg)
Definition: pqformat.c:453
StringInfoData * StringInfo
Definition: stringinfo.h:54

References buf, PG_GETARG_POINTER, PG_RETURN_INT64, and pq_getmsgint64().

◆ int8send()

Datum int8send ( PG_FUNCTION_ARGS  )

Definition at line 94 of file int8.c.

95 {
96  int64 arg1 = PG_GETARG_INT64(0);
98 
100  pq_sendint64(&buf, arg1);
102 }
#define PG_RETURN_BYTEA_P(x)
Definition: fmgr.h:371
void pq_begintypsend(StringInfo buf)
Definition: pqformat.c:326
bytea * pq_endtypsend(StringInfo buf)
Definition: pqformat.c:346
static void pq_sendint64(StringInfo buf, uint64 i)
Definition: pqformat.h:152

References buf, PG_GETARG_INT64, PG_RETURN_BYTEA_P, pq_begintypsend(), pq_endtypsend(), and pq_sendint64().

◆ int8shl()

Datum int8shl ( PG_FUNCTION_ARGS  )

Definition at line 1219 of file int8.c.

1220 {
1221  int64 arg1 = PG_GETARG_INT64(0);
1222  int32 arg2 = PG_GETARG_INT32(1);
1223 
1224  PG_RETURN_INT64(arg1 << arg2);
1225 }

References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_INT64.

◆ int8shr()

Datum int8shr ( PG_FUNCTION_ARGS  )

Definition at line 1228 of file int8.c.

1229 {
1230  int64 arg1 = PG_GETARG_INT64(0);
1231  int32 arg2 = PG_GETARG_INT32(1);
1232 
1233  PG_RETURN_INT64(arg1 >> arg2);
1234 }

References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_INT64.

◆ int8smaller()

Datum int8smaller ( PG_FUNCTION_ARGS  )

Definition at line 878 of file int8.c.

879 {
880  int64 arg1 = PG_GETARG_INT64(0);
881  int64 arg2 = PG_GETARG_INT64(1);
882  int64 result;
883 
884  result = ((arg1 < arg2) ? arg1 : arg2);
885 
886  PG_RETURN_INT64(result);
887 }

References PG_GETARG_INT64, and PG_RETURN_INT64.

◆ int8um()

Datum int8um ( PG_FUNCTION_ARGS  )

Definition at line 440 of file int8.c.

441 {
443  int64 result;
444 
445  if (unlikely(arg == PG_INT64_MIN))
446  ereport(ERROR,
447  (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
448  errmsg("bigint out of range")));
449  result = -arg;
450  PG_RETURN_INT64(result);
451 }

References arg, ereport, errcode(), errmsg(), ERROR, PG_GETARG_INT64, PG_INT64_MIN, PG_RETURN_INT64, and unlikely.

◆ int8up()

Datum int8up ( PG_FUNCTION_ARGS  )

Definition at line 454 of file int8.c.

455 {
457 
459 }

References arg, PG_GETARG_INT64, and PG_RETURN_INT64.

◆ int8xor()

Datum int8xor ( PG_FUNCTION_ARGS  )

Definition at line 1202 of file int8.c.

1203 {
1204  int64 arg1 = PG_GETARG_INT64(0);
1205  int64 arg2 = PG_GETARG_INT64(1);
1206 
1207  PG_RETURN_INT64(arg1 ^ arg2);
1208 }

References PG_GETARG_INT64, and PG_RETURN_INT64.

◆ oidtoi8()

Datum oidtoi8 ( PG_FUNCTION_ARGS  )

Definition at line 1366 of file int8.c.

1367 {
1368  Oid arg = PG_GETARG_OID(0);
1369 
1371 }
#define PG_GETARG_OID(n)
Definition: fmgr.h:275

References arg, PG_GETARG_OID, and PG_RETURN_INT64.