PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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 "utils/fmgroids.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 oidtooid8 (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 1338 of file int8.c.

1339{
1340 float8 num = PG_GETARG_FLOAT8(0);
1341
1342 /*
1343 * Get rid of any fractional part in the input. This is so we don't fail
1344 * on just-out-of-range values that would round into range. Note
1345 * assumption that rint() will pass through a NaN or Inf unchanged.
1346 */
1347 num = rint(num);
1348
1349 /* Range check */
1350 if (unlikely(isnan(num) || !FLOAT8_FITS_IN_INT64(num)))
1351 ereturn(fcinfo->context, (Datum) 0,
1353 errmsg("bigint out of range")));
1354
1355 PG_RETURN_INT64((int64) num);
1356}
int64_t int64
Definition c.h:680
double float8
Definition c.h:773
#define FLOAT8_FITS_IN_INT64(num)
Definition c.h:1219
#define unlikely(x)
Definition c.h:497
int errcode(int sqlerrcode)
Definition elog.c:875
#define ereturn(context, dummy_value,...)
Definition elog.h:280
#define PG_GETARG_FLOAT8(n)
Definition fmgr.h:283
#define PG_RETURN_INT64(x)
Definition fmgr.h:370
static char * errmsg
uint64_t Datum
Definition postgres.h:70
static int fb(int x)

References ereturn, errcode(), errmsg, fb(), 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 1374 of file int8.c.

1375{
1376 float4 num = PG_GETARG_FLOAT4(0);
1377
1378 /*
1379 * Get rid of any fractional part in the input. This is so we don't fail
1380 * on just-out-of-range values that would round into range. Note
1381 * assumption that rint() will pass through a NaN or Inf unchanged.
1382 */
1383 num = rint(num);
1384
1385 /* Range check */
1386 if (unlikely(isnan(num) || !FLOAT4_FITS_IN_INT64(num)))
1387 ereturn(fcinfo->context, (Datum) 0,
1389 errmsg("bigint out of range")));
1390
1391 PG_RETURN_INT64((int64) num);
1392}
#define FLOAT4_FITS_IN_INT64(num)
Definition c.h:1213
float float4
Definition c.h:772
#define PG_GETARG_FLOAT4(n)
Definition fmgr.h:282

References ereturn, errcode(), errmsg, fb(), 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 1427 of file int8.c.

1428{
1429 return generate_series_step_int8(fcinfo);
1430}
Datum generate_series_step_int8(PG_FUNCTION_ARGS)
Definition int8.c:1433

References generate_series_step_int8().

◆ generate_series_int8_support()

Datum generate_series_int8_support ( PG_FUNCTION_ARGS  )

Definition at line 1509 of file int8.c.

1510{
1512 Node *ret = NULL;
1513
1515 {
1516 /* Try to estimate the number of rows returned */
1518
1519 if (is_funcclause(req->node)) /* be paranoid */
1520 {
1521 List *args = ((FuncExpr *) req->node)->args;
1522 Node *arg1,
1523 *arg2,
1524 *arg3;
1525
1526 /* We can use estimated argument values here */
1528 arg2 = estimate_expression_value(req->root, lsecond(args));
1529 if (list_length(args) >= 3)
1530 arg3 = estimate_expression_value(req->root, lthird(args));
1531 else
1532 arg3 = NULL;
1533
1534 /*
1535 * If any argument is constant NULL, we can safely assume that
1536 * zero rows are returned. Otherwise, if they're all non-NULL
1537 * constants, we can calculate the number of rows that will be
1538 * returned. Use double arithmetic to avoid overflow hazards.
1539 */
1540 if ((IsA(arg1, Const) &&
1541 ((Const *) arg1)->constisnull) ||
1542 (IsA(arg2, Const) &&
1543 ((Const *) arg2)->constisnull) ||
1544 (arg3 != NULL && IsA(arg3, Const) &&
1545 ((Const *) arg3)->constisnull))
1546 {
1547 req->rows = 0;
1548 ret = (Node *) req;
1549 }
1550 else if (IsA(arg1, Const) &&
1551 IsA(arg2, Const) &&
1552 (arg3 == NULL || IsA(arg3, Const)))
1553 {
1554 double start,
1555 finish,
1556 step;
1557
1559 finish = DatumGetInt64(((Const *) arg2)->constvalue);
1560 step = arg3 ? DatumGetInt64(((Const *) arg3)->constvalue) : 1;
1561
1562 /* This equation works for either sign of step */
1563 if (step != 0)
1564 {
1565 req->rows = floor((finish - start + step) / step);
1566 ret = (Node *) req;
1567 }
1568 }
1569 }
1570 }
1571
1572 PG_RETURN_POINTER(ret);
1573}
Node * estimate_expression_value(PlannerInfo *root, Node *node)
Definition clauses.c:2660
#define PG_GETARG_POINTER(n)
Definition fmgr.h:277
#define PG_RETURN_POINTER(x)
Definition fmgr.h:363
return str start
static bool is_funcclause(const void *clause)
Definition nodeFuncs.h:69
#define IsA(nodeptr, _type_)
Definition nodes.h:162
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:416
Definition pg_list.h:54
Definition nodes.h:133

