PostgreSQL Source Code: src/backend/executor/execMain.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
31
32
33
34
35
36
37
39
65
66
67
72
73
75
76
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121void
123{
124
125
126
127
128
129
130
131
133
135 (*ExecutorStart_hook) (queryDesc, eflags);
136 else
138}
139
140void
142{
145
146
149
150
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
171
172
173
174
176 queryDesc->estate = estate;
177
179
180
181
182
183
185
187 {
189
193 }
194
195
198
199
200
201
203
204
205
206
208 {
210
211
212
213
214
218
219
220
221
222
223
224
227 break;
228
234 break;
235
236 default:
237 elog(ERROR, "unrecognized operation code: %d",
239 break;
240 }
241
242
243
244
250
251
252
253
254
257
258
259
260
262
264}
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296void
299{
301 (*ExecutorRun_hook) (queryDesc, direction, count);
302 else
304}
305
306void
309{
315
316
318
319 estate = queryDesc->estate;
320
323
324
326
327
328
329
331
332
335
336
337
338
339 operation = queryDesc->operation;
340 dest = queryDesc->dest;
341
342
343
344
346
349
351 dest->rStartup(dest, operation, queryDesc->tupDesc);
352
353
354
355
356
357
358
359
360
361
362
363
364
367 operation,
369 count,
370 direction,
371 dest);
372
373
374
375
376
378
379
380
381
383 dest->rShutdown(dest);
384
387
389}
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405void
407{
409 (*ExecutorFinish_hook) (queryDesc);
410 else
412}
413
414void
416{
419
420
422
423 estate = queryDesc->estate;
424
427
428
430
431
433
434
437
438
440
441
444
447
449
451}
452
453
454
455
456
457
458
459
460
461
462
463
464
465void
467{
469 (*ExecutorEnd_hook) (queryDesc);
470 else
472}
473
474void
476{
479
480
482
483 estate = queryDesc->estate;
484
486
490
491
492
493
494
495
498
499
500
501
503
505
506
509
510
511
512
514
515
516
517
518
520
521
526}
527
528
529
530
531
532
533
534
535void
537{
540
541
543
544 estate = queryDesc->estate;
545
547
548
550
551
552
553
555
556
557
558
560
562}
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581bool
583 bool ereport_on_violation)
584{
586 bool result = true;
587
588#ifdef USE_ASSERT_CHECKING
590
591
593 {
595
596 if (rte->perminfoindex != 0)
597 {
598
599
600
601
602
603
607
609
612 }
613 }
614
615
617#endif
618
619 foreach(l, rteperminfos)
620 {
622
625 if (!result)
626 {
627 if (ereport_on_violation)
631 return false;
632 }
633 }
634
636 result = (*ExecutorCheckPerms_hook) (rangeTable, rteperminfos,
637 ereport_on_violation);
638 return result;
639}
640
641
642
643
644
645bool
647{
651 Oid userid;
653
654 requiredPerms = perminfo->requiredPerms;
655 Assert(requiredPerms != 0);
656
657
658
659
660
661
662
663
664
667
668
669
670
671
672
676 {
677 int col = -1;
678
679
680
681
682
684 return false;
685
686
687
688
689
690
691
692
694 {
695
696
697
698
699
701 {
704 return false;
705 }
706
708 {
709
711
713 {
714
717 return false;
718 }
719 else
720 {
723 return false;
724 }
725 }
726 }
727
728
729
730
731
734 userid,
737 return false;
738
741 userid,
744 return false;
745 }
746 return true;
747}
748
749
750
751
752
753
754static bool
757{
758 int col = -1;
759
760
761
762
763
764
766 {
769 return false;
770 }
771
773 {
774
776
778 {
779
780 elog(ERROR, "whole-row update is not implemented");
781 }
782 else
783 {
786 return false;
787 }
788 }
789 return true;
790}
791
792
793
794
795
796
797
798
799
800
801static void
803{
805
806
807
808
809
810 foreach(l, plannedstmt->permInfos)
811 {
813
815 continue;
816
818 continue;
819
821 }
822
825}
826
827
828
829
830
831
832
833
834
835static void
837{
846 int i;
847
848
849
850
852
853
854
855
858
861
862
863
864
865
866
867
868
869
870
872
873
874
875
877 {
880 foreach(l, plannedstmt->rowMarks)
881 {
884 Oid relid;
887
888
890 continue;
891
892
893
894
895
898 continue;
899
900
902
903
905 {
912 break;
914
915 relation = NULL;
916 break;
917 default:
919 relation = NULL;
920 break;
921 }
922
923
924 if (relation)
926
928 erm->relation = relation;
929 erm->relid = relid;
936 erm->ermActive = false;
939
942
944 }
945 }
946
947
948
949
951
952
954
955
956
957
958
959
961 i = 1;
962 foreach(l, plannedstmt->subplans)
963 {
967
968
969
970
971
972
977
979
982
983 i++;
984 }
985
986
987
988
989
990
992
993
994
995
997
998
999
1000
1001
1003 {
1006
1007 foreach(tlist, plan->targetlist)
1008 {
1010
1011 if (tle->resjunk)
1012 {
1014 break;
1015 }
1016 }
1017
1019 {
1022
1025 slot);
1027
1028
1030 }
1031 }
1032
1034 queryDesc->planstate = planstate;
1035}
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053void
1056{
1059
1060
1063
1064 switch (resultRel->rd_rel->relkind)
1065 {
1068
1069
1070
1071
1072
1076 else
1078
1079
1080
1081
1082
1085 break;
1089 errmsg("cannot change sequence \"%s\"",
1091 break;
1095 errmsg("cannot change TOAST relation \"%s\"",
1097 break;
1099
1100
1101
1102
1103
1104
1105
1109 break;
1114 errmsg("cannot change materialized view \"%s\"",
1116 break;
1118
1120 switch (operation)
1121 {
1126 errmsg("cannot insert into foreign table \"%s\"",
1132 errmsg("foreign table \"%s\" does not allow inserts",
1134 break;
1139 errmsg("cannot update foreign table \"%s\"",
1145 errmsg("foreign table \"%s\" does not allow updates",
1147 break;
1152 errmsg("cannot delete from foreign table \"%s\"",
1158 errmsg("foreign table \"%s\" does not allow deletes",
1160 break;
1161 default:
1162 elog(ERROR, "unrecognized CmdType: %d", (int) operation);
1163 break;
1164 }
1165 break;
1166 default:
1169 errmsg("cannot change relation \"%s\"",
1171 break;
1172 }
1173}
1174
1175
1176
1177
1178
1179
1180
1181static void
1183{
1185
1186 switch (rel->rd_rel->relkind)
1187 {
1190
1191 break;
1193
1196 errmsg("cannot lock rows in sequence \"%s\"",
1198 break;
1200
1203 errmsg("cannot lock rows in TOAST relation \"%s\"",
1205 break;
1207
1210 errmsg("cannot lock rows in view \"%s\"",
1212 break;
1214
1218 errmsg("cannot lock rows in materialized view \"%s\"",
1220 break;
1222
1227 errmsg("cannot lock rows in foreign table \"%s\"",
1229 break;
1230 default:
1233 errmsg("cannot lock rows in relation \"%s\"",
1235 break;
1236 }
1237}
1238
1239
1240
1241
1242
1243
1244
1245
1246void
1251 int instrument_options)
1252{
1262
1265 {
1267
1272 if (instrument_options)
1274 }
1275 else
1276 {
1280 }
1283 else
1285
1286
1310
1311
1312
1313
1314
1315
1316
1318
1321
1326}
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1349{
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1365 {
1370 }
1371
1372
1373
1374
1375
1377 {
1382 }
1383
1384
1386 {
1391 }
1392
1393
1394
1395
1396
1397
1398
1399
1401
1402
1403
1404
1408 rel,
1409 0,
1415
1416
1417
1418
1419
1420
1422}
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1435{
1439
1440 if (!partRel->rd_rel->relispartition)
1441 elog(ERROR, "cannot find ancestors of a non-partition result relation");
1445 {
1449
1450 foreach(lc, oids)
1451 {
1455
1456
1457
1458
1459
1460
1461
1463 break;
1464
1465
1466
1467
1468
1471
1472
1476 }
1479 }
1480
1481
1483
1485}
1486
1487
1488
1489
1490
1491
1492
1493static void
1495{
1497
1498
1499
1500
1502
1503
1504
1505
1506
1507
1509 {
1511
1512 for (;;)
1513 {
1515
1516
1518
1520
1522 break;
1523 }
1524 }
1525}
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539static void
1541{
1543
1544
1545
1546
1548
1549
1550
1551
1553 {
1555
1557 }
1558
1559
1560
1561
1562
1563
1564
1566
1567
1568
1569
1570
1573}
1574
1575
1576
1577
1578void
1580{
1582
1583
1584
1585
1586
1587
1588
1589
1591 {
1594
1597 {
1599
1600
1601
1602
1603
1604 if (rInfo->ri_RangeTableIndex > 0)
1605 continue;
1606
1608 }
1609 }
1610
1611
1613 {
1615
1616
1617
1618
1619
1620
1622
1623
1624
1625
1626
1628
1630 }
1631}
1632
1633
1634
1635
1636
1637
1638void
1640{
1641 int i;
1642
1644 {
1647 }
1648}
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659static void
1666{
1672
1673
1674
1675
1677
1678
1679
1680
1682
1683
1684
1685
1686
1687
1688
1689
1692 else
1695
1699
1700
1701
1702
1703 for (;;)
1704 {
1705
1707
1708
1709
1710
1712
1713
1714
1715
1716
1718 break;
1719
1720
1721
1722
1723
1724
1725
1726
1727
1730
1731
1732
1733
1734
1736 {
1737
1738
1739
1740
1741
1742 if (!dest->receiveSlot(slot, dest))
1743 break;
1744 }
1745
1746
1747
1748
1749
1750
1753
1754
1755
1756
1757
1758
1761 break;
1762 }
1763
1764
1765
1766
1767
1770
1773}
1774
1775
1776
1777
1778
1779
1780
1781static const char *
1784{
1790
1791
1792
1793
1794
1795
1796 if (ncheck != rel->rd_rel->relchecks)
1797 elog(ERROR, "%d pg_constraint record(s) missing for relation \"%s\"",
1799
1800
1801
1802
1803
1804
1806 {
1809 for (int i = 0; i < ncheck; i++)
1810 {
1812
1813
1814 if (!check[i].ccenforced)
1815 continue;
1816
1821 }
1823 }
1824
1825
1826
1827
1828
1830
1831
1833
1834
1835 for (int i = 0; i < ncheck; i++)
1836 {
1838
1839
1840
1841
1842
1843
1846 }
1847
1848
1849 return NULL;
1850}
1851
1852
1853
1854
1855
1856
1857
1858
1859bool
1862{
1865
1866
1867
1868
1869
1870
1871
1872
1874 {
1875
1876
1877
1878
1881
1884 }
1885
1886
1887
1888
1889
1891
1892
1894
1895
1896
1897
1898
1900
1901
1904
1906}
1907
1908
1909
1910
1911
1912void
1916{
1921
1922
1923
1924
1925
1926
1927
1929 {
1933
1936
1938
1940
1941
1942
1943
1944
1945 if (map != NULL)
1950 }
1951 else
1952 {
1957 }
1958
1960 slot,
1961 tupdesc,
1963 64);
1966 errmsg("new row for relation \"%s\" violates partition constraint",
1970}
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983void
1986{
1992
1993 Assert(constr);
1994
1995
1996
1997
1998
1999
2000
2002 {
2004 {
2006
2011 }
2012 }
2013
2014
2015
2016
2018 {
2020
2025 }
2026
2027
2028
2029
2030 if (rel->rd_rel->relchecks > 0)
2031 {
2032 const char *failed;
2033
2034 if ((failed = ExecRelCheck(resultRelInfo, slot, estate)) != NULL)
2035 {
2038
2039
2040
2041
2042
2043
2044
2046 {
2050
2052
2054 tupdesc,
2055 false);
2056
2057
2058
2059
2060
2061 if (map != NULL)
2066 rel = rootrel->ri_RelationDesc;
2067 }
2068 else
2072 slot,
2073 tupdesc,
2075 64);
2078 errmsg("new row for relation \"%s\" violates check constraint \"%s\"",
2082 }
2083 }
2084}
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2100{
2104
2105
2106
2107
2108
2109
2111 {
2115
2117 {
2120
2121
2127
2130 }
2132 }
2133
2134
2135
2136
2137
2138
2140
2141
2143
2144
2146 {
2149
2151 if ((exprstate, econtext))
2153 }
2154
2155
2157}
2158
2159
2160
2161
2162static void
2165{
2173
2175
2176
2177
2178
2179
2180
2181
2183 {
2186
2188
2190 tupdesc,
2191 false);
2192
2193
2194
2195
2196
2197 if (map != NULL)
2202 rel = rootrel->ri_RelationDesc;
2203 }
2204 else
2207
2209 slot,
2210 tupdesc,
2212 64);
2215 errmsg("null value in column \"%s\" of relation \"%s\" violates not-null constraint",
2220}
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231void
2234{
2239 *l2;
2240
2241
2242
2243
2244
2246
2247
2249
2250
2253 {
2256
2257
2258
2259
2260
2261 if (wco->kind != kind)
2262 continue;
2263
2264
2265
2266
2267
2268
2269
2270
2272 {
2275
2276 switch (wco->kind)
2277 {
2278
2279
2280
2281
2282
2283
2284
2285
2286
2288
2290 {
2294
2296
2298 tupdesc,
2299 false);
2300
2301
2302
2303
2304
2305 if (map != NULL)
2308
2311 rel = rootrel->ri_RelationDesc;
2312 }
2313 else
2317 slot,
2318 tupdesc,
2320 64);
2321
2324 errmsg("new row violates check option for view \"%s\"",
2325 wco->relname),
2328 break;
2331 if (wco->polname != NULL)
2334 errmsg("new row violates row-level security policy \"%s\" for table \"%s\"",
2335 wco->polname, wco->relname)));
2336 else
2339 errmsg("new row violates row-level security policy for table \"%s\"",
2340 wco->relname)));
2341 break;
2344 if (wco->polname != NULL)
2347 errmsg("target row violates row-level security policy \"%s\" (USING expression) for table \"%s\"",
2348 wco->polname, wco->relname)));
2349 else
2352 errmsg("target row violates row-level security policy (USING expression) for table \"%s\"",
2353 wco->relname)));
2354 break;
2356 if (wco->polname != NULL)
2359 errmsg("new row violates row-level security policy \"%s\" (USING expression) for table \"%s\"",
2360 wco->polname, wco->relname)));
2361 else
2364 errmsg("new row violates row-level security policy (USING expression) for table \"%s\"",
2365 wco->relname)));
2366 break;
2367 default:
2368 elog(ERROR, "unrecognized WCO kind: %u", wco->kind);
2369 break;
2370 }
2371 }
2372 }
2373}
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394char *
2400{
2405 int i;
2409
2410
2411
2412
2413
2414
2416 return NULL;
2417
2419
2421
2422
2423
2424
2425
2426
2427
2428
2431 {
2432
2435 }
2436 else
2438
2439
2441
2442 for (i = 0; i < tupdesc->natts; i++)
2443 {
2445 char *val;
2446 int vallen;
2448
2449
2450 if (att->attisdropped)
2451 continue;
2452
2454 {
2455
2456
2457
2458
2459
2460
2465 {
2467
2470 else
2472
2474 }
2475 }
2476
2478 {
2480 val = "virtual";
2482 val = "null";
2483 else
2484 {
2486 bool typisvarlena;
2487
2489 &foutoid, &typisvarlena);
2491 }
2492
2495 else
2497
2498
2502 else
2503 {
2507 }
2508 }
2509 }
2510
2511
2513 return NULL;
2514
2516
2518 {
2521
2523 }
2524
2525 return buf.data;
2526}
2527
2528
2529
2530
2531
2532
2535{
2538
2539
2540
2541
2542
2543
2547
2550
2552}
2553
2554
2555
2556
2557
2558
2561{
2564 {
2566
2567 if (erm)
2568 return erm;
2569 }
2570 if (!missing_ok)
2571 elog(ERROR, "failed to find ExecRowMark for rangetable index %u", rti);
2572 return NULL;
2573}
2574
2575
2576
2577
2578
2579
2580
2581
2584{
2587
2589
2590
2592 {
2593
2599 }
2600 else
2601 {
2602
2608 }
2609
2610
2611 if (erm->rti != erm->prti)
2612 {
2618 }
2619
2620 return aerm;
2621}
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2655{
2658
2660
2661
2662
2663
2665
2666
2667
2668
2669
2673
2674
2675
2676
2677
2678
2681
2682
2683
2684
2686
2687
2688
2689
2690
2691
2692
2693
2696
2697
2698
2699
2700
2701
2704
2705 return slot;
2706}
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721void
2724 int epqParam, List *resultRelations)
2725{
2727
2728
2730 epqstate->epqParam = epqParam;
2732
2733
2734
2735
2736
2737
2738
2739
2742
2743
2744 epqstate->plan = subplan;
2746
2747
2754}
2755
2756
2757
2758
2759
2760
2761
2762void
2764{
2765
2767
2768 epqstate->plan = subplan;
2769
2771}
2772
2773
2774
2775
2776
2777
2778
2782{
2784
2788
2789 if (*slot == NULL)
2790 {
2792
2796 }
2797
2798 return *slot;
2799}
2800
2801
2802
2803
2804
2805
2806
2807bool
2809{
2813 bool isNull;
2814
2817
2819
2821 elog(ERROR, "EvalPlanQual doesn't support locking rowmarks");
2822
2823
2824 if (erm->rti != erm->prti)
2825 {
2826 Oid tableoid;
2827
2829 earm->toidAttNo,
2830 &isNull);
2831
2832 if (isNull)
2833 return false;
2834
2836
2838 if (tableoid != erm->relid)
2839 {
2840
2841 return false;
2842 }
2843 }
2844
2846 {
2848
2849
2851 earm->ctidAttNo,
2852 &isNull);
2853
2854 if (isNull)
2855 return false;
2856
2857
2859 {
2862
2864
2868 errmsg("cannot lock rows in foreign table \"%s\"",
2870
2873 datum,
2874 slot,
2877 elog(ERROR, "failed to fetch tuple for EvalPlanQual recheck");
2878
2879
2880
2881
2882
2883
2884 return true;
2885 }
2886 else
2887 {
2888
2892 elog(ERROR, "failed to fetch tuple for EvalPlanQual recheck");
2893 return true;
2894 }
2895 }
2896 else
2897 {
2899
2900
2902 earm->wholeAttNo,
2903 &isNull);
2904
2905 if (isNull)
2906 return false;
2907
2909 return true;
2910 }
2911}
2912
2913
2914
2915
2916
2917
2920{
2923
2927
2928 return slot;
2929}
2930
2931
2932
2933
2934void
2936{
2939
2940 if (recheckestate == NULL)
2941 {
2942
2944 }
2945 else
2946 {
2947
2948
2949
2952
2953
2954
2955
2956
2957
2959 rtsize * sizeof(bool));
2960
2961
2963 {
2964 int i;
2965
2966
2967
2968
2969
2970
2973
2975
2976 while (--i >= 0)
2977 {
2978
2983 }
2984 }
2985
2986
2987
2988
2989
2992 }
2993}
2994
2995
2996
2997
2998
2999
3000
3001static void
3003{
3009
3011
3013
3014
3015 rcestate->es_epq_active = epqstate;
3016
3017
3018
3019
3020
3021
3022
3035
3036
3037
3038
3039
3041
3044
3045
3046
3047
3048
3049
3050
3051
3054 {
3055 int i;
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3077
3078
3081
3082 while (--i >= 0)
3083 {
3084
3085 rcestate->es_param_exec_vals[i].value =
3087 rcestate->es_param_exec_vals[i].isnull =
3089 }
3090 }
3091
3092
3093
3094
3095
3096
3098
3099
3100
3101
3102
3103
3107
3108
3110
3111
3112
3113
3114
3115
3116
3117
3118
3121 {
3124
3128 }
3129
3130
3131
3132
3133
3134
3137 {
3139
3141 }
3142
3143
3144
3145
3146
3149
3151 {
3153
3156 }
3157
3159 rtsize * sizeof(bool));
3160
3161
3162
3163
3164
3165
3167
3169}
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182void
3184{
3189
3191
3192
3193
3194
3195
3197 {
3202 }
3203
3204
3205 if (estate == NULL)
3206 return;
3207
3209
3211
3213 {
3215
3217 }
3218
3219
3221
3222
3224
3226
3227
3228
3229
3230
3231
3233
3235
3236
3243}
AclResult pg_attribute_aclcheck_all(Oid table_oid, Oid roleid, AclMode mode, AclMaskHow how)
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult pg_attribute_aclcheck(Oid table_oid, AttrNumber attnum, Oid roleid, AclMode mode)
AclMode pg_class_aclmask(Oid table_oid, Oid roleid, AclMode mask, AclMaskHow how)
AclResult pg_class_aclcheck(Oid table_oid, Oid roleid, AclMode mode)
AttrMap * build_attrmap_by_name_if_req(TupleDesc indesc, TupleDesc outdesc, bool missing_ok)
#define AttributeNumberIsValid(attributeNumber)
#define InvalidAttrNumber
void pgstat_report_query_id(int64 query_id, bool force)
int bms_next_member(const Bitmapset *a, int prevbit)
int bms_num_members(const Bitmapset *a)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_copy(const Bitmapset *a)
#define Assert(condition)
#define MemSet(start, val, len)
#define OidIsValid(objectId)
bool IsInplaceUpdateRelation(Relation relation)
int errcode(int sqlerrcode)
int errdetail(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
void ExecReScan(PlanState *node)
ExprState * ExecPrepareExpr(Expr *node, EState *estate)
bool ExecCheck(ExprState *state, ExprContext *econtext)
ExprState * ExecPrepareCheck(List *qual, EState *estate)
void ExecCloseIndices(ResultRelInfo *resultRelInfo)
TupleTableSlot * ExecFilterJunk(JunkFilter *junkfilter, TupleTableSlot *slot)
AttrNumber ExecFindJunkAttributeInTlist(List *targetlist, const char *attrName)
JunkFilter * ExecInitJunkFilter(List *targetList, TupleTableSlot *slot)
static void EvalPlanQualStart(EPQState *epqstate, Plan *planTree)
static void ReportNotNullViolationError(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, int attnum)
LockTupleMode ExecUpdateLockMode(EState *estate, ResultRelInfo *relinfo)
ExecRowMark * ExecFindRowMark(EState *estate, Index rti, bool missing_ok)
ExecAuxRowMark * ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist)
ExecutorEnd_hook_type ExecutorEnd_hook
ResultRelInfo * ExecGetTriggerResultRel(EState *estate, Oid relid, ResultRelInfo *rootRelInfo)
TupleTableSlot * EvalPlanQualSlot(EPQState *epqstate, Relation relation, Index rti)
void CheckValidResultRel(ResultRelInfo *resultRelInfo, CmdType operation, OnConflictAction onConflictAction, List *mergeActions)
void EvalPlanQualBegin(EPQState *epqstate)
ExecutorFinish_hook_type ExecutorFinish_hook
char * ExecBuildSlotValueDescription(Oid reloid, TupleTableSlot *slot, TupleDesc tupdesc, Bitmapset *modifiedCols, int maxfieldlen)
bool ExecPartitionCheck(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, bool emitError)
static void ExecEndPlan(PlanState *planstate, EState *estate)
ExecutorStart_hook_type ExecutorStart_hook
void ExecutorEnd(QueryDesc *queryDesc)
void EvalPlanQualInit(EPQState *epqstate, EState *parentestate, Plan *subplan, List *auxrowmarks, int epqParam, List *resultRelations)
void ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
ExecutorCheckPerms_hook_type ExecutorCheckPerms_hook
void InitResultRelInfo(ResultRelInfo *resultRelInfo, Relation resultRelationDesc, Index resultRelationIndex, ResultRelInfo *partition_root_rri, int instrument_options)
void standard_ExecutorStart(QueryDesc *queryDesc, int eflags)
void ExecutorFinish(QueryDesc *queryDesc)
static void CheckValidRowMarkRel(Relation rel, RowMarkType markType)
void EvalPlanQualEnd(EPQState *epqstate)
static void ExecCheckXactReadOnly(PlannedStmt *plannedstmt)
void EvalPlanQualSetPlan(EPQState *epqstate, Plan *subplan, List *auxrowmarks)
void ExecutorRewind(QueryDesc *queryDesc)
void ExecutorStart(QueryDesc *queryDesc, int eflags)
AttrNumber ExecRelGenVirtualNotNull(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate, List *notnull_virtual_attrs)
TupleTableSlot * EvalPlanQual(EPQState *epqstate, Relation relation, Index rti, TupleTableSlot *inputslot)
bool ExecCheckOneRelPerms(RTEPermissionInfo *perminfo)
bool EvalPlanQualFetchRowMark(EPQState *epqstate, Index rti, TupleTableSlot *slot)
static bool ExecCheckPermissionsModified(Oid relOid, Oid userid, Bitmapset *modifiedCols, AclMode requiredPerms)
ExecutorRun_hook_type ExecutorRun_hook
static void ExecPostprocessPlan(EState *estate)
static const char * ExecRelCheck(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
static void ExecutePlan(QueryDesc *queryDesc, CmdType operation, bool sendTuples, uint64 numberTuples, ScanDirection direction, DestReceiver *dest)
void ExecCloseResultRelations(EState *estate)
void standard_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count)
void standard_ExecutorEnd(QueryDesc *queryDesc)
void ExecCloseRangeTableRelations(EState *estate)
void ExecPartitionCheckEmitError(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
void ExecConstraints(ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
static void InitPlan(QueryDesc *queryDesc, int eflags)
bool ExecCheckPermissions(List *rangeTable, List *rteperminfos, bool ereport_on_violation)
void ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count)
List * ExecGetAncestorResultRels(EState *estate, ResultRelInfo *resultRelInfo)
TupleTableSlot * EvalPlanQualNext(EPQState *epqstate)
void standard_ExecutorFinish(QueryDesc *queryDesc)
void ExecDoInitialPruning(EState *estate)
void ExecEndNode(PlanState *node)
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
void ExecShutdownNode(PlanState *node)
void CheckCmdReplicaIdentity(Relation rel, CmdType cmd)
void ExecResetTupleTable(List *tupleTable, bool shouldFree)
const TupleTableSlotOps TTSOpsVirtual
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
void ExecStoreHeapTupleDatum(Datum data, TupleTableSlot *slot)
TupleTableSlot * MakeTupleTableSlot(TupleDesc tupleDesc, const TupleTableSlotOps *tts_ops)
TupleDesc ExecGetResultType(PlanState *planstate)
Relation ExecGetRangeTableRelation(EState *estate, Index rti, bool isResultRel)
Bitmapset * ExecGetInsertedCols(ResultRelInfo *relinfo, EState *estate)
void ExecInitRangeTable(EState *estate, List *rangeTable, List *permInfos, Bitmapset *unpruned_relids)
Bitmapset * ExecGetUpdatedCols(ResultRelInfo *relinfo, EState *estate)
void FreeExecutorState(EState *estate)
Bitmapset * ExecGetAllUpdatedCols(ResultRelInfo *relinfo, EState *estate)
EState * CreateExecutorState(void)
#define EXEC_FLAG_BACKWARD
#define ResetPerTupleExprContext(estate)
#define GetPerTupleExprContext(estate)
void(* ExecutorFinish_hook_type)(QueryDesc *queryDesc)
static RangeTblEntry * exec_rt_fetch(Index rti, EState *estate)
void(* ExecutorRun_hook_type)(QueryDesc *queryDesc, ScanDirection direction, uint64 count)
void(* ExecutorStart_hook_type)(QueryDesc *queryDesc, int eflags)
static bool ExecQual(ExprState *state, ExprContext *econtext)
bool(* ExecutorCheckPerms_hook_type)(List *rangeTable, List *rtePermInfos, bool ereport_on_violation)
void(* ExecutorEnd_hook_type)(QueryDesc *queryDesc)
static TupleTableSlot * ExecProcNode(PlanState *node)
#define EXEC_FLAG_SKIP_TRIGGERS
#define EXEC_FLAG_EXPLAIN_ONLY
static Datum ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno, bool *isNull)
#define palloc_object(type)
#define palloc_array(type, count)
#define palloc0_array(type, count)
#define palloc0_object(type)
char * OidOutputFunctionCall(Oid functionId, Datum val)
FdwRoutine * GetFdwRoutineForRelation(Relation relation, bool makecopy)
Instrumentation * InstrAlloc(int n, int instrument_options, bool async_mode)
void InstrStartNode(Instrumentation *instr)
void InstrStopNode(Instrumentation *instr, double nTuples)
static void ItemPointerSetInvalid(ItemPointerData *pointer)
List * lappend(List *list, void *datum)
List * lappend_int(List *list, int datum)
@ LockTupleNoKeyExclusive
char * get_rel_name(Oid relid)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
char get_rel_relkind(Oid relid)
Oid get_rel_namespace(Oid relid)
bool MatViewIncrementalMaintenanceIsEnabled(void)
int pg_mbcliplen(const char *mbstr, int len, int limit)
bool isTempNamespace(Oid namespaceId)
void ExecSetParamPlanMulti(const Bitmapset *params, ExprContext *econtext)
ObjectType get_relkind_objtype(char relkind)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
RTEPermissionInfo * getRTEPermissionInfo(List *rteperminfos, RangeTblEntry *rte)
@ WCO_RLS_MERGE_UPDATE_CHECK
@ WCO_RLS_MERGE_DELETE_CHECK
List * RelationGetPartitionQual(Relation rel)
List * get_partition_ancestors(Oid relid)
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_node(type, var, lst)
#define foreach_int(var, lst)
static char buf[DEFAULT_XLOG_SEG_SIZE]
void pgstat_update_parallel_workers_stats(PgStat_Counter workers_to_launch, PgStat_Counter workers_launched)
#define RowMarkRequiresRowShareLock(marktype)
@ ROW_MARK_NOKEYEXCLUSIVE
static Oid DatumGetObjectId(Datum X)
static Pointer DatumGetPointer(Datum X)
@ MERGE_WHEN_NOT_MATCHED_BY_TARGET
@ MERGE_WHEN_NOT_MATCHED_BY_SOURCE
void * stringToNode(const char *str)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
int errtableconstraint(Relation rel, const char *conname)
int errtablecol(Relation rel, int attnum)
Bitmapset * RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind attrKind)
int errtable(Relation rel)
bool view_has_instead_trigger(Relation view, CmdType event, List *mergeActionList)
Node * build_generation_expression(Relation rel, int attrno)
void error_view_not_updatable(Relation view, CmdType command, List *mergeActionList, const char *detail)
Node * expand_generated_columns_in_expr(Node *node, Relation rel, int rt_index)
int check_enable_rls(Oid relid, Oid checkAsUser, bool noError)
#define ScanDirectionIsNoMovement(direction)
void UnregisterSnapshot(Snapshot snapshot)
Snapshot RegisterSnapshot(Snapshot snapshot)
Snapshot GetActiveSnapshot(void)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
ExecAuxRowMark ** relsubs_rowmark
TupleTableSlot * origslot
TupleTableSlot ** relsubs_slot
PlanState * recheckplanstate
List * es_part_prune_infos
int es_parallel_workers_to_launch
List * es_tuple_routing_result_relations
PlannedStmt * es_plannedstmt
QueryEnvironment * es_queryEnv
ParamExecData * es_param_exec_vals
uint64 es_total_processed
Bitmapset * es_unpruned_relids
List * es_part_prune_states
ParamListInfo es_param_list_info
ExecRowMark ** es_rowmarks
MemoryContext es_query_cxt
ScanDirection es_direction
struct EPQState * es_epq_active
PartitionDirectory es_partition_directory
List * es_trig_target_relations
List * es_opened_result_relations
bool es_use_parallel_mode
int es_parallel_workers_launched
Index es_range_table_size
const char * es_sourceText
List * es_auxmodifytables
JunkFilter * es_junkFilter
List * es_part_prune_results
Snapshot es_crosscheck_snapshot
TupleTableSlot * ecxt_scantuple
ExecForeignInsert_function ExecForeignInsert
ExecForeignUpdate_function ExecForeignUpdate
RefetchForeignRow_function RefetchForeignRow
ExecForeignDelete_function ExecForeignDelete
IsForeignRelUpdatable_function IsForeignRelUpdatable
TupleDesc jf_cleanTupType
LockClauseStrength strength
LockWaitPolicy waitPolicy
Bitmapset * rewindPlanIDs
Bitmapset * unprunableRelids
PlannedStmt * plannedstmt
struct Instrumentation * totaltime
QueryEnvironment * queryEnv
Snapshot crosscheck_snapshot
TupleConversionMap * ri_RootToChildMap
OnConflictActionState * ri_onConflict
ExprState ** ri_CheckConstraintExprs
TupleTableSlot * ri_PartitionTupleSlot
bool ri_projectNewInfoValid
List * ri_onConflictArbiterIndexes
struct ResultRelInfo * ri_RootResultRelInfo
ExprState * ri_PartitionCheckExpr
Instrumentation * ri_TrigInstrument
ExprState * ri_MergeJoinCondition
RelationPtr ri_IndexRelationDescs
TupleTableSlot * ri_ReturningSlot
List * ri_WithCheckOptions
TupleTableSlot * ri_oldTupleSlot
bool ri_RootToChildMapValid
struct CopyMultiInsertBuffer * ri_CopyMultiInsertBuffer
TriggerDesc * ri_TrigDesc
TupleTableSlot * ri_AllNullSlot
ExprState ** ri_GenVirtualNotNullConstraintExprs
Bitmapset * ri_extraUpdatedCols
ExprState ** ri_GeneratedExprsI
TupleConversionMap * ri_ChildToRootMap
bool ri_ChildToRootMapValid
List * ri_MergeActions[NUM_MERGE_MATCH_KINDS]
List * ri_ancestorResultRels
TupleTableSlot * ri_newTupleSlot
List * ri_WithCheckOptionExprs
ProjectionInfo * ri_projectNew
ProjectionInfo * ri_projectReturning
ExprState ** ri_GeneratedExprsU
struct FdwRoutine * ri_FdwRoutine
ExprState ** ri_TrigWhenExprs
FmgrInfo * ri_TrigFunctions
bool ri_usesFdwDirectModify
IndexInfo ** ri_IndexRelationInfo
TupleTableSlot * ri_TrigNewSlot
TupleTableSlot * ri_TrigOldSlot
#define FirstLowInvalidHeapAttributeNumber
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
static bool table_tuple_fetch_row_version(Relation rel, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot)
TriggerDesc * CopyTriggerDesc(TriggerDesc *trigdesc)
void AfterTriggerEndQuery(EState *estate)
void AfterTriggerBeginQuery(void)
TupleTableSlot * execute_attr_map_slot(AttrMap *attrMap, TupleTableSlot *in_slot, TupleTableSlot *out_slot)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
static void slot_getallattrs(TupleTableSlot *slot)
static TupleTableSlot * ExecCopySlot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
static void ExecMaterializeSlot(TupleTableSlot *slot)
static bool slot_attisnull(TupleTableSlot *slot, int attnum)
void PreventCommandIfReadOnly(const char *cmdname)
void PreventCommandIfParallelMode(const char *cmdname)
static const char * CreateCommandName(Node *parsetree)
void ExitParallelMode(void)
void EnterParallelMode(void)
bool IsInParallelMode(void)
CommandId GetCurrentCommandId(bool used)