PostgreSQL Source Code: src/backend/executor/execExpr.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
32
54
55
57{
58
59
60
61
67
70
73 Datum *resv, bool *resnull);
75 Oid funcid, Oid inputcollid,
79 Datum *resv, bool *resnull);
89 Datum *resv, bool *resnull);
93 Datum *resv, bool *resnull);
97 int transno, int setno, int setoff, bool ishash,
98 bool nullcheck);
100 Datum *resv, bool *resnull,
104 bool exists_coerce,
105 Datum *resv, bool *resnull);
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
144{
147
148
149 if (node == NULL)
150 return NULL;
151
152
154 state->expr = node;
155 state->parent = parent;
156 state->ext_params = NULL;
157
158
160
161
163
164
167
169
171}
172
173
174
175
176
177
178
181{
184
185
186 if (node == NULL)
187 return NULL;
188
189
191 state->expr = node;
192 state->parent = NULL;
193 state->ext_params = ext_params;
194
195
197
198
200
201
204
206
208}
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
230{
234
235
236 if (qual == NIL)
237 return NULL;
238
240
243 state->parent = parent;
244 state->ext_params = NULL;
245
246
248
249
251
252
253
254
255
256
257
258
260
261
262
263
266
268 {
269
271
272
276 state->steps_len - 1);
277 }
278
279
281 {
283
287 }
288
289
290
291
292
293
296
298
300}
301
302
303
304
305
306
307
308
309
310
311
312
313
316{
317
318 if (qual == NIL)
319 return NULL;
320
322
323
324
325
326
327
329}
330
331
332
333
336{
339
340 foreach(lc, nodes)
341 {
343
345 }
346
347 return result;
348}
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
375{
380
382
385 state->expr = (Expr *) targetList;
386 state->parent = parent;
387 state->ext_params = NULL;
388
389 state->resultslot = slot;
390
391
393
394
395 foreach(lc, targetList)
396 {
400 bool isSafeVar = false;
401
402
403
404
405
406
407
408
409
410 if (tle->expr != NULL &&
412 ((Var *) tle->expr)->varattno > 0)
413 {
414
417
418 if (inputDesc == NULL)
419 isSafeVar = true;
420 else if (attnum <= inputDesc->natts)
421 {
423
424
425
426
427
428
429 if (!attr->attisdropped && variable->vartype == attr->atttypid)
430 {
431 isSafeVar = true;
432 }
433 }
434 }
435
436 if (isSafeVar)
437 {
438
440 {
442
444 break;
445
447
449 break;
450
451
452
453 default:
454
455
456
457
458
459 switch (variable->varreturningtype)
460 {
463 break;
467 break;
471 break;
472 }
473 break;
474 }
475
479 }
480 else
481 {
482
483
484
485
486
487
488
489
492
493
494
495
496
499 else
503 }
504 }
505
508
510
511 return projInfo;
512}
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
548 bool evalTargetList,
549 List *targetColnos,
554{
557 int nAssignableCols;
558 bool sawJunk;
562 int outerattnum;
564 *lc2;
565
567
570 if (evalTargetList)
571 state->expr = (Expr *) targetList;
572 else
573 state->expr = NULL;
574 state->parent = parent;
575 state->ext_params = NULL;
576
577 state->resultslot = slot;
578
579
580
581
582
583 nAssignableCols = 0;
584 sawJunk = false;
585 foreach(lc, targetList)
586 {
588
589 if (tle->resjunk)
590 sawJunk = true;
591 else
592 {
593 if (sawJunk)
594 elog(ERROR, "subplan target list is out of order");
595 nAssignableCols++;
596 }
597 }
598
599
600 if (nAssignableCols != list_length(targetColnos))
601 elog(ERROR, "targetColnos does not match subplan target list");
602
603
604
605
606
607
608 assignedCols = NULL;
609 foreach(lc, targetColnos)
610 {
612
613 assignedCols = bms_add_member(assignedCols, targetattnum);
614 }
615
616
617
618
619
620
622 {
624
626 continue;
628 continue;
630 break;
631 }
632
633
634
635
636
637
638 if (evalTargetList)
640 else
642
644
645
646
647
648
649
650
651
652 outerattnum = 0;
653 forboth(lc, targetList, lc2, targetColnos)
654 {
658
659 Assert(!tle->resjunk);
660
661
662
663
664 if (targetattnum <= 0 || targetattnum > relDesc->natts)
666 (errcode(ERRCODE_DATATYPE_MISMATCH),
667 errmsg("table row type and query-specified row type do not match"),
668 errdetail("Query has too many columns.")));
670
671 if (attr->attisdropped)
673 (errcode(ERRCODE_DATATYPE_MISMATCH),
674 errmsg("table row type and query-specified row type do not match"),
675 errdetail("Query provides a value for a dropped column at ordinal position %d.",
676 targetattnum)));
679 (errcode(ERRCODE_DATATYPE_MISMATCH),
680 errmsg("table row type and query-specified row type do not match"),
681 errdetail("Table has type %s at ordinal position %d, but query expects %s.",
683 targetattnum,
685
686
687 if (evalTargetList)
688 {
689
690
691
692
693
694
697
701 }
702 else
703 {
704
709 }
710 outerattnum++;
711 }
712
713
714
715
716
718 {
720
722 {
723
730
734 }
736 {
737
742 }
743 }
744
747
749
750 return projInfo;
751}
752
753
754
755
756
757
758
759
760
761
762
763
766{
769
771
773
775
777
778 return result;
779}
780
781
782
783
784
785
786
787
788
789
790
791
794{
797
799
801
803
805
806 return result;
807}
808
809
810
811
812
813
814
817{
820
822
824
826
828
829 return result;
830}
831
832
833
834
835
836
837
840{
844
845
847
848 foreach(lc, nodes)
849 {
851
853 }
854
856
857 return result;
858}
859
860
861
862
863
864
865
866
867
868
869
870
871bool
873{
875 bool isnull;
876
877
878 if (state == NULL)
879 return true;
880
881
883
885
886 if (isnull)
887 return true;
888
890}
891
892
893
894
895
896
897
898
899
900
901static void
903{
905 return;
906
908}
909
910
911
912
913
914
915
916
917
918static void
920 Datum *resv, bool *resnull)
921{
923
924
926
927
928 Assert(resv != NULL && resnull != NULL);
930 scratch.resnull = resnull;
931
932
934 {
935 case T_Var:
936 {
938
940 {
941
943 }
944 else if (variable->varattno <= 0)
945 {
946
951 {
954 break;
957 break;
958
959
960
961 default:
962 switch (variable->varreturningtype)
963 {
966 break;
970 break;
974 break;
975 }
976 break;
977 }
978 }
979 else
980 {
981
986 {
989 break;
992 break;
993
994
995
996 default:
997 switch (variable->varreturningtype)
998 {
1001 break;
1005 break;
1009 break;
1010 }
1011 break;
1012 }
1013 }
1014
1016 break;
1017 }
1018
1019 case T_Const:
1020 {
1022
1026
1028 break;
1029 }
1030
1031 case T_Param:
1032 {
1035
1037 {
1043 break;
1045
1046
1047
1048
1049
1050
1051
1052 if (state->ext_params)
1053 params = state->ext_params;
1054 else if (state->parent &&
1055 state->parent->state)
1056 params = state->parent->state->es_param_list_info;
1057 else
1058 params = NULL;
1060 {
1062 resv, resnull);
1063 }
1064 else
1065 {
1070 }
1071 break;
1072 default:
1073 elog(ERROR, "unrecognized paramkind: %d",
1075 break;
1076 }
1077 break;
1078 }
1079
1080 case T_Aggref:
1081 {
1083
1086
1088 {
1090
1092 }
1093 else
1094 {
1095
1096 elog(ERROR, "Aggref found in non-Agg plan node");
1097 }
1098
1100 break;
1101 }
1102
1103 case T_GroupingFunc:
1104 {
1106 Agg *agg;
1107
1110 elog(ERROR, "GroupingFunc found in non-Agg plan node");
1111
1113
1114 agg = (Agg *) (state->parent->plan);
1115
1118 else
1120
1122 break;
1123 }
1124
1125 case T_WindowFunc:
1126 {
1129
1130 wfstate->wfunc = wfunc;
1131
1133 {
1135 int nfuncs;
1136
1138 nfuncs = ++winstate->numfuncs;
1139 if (wfunc->winagg)
1141
1142
1147
1148
1149
1150
1151
1152
1153
1154 if (nfuncs != winstate->numfuncs)
1156 (errcode(ERRCODE_WINDOWING_ERROR),
1157 errmsg("window function calls cannot be nested")));
1158 }
1159 else
1160 {
1161
1162 elog(ERROR, "WindowFunc found in non-WindowAgg plan node");
1163 }
1164
1168 break;
1169 }
1170
1171 case T_MergeSupportFunc:
1172 {
1173
1174 if (->parent ||
1177 elog(ERROR, "MergeSupportFunc found in non-merge plan node");
1178
1181 break;
1182 }
1183
1184 case T_SubscriptingRef:
1185 {
1187
1189 break;
1190 }
1191
1192 case T_FuncExpr:
1193 {
1195
1197 func->args, func->funcid, func->inputcollid,
1200 break;
1201 }
1202
1203 case T_OpExpr:
1204 {
1206
1208 op->args, op->opfuncid, op->inputcollid,
1211 break;
1212 }
1213
1214 case T_DistinctExpr:
1215 {
1217
1219 op->args, op->opfuncid, op->inputcollid,
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1233 break;
1234 }
1235
1236 case T_NullIfExpr:
1237 {
1239
1241 op->args, op->opfuncid, op->inputcollid,
1243
1244
1245
1246
1247
1248
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1263 break;
1264 }
1265
1266 case T_ScalarArrayOpExpr:
1267 {
1269 Expr *scalararg;
1270 Expr *arrayarg;
1274 Oid cmpfuncid;
1275
1276
1277
1278
1279
1280
1281
1283 {
1285 cmpfuncid = opexpr->negfuncid;
1286 }
1287 else
1288 cmpfuncid = opexpr->opfuncid;
1289
1293
1294
1295 aclresult = object_aclcheck(ProcedureRelationId, cmpfuncid,
1302
1304 {
1305 aclresult = object_aclcheck(ProcedureRelationId, opexpr->hashfuncid,
1312 }
1313
1314
1320 opexpr->inputcollid, NULL, NULL);
1321
1322
1323
1324
1325
1326
1327
1328
1330 {
1331
1334
1335
1336
1337
1338
1339
1340
1341
1343
1344
1350
1351
1353 }
1354 else
1355 {
1356
1360
1361
1362
1363
1364
1365
1366
1368
1369
1377 }
1378 break;
1379 }
1380
1381 case T_BoolExpr:
1382 {
1385 List *adjust_jumps = NIL;
1386 int off;
1388
1389
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406 off = 0;
1407 foreach(lc, boolexpr->args)
1408 {
1410
1411
1413
1414
1415 switch (boolexpr->boolop)
1416 {
1419
1420 if (off == 0)
1422 else if (off + 1 == nargs)
1424 else
1426 break;
1429
1430 if (off == 0)
1432 else if (off + 1 == nargs)
1434 else
1436 break;
1439
1441 break;
1442 default:
1443 elog(ERROR, "unrecognized boolop: %d",
1444 (int) boolexpr->boolop);
1445 break;
1446 }
1447
1450 adjust_jumps = lappend_int(adjust_jumps,
1451 state->steps_len - 1);
1452 off++;
1453 }
1454
1455
1456 foreach(lc, adjust_jumps)
1457 {
1459
1462 }
1463
1464 break;
1465 }
1466
1467 case T_SubPlan:
1468 {
1470
1471
1472
1473
1474
1475
1476
1478 {
1483 break;
1484 }
1485
1487 break;
1488 }
1489
1490 case T_FieldSelect:
1491 {
1493
1494
1496
1497
1502
1504 break;
1505 }
1506
1507 case T_FieldStore:
1508 {
1513 bool *nulls;
1514 int ncolumns;
1516 *l2;
1517
1518
1520 ncolumns = tupDesc->natts;
1522
1523
1526
1527
1530
1531
1533
1534
1542
1543
1545 {
1548 Datum *save_innermost_caseval;
1549 bool *save_innermost_casenull;
1550
1551 if (fieldnum <= 0 || fieldnum > ncolumns)
1552 elog(ERROR, "field number %d is out of range in FieldStore",
1553 fieldnum);
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579 save_innermost_caseval = state->innermost_caseval;
1580 save_innermost_casenull = state->innermost_casenull;
1581 state->innermost_caseval = &values[fieldnum - 1];
1582 state->innermost_casenull = &nulls[fieldnum - 1];
1583
1585 &values[fieldnum - 1],
1586 &nulls[fieldnum - 1]);
1587
1588 state->innermost_caseval = save_innermost_caseval;
1589 state->innermost_casenull = save_innermost_casenull;
1590 }
1591
1592
1600 break;
1601 }
1602
1603 case T_RelabelType:
1604 {
1605
1607
1609 break;
1610 }
1611
1612 case T_CoerceViaIO:
1613 {
1615 Oid iofunc;
1616 bool typisvarlena;
1617 Oid typioparam;
1619
1620
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631 if (state->escontext == NULL)
1633 else
1635
1636
1639
1641 &iofunc, &typisvarlena);
1647
1648
1651
1653 &iofunc, &typioparam);
1659
1660
1661
1662
1663
1669
1671
1673 break;
1674 }
1675
1676 case T_ArrayCoerceExpr:
1677 {
1679 Oid resultelemtype;
1681
1682
1684
1688 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1689 errmsg("target type is not an array")));
1690
1691
1692
1693
1694
1695
1696
1701
1704
1707
1708 if (elemstate->steps_len == 1 &&
1710 {
1711
1712 elemstate = NULL;
1713 }
1714 else
1715 {
1716
1719
1721 }
1722
1726
1727 if (elemstate)
1728 {
1729
1731 }
1732 else
1733 {
1734
1736 }
1737
1739 break;
1740 }
1741
1742 case T_ConvertRowtypeExpr:
1743 {
1746
1747
1749 rowcachep[0].cacheptr = NULL;
1750 rowcachep[1].cacheptr = NULL;
1751
1752
1754
1755
1763
1765 break;
1766 }
1767
1768
1769 case T_CaseExpr:
1770 {
1772 List *adjust_jumps = NIL;
1773 Datum *caseval = NULL;
1774 bool *casenull = NULL;
1776
1777
1778
1779
1780
1781
1782 if (caseExpr->arg != NULL)
1783 {
1784
1787
1789 caseval, casenull);
1790
1791
1792
1793
1794
1796 {
1797
1800 scratch.resnull = casenull;
1804
1806 scratch.resnull = resnull;
1807 }
1808 }
1809
1810
1811
1812
1813
1814
1815
1816 foreach(lc, caseExpr->args)
1817 {
1819 Datum *save_innermost_caseval;
1820 bool *save_innermost_casenull;
1821 int whenstep;
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833 save_innermost_caseval = state->innermost_caseval;
1834 save_innermost_casenull = state->innermost_casenull;
1835 state->innermost_caseval = caseval;
1836 state->innermost_casenull = casenull;
1837
1838
1840
1841 state->innermost_caseval = save_innermost_caseval;
1842 state->innermost_casenull = save_innermost_casenull;
1843
1844
1846 scratch.d.jump.jumpdone = -1;
1848 whenstep = state->steps_len - 1;
1849
1850
1851
1852
1853
1855
1856
1858 scratch.d.jump.jumpdone = -1;
1860
1861
1862
1863
1864
1865 adjust_jumps = lappend_int(adjust_jumps,
1866 state->steps_len - 1);
1867
1868
1869
1870
1871
1872 state->steps[whenstep].d.jump.jumpdone = state->steps_len;
1873 }
1874
1875
1877
1878
1880 resv, resnull);
1881
1882
1883 foreach(lc, adjust_jumps)
1884 {
1886
1890 }
1891
1892 break;
1893 }
1894
1895 case T_CaseTestExpr:
1896 {
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906 if (state->innermost_caseval == NULL)
1908 else
1909 {
1913 }
1915 break;
1916 }
1917
1918 case T_ArrayExpr:
1919 {
1921 int nelems = list_length(arrayexpr->elements);
1923 int elemoff;
1924
1925
1926
1927
1928
1929
1936
1937
1940
1941
1946
1947
1948 elemoff = 0;
1949 foreach(lc, arrayexpr->elements)
1950 {
1952
1956 elemoff++;
1957 }
1958
1959
1961 break;
1962 }
1963
1964 case T_RowExpr:
1965 {
1969 int i;
1971
1972
1973 if (rowexpr->row_typeid == RECORDOID)
1974 {
1975
1977
1979
1981 }
1982 else
1983 {
1984
1986 }
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996 Assert(nelems <= tupdesc->natts);
1997 nelems = Max(nelems, tupdesc->natts);
1998
1999
2000
2001
2002
2005
2006
2011
2012 memset(scratch.d.row.elemnulls, true, sizeof(bool) * nelems);
2013
2014
2015 i = 0;
2016 foreach(l, rowexpr->args)
2017 {
2020
2021 if (!att->attisdropped)
2022 {
2023
2024
2025
2026
2027
2028
2031 (errcode(ERRCODE_DATATYPE_MISMATCH),
2032 errmsg("ROW() column has type %s instead of type %s",
2035 }
2036 else
2037 {
2038
2039
2040
2041
2042
2044 }
2045
2046
2050 i++;
2051 }
2052
2053
2055 break;
2056 }
2057
2058 case T_RowCompareExpr:
2059 {
2061 int nopers = list_length(rcexpr->opnos);
2062 List *adjust_jumps = NIL;
2064 *l_right_expr,
2065 *l_opno,
2066 *l_opfamily,
2067 *l_inputcollid;
2069
2070
2071
2072
2073
2074
2079
2081 l_right_expr, rcexpr->rargs,
2082 l_opno, rcexpr->opnos,
2083 l_opfamily, rcexpr->opfamilies,
2084 l_inputcollid, rcexpr->inputcollids)
2085 {
2091 int strategy;
2092 Oid lefttype;
2093 Oid righttype;
2094 Oid proc;
2097
2099 &strategy,
2100 &lefttype,
2101 &righttype);
2103 lefttype,
2104 righttype,
2107 elog(ERROR, "missing support function %d(%u,%u) in opfamily %u",
2108 BTORDER_PROC, lefttype, righttype, opfamily);
2109
2110
2116 inputcollid, NULL, NULL);
2117
2118
2119
2120
2121
2122
2123
2124
2125
2130
2135
2138
2140 adjust_jumps = lappend_int(adjust_jumps,
2141 state->steps_len - 1);
2142 }
2143
2144
2145
2146
2147
2148 if (nopers == 0)
2149 {
2154 }
2155
2156
2160
2161
2162 foreach(lc, adjust_jumps)
2163 {
2165
2169
2170
2172
2174 }
2175
2176 break;
2177 }
2178
2179 case T_CoalesceExpr:
2180 {
2182 List *adjust_jumps = NIL;
2184
2185
2187
2188
2189
2190
2191
2192 foreach(lc, coalesce->args)
2193 {
2195
2196
2198
2199
2201 scratch.d.jump.jumpdone = -1;
2203
2204 adjust_jumps = lappend_int(adjust_jumps,
2205 state->steps_len - 1);
2206 }
2207
2208
2209
2210
2211
2212
2213
2214
2215 foreach(lc, adjust_jumps)
2216 {
2218
2222 }
2223
2224 break;
2225 }
2226
2227 case T_MinMaxExpr:
2228 {
2235 int off;
2236
2237
2242 (errcode(ERRCODE_UNDEFINED_FUNCTION),
2243 errmsg("could not identify a comparison function for type %s",
2245
2246
2247
2248
2249
2250
2251
2252
2253
2259 minmaxexpr->inputcollid, NULL, NULL);
2260
2262
2266
2270
2271
2272 off = 0;
2273 foreach(lc, minmaxexpr->args)
2274 {
2276
2280 off++;
2281 }
2282
2283
2285 break;
2286 }
2287
2288 case T_SQLValueFunction:
2289 {
2291
2294
2296 break;
2297 }
2298
2299 case T_XmlExpr:
2300 {
2304 int off;
2306
2309
2310
2311 if (nnamed)
2312 {
2315 }
2316 else
2317 {
2320 }
2321
2322 if (nargs)
2323 {
2326 }
2327 else
2328 {
2331 }
2332
2333
2334 off = 0;
2336 {
2338
2342 off++;
2343 }
2344
2345 off = 0;
2346 foreach(arg, xexpr->args)
2347 {
2349
2353 off++;
2354 }
2355
2356
2358 break;
2359 }
2360
2361 case T_JsonValueExpr:
2362 {
2364
2369 break;
2370 }
2371
2372 case T_JsonConstructorExpr:
2373 {
2378 int argno = 0;
2379
2380 if (ctor->func)
2381 {
2383 }
2386 {
2387
2389 }
2390 else
2391 {
2393
2395
2398
2403 jcstate->nargs = nargs;
2404
2405 foreach(lc, args)
2406 {
2408
2410
2412 {
2413
2415
2416 jcstate->arg_values[argno] = con->constvalue;
2417 jcstate->arg_nulls[argno] = con->constisnull;
2418 }
2419 else
2420 {
2424 }
2425 argno++;
2426 }
2427
2428
2430 {
2431 bool is_jsonb =
2433
2436
2437 for (int i = 0; i < nargs; i++)
2438 {
2440 Oid outfuncid;
2442
2444 &category, &outfuncid);
2445
2448 }
2449 }
2450
2452 }
2453
2455 {
2456 Datum *innermost_caseval = state->innermost_caseval;
2457 bool *innermost_isnull = state->innermost_casenull;
2458
2459 state->innermost_caseval = resv;
2460 state->innermost_casenull = resnull;
2461
2463
2464 state->innermost_caseval = innermost_caseval;
2465 state->innermost_casenull = innermost_isnull;
2466 }
2467 }
2468 break;
2469
2470 case T_JsonIsPredicate:
2471 {
2473
2475
2478
2480 break;
2481 }
2482
2483 case T_JsonExpr:
2484 {
2486
2487
2488
2489
2490
2491
2494 resv, resnull);
2495 else
2497 break;
2498 }
2499
2500 case T_NullTest:
2501 {
2503
2505 {
2506 if (ntest->argisrow)
2508 else
2510 }
2512 {
2513 if (ntest->argisrow)
2515 else
2517 }
2518 else
2519 {
2520 elog(ERROR, "unrecognized nulltesttype: %d",
2522 }
2523
2525
2526
2528 resv, resnull);
2529
2530
2532 break;
2533 }
2534
2535 case T_BooleanTest:
2536 {
2538
2539
2540
2541
2542
2543
2544
2546
2548 {
2551 break;
2554 break;
2557 break;
2560 break;
2562
2564 break;
2566
2568 break;
2569 default:
2570 elog(ERROR, "unrecognized booltesttype: %d",
2572 }
2573
2575 break;
2576 }
2577
2578 case T_CoerceToDomain:
2579 {
2581
2583 resv, resnull);
2584 break;
2585 }
2586
2587 case T_CoerceToDomainValue:
2588 {
2589
2590
2591
2592
2593
2594
2595
2596
2597 if (state->innermost_domainval == NULL)
2599 else
2600 {
2602
2605 }
2607 break;
2608 }
2609
2610 case T_CurrentOfExpr:
2611 {
2614 break;
2615 }
2616
2617 case T_NextValueExpr:
2618 {
2620
2624
2626 break;
2627 }
2628
2629 case T_ReturningExpr:
2630 {
2632 int retstep;
2633
2634
2640 retstep = state->steps_len - 1;
2641
2642
2644
2645
2646 state->steps[retstep].d.returningexpr.jumpdone = state->steps_len;
2647
2648
2651 else
2653
2654 break;
2655 }
2656
2657 default:
2658 elog(ERROR, "unrecognized node type: %d",
2660 break;
2661 }
2662}
2663
2664
2665
2666
2667
2668
2669
2670void
2672{
2674 {
2677 }
2679 {
2683 }
2684
2686}
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696static void
2699{
2704 int argno;
2706
2707
2712
2713
2714
2715
2716
2717
2718
2721 (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
2722 errmsg_plural("cannot pass more than %d argument to a function",
2723 "cannot pass more than %d arguments to a function",
2726
2727
2732
2733
2736
2737
2739 nargs, inputcollid, NULL, NULL);
2740
2741
2744
2745
2748 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2749 errmsg("set-valued function called in context that cannot accept a set"),
2753
2754
2755 argno = 0;
2756 foreach(lc, args)
2757 {
2759
2761 {
2762
2763
2764
2765
2767
2768 fcinfo->args[argno].value = con->constvalue;
2769 fcinfo->args[argno].isnull = con->constisnull;
2770 }
2771 else
2772 {
2776 }
2777 argno++;
2778 }
2779
2780
2781 if (pgstat_track_functions <= flinfo->fn_stats)
2782 {
2783 if (flinfo->fn_strict && nargs > 0)
2784 {
2785
2786 if (nargs == 1)
2788 else if (nargs == 2)
2790 else
2792 }
2793 else
2795 }
2796 else
2797 {
2798 if (flinfo->fn_strict && nargs > 0)
2800 else
2802 }
2803}
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813static void
2816 Datum *resv, bool *resnull)
2817{
2822
2823 if (->parent)
2824 elog(ERROR, "SubPlan found with no parent plan");
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2841 {
2844
2847
2850
2853 }
2854
2856
2857
2859 sstate);
2860
2863 scratch.resnull = resnull;
2865
2867}
2868
2869
2870
2871
2872
2873static void
2875{
2877
2878
2880
2881
2883}
2884
2885
2886
2887
2888
2889static void
2891{
2894
2897
2898
2899
2900
2901
2903 {
2911 }
2913 {
2921 }
2923 {
2931 }
2933 {
2941 }
2943 {
2951 }
2952
2953
2954
2955
2956
2957
2958
2959
2961 {
2963
2965
2966
2969 }
2970}
2971
2972
2973
2974
2975static bool
2977{
2978 if (node == NULL)
2979 return false;
2981 {
2984
2986 {
2989 break;
2990
2993 break;
2994
2995
2996
2997 default:
2998 switch (variable->varreturningtype)
2999 {
3002 break;
3005 break;
3008 break;
3009 }
3010 break;
3011 }
3012 return false;
3013 }
3014
3015
3017 {
3019
3022 subplan);
3023 }
3024
3025
3026
3027
3028
3029
3030
3032 return false;
3034 return false;
3036 return false;
3038}
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054static bool
3056{
3060 bool isfixed = false;
3062
3068
3070 {
3074 }
3075 else if (!parent)
3076 {
3077 isfixed = false;
3078 }
3080 {
3082
3084 {
3085 isfixed = false;
3086 }
3088 {
3089 isfixed = true;
3092 }
3093 else if (is)
3094 {
3097 }
3098 }
3100 {
3102
3104 {
3105 isfixed = false;
3106 }
3108 {
3109 isfixed = true;
3112 }
3113 else if (os)
3114 {
3117 }
3118 }
3122 {
3124
3126 tts_ops = parent->scanops;
3127
3130 }
3131
3132 if (isfixed && desc != NULL && tts_ops != NULL)
3133 {
3137 }
3138 else
3139 {
3143 }
3144
3145
3147 return false;
3148
3149 return true;
3150}
3151
3152
3153
3154
3155
3156static void
3158{
3160
3161
3168
3169
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187 if (parent)
3188 {
3190
3191 switch (nodeTag(parent))
3192 {
3193 case T_SubqueryScanState:
3195 break;
3196 case T_CteScanState:
3197 subplan = ((CteScanState *) parent)->cteplanstate;
3198 break;
3199 default:
3200 break;
3201 }
3202
3203 if (subplan)
3204 {
3205 bool junk_filter_needed = false;
3207
3208
3210 {
3212
3213 if (tle->resjunk)
3214 {
3215 junk_filter_needed = true;
3216 break;
3217 }
3218 }
3219
3220
3221 if (junk_filter_needed)
3222 {
3227 }
3228 }
3229 }
3230}
3231
3232
3233
3234
3235static void
3238{
3239 bool isAssignment = (sbsref->refassgnexpr != NULL);
3245 char *ptr;
3246 List *adjust_jumps = NIL;
3248 int i;
3249
3250
3252 if (!sbsroutines)
3254 (errcode(ERRCODE_DATATYPE_MISMATCH),
3255 errmsg("cannot subscript type %s because it does not support subscripting",
3260
3261
3263 (nupper + nlower) * (sizeof(Datum) +
3264 2 * sizeof(bool)));
3265
3266
3268 sbsrefstate->numupper = nupper;
3269 sbsrefstate->numlower = nlower;
3270
3273 ptr += nupper * sizeof(Datum);
3275 ptr += nlower * sizeof(Datum);
3277 ptr += nupper * sizeof(bool);
3279 ptr += nlower * sizeof(bool);
3281 ptr += nupper * sizeof(bool);
3283
3284
3285
3286
3287
3288
3289
3290
3291 memset(&methods, 0, sizeof(methods));
3292 sbsroutines->exec_setup(sbsref, sbsrefstate, &methods);
3293
3294
3295
3296
3297
3298
3299
3301
3302
3303
3304
3305
3306
3307 if (!isAssignment && sbsroutines->fetch_strict)
3308 {
3310 scratch->d.jump.jumpdone = -1;
3312 adjust_jumps = lappend_int(adjust_jumps,
3313 state->steps_len - 1);
3314 }
3315
3316
3317 i = 0;
3319 {
3321
3322
3323 if ()
3324 {
3327 }
3328 else
3329 {
3331
3335 }
3336 i++;
3337 }
3338
3339
3340 i = 0;
3342 {
3344
3345
3346 if ()
3347 {
3350 }
3351 else
3352 {
3354
3358 }
3359 i++;
3360 }
3361
3362
3364 {
3370 adjust_jumps = lappend_int(adjust_jumps,
3371 state->steps_len - 1);
3372 }
3373
3374 if (isAssignment)
3375 {
3376 Datum *save_innermost_caseval;
3377 bool *save_innermost_casenull;
3378
3379
3382 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3383 errmsg("type %s does not support subscripted assignment",
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3401 {
3404 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3405 errmsg("type %s does not support subscripted assignment",
3411 }
3412
3413
3414 save_innermost_caseval = state->innermost_caseval;
3415 save_innermost_casenull = state->innermost_casenull;
3417 state->innermost_casenull = &sbsrefstate->prevnull;
3418
3419
3422
3423 state->innermost_caseval = save_innermost_caseval;
3424 state->innermost_casenull = save_innermost_casenull;
3425
3426
3431 }
3432 else
3433 {
3434
3439 }
3440
3441
3442 foreach(lc, adjust_jumps)
3443 {
3445
3447 {
3450 }
3451 else
3452 {
3456 }
3457 }
3458}
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477static bool
3479{
3480 if (expr == NULL)
3481 return false;
3483 {
3485
3487 return true;
3488 }
3490 {
3492
3494 return true;
3495 }
3497 {
3499
3501 }
3503 {
3505
3507 }
3508 return false;
3509}
3510
3511
3512
3513
3514static void
3517{
3519 Datum *domainval = NULL;
3520 bool *domainnull = NULL;
3522
3524
3528
3529
3530
3531
3532
3533
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3555 constraint_ref,
3557 false);
3558
3559
3560
3561
3562
3563
3565 {
3567 Datum *save_innermost_domainval;
3568 bool *save_innermost_domainnull;
3569
3571
3573 {
3577 break;
3579
3581 {
3586 }
3587
3588
3589
3590
3591
3592 if (domainval == NULL)
3593 {
3594
3595
3596
3597
3599 {
3601
3602
3605
3606
3608 scratch2.resvalue = domainval;
3609 scratch2.resnull = domainnull;
3613 }
3614 else
3615 {
3616
3617 domainval = resv;
3618 domainnull = resnull;
3619 }
3620 }
3621
3622
3623
3624
3625
3626
3627
3628 save_innermost_domainval = state->innermost_domainval;
3629 save_innermost_domainnull = state->innermost_domainnull;
3630 state->innermost_domainval = domainval;
3631 state->innermost_domainnull = domainnull;
3632
3633
3637
3638 state->innermost_domainval = save_innermost_domainval;
3639 state->innermost_domainnull = save_innermost_domainnull;
3640
3641
3644
3645 break;
3646 default:
3647 elog(ERROR, "unrecognized constraint type: %d",
3649 break;
3650 }
3651 }
3652}
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3670 bool doSort, bool doHash, bool nullcheck)
3671{
3677
3678 state->expr = (Expr *) aggstate;
3679 state->parent = parent;
3680
3683
3684
3685
3686
3687
3688 for (int transno = 0; transno < aggstate->numtrans; transno++)
3689 {
3691
3693 &deform);
3695 &deform);
3697 &deform);
3699 &deform);
3701 &deform);
3702 }
3704
3705
3706
3707
3708 for (int transno = 0; transno < aggstate->numtrans; transno++)
3709 {
3712 List *adjust_bailout = NIL;
3714 bool *strictnulls = NULL;
3715 int argno;
3717
3718
3719
3720
3721
3722
3723
3725 {
3726
3729
3731 scratch.d.jump.jumpdone = -1;
3733 adjust_bailout = lappend_int(adjust_bailout,
3734 state->steps_len - 1);
3735 }
3736
3737
3738
3739
3740 argno = 0;
3741 if (isCombine)
3742 {
3743
3744
3745
3746
3747
3749
3752
3753 strictargs = trans_fcinfo->args + 1;
3755
3756
3757
3758
3759
3761 {
3762
3763
3764
3765
3767 &trans_fcinfo->args[argno + 1].value,
3768 &trans_fcinfo->args[argno + 1].isnull);
3769 }
3770 else
3771 {
3773
3774
3778
3779
3782
3783
3784
3785
3786
3789 else
3791
3796
3798
3800 adjust_bailout = lappend_int(adjust_bailout,
3801 state->steps_len - 1);
3802
3803
3806 }
3807 argno++;
3808
3810 }
3812 {
3814
3815
3816
3817
3818
3819
3820 strictargs = trans_fcinfo->args + 1;
3821
3823 {
3825
3826
3827
3828
3829
3831 break;
3832
3833
3834
3835
3836
3838 &trans_fcinfo->args[argno + 1].value,
3839 &trans_fcinfo->args[argno + 1].isnull);
3840 argno++;
3841 }
3843 }
3844 else if (pertrans->numInputs == 1)
3845 {
3846
3847
3848
3849
3852
3854
3856 &state->resvalue,
3857 &state->resnull);
3858 strictnulls = &state->resnull;
3859 argno++;
3860
3862 }
3863 else
3864 {
3865
3866
3867
3868
3872
3873 strictnulls = nulls;
3874
3876 {
3878
3880 &values[argno], &nulls[argno]);
3881 argno++;
3882 }
3884 }
3885
3886
3887
3888
3889
3890
3892 {
3893 if (strictnulls)
3895 else if (strictargs && pertrans->numTransInputs == 1)
3897 else
3904 adjust_bailout = lappend_int(adjust_bailout,
3905 state->steps_len - 1);
3906 }
3907
3908
3910 {
3913 else
3915
3919 adjust_bailout = lappend_int(adjust_bailout,
3920 state->steps_len - 1);
3921 }
3922
3923
3924
3925
3926
3927
3928 if (doSort)
3929 {
3930 int processGroupingSets = Max(phase->numsets, 1);
3931 int setoff = 0;
3932
3933 for (int setno = 0; setno < processGroupingSets; setno++)
3934 {
3936 pertrans, transno, setno, setoff, false,
3937 nullcheck);
3938 setoff++;
3939 }
3940 }
3941
3942 if (doHash)
3943 {
3944 int numHashes = aggstate->num_hashes;
3945 int setoff;
3946
3947
3949 setoff = aggstate->maxsets;
3950 else
3951 setoff = 0;
3952
3953 for (int setno = 0; setno < numHashes; setno++)
3954 {
3956 pertrans, transno, setno, setoff, true,
3957 nullcheck);
3958 setoff++;
3959 }
3960 }
3961
3962
3963 foreach(bail, adjust_bailout)
3964 {
3966
3968 {
3971 }
3975 {
3978 }
3980 {
3983 }
3986 {
3989 }
3990 else
3992 }
3993 }
3994
3999
4001
4003}
4004
4005
4006
4007
4008
4009
4010static void
4014 int transno, int setno, int setoff, bool ishash,
4015 bool nullcheck)
4016{
4018 int adjust_jumpnull = -1;
4019
4020 if (ishash)
4022 else
4023 aggcontext = aggstate->aggcontexts[setno];
4024
4025
4026 if (nullcheck)
4027 {
4030
4033 adjust_jumpnull = state->steps_len - 1;
4034 }
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4071 {
4073 {
4079 else
4081 }
4082 else
4083 {
4089 else
4091 }
4092 }
4093 else if (pertrans->numInputs == 1)
4095 else
4097
4104
4105
4106 if (adjust_jumpnull != -1)
4107 {
4109
4113 }
4114}
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4134 FmgrInfo *hashfunctions, Oid *collations,
4137{
4141 intptr_t opcode;
4143
4144 Assert(numCols >= 0);
4145
4146 state->parent = parent;
4147
4148
4149
4150
4151
4152
4153 if ((int64) numCols + (init_value != 0) > 1)
4155
4156
4157 for (int i = 0; i < numCols; i++)
4158 last_attnum = Max(last_attnum, keyColIdx[i]);
4159
4167
4168 if (init_value == 0)
4169 {
4170
4171
4172
4173
4174
4176 }
4177 else
4178 {
4179
4180
4181
4182
4183
4186 scratch.resvalue = numCols > 0 ? &iresult->value : &state->resvalue;
4188
4190
4191
4192
4193
4194
4196 }
4197
4198 for (int i = 0; i < numCols; i++)
4199 {
4202 Oid inputcollid = collations[i];
4204
4205 finfo = &hashfunctions[i];
4207
4208
4210
4211
4212
4213
4214
4221
4223
4224
4225 scratch.opcode = opcode;
4226
4227 if (i == numCols - 1)
4228 {
4229
4230
4231
4232
4235 }
4236 else
4237 {
4238 Assert(iresult != NULL);
4239
4240
4243 }
4244
4245
4246
4247
4248
4250
4255
4257
4258
4260 }
4261
4266
4268
4270}
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4293 const Oid *hashfunc_oids, const List *collations,
4294 const List *hash_exprs, const bool *opstrict,
4296{
4300 List *adjust_jumps = NIL;
4303 intptr_t strict_opcode;
4304 intptr_t opcode;
4305 int num_exprs = list_length(hash_exprs);
4306
4308
4309 state->parent = parent;
4310
4311
4313
4314
4315
4316
4317
4318
4319 if ((int64) num_exprs + (init_value != 0) > 1)
4321
4322 if (init_value == 0)
4323 {
4324
4325
4326
4327
4328
4331 }
4332 else
4333 {
4334
4335
4336
4337
4338
4341 scratch.resvalue = num_exprs > 0 ? &iresult->value : &state->resvalue;
4342 scratch.resnull = num_exprs > 0 ? &iresult->isnull : &state->resnull;
4343
4345
4346
4347
4348
4349
4352 }
4353
4354 forboth(lc, hash_exprs, lc2, collations)
4355 {
4360 Oid funcid;
4362
4363 funcid = hashfunc_oids[i];
4364
4365
4368
4370
4371
4372
4373
4374
4379
4380 if (i == num_exprs - 1)
4381 {
4382
4385 }
4386 else
4387 {
4388 Assert(iresult != NULL);
4389
4390
4393 }
4394
4395
4396
4397
4398
4400
4401
4403
4407
4408 scratch.opcode = opstrict[i] && !keep_nulls ? strict_opcode : opcode;
4410
4412 adjust_jumps = lappend_int(adjust_jumps, state->steps_len - 1);
4413
4414
4415
4416
4417
4420 }
4421
4422
4423 foreach(lc, adjust_jumps)
4424 {
4426
4433 }
4434
4439
4441
4443}
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4459 int numCols,
4461 const Oid *eqfunctions,
4462 const Oid *collations,
4464{
4467 int maxatt = -1;
4468 List *adjust_jumps = NIL;
4470
4471
4472
4473
4474
4475 if (numCols == 0)
4476 return NULL;
4477
4478 state->expr = NULL;
4480 state->parent = parent;
4481
4484
4485
4486 for (int natt = 0; natt < numCols; natt++)
4487 {
4488 int attno = keyColIdx[natt];
4489
4490 if (attno > maxatt)
4491 maxatt = attno;
4492 }
4493 Assert(maxatt >= 0);
4494
4495
4503
4511
4512
4513
4514
4515
4516 for (int natt = numCols; --natt >= 0;)
4517 {
4518 int attno = keyColIdx[natt];
4521 Oid foid = eqfunctions[natt];
4526
4527
4531
4533
4534
4540 collid, NULL, NULL);
4541
4542
4550
4551
4559
4560
4569
4570
4576 adjust_jumps = lappend_int(adjust_jumps,
4577 state->steps_len - 1);
4578 }
4579
4580
4581 foreach(lc, adjust_jumps)
4582 {
4584
4588 }
4589
4594
4596
4598}
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4619 const Oid *eqfunctions,
4620 const Oid *collations,
4621 const List *param_exprs,
4623{
4627 List *adjust_jumps = NIL;
4629
4630 state->expr = NULL;
4632 state->parent = parent;
4633
4636
4637
4645
4653
4654 for (int attno = 0; attno < maxatt; attno++)
4655 {
4657 Oid foid = eqfunctions[attno];
4662
4663
4667
4669
4670
4676 collid, NULL, NULL);
4677
4678
4686
4687
4695
4696
4705
4706
4712 adjust_jumps = lappend_int(adjust_jumps,
4713 state->steps_len - 1);
4714 }
4715
4716
4717 foreach(lc, adjust_jumps)
4718 {
4720
4724 }
4725
4730
4732
4734}
4735
4736
4737
4738
4739static void
4741 Datum *resv, bool *resnull,
4743{
4747 List *jumps_return_null = NIL;
4748 List *jumps_to_end = NIL;
4751 bool returning_domain =
4753
4755
4756 jsestate->jsexpr = jsexpr;
4757
4758
4759
4760
4761
4765
4766
4767 jumps_return_null = lappend_int(jumps_return_null, state->steps_len);
4772
4773
4774
4775
4776
4780
4781
4782 jumps_return_null = lappend_int(jumps_return_null, state->steps_len);
4787
4788
4792 {
4796
4801
4803
4805 }
4806
4807
4810 scratch->resnull = resnull;
4813
4814
4815
4816
4817
4818
4819 foreach(lc, jumps_return_null)
4820 {
4822
4824 }
4827 scratch->resnull = resnull;
4831
4834
4835
4836
4837
4838
4839
4841
4842
4843
4844
4845
4848 {
4850
4854 resv, resnull);
4855 }
4857 {
4858
4859
4860
4861
4862
4863 Oid typinput;
4864 Oid typioparam;
4867
4874
4875
4876
4877
4878
4884
4886 }
4887
4888
4889
4890
4891
4892
4894 {
4898 }
4899
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4917 returning_domain))
4918 {
4920
4922
4923
4930
4931
4932
4933
4934
4935 saved_escontext = state->escontext;
4936 state->escontext = escontext;
4938 state, resv, resnull);
4939 state->escontext = saved_escontext;
4940
4941
4945 resv, resnull);
4946
4947
4948
4949
4950
4954 {
4957 scratch->resnull = resnull;
4960 }
4961
4962
4967 }
4968
4969
4970
4971
4972
4973
4974
4975
4976 if (jsexpr->on_empty != NULL &&
4980 returning_domain))
4981 {
4983
4985
4986
4993
4994
4995
4996
4997
4998 saved_escontext = state->escontext;
4999 state->escontext = escontext;
5001 state, resv, resnull);
5002 state->escontext = saved_escontext;
5003
5004
5008 resv, resnull);
5009
5010
5011
5012
5013
5017 {
5018
5021 scratch->resnull = resnull;
5024 }
5025 }
5026
5027 foreach(lc, jumps_to_end)
5028 {
5030
5032 }
5033
5035}
5036
5037
5038
5039
5040
5041static void
5044 bool exists_coerce,
5045 Datum *resv, bool *resnull)
5046{
5048
5049
5052 scratch.resnull = resnull;
5064}
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
#define InvalidAttrNumber
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
static Datum values[MAXATTR]
#define OidIsValid(objectId)
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void ExecReadyInterpretedExpr(ExprState *state)
static void ExecInitCoerceToDomain(ExprEvalStep *scratch, CoerceToDomain *ctest, ExprState *state, Datum *resv, bool *resnull)
static void ExecInitSubPlanExpr(SubPlan *subplan, ExprState *state, Datum *resv, bool *resnull)
ExprState * ExecBuildHash32FromAttrs(TupleDesc desc, const TupleTableSlotOps *ops, FmgrInfo *hashfunctions, Oid *collations, int numCols, AttrNumber *keyColIdx, PlanState *parent, uint32 init_value)
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
ExprState * ExecPrepareExpr(Expr *node, EState *estate)
bool ExecCheck(ExprState *state, ExprContext *econtext)
ExprState * ExecInitCheck(List *qual, PlanState *parent)
static void ExecPushExprSetupSteps(ExprState *state, ExprSetupInfo *info)
static void ExecInitExprRec(Expr *node, ExprState *state, Datum *resv, bool *resnull)
static void ExecBuildAggTransCall(ExprState *state, AggState *aggstate, ExprEvalStep *scratch, FunctionCallInfo fcinfo, AggStatePerTrans pertrans, int transno, int setno, int setoff, bool ishash, bool nullcheck)
static void ExecInitWholeRowVar(ExprEvalStep *scratch, Var *variable, ExprState *state)
void ExprEvalPushStep(ExprState *es, const ExprEvalStep *s)
ProjectionInfo * ExecBuildProjectionInfo(List *targetList, ExprContext *econtext, TupleTableSlot *slot, PlanState *parent, TupleDesc inputDesc)
struct ExprSetupInfo ExprSetupInfo
static bool isAssignmentIndirectionExpr(Expr *expr)
static void ExecInitSubscriptingRef(ExprEvalStep *scratch, SubscriptingRef *sbsref, ExprState *state, Datum *resv, bool *resnull)
ExprState * ExecPrepareQual(List *qual, EState *estate)
ExprState * ExecInitQual(List *qual, PlanState *parent)
static bool expr_setup_walker(Node *node, ExprSetupInfo *info)
static void ExecInitJsonCoercion(ExprState *state, JsonReturning *returning, ErrorSaveContext *escontext, bool omit_quotes, bool exists_coerce, Datum *resv, bool *resnull)
List * ExecInitExprList(List *nodes, PlanState *parent)
ExprState * ExecInitExprWithParams(Expr *node, ParamListInfo ext_params)
ProjectionInfo * ExecBuildUpdateProjection(List *targetList, bool evalTargetList, List *targetColnos, TupleDesc relDesc, ExprContext *econtext, TupleTableSlot *slot, PlanState *parent)
ExprState * ExecBuildGroupingEqual(TupleDesc ldesc, TupleDesc rdesc, const TupleTableSlotOps *lops, const TupleTableSlotOps *rops, int numCols, const AttrNumber *keyColIdx, const Oid *eqfunctions, const Oid *collations, PlanState *parent)
static bool ExecComputeSlotInfo(ExprState *state, ExprEvalStep *op)
ExprState * ExecBuildAggTrans(AggState *aggstate, AggStatePerPhase phase, bool doSort, bool doHash, bool nullcheck)
static void ExecInitFunc(ExprEvalStep *scratch, Expr *node, List *args, Oid funcid, Oid inputcollid, ExprState *state)
static void ExecCreateExprSetupSteps(ExprState *state, Node *node)
List * ExecPrepareExprList(List *nodes, EState *estate)
static void ExecReadyExpr(ExprState *state)
static void ExecInitJsonExpr(JsonExpr *jsexpr, ExprState *state, Datum *resv, bool *resnull, ExprEvalStep *scratch)
ExprState * ExecBuildParamSetEqual(TupleDesc desc, const TupleTableSlotOps *lops, const TupleTableSlotOps *rops, const Oid *eqfunctions, const Oid *collations, const List *param_exprs, PlanState *parent)
ExprState * ExecBuildHash32Expr(TupleDesc desc, const TupleTableSlotOps *ops, const Oid *hashfunc_oids, const List *collations, const List *hash_exprs, const bool *opstrict, PlanState *parent, uint32 init_value, bool keep_nulls)
ExprState * ExecPrepareCheck(List *qual, EState *estate)
@ EEOP_FUNCEXPR_STRICT_FUSAGE
@ EEOP_HASHDATUM_NEXT32_STRICT
@ EEOP_JSONEXPR_COERCION_FINISH
@ EEOP_HASHDATUM_FIRST_STRICT
@ EEOP_AGG_PLAIN_PERGROUP_NULLCHECK
@ EEOP_AGG_STRICT_DESERIALIZE
@ EEOP_BOOLTEST_IS_NOT_FALSE
@ EEOP_AGG_PLAIN_TRANS_BYREF
@ EEOP_AGG_PRESORTED_DISTINCT_MULTI
@ EEOP_AGG_PLAIN_TRANS_BYVAL
@ EEOP_NULLTEST_ROWISNOTNULL
@ EEOP_ASSIGN_TMP_MAKE_RO
@ EEOP_BOOL_OR_STEP_FIRST
@ EEOP_AGG_STRICT_INPUT_CHECK_NULLS
@ EEOP_AGG_STRICT_INPUT_CHECK_ARGS_1
@ EEOP_AGG_STRICT_INPUT_CHECK_ARGS
@ EEOP_NULLTEST_ROWISNULL
@ EEOP_NULLTEST_ISNOTNULL
@ EEOP_MERGE_SUPPORT_FUNC
@ EEOP_AGG_PRESORTED_DISTINCT_SINGLE
@ EEOP_BOOL_AND_STEP_FIRST
@ EEOP_DOMAIN_TESTVAL_EXT
@ EEOP_BOOL_AND_STEP_LAST
@ EEOP_AGG_ORDERED_TRANS_DATUM
@ EEOP_HASHDATUM_SET_INITVAL
@ EEOP_AGG_PLAIN_TRANS_STRICT_BYREF
@ EEOP_BOOLTEST_IS_NOT_TRUE
@ EEOP_AGG_PLAIN_TRANS_INIT_STRICT_BYVAL
@ EEOP_AGG_PLAIN_TRANS_STRICT_BYVAL
@ EEOP_AGG_PLAIN_TRANS_INIT_STRICT_BYREF
@ EEOP_HASHED_SCALARARRAYOP
@ EEOP_AGG_ORDERED_TRANS_TUPLE
JunkFilter * ExecInitJunkFilter(List *targetList, TupleTableSlot *slot)
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
const TupleTableSlotOps TTSOpsVirtual
void ExecTypeSetColNames(TupleDesc typeInfo, List *namesList)
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
TupleDesc ExecTypeFromExprList(List *exprList)
TupleDesc ExecGetResultType(PlanState *planstate)
int executor_errposition(EState *estate, int location)
const TupleTableSlotOps * ExecGetResultSlotOps(PlanState *planstate, bool *isfixed)
#define outerPlanState(node)
#define EEO_FLAG_NEW_IS_NULL
#define innerPlanState(node)
#define EEO_FLAG_OLD_IS_NULL
static Datum ExecEvalExprSwitchContext(ExprState *state, ExprContext *econtext, bool *isNull)
#define palloc_object(type)
#define palloc_array(type, count)
#define palloc0_object(type)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
#define SizeForFunctionCallInfo(nargs)
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
#define fmgr_info_set_expr(expr, finfo)
char * format_type_be(Oid type_oid)
Assert(PointerIsAligned(start, uint64))
if(TABLE==NULL||TABLE_index==NULL)
bool jit_compile_expr(struct ExprState *state)
void json_categorize_type(Oid typoid, bool is_jsonb, JsonTypeCategory *tcategory, Oid *outfuncoid)
List * lappend(List *list, void *datum)
List * lappend_int(List *list, int datum)
void get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op, int *strategy, Oid *lefttype, Oid *righttype)
Oid get_element_type(Oid typid)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
const struct SubscriptRoutines * getSubscriptingRoutines(Oid typid, Oid *typelemp)
char * get_func_name(Oid funcid)
int16 get_typlen(Oid typid)
char get_typtype(Oid typid)
Oid getBaseType(Oid typid)
Expr * make_ands_explicit(List *andclauses)
Const * makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid)
void * repalloc(void *pointer, Size size)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
int exprLocation(const Node *expr)
#define expression_tree_walker(n, w, c)
SubPlanState * ExecInitSubPlan(SubPlan *subplan, PlanState *parent)
#define IsA(nodeptr, _type_)
#define DO_AGGSPLIT_COMBINE(as)
#define castNode(_type_, nodeptr)
#define InvokeFunctionExecuteHook(objectId)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
FormData_pg_attribute * Form_pg_attribute
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
#define foreach_current_index(var_or_cell)
#define foreach_ptr(type, var, lst)
#define forfive(cell1, list1, cell2, list2, cell3, list3, cell4, list4, cell5, list5)
#define foreach_int(var, lst)
Expr * expression_planner(Expr *expr)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Datum ObjectIdGetDatum(Oid X)
static Datum Int32GetDatum(int32 X)
static Datum UInt32GetDatum(uint32 X)
void check_stack_depth(void)
TupleTableSlot * sortslot
FunctionCallInfo deserialfn_fcinfo
FunctionCallInfo transfn_fcinfo
AggStatePerTrans pertrans
ExprContext * hashcontext
ExprContext ** aggcontexts
BoolTestType booltesttype
DomainConstraintType constrainttype
MemoryContext es_query_cxt
struct ExprEvalStep::@57::@66 boolexpr
ExprState * elemexprstate
struct ExprEvalStep::@57::@88 hashdatum_initvalue
struct ExprEvalStep::@57::@74 iocoerce
struct ExprEvalStep::@57::@62 assign_tmp
WindowFuncExprState * wfstate
struct ExprEvalStep::@57::@97 window_func
void * json_coercion_cache
struct ExprEvalStep::@57::@100 agg_strict_input_check
ExecEvalBoolSubroutine subscriptfunc
struct ExprEvalStep::@57::@84 fieldstore
struct ExprEvalStep::@57::@69 nulltest_row
struct ExprEvalStep::@57::@85 sbsref_subscript
struct ExprEvalStep::@57::@80 rowcompare_step
struct ExprEvalStep::@57::@103 agg_trans
struct ExprEvalStep::@57::@79 row
struct ExprEvalStep::@57::@95 aggref
struct ExprEvalStep::@57::@86 sbsref
struct ExprEvalStep::@57::@59 var
struct ExprEvalStep::@57::@83 fieldselect
struct ExprEvalStep::@57::@92 hashedscalararrayop
struct ExprEvalStep::@57::@101 agg_plain_pergroup_nullcheck
struct ExprEvalStep::@57::@70 param
struct SubscriptingRefState * state
VarReturningType varreturningtype
struct ExprEvalStep::@57::@104 is_json
struct ExprEvalStep::@57::@72 casetest
AggStatePerTrans pertrans
struct JsonExprState * jsestate
struct ExprEvalStep::@57::@91 scalararrayop
struct ExprEvalStep::@57::@106 jsonexpr_coercion
struct ExprEvalStep::@57::@68 jump
struct ExprEvalStep::@57::@105 jsonexpr
struct ExprEvalStep::@57::@64 constval
FunctionCallInfo fcinfo_data_in
struct ExprEvalStep::@57::@90 convert_rowtype
struct ExprEvalStep::@57::@89 hashdatum
ExprEvalRowtypeCache * incache
struct ExprEvalStep::@57::@98 subplan
const TupleTableSlotOps * kind
struct ExprEvalStep::@57::@102 agg_presorted_distinctcheck
struct ExprEvalStep::@57::@65 func
FunctionCallInfo fcinfo_data
struct ExprEvalStep::@57::@67 qualexpr
struct ExprEvalStep::@57::@77 arrayexpr
struct ExprEvalStep::@57::@96 grouping_func
ErrorSaveContext * escontext
struct ExprEvalStep::@57::@61 assign_var
union ExprEvalStep::@57 d
struct ExprEvalStep::@57::@94 json_constructor
struct ExprEvalStep::@57::@75 sqlvaluefunction
struct ExprEvalStep::@57::@58 fetch
struct ExprEvalStep::@57::@63 returningexpr
struct ExprEvalStep::@57::@78 arraycoerce
FunctionCallInfo fcinfo_data_out
struct ExprEvalStep::@57::@81 rowcompare_final
ExprEvalRowtypeCache * outcache
struct ExprEvalStep::@57::@93 xmlexpr
struct ExprEvalStep::@57::@82 minmax
struct ExprEvalStep::@57::@76 nextvalueexpr
ExprEvalRowtypeCache rowcache
struct JsonConstructorExprState * jcstate
struct ExprEvalStep::@57::@87 domaincheck
struct ExprEvalStep::@57::@73 make_readonly
struct ExprEvalStep::@57::@60 wholerow
struct ArrayMapState * amstate
struct ExprEvalStep::@57::@99 agg_deserialize
List * multiexpr_subplans
struct ExprEvalStep * steps
bool * innermost_casenull
Datum * innermost_caseval
NullableDatum args[FLEXIBLE_ARRAY_MEMBER]
struct JsonConstructorExprState::@107 * arg_type_cache
JsonConstructorExpr * constructor
JsonReturning * returning
FunctionCallInfo input_fcinfo
ErrorSaveContext escontext
NullableDatum formatted_expr
JsonReturning * returning
JsonFormatType format_type
NullTestType nulltesttype
ParamCompileHook paramCompile
const TupleTableSlotOps * outerops
const TupleTableSlotOps * innerops
const TupleTableSlotOps * scanops
ExprContext * pi_exprContext
ExecEvalSubroutine sbs_fetch_old
ExecEvalBoolSubroutine sbs_check_subscripts
ExecEvalSubroutine sbs_assign
ExecEvalSubroutine sbs_fetch
SubscriptExecSetup exec_setup
#define ReleaseTupleDesc(tupdesc)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
static CompactAttribute * TupleDescCompactAttr(TupleDesc tupdesc, int i)
void InitDomainConstraintRef(Oid type_id, DomainConstraintRef *ref, MemoryContext refctx, bool need_exprstate)
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
bool DomainHasConstraints(Oid type_id)
TupleDesc lookup_rowtype_tupdesc_copy(Oid type_id, int32 typmod)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
#define TYPECACHE_CMP_PROC
static void convert(const int_fast32_t val, char *const buf)