References DatumGetInt64(), estimate_expression_value(), fb(), is_funcclause(), IsA, linitial, list_length(), lsecond, lthird, PG_GETARG_POINTER, PG_RETURN_POINTER, and start.

◆ generate_series_step_int8()

Datum generate_series_step_int8 ( PG_FUNCTION_ARGS  )

Definition at line 1433 of file int8.c.

1434{
1437 int64 result;
1438 MemoryContext oldcontext;
1439
1440 /* stuff done only on the first call of the function */
1441 if (SRF_IS_FIRSTCALL())
1442 {
1444 int64 finish = PG_GETARG_INT64(1);
1445 int64 step = 1;
1446
1447 /* see if we were given an explicit step size */
1448 if (PG_NARGS() == 3)
1449 step = PG_GETARG_INT64(2);
1450 if (step == 0)
1451 ereport(ERROR,
1453 errmsg("step size cannot equal zero")));
1454
1455 /* create a function context for cross-call persistence */
1457
1458 /*
1459 * switch to memory context appropriate for multiple function calls
1460 */
1461 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
1462
1463 /* allocate memory for user context */
1465
1466 /*
1467 * Use fctx to keep state from call to call. Seed current with the
1468 * original start value
1469 */
1470 fctx->current = start;
1471 fctx->finish = finish;
1472 fctx->step = step;
1473
1474 funcctx->user_fctx = fctx;
1475 MemoryContextSwitchTo(oldcontext);
1476 }
1477
1478 /* stuff done on every call of the function */
1480
1481 /*
1482 * get the saved state and use current as the result for this iteration
1483 */
1484 fctx = funcctx->user_fctx;
1485 result = fctx->current;
1486
1487 if ((fctx->step > 0 && fctx->current <= fctx->finish) ||
1488 (fctx->step < 0 && fctx->current >= fctx->finish))
1489 {
1490 /*
1491 * Increment current in preparation for next iteration. If next-value
1492 * computation overflows, this is the final result.
1493 */
1494 if (pg_add_s64_overflow(fctx->current, fctx->step, &fctx->current))
1495 fctx->step = 0;
1496
1497 /* do when there is more left to send */
1499 }
1500 else
1501 /* do when there is no more left */
1503}
uint32 result
#define ERROR
Definition elog.h:40
#define ereport(elevel,...)
Definition elog.h:152
#define palloc_object(type)
Definition fe_memutils.h:89
#define PG_NARGS()
Definition fmgr.h:203
#define PG_GETARG_INT64(n)
Definition fmgr.h:284
#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:235
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:138
static Datum Int64GetDatum(int64 X)
Definition postgres.h:426

References ereport, errcode(), errmsg, ERROR, fb(), Int64GetDatum(), MemoryContextSwitchTo(), palloc_object, pg_add_s64_overflow(), PG_GETARG_INT64, PG_NARGS, result, SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, and start.

Referenced by generate_series_int8().

◆ i8tod()

Datum i8tod ( PG_FUNCTION_ARGS  )

Definition at line 1323 of file int8.c.

1324{
1326 float8 result;
1327
1328 result = arg;
1329
1331}
Datum arg
Definition elog.c:1323
#define PG_RETURN_FLOAT8(x)
Definition fmgr.h:369

References arg, PG_GETARG_INT64, PG_RETURN_FLOAT8, and result.

◆ i8tof()

Datum i8tof ( PG_FUNCTION_ARGS  )

Definition at line 1359 of file int8.c.

1360{
1362 float4 result;
1363
1364 result = arg;
1365
1367}
#define PG_RETURN_FLOAT4(x)
Definition fmgr.h:368

