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 /*
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}
902
903
904Datum
915
916Datum
927
928Datum
941
942Datum
955
956Datum
969
970Datum
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}
1008
1009Datum
1022
1023Datum
1036
1037Datum
1050
1051Datum
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}
1069
1070Datum
1083
1084Datum
1097
1098Datum
1111
1112Datum
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}
1150
1151Datum
1164
1165Datum
1178
1179Datum
1192
1193Datum
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}
1211
1212/*
1213 * Binary arithmetics
1214 *
1215 * int8and - returns arg1 & arg2
1216 * int8or - returns arg1 | arg2
1217 * int8xor - returns arg1 # arg2
1218 * int8not - returns ~arg1
1219 * int8shl - returns arg1 << arg2
1220 * int8shr - returns arg1 >> arg2
1221 */
1222
1223Datum
1231
1232Datum
1240
1241Datum
1249
1250Datum
1257
1258Datum
1266
1267Datum
1275
1276/*----------------------------------------------------------
1277 * Conversion operators.
1278 *---------------------------------------------------------*/
1279
1280Datum
1287
1288Datum
1290{
1292
1294 ereturn(fcinfo->context, (Datum) 0,
1296 errmsg("integer out of range")));
1297
1299}
1300
1301Datum
1308
1309Datum
1311{
1313
1315 ereturn(fcinfo->context, (Datum) 0,
1317 errmsg("smallint out of range")));
1318
1320}
1321
1322Datum
1324{
1326 float8 result;
1327
1328 result = arg;
1329
1331}
1332
1333/*
1334 * dtoi8()
1335 * Convert float8 to 8-byte integer.
1336 */
1337Datum
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}
1357
1358Datum
1360{
1362 float4 result;
1363
1364 result = arg;
1365
1367}
1368
1369/*
1370 * ftoi8()
1371 * Convert float4 to 8-byte integer.
1372 */
1373Datum
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}
1393
1394Datum
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}
1406
1407Datum
1414
1415Datum
1422
1423/*
1424 * non-persistent numeric series generator
1425 */
1426Datum
1431
1432Datum
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}
1504
1505/*
1506 * Planner support function for generate_series(int8, int8 [, int8])
1507 */
1508Datum
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}
#define MAXINT8LEN
Definition builtins.h:22
uint64 Oid8
Definition c.h:815
#define PG_INT32_MAX
Definition c.h:732
#define PG_UINT32_MAX
Definition c.h:733
#define FLOAT4_FITS_IN_INT64(num)
Definition c.h:1213
#define Assert(condition)
Definition c.h:1002
int64_t int64
Definition c.h:680
double float8
Definition c.h:773
int16_t int16
Definition c.h:678
#define FLOAT8_FITS_IN_INT64(num)
Definition c.h:1219
#define PG_INT16_MIN
Definition c.h:728
int32_t int32
Definition c.h:679
#define PG_INT64_MIN
Definition c.h:734
#define unlikely(x)
Definition c.h:497
float float4
Definition c.h:772
#define PG_INT32_MIN
Definition c.h:731
#define PG_INT16_MAX
Definition c.h:729
uint32 result
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
Node * estimate_expression_value(PlannerInfo *root, Node *node)
Definition clauses.c:2660
bool expr_is_nonnullable(PlannerInfo *root, Expr *expr, NotNullSource source)
Definition clauses.c:4804
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:971
Datum int8ge(PG_FUNCTION_ARGS)
Definition int8.c:161
Datum i8tooid(PG_FUNCTION_ARGS)
Definition int8.c:1395
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:929
Datum int48pl(PG_FUNCTION_ARGS)
Definition int8.c:1010
Datum int8out(PG_FUNCTION_ARGS)
Definition int8.c:63
Datum int82mi(PG_FUNCTION_ARGS)
Definition int8.c:1085
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:1289
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:1251
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:1433
Datum generate_series_int8(PG_FUNCTION_ARGS)
Definition int8.c:1427
Datum int8eq(PG_FUNCTION_ARGS)
Definition int8.c:116
Datum generate_series_int8_support(PG_FUNCTION_ARGS)
Definition int8.c:1509
Datum int82div(PG_FUNCTION_ARGS)
Definition int8.c:1113
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:1323
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:1408
Datum int28pl(PG_FUNCTION_ARGS)
Definition int8.c:1152
Datum int84eq(PG_FUNCTION_ARGS)
Definition int8.c:174
Datum int28div(PG_FUNCTION_ARGS)
Definition int8.c:1194
Datum int8pl(PG_FUNCTION_ARGS)
Definition int8.c:469
Datum int8larger(PG_FUNCTION_ARGS)
Definition int8.c:905
Datum int8xor(PG_FUNCTION_ARGS)
Definition int8.c:1242
Datum int28(PG_FUNCTION_ARGS)
Definition int8.c:1302
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:1071
Datum int48mul(PG_FUNCTION_ARGS)
Definition int8.c:1038
Datum int48mi(PG_FUNCTION_ARGS)
Definition int8.c:1024
Datum oidtooid8(PG_FUNCTION_ARGS)
Definition int8.c:1416
Datum int8up(PG_FUNCTION_ARGS)
Definition int8.c:461
Datum int8smaller(PG_FUNCTION_ARGS)
Definition int8.c:917
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:1099
Datum dtoi8(PG_FUNCTION_ARGS)
Definition int8.c:1338
Datum int82ge(PG_FUNCTION_ARGS)
Definition int8.c:335
Datum int48div(PG_FUNCTION_ARGS)
Definition int8.c:1052
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:1233
Datum int48(PG_FUNCTION_ARGS)
Definition int8.c:1281
Datum int8shr(PG_FUNCTION_ARGS)
Definition int8.c:1268
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:943
Datum int82ne(PG_FUNCTION_ARGS)
Definition int8.c:299
Datum int82(PG_FUNCTION_ARGS)
Definition int8.c:1310
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:1259
Datum i8tof(PG_FUNCTION_ARGS)
Definition int8.c:1359
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:1374
Datum int8and(PG_FUNCTION_ARGS)
Definition int8.c:1224
Datum int84mul(PG_FUNCTION_ARGS)
Definition int8.c:957
Datum int8um(PG_FUNCTION_ARGS)
Definition int8.c:447
Datum int28mi(PG_FUNCTION_ARGS)
Definition int8.c:1166
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:1180
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:162
#define makeNode(_type_)
Definition nodes.h:159
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_EXCLUDE_CURRENT_ROW
Definition parsenodes.h:629
#define FRAMEOPTION_START_UNBOUNDED_PRECEDING
Definition parsenodes.h:619
#define FRAMEOPTION_RANGE
Definition parsenodes.h:615
#define FRAMEOPTION_END_UNBOUNDED_FOLLOWING
Definition parsenodes.h:622
#define FRAMEOPTION_EXCLUSION
Definition parsenodes.h:637
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: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
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:133
Expr * aggfilter
Definition primnodes.h:600
static uint32 gcd(uint32 a, uint32 b)