PostgreSQL Source Code git master
Loading...
Searching...
No Matches
int8.c
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * int8.c
4 * Internal 64-bit integer operations
5 *
6 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
8 *
9 * IDENTIFICATION
10 * src/backend/utils/adt/int8.c
11 *
12 *-------------------------------------------------------------------------
13 */
14#include "postgres.h"
15
16#include <ctype.h>
17#include <limits.h>
18#include <math.h>
19
20#include "common/int.h"
21#include "funcapi.h"
22#include "libpq/pqformat.h"
23#include "nodes/nodeFuncs.h"
24#include "nodes/supportnodes.h"
25#include "optimizer/optimizer.h"
26#include "utils/builtins.h"
27#include "utils/fmgroids.h"
28
29typedef struct
30{
35
36
37/***********************************************************************
38 **
39 ** Routines for 64-bit integers.
40 **
41 ***********************************************************************/
42
43/*----------------------------------------------------------
44 * Formatting and conversion routines.
45 *---------------------------------------------------------*/
46
47/*
48 * int8in()
49 */
52{
53 char *num = PG_GETARG_CSTRING(0);
54
55 PG_RETURN_INT64(pg_strtoint64_safe(num, fcinfo->context));
56}
57
58
59/*
60 * int8out()
61 */
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}
80
81/*
82 * int8recv - converts external binary format to int8
83 */
91
92/*
93 * int8send - converts int8 to binary format
94 */
105
106
107/*----------------------------------------------------------
108 * Relational operators for int8s, including cross-data-type comparisons.
109 *---------------------------------------------------------*/
110
111/*
112 * int8relop()
113 * Is val1 relop val2?
114 */
115Datum
123
124Datum
132
133Datum
141
142Datum
150
151Datum
159
160Datum
168
169/*
170 * int84relop()
171 * Is 64-bit val1 relop 32-bit val2?
172 */
173Datum
181
182Datum
190
191Datum
199
200Datum
208
209Datum
217
218Datum
226
227/*
228 * int48relop()
229 * Is 32-bit val1 relop 64-bit val2?
230 */
231Datum
239
240Datum
248
249Datum
257
258Datum
266
267Datum
275
276Datum
284
285/*
286 * int82relop()
287 * Is 64-bit val1 relop 16-bit val2?
288 */
289Datum
297
298Datum
306
307Datum
315
316Datum
324
325Datum
333
334Datum
342
343/*
344 * int28relop()
345 * Is 16-bit val1 relop 64-bit val2?
346 */
347Datum
355
356Datum
364
365Datum
373
374Datum
382
383Datum
391
392Datum
400
401/*
402 * in_range support function for int8.
403 *
404 * Note: we needn't supply int8_int4 or int8_int2 variants, as implicit
405 * coercion of the offset value takes care of those scenarios just as well.
406 */
407Datum
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}
440
441
442/*----------------------------------------------------------
443 * Arithmetic operators on 64-bit integers.
444 *---------------------------------------------------------*/
445
446Datum
448{
451
452 if (unlikely(arg == PG_INT64_MIN))
455 errmsg("bigint out of range")));
456 result = -arg;
458}
459
460Datum
467
468Datum
481
482Datum
495
496Datum
509
510Datum
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}
548
549/*
550 * int8abs()
551 * Absolute value
552 */
553Datum
555{
558
559 if (unlikely(arg1 == PG_INT64_MIN))
562 errmsg("bigint out of range")));
563 result = (arg1 < 0) ? -arg1 : arg1;
565}
566
567/*
568 * int8mod()
569 * Modulo operation.
570 */
571Datum
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}
598
599/*
600 * Greatest Common Divisor
601 *
602 * Returns the largest positive integer that exactly divides both inputs.
603 * Special cases:
604 * - gcd(x, 0) = gcd(0, x) = abs(x)
605 * because 0 is divisible by anything
606 * - gcd(0, 0) = 0
607 * complies with the previous definition and is a common convention
608 *
609 * Special care must be taken if either input is INT64_MIN ---
610 * gcd(0, INT64_MIN), gcd(INT64_MIN, 0) and gcd(INT64_MIN, INT64_MIN) are
611 * all equal to abs(INT64_MIN), which cannot be represented as a 64-bit signed
612 * integer.
613 */
614static int64
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}
674
675Datum
686
687/*
688 * Least Common Multiple
689 */
690Datum
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}
726
727Datum
740
741Datum
754
755
756/*
757 * These functions are exactly like int8inc/int8dec but are used for
758 * aggregates that count only non-null values. Since the functions are
759 * declared strict, the null checks happen before we ever get here, and all we
760 * need do is increment the state value. We could actually make these pg_proc
761 * entries point right at int8inc/int8dec, but then the opr_sanity regression
762 * test would complain about mismatched entries for a built-in function.
763 */
764
765Datum
767{
768 return int8inc(fcinfo);
769}
770
771Datum
773{
774 return int8inc(fcinfo);
775}
776
777Datum
779{
780 return int8dec(fcinfo);
781}
782
783/*
784 * int8inc_support
785 * prosupport function for int8inc() and int8inc_any()
786 */
787Datum
789{
791
793 {
796 int frameOptions = req->window_clause->frameOptions;
797
798 /* No ORDER BY clause then all rows are peers */
799 if (req->window_clause->orderClause == NIL)
800 monotonic = MONOTONICFUNC_BOTH;
801 else
802 {
803 /*
804 * Otherwise take into account the frame options. When the frame
805 * bound is the start of the window then the resulting value can
806 * never decrease, therefore is monotonically increasing
807 */
808 if (frameOptions & FRAMEOPTION_START_UNBOUNDED_PRECEDING)
809 monotonic |= MONOTONICFUNC_INCREASING;
810
811 /*
812 * Likewise, if the frame bound is the end of the window then the
813 * resulting value can never decrease.
814 */
815 if (frameOptions & FRAMEOPTION_END_UNBOUNDED_FOLLOWING)
816 monotonic |= MONOTONICFUNC_DECREASING;
817 }
818
819 req->monotonic = monotonic;
821 }
822
824 {
826 Aggref *agg = req->aggref;
827
828 /*
829 * Check for COUNT(ANY) and try to convert to COUNT(*). The input
830 * argument cannot be NULL, we can't have an ORDER BY / DISTINCT in
831 * the aggregate, and agglevelsup must be 0.
832 *
833 * Technically COUNT(ANY) must have 1 arg, but be paranoid and check.
834 */
835 if (agg->aggfnoid == F_COUNT_ANY && list_length(agg->args) == 1)
836 {
837 TargetEntry *tle = (TargetEntry *) linitial(agg->args);
838 Expr *arg = tle->expr;
839
840 /* Check for unsupported cases */
841 if (agg->aggdistinct != NIL || agg->aggorder != NIL ||
842 agg->agglevelsup != 0)
844
845 /* If the arg isn't NULLable, do the conversion */
847 {
848 Aggref *newagg;
849
850 /* We don't expect these to have been set yet */
851 Assert(agg->aggtransno == -1);
852 Assert(agg->aggtranstype == InvalidOid);
853
854 /* Convert COUNT(ANY) to COUNT(*) by making a new Aggref */
856 memcpy(newagg, agg, sizeof(Aggref));
857 newagg->aggfnoid = F_COUNT_;
858
859 /* count(*) has no args */
860 newagg->aggargtypes = NULL;
861 newagg->args = NULL;
862 newagg->aggstar = true;
863 newagg->location = -1;
864
866 }
867 }
868 }
869
871}
872
873
874Datum
885
886Datum
897
898Datum
911
912Datum
925
926Datum
939
940Datum
942{
946
947 if (arg2 == 0)
948 {
951 errmsg("division by zero")));
952 /* ensure compiler realizes we mustn't reach the division (gcc bug) */
954 }
955
956 /*
957 * INT64_MIN / -1 is problematic, since the result can't be represented on
958 * a two's-complement machine. Some machines produce INT64_MIN, some
959 * produce zero, some throw an exception. We can dodge the problem by
960 * recognizing that division by -1 is the same as negation.
961 */
962 if (arg2 == -1)
963 {
964 if (unlikely(arg1 == PG_INT64_MIN))
967 errmsg("bigint out of range")));
968 result = -arg1;
970 }
971
972 /* No overflow is possible */
973
974 result = arg1 / arg2;
975
977}
978
979Datum
992
993Datum
1006
1007Datum
1020
1021Datum
1023{
1026
1027 if (unlikely(arg2 == 0))
1028 {
1029 ereport(ERROR,
1031 errmsg("division by zero")));
1032 /* ensure compiler realizes we mustn't reach the division (gcc bug) */
1034 }
1035
1036 /* No overflow is possible */
1038}
1039
1040Datum
1053
1054Datum
1067
1068Datum
1081
1082Datum
1084{
1087 int64 result;
1088
1089 if (unlikely(arg2 == 0))
1090 {
1091 ereport(ERROR,
1093 errmsg("division by zero")));
1094 /* ensure compiler realizes we mustn't reach the division (gcc bug) */
1096 }
1097
1098 /*
1099 * INT64_MIN / -1 is problematic, since the result can't be represented on
1100 * a two's-complement machine. Some machines produce INT64_MIN, some
1101 * produce zero, some throw an exception. We can dodge the problem by
1102 * recognizing that division by -1 is the same as negation.
1103 */
1104 if (arg2 == -1)
1105 {
1106 if (unlikely(arg1 == PG_INT64_MIN))
1107 ereport(ERROR,
1109 errmsg("bigint out of range")));
1110 result = -arg1;
1112 }
1113
1114 /* No overflow is possible */
1115
1116 result = arg1 / arg2;
1117
1119}
1120
1121Datum
1134
1135Datum
1148
1149Datum
1162
1163Datum
1165{
1168
1169 if (unlikely(arg2 == 0))
1170 {
1171 ereport(ERROR,
1173 errmsg("division by zero")));
1174 /* ensure compiler realizes we mustn't reach the division (gcc bug) */
1176 }
1177
1178 /* No overflow is possible */
1180}
1181
1182/*
1183 * Binary arithmetics
1184 *
1185 * int8and - returns arg1 & arg2
1186 * int8or - returns arg1 | arg2
1187 * int8xor - returns arg1 # arg2
1188 * int8not - returns ~arg1
1189 * int8shl - returns arg1 << arg2
1190 * int8shr - returns arg1 >> arg2
1191 */
1192
1193Datum
1201
1202Datum
1210
1211Datum
1219
1220Datum
1227
1228Datum
1236
1237Datum
1245
1246/*----------------------------------------------------------
1247 * Conversion operators.
1248 *---------------------------------------------------------*/
1249
1250Datum
1257
1258Datum
1260{
1262
1264 ereturn(fcinfo->context, (Datum) 0,
1266 errmsg("integer out of range")));
1267
1269}
1270
1271Datum
1278
1279Datum
1281{
1283
1285 ereturn(fcinfo->context, (Datum) 0,
1287 errmsg("smallint out of range")));
1288
1290}
1291
1292Datum
1294{
1296 float8 result;
1297
1298 result = arg;
1299
1301}
1302
1303/*
1304 * dtoi8()
1305 * Convert float8 to 8-byte integer.
1306 */
1307Datum
1309{
1310 float8 num = PG_GETARG_FLOAT8(0);
1311
1312 /*
1313 * Get rid of any fractional part in the input. This is so we don't fail
1314 * on just-out-of-range values that would round into range. Note
1315 * assumption that rint() will pass through a NaN or Inf unchanged.
1316 */
1317 num = rint(num);
1318
1319 /* Range check */
1320 if (unlikely(isnan(num) || !FLOAT8_FITS_IN_INT64(num)))
1321 ereturn(fcinfo->context, (Datum) 0,
1323 errmsg("bigint out of range")));
1324
1325 PG_RETURN_INT64((int64) num);
1326}
1327
1328Datum
1330{
1332 float4 result;
1333
1334 result = arg;
1335
1337}
1338
1339/*
1340 * ftoi8()
1341 * Convert float4 to 8-byte integer.
1342 */
1343Datum
1345{
1346 float4 num = PG_GETARG_FLOAT4(0);
1347
1348 /*
1349 * Get rid of any fractional part in the input. This is so we don't fail
1350 * on just-out-of-range values that would round into range. Note
1351 * assumption that rint() will pass through a NaN or Inf unchanged.
1352 */
1353 num = rint(num);
1354
1355 /* Range check */
1356 if (unlikely(isnan(num) || !FLOAT4_FITS_IN_INT64(num)))
1357 ereturn(fcinfo->context, (Datum) 0,
1359 errmsg("bigint out of range")));
1360
1361 PG_RETURN_INT64((int64) num);
1362}
1363
1364Datum
1366{
1368
1369 if (unlikely(arg < 0) || unlikely(arg > PG_UINT32_MAX))
1370 ereturn(fcinfo->context, (Datum) 0,
1372 errmsg("OID out of range")));
1373
1375}
1376
1377Datum
1384
1385Datum
1392
1393/*
1394 * non-persistent numeric series generator
1395 */
1396Datum
1401
1402Datum
1404{
1407 int64 result;
1408 MemoryContext oldcontext;
1409
1410 /* stuff done only on the first call of the function */
1411 if (SRF_IS_FIRSTCALL())
1412 {
1414 int64 finish = PG_GETARG_INT64(1);
1415 int64 step = 1;
1416
1417 /* see if we were given an explicit step size */
1418 if (PG_NARGS() == 3)
1419 step = PG_GETARG_INT64(2);
1420 if (step == 0)
1421 ereport(ERROR,
1423 errmsg("step size cannot equal zero")));
1424
1425 /* create a function context for cross-call persistence */
1427
1428 /*
1429 * switch to memory context appropriate for multiple function calls
1430 */
1431 oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
1432
1433 /* allocate memory for user context */
1435
1436 /*
1437 * Use fctx to keep state from call to call. Seed current with the
1438 * original start value
1439 */
1440 fctx->current = start;
1441 fctx->finish = finish;
1442 fctx->step = step;
1443
1444 funcctx->user_fctx = fctx;
1445 MemoryContextSwitchTo(oldcontext);
1446 }
1447
1448 /* stuff done on every call of the function */
1450
1451 /*
1452 * get the saved state and use current as the result for this iteration
1453 */
1454 fctx = funcctx->user_fctx;
1455 result = fctx->current;
1456
1457 if ((fctx->step > 0 && fctx->current <= fctx->finish) ||
1458 (fctx->step < 0 && fctx->current >= fctx->finish))
1459 {
1460 /*
1461 * Increment current in preparation for next iteration. If next-value
1462 * computation overflows, this is the final result.
1463 */
1464 if (pg_add_s64_overflow(fctx->current, fctx->step, &fctx->current))
1465 fctx->step = 0;
1466
1467 /* do when there is more left to send */
1469 }
1470 else
1471 /* do when there is no more left */
1473}
1474
1475/*
1476 * Planner support function for generate_series(int8, int8 [, int8])
1477 */
1478Datum
1480{
1482 Node *ret = NULL;
1483
1485 {
1486 /* Try to estimate the number of rows returned */
1488
1489 if (is_funcclause(req->node)) /* be paranoid */
1490 {
1491 List *args = ((FuncExpr *) req->node)->args;
1492 Node *arg1,
1493 *arg2,
1494 *arg3;
1495
1496 /* We can use estimated argument values here */
1498 arg2 = estimate_expression_value(req->root, lsecond(args));
1499 if (list_length(args) >= 3)
1500 arg3 = estimate_expression_value(req->root, lthird(args));
1501 else
1502 arg3 = NULL;
1503
1504 /*
1505 * If any argument is constant NULL, we can safely assume that
1506 * zero rows are returned. Otherwise, if they're all non-NULL
1507 * constants, we can calculate the number of rows that will be
1508 * returned. Use double arithmetic to avoid overflow hazards.
1509 */
1510 if ((IsA(arg1, Const) &&
1511 ((Const *) arg1)->constisnull) ||
1512 (IsA(arg2, Const) &&
1513 ((Const *) arg2)->constisnull) ||
1514 (arg3 != NULL && IsA(arg3, Const) &&
1515 ((Const *) arg3)->constisnull))
1516 {
1517 req->rows = 0;
1518 ret = (Node *) req;
1519 }
1520 else if (IsA(arg1, Const) &&
1521 IsA(arg2, Const) &&
1522 (arg3 == NULL || IsA(arg3, Const)))
1523 {
1524 double start,
1525 finish,
1526 step;
1527
1529 finish = DatumGetInt64(((Const *) arg2)->constvalue);
1530 step = arg3 ? DatumGetInt64(((Const *) arg3)->constvalue) : 1;
1531
1532 /* This equation works for either sign of step */
1533 if (step != 0)
1534 {
1535 req->rows = floor((finish - start + step) / step);
1536 ret = (Node *) req;
1537 }
1538 }
1539 }
1540 }
1541
1542 PG_RETURN_POINTER(ret);
1543}
#define MAXINT8LEN
Definition builtins.h:22
uint64 Oid8
Definition c.h:756
#define PG_INT32_MAX
Definition c.h:673
#define PG_UINT32_MAX
Definition c.h:674
#define FLOAT4_FITS_IN_INT64(num)
Definition c.h:1173
#define Assert(condition)
Definition c.h:943
int64_t int64
Definition c.h:621
double float8
Definition c.h:714
int16_t int16
Definition c.h:619
#define FLOAT8_FITS_IN_INT64(num)
Definition c.h:1179
#define PG_INT16_MIN
Definition c.h:669
int32_t int32
Definition c.h:620
#define PG_INT64_MIN
Definition c.h:675
#define unlikely(x)
Definition c.h:438
float float4
Definition c.h:713
#define PG_INT32_MIN
Definition c.h:672
#define PG_INT16_MAX
Definition c.h:670
uint32 result
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
Node * estimate_expression_value(PlannerInfo *root, Node *node)
Definition clauses.c:2641
bool expr_is_nonnullable(PlannerInfo *root, Expr *expr, NotNullSource source)
Definition clauses.c:4785
Datum arg
Definition elog.c:1323
int errcode(int sqlerrcode)
Definition elog.c:875
#define ereturn(context, dummy_value,...)
Definition elog.h:280
#define ERROR
Definition elog.h:40
#define ereport(elevel,...)
Definition elog.h:152
#define palloc_object(type)
Definition fe_memutils.h:89
#define PG_GETARG_OID(n)
Definition fmgr.h:275
#define PG_RETURN_BYTEA_P(x)
Definition fmgr.h:373
#define PG_GETARG_FLOAT8(n)
Definition fmgr.h:283
#define PG_RETURN_FLOAT8(x)
Definition fmgr.h:369
#define PG_GETARG_POINTER(n)
Definition fmgr.h:277
#define PG_RETURN_CSTRING(x)
Definition fmgr.h:364
#define PG_RETURN_INT64(x)
Definition fmgr.h:370
#define PG_NARGS()
Definition fmgr.h:203
#define PG_GETARG_CSTRING(n)
Definition fmgr.h:278
#define PG_RETURN_NULL()
Definition fmgr.h:346
#define PG_GETARG_INT64(n)
Definition fmgr.h:284
#define PG_RETURN_INT16(x)
Definition fmgr.h:357
#define PG_RETURN_OID8(x)
Definition fmgr.h:362
#define PG_RETURN_INT32(x)
Definition fmgr.h:355
#define PG_GETARG_INT32(n)
Definition fmgr.h:269
#define PG_GETARG_BOOL(n)
Definition fmgr.h:274
#define PG_GETARG_FLOAT4(n)
Definition fmgr.h:282
#define PG_RETURN_POINTER(x)
Definition fmgr.h:363
#define PG_RETURN_FLOAT4(x)
Definition fmgr.h:368
#define PG_RETURN_OID(x)
Definition fmgr.h:361
#define PG_FUNCTION_ARGS
Definition fmgr.h:193
#define PG_RETURN_BOOL(x)
Definition fmgr.h:360
#define PG_GETARG_INT16(n)
Definition fmgr.h:271
#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
return str start
static const FormData_pg_attribute a1
Definition heap.c:144
static const FormData_pg_attribute a2
Definition heap.c:157
long val
Definition informix.c:689
Datum int8lcm(PG_FUNCTION_ARGS)
Definition int8.c:691
Datum int84div(PG_FUNCTION_ARGS)
Definition int8.c:941
Datum int8ge(PG_FUNCTION_ARGS)
Definition int8.c:161
Datum i8tooid(PG_FUNCTION_ARGS)
Definition int8.c:1365
Datum int8dec_any(PG_FUNCTION_ARGS)
Definition int8.c:778
Datum in_range_int8_int8(PG_FUNCTION_ARGS)
Definition int8.c:408
Datum int8abs(PG_FUNCTION_ARGS)
Definition int8.c:554
Datum int48ge(PG_FUNCTION_ARGS)
Definition int8.c:277
Datum int82le(PG_FUNCTION_ARGS)
Definition int8.c:326
Datum int28lt(PG_FUNCTION_ARGS)
Definition int8.c:366
Datum int84pl(PG_FUNCTION_ARGS)
Definition int8.c:899
Datum int48pl(PG_FUNCTION_ARGS)
Definition int8.c:980
Datum int8out(PG_FUNCTION_ARGS)
Definition int8.c:63
Datum int82mi(PG_FUNCTION_ARGS)
Definition int8.c:1055
Datum int84gt(PG_FUNCTION_ARGS)
Definition int8.c:201
Datum int28ne(PG_FUNCTION_ARGS)
Definition int8.c:357
Datum int8send(PG_FUNCTION_ARGS)
Definition int8.c:96
Datum int8ne(PG_FUNCTION_ARGS)
Definition int8.c:125
Datum int84(PG_FUNCTION_ARGS)
Definition int8.c:1259
Datum int8mul(PG_FUNCTION_ARGS)
Definition int8.c:497
Datum int84ge(PG_FUNCTION_ARGS)
Definition int8.c:219
Datum int48lt(PG_FUNCTION_ARGS)
Definition int8.c:250
Datum int8gcd(PG_FUNCTION_ARGS)
Definition int8.c:676
Datum int8not(PG_FUNCTION_ARGS)
Definition int8.c:1221
Datum int8le(PG_FUNCTION_ARGS)
Definition int8.c:152
Datum int8lt(PG_FUNCTION_ARGS)
Definition int8.c:134
Datum int48eq(PG_FUNCTION_ARGS)
Definition int8.c:232
Datum generate_series_step_int8(PG_FUNCTION_ARGS)
Definition int8.c:1403
Datum generate_series_int8(PG_FUNCTION_ARGS)
Definition int8.c:1397
Datum int8eq(PG_FUNCTION_ARGS)
Definition int8.c:116
Datum generate_series_int8_support(PG_FUNCTION_ARGS)
Definition int8.c:1479
Datum int82div(PG_FUNCTION_ARGS)
Definition int8.c:1083
Datum int48le(PG_FUNCTION_ARGS)
Definition int8.c:268
Datum int28gt(PG_FUNCTION_ARGS)
Definition int8.c:375
Datum i8tod(PG_FUNCTION_ARGS)
Definition int8.c:1293
Datum int8inc_support(PG_FUNCTION_ARGS)
Definition int8.c:788
Datum int8in(PG_FUNCTION_ARGS)
Definition int8.c:51
Datum int8mod(PG_FUNCTION_ARGS)
Definition int8.c:572
Datum oidtoi8(PG_FUNCTION_ARGS)
Definition int8.c:1378
Datum int28pl(PG_FUNCTION_ARGS)
Definition int8.c:1122
Datum int84eq(PG_FUNCTION_ARGS)
Definition int8.c:174
Datum int28div(PG_FUNCTION_ARGS)
Definition int8.c:1164
Datum int8pl(PG_FUNCTION_ARGS)
Definition int8.c:469
Datum int8larger(PG_FUNCTION_ARGS)
Definition int8.c:875
Datum int8xor(PG_FUNCTION_ARGS)
Definition int8.c:1212
Datum int28(PG_FUNCTION_ARGS)
Definition int8.c:1272
Datum int8gt(PG_FUNCTION_ARGS)
Definition int8.c:143
Datum int8div(PG_FUNCTION_ARGS)
Definition int8.c:511
Datum int48ne(PG_FUNCTION_ARGS)
Definition int8.c:241
Datum int82pl(PG_FUNCTION_ARGS)
Definition int8.c:1041
Datum int48mul(PG_FUNCTION_ARGS)
Definition int8.c:1008
Datum int48mi(PG_FUNCTION_ARGS)
Definition int8.c:994
Datum oidtooid8(PG_FUNCTION_ARGS)
Definition int8.c:1386
Datum int8up(PG_FUNCTION_ARGS)
Definition int8.c:461
Datum int8smaller(PG_FUNCTION_ARGS)
Definition int8.c:887
Datum int28le(PG_FUNCTION_ARGS)
Definition int8.c:384
static int64 int8gcd_internal(int64 arg1, int64 arg2)
Definition int8.c:615
Datum int82lt(PG_FUNCTION_ARGS)
Definition int8.c:308
Datum int82gt(PG_FUNCTION_ARGS)
Definition int8.c:317
Datum int82mul(PG_FUNCTION_ARGS)
Definition int8.c:1069
Datum dtoi8(PG_FUNCTION_ARGS)
Definition int8.c:1308
Datum int82ge(PG_FUNCTION_ARGS)
Definition int8.c:335
Datum int48div(PG_FUNCTION_ARGS)
Definition int8.c:1022
Datum int8inc_any(PG_FUNCTION_ARGS)
Definition int8.c:766
Datum int48gt(PG_FUNCTION_ARGS)
Definition int8.c:259
Datum int8or(PG_FUNCTION_ARGS)
Definition int8.c:1203
Datum int48(PG_FUNCTION_ARGS)
Definition int8.c:1251
Datum int8shr(PG_FUNCTION_ARGS)
Definition int8.c:1238
Datum int8recv(PG_FUNCTION_ARGS)
Definition int8.c:85
Datum int84le(PG_FUNCTION_ARGS)
Definition int8.c:210
Datum int8dec(PG_FUNCTION_ARGS)
Definition int8.c:742
Datum int84mi(PG_FUNCTION_ARGS)
Definition int8.c:913
Datum int82ne(PG_FUNCTION_ARGS)
Definition int8.c:299
Datum int82(PG_FUNCTION_ARGS)
Definition int8.c:1280
Datum int8inc_float8_float8(PG_FUNCTION_ARGS)
Definition int8.c:772
Datum int28ge(PG_FUNCTION_ARGS)
Definition int8.c:393
Datum int8shl(PG_FUNCTION_ARGS)
Definition int8.c:1229
Datum i8tof(PG_FUNCTION_ARGS)
Definition int8.c:1329
Datum int82eq(PG_FUNCTION_ARGS)
Definition int8.c:290
Datum int84ne(PG_FUNCTION_ARGS)
Definition int8.c:183
Datum int8mi(PG_FUNCTION_ARGS)
Definition int8.c:483
Datum ftoi8(PG_FUNCTION_ARGS)
Definition int8.c:1344
Datum int8and(PG_FUNCTION_ARGS)
Definition int8.c:1194
Datum int84mul(PG_FUNCTION_ARGS)
Definition int8.c:927
Datum int8um(PG_FUNCTION_ARGS)
Definition int8.c:447
Datum int28mi(PG_FUNCTION_ARGS)
Definition int8.c:1136
Datum int84lt(PG_FUNCTION_ARGS)
Definition int8.c:192
Datum int28eq(PG_FUNCTION_ARGS)
Definition int8.c:348
Datum int28mul(PG_FUNCTION_ARGS)
Definition int8.c:1150
Datum int8inc(PG_FUNCTION_ARGS)
Definition int8.c:728
static bool pg_mul_s64_overflow(int64 a, int64 b, int64 *result)
Definition int.h:293
static bool pg_sub_s64_overflow(int64 a, int64 b, int64 *result)
Definition int.h:262
static bool pg_add_s64_overflow(int64 a, int64 b, int64 *result)
Definition int.h:235
void * palloc(Size size)
Definition mcxt.c:1390
static bool is_funcclause(const void *clause)
Definition nodeFuncs.h:69
#define IsA(nodeptr, _type_)
Definition nodes.h:164
#define makeNode(_type_)
Definition nodes.h:161
int64 pg_strtoint64_safe(const char *s, Node *escontext)
Definition numutils.c:649
int pg_lltoa(int64 value, char *a)
Definition numutils.c:1226
static char * errmsg
@ NOTNULL_SOURCE_HASHTABLE
Definition optimizer.h:137
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:138
#define FRAMEOPTION_START_UNBOUNDED_PRECEDING
Definition parsenodes.h:617
#define FRAMEOPTION_END_UNBOUNDED_FOLLOWING
Definition parsenodes.h:620
const void size_t len
static int list_length(const List *l)
Definition pg_list.h:152
#define NIL
Definition pg_list.h:68
#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 char buf[DEFAULT_XLOG_SEG_SIZE]
MonotonicFunction
Definition plannodes.h:1838
@ MONOTONICFUNC_NONE
Definition plannodes.h:1839
@ MONOTONICFUNC_DECREASING
Definition plannodes.h:1841
@ MONOTONICFUNC_INCREASING
Definition plannodes.h:1840
@ MONOTONICFUNC_BOTH
Definition plannodes.h:1842
static Datum Int64GetDatum(int64 X)
Definition postgres.h:426
static int64 DatumGetInt64(Datum X)
Definition postgres.h:416
uint64_t Datum
Definition postgres.h:70
#define InvalidOid
unsigned int Oid
void pq_begintypsend(StringInfo buf)
Definition pqformat.c:325
int64 pq_getmsgint64(StringInfo msg)
Definition pqformat.c:452
bytea * pq_endtypsend(StringInfo buf)
Definition pqformat.c:345
static void pq_sendint64(StringInfo buf, uint64 i)
Definition pqformat.h:152
static int fb(int x)
struct StringInfoData * StringInfo
Definition string.h:15
Definition pg_list.h:54
Definition nodes.h:135
static uint32 gcd(uint32 a, uint32 b)