References arg, PG_GETARG_INT64, PG_RETURN_FLOAT4, and result.

◆ i8tooid()

Datum i8tooid ( PG_FUNCTION_ARGS  )

Definition at line 1395 of file int8.c.

1396{
1398
1399 if (unlikely(arg < 0) || unlikely(arg > PG_UINT32_MAX))
1400 ereturn(fcinfo->context, (Datum) 0,
1402 errmsg("OID out of range")));
1403
1405}
#define PG_UINT32_MAX
Definition c.h:733
#define PG_RETURN_OID(x)
Definition fmgr.h:361
unsigned int Oid

References arg, ereturn, errcode(), errmsg, fb(), 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 408 of file int8.c.

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

References ereport, errcode(), errmsg, ERROR, fb(), 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 1302 of file int8.c.

1303{
1305
1307}
int16_t int16
Definition c.h:678
#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 1194 of file int8.c.

1195{
1198
1199 if (unlikely(arg2 == 0))
1200 {
1201 ereport(ERROR,
1203 errmsg("division by zero")));
1204 /* ensure compiler realizes we mustn't reach the division (gcc bug) */
1206 }
1207
1208 /* No overflow is possible */
1210}
#define PG_RETURN_NULL()
Definition fmgr.h:346

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

◆ int28eq()

Datum int28eq ( PG_FUNCTION_ARGS  )

Definition at line 348 of file int8.c.

349{
352
354}

References fb(), PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int28ge()

Datum int28ge ( PG_FUNCTION_ARGS  )

Definition at line 393 of file int8.c.

394{
397
399}

References fb(), PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int28gt()

Datum int28gt ( PG_FUNCTION_ARGS  )

Definition at line 375 of file int8.c.

376{
379
381}

References fb(), PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int28le()

Datum int28le ( PG_FUNCTION_ARGS  )

Definition at line 384 of file int8.c.

385{
388
390}

References fb(), PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int28lt()

Datum int28lt ( PG_FUNCTION_ARGS  )

Definition at line 366 of file int8.c.

367{
370
372}

References fb(), PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int28mi()

Datum int28mi ( PG_FUNCTION_ARGS  )

Definition at line 1166 of file int8.c.

1167{
1170 int64 result;
1171
1173 ereport(ERROR,
1175 errmsg("bigint out of range")));
1177}
static bool pg_sub_s64_overflow(int64 a, int64 b, int64 *result)
Definition int.h:262

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

◆ int28mul()

Datum int28mul ( PG_FUNCTION_ARGS  )

Definition at line 1180 of file int8.c.

1181{
1184 int64 result;
1185
1187 ereport(ERROR,
1189 errmsg("bigint out of range")));
1191}
static bool pg_mul_s64_overflow(int64 a, int64 b, int64 *result)
Definition int.h:293

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

◆ int28ne()

Datum int28ne ( PG_FUNCTION_ARGS  )

Definition at line 357 of file int8.c.

358{
361
363}

References fb(), PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int28pl()

Datum int28pl ( PG_FUNCTION_ARGS  )

◆ int48()

Datum int48 ( PG_FUNCTION_ARGS  )

Definition at line 1281 of file int8.c.

1282{
1284
1286}
int32_t int32
Definition c.h:679
#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 1052 of file int8.c.

1053{
1056
1057 if (unlikely(arg2 == 0))
1058 {
1059 ereport(ERROR,
1061 errmsg("division by zero")));
1062 /* ensure compiler realizes we mustn't reach the division (gcc bug) */
1064 }
1065
1066 /* No overflow is possible */
1068}

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

◆ int48eq()

Datum int48eq ( PG_FUNCTION_ARGS  )

Definition at line 232 of file int8.c.

233{
236
238}

References fb(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int48ge()

Datum int48ge ( PG_FUNCTION_ARGS  )

Definition at line 277 of file int8.c.

278{
281
283}

References fb(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int48gt()

Datum int48gt ( PG_FUNCTION_ARGS  )

Definition at line 259 of file int8.c.

260{
263
265}

References fb(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int48le()

Datum int48le ( PG_FUNCTION_ARGS  )

Definition at line 268 of file int8.c.

269{
272
274}

References fb(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int48lt()

Datum int48lt ( PG_FUNCTION_ARGS  )

Definition at line 250 of file int8.c.

251{
254
256}

References fb(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int48mi()

Datum int48mi ( PG_FUNCTION_ARGS  )

◆ int48mul()

Datum int48mul ( PG_FUNCTION_ARGS  )

◆ int48ne()

Datum int48ne ( PG_FUNCTION_ARGS  )

Definition at line 241 of file int8.c.

242{
245
247}

References fb(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int48pl()

Datum int48pl ( PG_FUNCTION_ARGS  )

◆ int82()

Datum int82 ( PG_FUNCTION_ARGS  )

Definition at line 1310 of file int8.c.

1311{
1313
1315 ereturn(fcinfo->context, (Datum) 0,
1317 errmsg("smallint out of range")));
1318
1320}
#define PG_INT16_MIN
Definition c.h:728
#define PG_INT16_MAX
Definition c.h:729
#define PG_RETURN_INT16(x)
Definition fmgr.h:357

References arg, ereturn, errcode(), errmsg, fb(), PG_GETARG_INT64, PG_INT16_MAX, PG_INT16_MIN, PG_RETURN_INT16, and unlikely.

◆ int82div()

Datum int82div ( PG_FUNCTION_ARGS  )

Definition at line 1113 of file int8.c.

1114{
1117 int64 result;
1118
1119 if (unlikely(arg2 == 0))
1120 {
1121 ereport(ERROR,
1123 errmsg("division by zero")));
1124 /* ensure compiler realizes we mustn't reach the division (gcc bug) */
1126 }
1127
1128 /*
1129 * INT64_MIN / -1 is problematic, since the result can't be represented on
1130 * a two's-complement machine. Some machines produce INT64_MIN, some
1131 * produce zero, some throw an exception. We can dodge the problem by
1132 * recognizing that division by -1 is the same as negation.
1133 */
1134 if (arg2 == -1)
1135 {
1136 if (unlikely(arg1 == PG_INT64_MIN))
1137 ereport(ERROR,
1139 errmsg("bigint out of range")));
1140 result = -arg1;
1142 }
1143
1144 /* No overflow is possible */
1145
1146 result = arg1 / arg2;
1147
1149}
#define PG_INT64_MIN
Definition c.h:734

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

◆ int82eq()

Datum int82eq ( PG_FUNCTION_ARGS  )

Definition at line 290 of file int8.c.

291{
294
296}

References fb(), PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int82ge()

Datum int82ge ( PG_FUNCTION_ARGS  )

Definition at line 335 of file int8.c.

336{
339
341}

References fb(), PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int82gt()

Datum int82gt ( PG_FUNCTION_ARGS  )

Definition at line 317 of file int8.c.

318{
321
323}

References fb(), PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int82le()

Datum int82le ( PG_FUNCTION_ARGS  )

Definition at line 326 of file int8.c.

327{
330
332}

References fb(), PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int82lt()

Datum int82lt ( PG_FUNCTION_ARGS  )

Definition at line 308 of file int8.c.

309{
312
314}

References fb(), PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int82mi()

Datum int82mi ( PG_FUNCTION_ARGS  )

◆ int82mul()

Datum int82mul ( PG_FUNCTION_ARGS  )

◆ int82ne()

Datum int82ne ( PG_FUNCTION_ARGS  )

Definition at line 299 of file int8.c.

300{
303
305}

References fb(), PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int82pl()

Datum int82pl ( PG_FUNCTION_ARGS  )

◆ int84()

Datum int84 ( PG_FUNCTION_ARGS  )

Definition at line 1289 of file int8.c.

1290{
1292
1294 ereturn(fcinfo->context, (Datum) 0,
1296 errmsg("integer out of range")));
1297
1299}
#define PG_INT32_MAX
Definition c.h:732
#define PG_INT32_MIN
Definition c.h:731
#define PG_RETURN_INT32(x)
Definition fmgr.h:355

References arg, ereturn, errcode(), errmsg, fb(), PG_GETARG_INT64, PG_INT32_MAX, PG_INT32_MIN, PG_RETURN_INT32, and unlikely.

◆ int84div()

Datum int84div ( PG_FUNCTION_ARGS  )

Definition at line 971 of file int8.c.

972{
976
977 if (arg2 == 0)
978 {
981 errmsg("division by zero")));
982 /* ensure compiler realizes we mustn't reach the division (gcc bug) */
984 }
985
986 /*
987 * INT64_MIN / -1 is problematic, since the result can't be represented on
988 * a two's-complement machine. Some machines produce INT64_MIN, some
989 * produce zero, some throw an exception. We can dodge the problem by
990 * recognizing that division by -1 is the same as negation.
991 */
992 if (arg2 == -1)
993 {
994 if (unlikely(arg1 == PG_INT64_MIN))
997 errmsg("bigint out of range")));
998 result = -arg1;
1000 }
1001
1002 /* No overflow is possible */
1003
1004 result = arg1 / arg2;
1005
1007}

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

◆ int84eq()

Datum int84eq ( PG_FUNCTION_ARGS  )

Definition at line 174 of file int8.c.

175{
178
180}

References fb(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int84ge()

Datum int84ge ( PG_FUNCTION_ARGS  )

Definition at line 219 of file int8.c.

220{
223
225}

References fb(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int84gt()

Datum int84gt ( PG_FUNCTION_ARGS  )

Definition at line 201 of file int8.c.

202{
205
207}

References fb(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int84le()

Datum int84le ( PG_FUNCTION_ARGS  )

Definition at line 210 of file int8.c.

211{
214
216}

References fb(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int84lt()

Datum int84lt ( PG_FUNCTION_ARGS  )

Definition at line 192 of file int8.c.

193{
196
198}

References fb(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int84mi()

◆ int84mul()

◆ int84ne()

Datum int84ne ( PG_FUNCTION_ARGS  )

Definition at line 183 of file int8.c.

184{
187
189}

References fb(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int84pl()

◆ int8abs()

Datum int8abs ( PG_FUNCTION_ARGS  )

Definition at line 554 of file int8.c.

555{
558
559 if (unlikely(arg1 == PG_INT64_MIN))
562 errmsg("bigint out of range")));
563 result = (arg1 < 0) ? -arg1 : arg1;
565}

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

◆ int8and()

Datum int8and ( PG_FUNCTION_ARGS  )

Definition at line 1224 of file int8.c.

1225{
1228
1230}

References fb(), PG_GETARG_INT64, and PG_RETURN_INT64.

◆ int8dec()

Datum int8dec ( PG_FUNCTION_ARGS  )

Definition at line 742 of file int8.c.

743{
746
750 errmsg("bigint out of range")));
751
753}

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

Referenced by int8dec_any().

◆ int8dec_any()

Datum int8dec_any ( PG_FUNCTION_ARGS  )

Definition at line 778 of file int8.c.

779{
780 return int8dec(fcinfo);
781}
Datum int8dec(PG_FUNCTION_ARGS)
Definition int8.c:742

References int8dec().

◆ int8div()

Datum int8div ( PG_FUNCTION_ARGS  )

Definition at line 511 of file int8.c.

512{
516
517 if (arg2 == 0)
518 {
521 errmsg("division by zero")));
522 /* ensure compiler realizes we mustn't reach the division (gcc bug) */
524 }
525
526 /*
527 * INT64_MIN / -1 is problematic, since the result can't be represented on
528 * a two's-complement machine. Some machines produce INT64_MIN, some
529 * produce zero, some throw an exception. We can dodge the problem by
530 * recognizing that division by -1 is the same as negation.
531 */
532 if (arg2 == -1)
533 {
534 if (unlikely(arg1 == PG_INT64_MIN))
537 errmsg("bigint out of range")));
538 result = -arg1;
540 }
541
542 /* No overflow is possible */
543
544 result = arg1 / arg2;
545
547}

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

◆ int8eq()

Datum int8eq ( PG_FUNCTION_ARGS  )

Definition at line 116 of file int8.c.

117{
120
122}

References fb(), PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int8gcd()

Datum int8gcd ( PG_FUNCTION_ARGS  )

Definition at line 676 of file int8.c.

677{
681
683
685}
static int64 int8gcd_internal(int64 arg1, int64 arg2)
Definition int8.c:615

References fb(), int8gcd_internal(), PG_GETARG_INT64, PG_RETURN_INT64, and result.

◆ int8gcd_internal()

static int64 int8gcd_internal ( int64  arg1,
int64  arg2 
)
static

Definition at line 615 of file int8.c.

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

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

Referenced by int8gcd(), and int8lcm().

◆ int8ge()

Datum int8ge ( PG_FUNCTION_ARGS  )

Definition at line 161 of file int8.c.

162{
165
167}

References fb(), PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int8gt()

Datum int8gt ( PG_FUNCTION_ARGS  )

Definition at line 143 of file int8.c.

144{
147
149}

References fb(), PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int8in()

Datum int8in ( PG_FUNCTION_ARGS  )

Definition at line 51 of file int8.c.

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

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 728 of file int8.c.

729{
732
736 errmsg("bigint out of range")));
737
739}

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

Referenced by int8inc_any(), and int8inc_float8_float8().

◆ int8inc_any()

Datum int8inc_any ( PG_FUNCTION_ARGS  )

Definition at line 766 of file int8.c.

767{
768 return int8inc(fcinfo);
769}
Datum int8inc(PG_FUNCTION_ARGS)
Definition int8.c:728

References int8inc().

◆ int8inc_float8_float8()

Datum int8inc_float8_float8 ( PG_FUNCTION_ARGS  )

Definition at line 772 of file int8.c.

773{
774 return int8inc(fcinfo);
775}

References int8inc().

◆ int8inc_support()

Datum int8inc_support ( PG_FUNCTION_ARGS  )

Definition at line 788 of file int8.c.

789{
791
793 {
796 int frameOptions = req->window_clause->frameOptions;
797
798 /*
799 * Because an EXCLUDE clauses in the window definition can exclude
800 * rows that have previously been included in the aggregate result for
801 * prior rows, this can break the monotonic properties that might
802 * otherwise be guaranteed. There's a narrow set of circumstances
803 * that can be guaranteed, which we check for below.
804 */
805 if (frameOptions & FRAMEOPTION_EXCLUSION)
806 {
807 WindowFunc *wfunc = req->window_func;
808
809 /*
810 * To add handling for all valid monotonic cases with an EXCLUDE
811 * clause is complex and likely not worth troubling over. For
812 * now, just bail unless we see EXCLUDE CURRENT ROW with COUNT(*)
813 * and no FILTER. Excluding the current row is fine when using
814 * COUNT(*) as this always reduces the count by 1. The same isn't
815 * true for COUNY(ANY) as a NULL won't be counted, and a
816 * subsequent non-NULL could make the count decrease.
817 */
818 if ((frameOptions & FRAMEOPTION_EXCLUDE_CURRENT_ROW) == 0 ||
819 wfunc->winfnoid != F_COUNT_ ||
820 wfunc->aggfilter != NULL)
821 {
822 req->monotonic = MONOTONICFUNC_NONE;
824 }
825 }
826
827 /* No ORDER BY clause and RANGE mode means all rows are peers. */
828 if (req->window_clause->orderClause == NIL &&
829 (frameOptions & FRAMEOPTION_RANGE))
830 monotonic = MONOTONICFUNC_BOTH;
831 else
832 {
833 /*
834 * Otherwise take into account the frame options. When the frame
835 * bound is the start of the window then the resulting value can
836 * never decrease, therefore is monotonically increasing
837 */
838 if (frameOptions & FRAMEOPTION_START_UNBOUNDED_PRECEDING)
839 monotonic |= MONOTONICFUNC_INCREASING;
840
841 /*
842 * Likewise, if the frame bound is the end of the window then the
843 * resulting value can never decrease.
844 */
845 if (frameOptions & FRAMEOPTION_END_UNBOUNDED_FOLLOWING)
846 monotonic |= MONOTONICFUNC_DECREASING;
847 }
848
849 req->monotonic = monotonic;
851 }
852
854 {
856 Aggref *agg = req->aggref;
857
858 /*
859 * Check for COUNT(ANY) and try to convert to COUNT(*). The input
860 * argument cannot be NULL, we can't have an ORDER BY / DISTINCT in
861 * the aggregate, and agglevelsup must be 0.
862 *
863 * Technically COUNT(ANY) must have 1 arg, but be paranoid and check.
864 */
865 if (agg->aggfnoid == F_COUNT_ANY && list_length(agg->args) == 1)
866 {
867 TargetEntry *tle = (TargetEntry *) linitial(agg->args);
868 Expr *arg = tle->expr;
869
870 /* Check for unsupported cases */
871 if (agg->aggdistinct != NIL || agg->aggorder != NIL ||
872 agg->agglevelsup != 0)
874
875 /* If the arg isn't NULLable, do the conversion */
877 {
878 Aggref *newagg;
879
880 /* We don't expect these to have been set yet */
881 Assert(agg->aggtransno == -1);
882 Assert(agg->aggtranstype == InvalidOid);
883
884 /* Convert COUNT(ANY) to COUNT(*) by making a new Aggref */
886 memcpy(newagg, agg, sizeof(Aggref));
887 newagg->aggfnoid = F_COUNT_;
888
889 /* count(*) has no args */
890 newagg->aggargtypes = NULL;
891 newagg->args = NULL;
892 newagg->aggstar = true;
893 newagg->location = -1;
894
896 }
897 }
898 }
899
901}
#define Assert(condition)
Definition c.h:1002
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
bool expr_is_nonnullable(PlannerInfo *root, Expr *expr, NotNullSource source)
Definition clauses.c:4804
#define makeNode(_type_)
Definition nodes.h:159
@ NOTNULL_SOURCE_HASHTABLE
Definition optimizer.h:137
#define FRAMEOPTION_EXCLUDE_CURRENT_ROW
Definition parsenodes.h:628
#define FRAMEOPTION_START_UNBOUNDED_PRECEDING
Definition parsenodes.h:618
#define FRAMEOPTION_RANGE
Definition parsenodes.h:614
#define FRAMEOPTION_END_UNBOUNDED_FOLLOWING
Definition parsenodes.h:621
#define FRAMEOPTION_EXCLUSION
Definition parsenodes.h:636
#define NIL
Definition pg_list.h:68
MonotonicFunction
Definition plannodes.h:1840
@ MONOTONICFUNC_NONE
Definition plannodes.h:1841
@ MONOTONICFUNC_DECREASING
Definition plannodes.h:1843
@ MONOTONICFUNC_INCREASING
Definition plannodes.h:1842
@ MONOTONICFUNC_BOTH
Definition plannodes.h:1844
#define InvalidOid
Expr * aggfilter
Definition primnodes.h:600

References WindowFunc::aggfilter, arg, Assert, expr_is_nonnullable(), fb(), FRAMEOPTION_END_UNBOUNDED_FOLLOWING, FRAMEOPTION_EXCLUDE_CURRENT_ROW, FRAMEOPTION_EXCLUSION, FRAMEOPTION_RANGE, FRAMEOPTION_START_UNBOUNDED_PRECEDING, WindowClause::frameOptions, InvalidOid, IsA, linitial, list_length(), makeNode, memcpy(), MONOTONICFUNC_BOTH, MONOTONICFUNC_DECREASING, MONOTONICFUNC_INCREASING, MONOTONICFUNC_NONE, NIL, NOTNULL_SOURCE_HASHTABLE, PG_GETARG_POINTER, PG_RETURN_POINTER, SupportRequestWFuncMonotonic::window_clause, and WindowFunc::winfnoid.

◆ int8larger()

Datum int8larger ( PG_FUNCTION_ARGS  )

Definition at line 905 of file int8.c.

906{
910
911 result = ((arg1 > arg2) ? arg1 : arg2);
912
914}

References fb(), PG_GETARG_INT64, PG_RETURN_INT64, and result.

◆ int8lcm()

Datum int8lcm ( PG_FUNCTION_ARGS  )

Definition at line 691 of file int8.c.

692{
695 int64 gcd;
697
698 /*
699 * Handle lcm(x, 0) = lcm(0, x) = 0 as a special case. This prevents a
700 * division-by-zero error below when x is zero, and an overflow error from
701 * the GCD computation when x = INT64_MIN.
702 */
703 if (arg1 == 0 || arg2 == 0)
705
706 /* lcm(x, y) = abs(x / gcd(x, y) * y) */
708 arg1 = arg1 / gcd;
709
713 errmsg("bigint out of range")));
714
715 /* If the result is INT64_MIN, it cannot be represented. */
719 errmsg("bigint out of range")));
720
721 if (result < 0)
722 result = -result;
723
725}
static uint32 gcd(uint32 a, uint32 b)

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

◆ int8le()

Datum int8le ( PG_FUNCTION_ARGS  )

Definition at line 152 of file int8.c.

153{
156
158}

References fb(), PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int8lt()

Datum int8lt ( PG_FUNCTION_ARGS  )

Definition at line 134 of file int8.c.

135{
138
140}

References fb(), PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int8mi()

◆ int8mod()

Datum int8mod ( PG_FUNCTION_ARGS  )

Definition at line 572 of file int8.c.

573{
576
577 if (unlikely(arg2 == 0))
578 {
581 errmsg("division by zero")));
582 /* ensure compiler realizes we mustn't reach the division (gcc bug) */
584 }
585
586 /*
587 * Some machines throw a floating-point exception for INT64_MIN % -1,
588 * which is a bit silly since the correct answer is perfectly
589 * well-defined, namely zero.
590 */
591 if (arg2 == -1)
593
594 /* No overflow is possible */
595
597}

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

◆ int8mul()

Datum int8mul ( PG_FUNCTION_ARGS  )

Definition at line 497 of file int8.c.

498{
502
506 errmsg("bigint out of range")));
508}

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

Referenced by int8_to_char().

◆ int8ne()

Datum int8ne ( PG_FUNCTION_ARGS  )

Definition at line 125 of file int8.c.

126{
129
131}

References fb(), PG_GETARG_INT64, and PG_RETURN_BOOL.

◆ int8not()

Datum int8not ( PG_FUNCTION_ARGS  )

Definition at line 1251 of file int8.c.

1252{
1254
1256}

References fb(), PG_GETARG_INT64, and PG_RETURN_INT64.

◆ int8or()

Datum int8or ( PG_FUNCTION_ARGS  )

Definition at line 1233 of file int8.c.

1234{
1237
1239}

References fb(), PG_GETARG_INT64, and PG_RETURN_INT64.

◆ int8out()

Datum int8out ( PG_FUNCTION_ARGS  )

Definition at line 63 of file int8.c.

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

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

Referenced by int8_to_char().

◆ int8pl()

◆ int8recv()

Datum int8recv ( PG_FUNCTION_ARGS  )

Definition at line 85 of file int8.c.

86{
88
90}
int64 pq_getmsgint64(StringInfo msg)
Definition pqformat.c:452
struct StringInfoData * StringInfo
Definition string.h:15

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

◆ int8send()

Datum int8send ( PG_FUNCTION_ARGS  )

Definition at line 96 of file int8.c.

97{
100
104}
#define PG_RETURN_BYTEA_P(x)
Definition fmgr.h:373
void pq_begintypsend(StringInfo buf)
Definition pqformat.c:325
bytea * pq_endtypsend(StringInfo buf)
Definition pqformat.c:345
static void pq_sendint64(StringInfo buf, uint64 i)
Definition pqformat.h:152

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

Referenced by int8_bytea().

◆ int8shl()

Datum int8shl ( PG_FUNCTION_ARGS  )

Definition at line 1259 of file int8.c.

1260{
1263
1265}

References fb(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_INT64.

◆ int8shr()

Datum int8shr ( PG_FUNCTION_ARGS  )

Definition at line 1268 of file int8.c.

1269{
1272
1274}

References fb(), PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_INT64.

◆ int8smaller()

Datum int8smaller ( PG_FUNCTION_ARGS  )

Definition at line 917 of file int8.c.

918{
922
923 result = ((arg1 < arg2) ? arg1 : arg2);
924
926}

References fb(), PG_GETARG_INT64, PG_RETURN_INT64, and result.

◆ int8um()

Datum int8um ( PG_FUNCTION_ARGS  )

Definition at line 447 of file int8.c.

448{
451
452 if (unlikely(arg == PG_INT64_MIN))
455 errmsg("bigint out of range")));
456 result = -arg;
458}

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

◆ int8up()

Datum int8up ( PG_FUNCTION_ARGS  )

Definition at line 461 of file int8.c.

462{
464
466}

References arg, PG_GETARG_INT64, and PG_RETURN_INT64.

◆ int8xor()

Datum int8xor ( PG_FUNCTION_ARGS  )

Definition at line 1242 of file int8.c.

1243{
1246
1248}

References fb(), PG_GETARG_INT64, and PG_RETURN_INT64.

◆ oidtoi8()

Datum oidtoi8 ( PG_FUNCTION_ARGS  )

Definition at line 1408 of file int8.c.

1409{
1410 Oid arg = PG_GETARG_OID(0);
1411
1413}
#define PG_GETARG_OID(n)
Definition fmgr.h:275

References arg, PG_GETARG_OID, and PG_RETURN_INT64.

◆ oidtooid8()

Datum oidtooid8 ( PG_FUNCTION_ARGS  )

Definition at line 1416 of file int8.c.

1417{
1418 Oid arg = PG_GETARG_OID(0);
1419
1421}
uint64 Oid8
Definition c.h:815
#define PG_RETURN_OID8(x)
Definition fmgr.h:362

References arg, PG_GETARG_OID, and PG_RETURN_OID8.