PostgreSQL Source Code: src/backend/optimizer/plan/createplan.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
18
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69#define CP_EXACT_TLIST 0x0001
70#define CP_SMALL_TLIST 0x0002
71#define CP_LABEL_TLIST 0x0004
72#define CP_IGNORE_TLIST 0x0008
73
74
76 int flags);
78 int flags);
87 int flags);
89 int flags);
94 int flags);
96 int flags);
100 int flags);
102 bool parallel_safe);
113 int flags);
116 int flags);
119 int flags);
178 double limit_tuples);
180 List *pathkeys, double limit_tuples);
185 Oid indexid, List *indexqual, List *indexqualorig,
186 List *indexorderby, List *indexorderbyorig,
187 List *indexorderbyops,
190 Index scanrelid, Oid indexid,
191 List *indexqual, List *recheckqual,
192 List *indexorderby,
193 List *indextlist,
196 List *indexqual,
197 List *indexqualorig);
200 Plan *lefttree,
201 List *bitmapqualorig,
202 Index scanrelid);
204 List *tidquals);
206 Index scanrelid, List *tidrangequals);
210 Plan *subplan);
214 Index scanrelid, List *values_lists);
218 Index scanrelid, int ctePlanId, int cteParam);
220 Index scanrelid, char *enrname);
222 Index scanrelid, int wtParam);
224 Plan *lefttree,
225 Plan *righttree,
226 int wtParam,
227 List *distinctList,
233 Plan *lefttree, Plan *righttree,
234 JoinType jointype, bool inner_unique);
237 List *hashclauses,
238 List *hashoperators, List *hashcollations,
239 List *hashkeys,
240 Plan *lefttree, Plan *righttree,
241 JoinType jointype, bool inner_unique);
243 List *hashkeys,
244 Oid skewTable,
246 bool skewInherit);
249 List *mergeclauses,
254 Plan *lefttree, Plan *righttree,
255 JoinType jointype, bool inner_unique,
256 bool skip_mark_restore);
261 int numCols, int nPresortedCols,
276 List *pathkeys, Relids relids, int nPresortedCols);
279 Plan *lefttree);
282 Oid *collations, List *param_exprs,
283 bool singlerow, bool binary_mode,
287 double est_hit_ratio);
291 List *runCondition, List *qual, bool topWindow,
292 Plan *lefttree);
295 Plan *lefttree);
297 List *pathkeys, int numCols,
300 int nworkers, int rescan_param, bool single_copy, Plan *subplan);
302 List *tlist, Plan *lefttree, Plan *righttree,
306 Plan *subplan);
311 CmdType operation, bool canSetTag,
312 Index nominalRelation, Index rootRelation,
313 List *resultRelations,
314 List *updateColnosLists,
315 List *withCheckOptionLists, List *returningLists,
317 List *mergeActionLists, List *mergeJoinConditions,
318 int epqParam);
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
340{
342
343
345
346
348 root->curOuterParams = NIL;
349
350
352
353
354
355
356
357
358
359
362
363
364
365
366
367
368
369
371
372
373 if (root->curOuterParams != NIL)
374 elog(ERROR, "failed to assign all NestLoopParams to plan nodes");
375
376
377
378
379
381
383}
384
385
386
387
388
391{
393
394
396
398 {
416 break;
422 break;
426 flags);
427 break;
431 flags);
432 break;
435 {
438 flags);
439 }
441 {
444 }
446 {
449 }
450 else
451 {
452
455 }
456 break;
460 break;
464 flags);
465 break;
469 flags);
470 break;
474 flags);
475 break;
479 break;
483 flags);
484 break;
488 flags);
489 break;
493 break;
498 else
499 {
503 }
504 break;
508 break;
512 flags);
513 break;
517 break;
521 flags);
522 break;
526 break;
530 flags);
531 break;
535 break;
536 default:
537 elog(ERROR, "unrecognized node type: %d",
540 break;
541 }
542
544}
545
546
547
548
549
552{
558
559
560
561
562
563
564
565
566
567
568
569
570
572 {
576 break;
577 default:
579 break;
580 }
581
582
583
584
585
586
587
590 best_path->param_info->ppi_clauses);
591
592
593
594
595
596
597
598
599
600
601
603 {
605
610 else
612
614 }
615 else
618 flags = 0;
619
620
621
622
623
624
625
626
627
628
629
631 {
632 tlist = NULL;
633 }
635 {
637 {
638
640
641
642
643
644
647 }
648 else
649 {
651 if (tlist == NIL)
652 {
653
655 }
656 else
657 {
658
661 }
662 }
663 }
664 else
665 {
667 }
668
670 {
674 tlist,
676 break;
677
681 tlist,
683 break;
684
688 tlist,
690 false);
691 break;
692
696 tlist,
698 true);
699 break;
700
704 tlist,
706 break;
707
711 tlist,
713 break;
714
718 tlist,
720 break;
721
725 tlist,
727 break;
728
732 tlist,
734 break;
735
739 tlist,
741 break;
742
746 tlist,
748 break;
749
753 tlist,
755 break;
756
760 tlist,
762 break;
763
767 tlist,
769 break;
770
774 tlist,
776 break;
777
781 tlist,
783 break;
784
788 tlist,
790 break;
791
792 default:
793 elog(ERROR, "unrecognized node type: %d",
796 break;
797 }
798
799
800
801
802
803
806
808}
809
810
811
812
813
814
815
818{
821 int resno = 1;
823
824 foreach(v, path->pathtarget->exprs)
825 {
828
829
830
831
832
833
834
835 if (path->param_info)
837
839 resno,
841 false);
844
846 resno++;
847 }
848 return tlist;
849}
850
851
852
853
854
855
856static bool
858{
860 int i;
862
863
864
865
867 return false;
868
869
870
871
872
879 return false;
880
881
882
883
884
885
887 return false;
888
889
890
891
892
893
894
896 return false;
897
898
899
900
901
902
904 path->pathtarget->exprs == NIL)
905 return false;
906
907
908
909
910
911
913 {
915 return false;
916 }
917
918
919
920
921
922 foreach(lc, root->placeholder_list)
923 {
925
928 return false;
929 }
930
931
932
933
934
935
937 {
939
940 for (i = 0; i < indexinfo->ncolumns; i++)
941 {
942 if (!indexinfo->canreturn[i])
943 return false;
944 }
945 }
946
947
948
949
950
951
952
953
954
955
956 if ((flags & CP_LABEL_TLIST) && path->pathtarget->sortgrouprefs)
957 {
959
960 i = 0;
961 foreach(lc, path->pathtarget->exprs)
962 {
964
965 if (path->pathtarget->sortgrouprefs[i])
966 {
967 if (expr && IsA(expr, Var))
968 {
969 int attno = ((Var *) expr)->varattno;
970
973 return false;
975 }
976 else
977 return false;
978 }
979 i++;
980 }
981 }
982
983 return true;
984}
985
986
987
988
989
990
991
992
995{
996
997 if (->hasPseudoConstantQuals)
998 return NIL;
999
1000
1002
1003
1005}
1006
1007
1008
1009
1010
1011
1012
1013static Plan *
1016{
1018
1020
1021
1022
1023
1024
1025
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1039 {
1041
1045 }
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1060
1061
1063
1064 return &gplan->plan;
1065}
1066
1067
1068
1069
1070
1071
1072static Plan *
1074{
1077
1078 switch (best_path->path.pathtype)
1079 {
1083 break;
1087 break;
1091 break;
1092 default:
1093 elog(ERROR, "unrecognized node type: %d",
1094 (int) best_path->path.pathtype);
1096 break;
1097 }
1098
1099
1100
1101
1102
1103
1108
1109#ifdef NOT_USED
1110
1111
1112
1113
1114
1115
1120#endif
1121
1122 return plan;
1123}
1124
1125
1126
1127
1128
1129
1130
1131static bool
1133{
1135 {
1137 {
1139
1140
1141
1142
1143
1145 return false;
1146
1147
1148
1149
1150
1154 break;
1155 return false;
1156 }
1158 {
1159 FdwRoutine *fdwroutine = path->parent->fdwroutine;
1160
1161
1162
1163
1164
1166 return false;
1167
1171 break;
1172 return false;
1173 }
1175
1176
1177
1178
1179
1181 return false;
1182
1183
1184
1185
1186
1189 return true;
1190 return false;
1191 default:
1192 return false;
1193 }
1194
1195 plan->async_capable = true;
1196
1197 return true;
1198}
1199
1200
1201
1202
1203
1204
1205
1206
1207static Plan *
1209{
1217 int nasyncplans = 0;
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1236 {
1237
1239
1242 false)),
1244
1246
1247 return plan;
1248 }
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1262 plan->plan.targetlist = tlist;
1265 plan->plan.righttree = NULL;
1267 plan->child_append_relid_sets = best_path->child_append_relid_sets;
1268
1269 if (pathkeys != NIL)
1270 {
1271
1272
1273
1274
1275
1276
1280 true,
1287 }
1288
1289
1291 ->path.parallel_safe &&
1293
1294
1295 foreach(subpaths, best_path->subpaths)
1296 {
1298 Plan *subplan;
1299
1300
1302
1303
1304
1305
1306
1307 if (pathkeys != NIL)
1308 {
1311 Oid *sortOperators;
1312 Oid *collations;
1314 int presorted_keys;
1315
1316
1317
1318
1319
1320
1321
1323 subpath->parent->relids,
1325 false,
1327 &sortColIdx,
1328 &sortOperators,
1329 &collations,
1331
1332
1333
1334
1335
1336
1337
1341 elog(ERROR, "Append child's targetlist doesn't match Append");
1348
1349
1351 &presorted_keys))
1352 {
1354
1355
1356
1357
1358
1360 {
1363 sortColIdx, sortOperators,
1365
1368 pathkeys,
1370 }
1371 else
1372 {
1374 sortColIdx, sortOperators,
1376
1379 }
1380
1382 }
1383 }
1384
1385
1387 {
1389 ++nasyncplans;
1390 }
1391
1392 subplans = lappend(subplans, subplan);
1393 }
1394
1395
1396 plan->part_prune_index = -1;
1397
1398
1399
1400
1401
1402
1404 {
1406
1408
1410 {
1412
1416
1418 }
1419
1424 }
1425
1426 plan->appendplans = subplans;
1427 plan->nasyncplans = nasyncplans;
1428 plan->first_partial_plan = best_path->first_partial_path;
1429
1431
1432
1433
1434
1435
1436
1438 {
1441 plan->plan.parallel_safe);
1442 }
1443 else
1445}
1446
1447
1448
1449
1450
1451
1452
1453
1454static Plan *
1456 int flags)
1457{
1467
1468
1469
1470
1471
1472
1473
1475 plan->targetlist = tlist;
1481
1482
1483
1484
1485
1486
1487
1491 true,
1493 &node->sortColIdx,
1494 &node->sortOperators,
1495 &node->collations,
1496 &node->nullsFirst);
1498
1499
1500
1501
1502
1503
1504 foreach(subpaths, best_path->subpaths)
1505 {
1507 Plan *subplan;
1510 Oid *sortOperators;
1511 Oid *collations;
1513 int presorted_keys;
1514
1515
1516
1518
1519
1521 subpath->parent->relids,
1522 node->sortColIdx,
1523 false,
1525 &sortColIdx,
1526 &sortOperators,
1527 &collations,
1529
1530
1531
1532
1533
1534
1535
1537 if (memcmp(sortColIdx, node->sortColIdx,
1539 elog(ERROR, "MergeAppend child's targetlist doesn't match MergeAppend");
1540 Assert(memcmp(sortOperators, node->sortOperators,
1546
1547
1549 &presorted_keys))
1550 {
1552
1553
1554
1555
1556
1558 {
1561 sortColIdx, sortOperators,
1563
1566 pathkeys,
1568 }
1569 else
1570 {
1572 sortColIdx, sortOperators,
1574
1577 }
1578
1580 }
1581
1582 subplans = lappend(subplans, subplan);
1583 }
1584
1585
1587
1588
1589
1590
1591
1592
1594 {
1596
1598
1599
1601
1606 }
1607
1609
1610
1611
1612
1613
1614
1616 {
1619 }
1620 else
1621 return plan;
1622}
1623
1624
1625
1626
1627
1628
1629
1630
1633{
1635 List *tlist;
1636 List *quals;
1637
1639
1640
1642
1644
1646
1647 return plan;
1648}
1649
1650
1651
1652
1653
1654
1655
1658{
1660 Plan *subplan;
1661 List *tlist;
1662
1663
1665
1667
1669
1671
1672 return plan;
1673}
1674
1675
1676
1677
1678
1679
1680
1681
1684{
1686 Plan *subplan;
1687
1688
1689
1690
1691
1692
1695
1697
1699
1700 return plan;
1701}
1702
1703
1704
1705
1706
1707
1708
1709
1712{
1715 Plan *subplan;
1716 Oid *operators;
1717 Oid *collations;
1721 int nkeys;
1722 int i;
1723
1726
1729
1732 operators = palloc(nkeys * sizeof(Oid));
1733 collations = palloc(nkeys * sizeof(Oid));
1734
1735 i = 0;
1737 {
1740
1741 operators[i] = opno;
1743 i++;
1744 }
1745
1747
1748 plan = make_memoize(subplan, operators, collations, param_exprs,
1752
1754
1755 return plan;
1756}
1757
1758
1759
1760
1761
1762
1763
1766{
1768 Plan *subplan;
1769 List *tlist;
1770
1771
1772
1773
1774
1775
1776
1778
1780
1786 subplan);
1787
1789
1790
1791 root->glob->parallelModeNeeded = true;
1792
1794}
1795
1796
1797
1798
1799
1800
1801
1804{
1806 Plan *subplan;
1809
1810
1812
1813
1815 gm_plan->plan.targetlist = tlist;
1818
1819
1821
1822
1824
1825
1827 best_path->subpath->parent->relids,
1829 false,
1832 &gm_plan->sortOperators,
1835
1836
1837
1838
1839
1841
1842
1843 gm_plan->plan.lefttree = subplan;
1844
1845
1846 root->glob->parallelModeNeeded = true;
1847
1849}
1850
1851
1852
1853
1854
1855
1856
1857
1858static Plan *
1860{
1862 Plan *subplan;
1863 List *tlist;
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1880 {
1881
1882
1883
1884
1885
1891 }
1893 {
1894
1895
1896
1897
1898
1899
1904 }
1905 else
1906 {
1907
1908
1909
1910
1914 }
1915
1916
1917
1918
1919
1920
1921
1922
1923
1925 {
1926
1927 plan = subplan;
1929
1930
1931 plan->startup_cost = best_path->path.startup_cost;
1934 plan->plan_width = best_path->path.pathtarget->width;
1935 plan->parallel_safe = best_path->path.parallel_safe;
1936
1937 }
1938 else
1939 {
1941
1943 }
1944
1945 return plan;
1946}
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959static Plan *
1961{
1963
1965
1966
1967
1968
1969
1970
1971
1972
1974 plan->parallel_safe = parallel_safe;
1975
1976 return plan;
1977}
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1993{
1994
1995
1996
1997
1998
2004 else
2005 {
2006
2009 }
2010 return subplan;
2011}
2012
2013
2014
2015
2016
2017
2018
2019static Sort *
2021{
2023 Plan *subplan;
2024
2025
2026
2027
2028
2029
2032
2033
2034
2035
2036
2037
2038
2042
2044
2045 return plan;
2046}
2047
2048
2049
2050
2051
2052
2055 int flags)
2056{
2058 Plan *subplan;
2059
2060
2068
2070
2071 return plan;
2072}
2073
2074
2075
2076
2077
2078
2079
2082{
2084 Plan *subplan;
2085 List *tlist;
2086 List *quals;
2087
2088
2089
2090
2091
2093
2095
2097
2099 quals,
2106 subplan);
2107
2109
2110 return plan;
2111}
2112
2113
2114
2115
2116
2117
2118
2121{
2123 Plan *subplan;
2124
2125
2126
2127
2128
2131
2132
2133
2134
2135
2136
2137
2143
2145
2146 return plan;
2147}
2148
2149
2150
2151
2152
2153
2154
2155static Agg *
2157{
2159 Plan *subplan;
2160 List *tlist;
2161 List *quals;
2162
2163
2164
2165
2166
2168
2170
2172
2186 subplan);
2187
2189
2190 return plan;
2191}
2192
2193
2194
2195
2196
2197
2198
2199
2200
2203{
2207 int i;
2208
2210
2212
2213 i = 0;
2214 foreach(lc, groupClause)
2215 {
2217
2219 }
2220
2222}
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239static Plan *
2241{
2243 Plan *subplan;
2247 List *chain;
2249
2250
2253
2254
2255
2256
2257
2259
2260
2261
2262
2263
2264
2266 foreach(lc, root->processed_groupClause)
2267 {
2269
2270 if (gc->tleSortGroupRef > maxref)
2272 }
2273
2275
2276
2277 foreach(lc, root->processed_groupClause)
2278 {
2281
2283 }
2284
2285
2286
2287
2288
2291
2292
2293
2294
2295
2296
2297
2298 chain = NIL;
2300 {
2302
2304 {
2310
2312
2314 {
2318 subplan);
2319 }
2320
2321 if (->is_hashed)
2323
2324 if (rollup->is_hashed)
2328 else
2330
2344
2345
2346
2347
2349 {
2352 }
2353
2355 }
2356 }
2357
2358
2359
2360
2361 {
2365
2367
2369
2379 chain,
2382 subplan);
2383
2384
2386 }
2387
2389}
2390
2391
2392
2393
2394
2395
2396
2399{
2401 List *tlist;
2403
2404
2406 {
2411
2412
2413
2414
2415
2416
2417
2419
2425
2426
2427 plan->disabled_nodes = mminfo->path->disabled_nodes;
2428 plan->startup_cost = mminfo->path->startup_cost;
2429 plan->total_cost = mminfo->pathcost;
2430 plan->plan_rows = 1;
2431 plan->plan_width = mminfo->path->pathtarget->width;
2432 plan->parallel_aware = false;
2433 plan->parallel_safe = mminfo->path->parallel_safe;
2434
2435
2437 }
2438
2439
2441
2445
2447
2448
2449
2450
2451
2452
2453
2456
2457 return plan;
2458}
2459
2460
2461
2462
2463
2464
2465
2468{
2473 Plan *subplan;
2474 List *tlist;
2475 int partNumCols;
2479 int ordNumCols;
2484
2485
2486
2487
2488
2489
2490
2493
2495
2496
2497
2498
2499
2503
2504 partNumCols = 0;
2506 {
2509
2514 partNumCols++;
2515 }
2516
2520
2521 ordNumCols = 0;
2523 {
2526
2531 ordNumCols++;
2532 }
2533
2534
2536 wc,
2537 partNumCols,
2541 ordNumCols,
2548 subplan);
2549
2551
2552 return plan;
2553}
2554
2555
2556
2557
2558
2559
2560
2563{
2568
2569
2570
2571
2572
2577
2580 tlist,
2585
2587
2588 return plan;
2589}
2590
2591
2592
2593
2594
2595
2596
2599{
2603 List *tlist;
2604
2605
2608
2610
2617
2619
2620 return plan;
2621}
2622
2623
2624
2625
2626
2627
2628
2631 int flags)
2632{
2634 Plan *subplan;
2635
2636
2638
2640
2642
2643 return plan;
2644}
2645
2646
2647
2648
2649
2650
2651
2654{
2657 Plan *subplan;
2658
2659
2661
2662
2664
2666 subplan,
2673 best_path->withCheckOptionLists,
2680
2682
2683 return plan;
2684}
2685
2686
2687
2688
2689
2690
2691
2694{
2696 Plan *subplan;
2701
2702
2704
2705
2707 {
2710
2715
2717 foreach(l, parse->sortClause)
2718 {
2721
2726 }
2727 }
2728
2734
2736
2737 return plan;
2738}
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2756{
2759
2760
2763
2764
2766
2767
2769
2770
2772 {
2775 }
2776
2780
2782
2784}
2785
2786
2787
2788
2789
2790
2794{
2799
2800
2806
2807
2809
2810
2812
2813
2815 {
2820 }
2821
2826
2828
2830}
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842static Scan *
2845 List *tlist,
2848{
2859 List *indexorderbyops = NIL;
2861
2862
2865
2868
2869
2870
2871
2872
2873
2874
2878
2879
2880
2881
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2914 {
2916
2917 if (rinfo->pseudoconstant)
2918 continue;
2920 continue;
2923 false))
2924 continue;
2926 }
2927
2928
2930
2931
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2944 {
2949 indexorderbys = (List *)
2951 }
2952
2953
2954
2955
2956
2957 if (indexorderbys)
2958 {
2961
2962
2963
2964
2965
2966
2969 {
2973 Oid sortop;
2974
2975
2977 exprtype,
2978 exprtype,
2981 elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
2982 pathkey->pk_cmptype, exprtype, exprtype, pathkey->pk_opfamily);
2983 indexorderbyops = lappend_oid(indexorderbyops, sortop);
2984 }
2985 }
2986
2987
2988
2989
2990
2991
2993 {
2994 int i = 0;
2995
2997 {
2999
3000 indextle->resjunk = !indexinfo->canreturn[i];
3001 i++;
3002 }
3003 }
3004
3005
3010 indexoid,
3016 else
3020 indexoid,
3024 indexorderbys,
3025 indexorderbyops,
3027
3029
3031}
3032
3033
3034
3035
3036
3037
3041 List *tlist,
3043{
3046 List *bitmapqualorig;
3047 List *indexquals;
3052
3053
3056
3057
3059 &bitmapqualorig, &indexquals,
3061
3062 if (best_path->path.parallel_aware)
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3093 {
3096
3097 if (rinfo->pseudoconstant)
3098 continue;
3100 continue;
3102 continue;
3105 continue;
3107 }
3108
3109
3111
3112
3114
3115
3116
3117
3118
3119
3120
3122
3123
3124
3125
3126
3127
3129 {
3132 bitmapqualorig = (List *)
3134 }
3135
3136
3140 bitmapqualorig,
3142
3144
3146}
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168static Plan *
3171{
3173
3175 {
3182
3183
3184
3185
3186
3187
3188
3189
3190 foreach(l, apath->bitmapquals)
3191 {
3192 Plan *subplan;
3196
3200 subplans = lappend(subplans, subplan);
3203
3205 }
3207 plan->startup_cost = apath->path.startup_cost;
3208 plan->total_cost = apath->path.total_cost;
3209 plan->plan_rows =
3211 plan->plan_width = 0;
3212 plan->parallel_aware = false;
3213 plan->parallel_safe = apath->path.parallel_safe;
3217 }
3219 {
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237 foreach(l, opath->bitmapquals)
3238 {
3239 Plan *subplan;
3243
3247 subplans = lappend(subplans, subplan);
3258 }
3259
3260
3261
3262
3263
3265 {
3267 }
3268 else
3269 {
3271 plan->startup_cost = opath->path.startup_cost;
3272 plan->total_cost = opath->path.total_cost;
3273 plan->plan_rows =
3275 plan->plan_width = 0;
3276 plan->parallel_aware = false;
3277 plan->parallel_safe = opath->path.parallel_safe;
3278 }
3279
3280
3281
3282
3283
3284
3286 *qual = NIL;
3289 else
3292 *indexqual = NIL;
3295 else
3298 }
3300 {
3307
3308
3312
3317
3318 plan->startup_cost = 0.0;
3319 plan->total_cost = ipath->indextotalcost;
3320 plan->plan_rows =
3322 plan->plan_width = 0;
3323 plan->parallel_aware = false;
3324 plan->parallel_safe = ipath->path.parallel_safe;
3325
3329 foreach(l, ipath->indexclauses)
3330 {
3333
3334 Assert(!rinfo->pseudoconstant);
3338 if (rinfo->parent_ec)
3340 }
3341
3342 foreach(l, ipath->indexinfo->indpred)
3343 {
3345
3346
3347
3348
3349
3350
3351
3353 {
3356 }
3357 }
3361 }
3362 else
3363 {
3364 elog(ERROR, "unrecognized node type: %d", nodeTag(bitmapqual));
3366 }
3367
3368 return plan;
3369}
3370
3371
3372
3373
3374
3375
3379{
3383
3384
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3408 {
3411
3413 {
3415
3416 if (rinfo->pseudoconstant)
3417 continue;
3419 continue;
3421 continue;
3423 }
3425 }
3426
3427
3429
3430
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3448
3449
3451 {
3452 tidquals = (List *)
3456 }
3457
3461 tidquals);
3462
3464
3466}
3467
3468
3469
3470
3471
3472
3476{
3480
3481
3484
3485
3486
3487
3488
3489
3490 {
3493
3495 {
3497
3498 if (rinfo->pseudoconstant)
3499 continue;
3501 continue;
3503 }
3505 }
3506
3507
3509
3510
3513
3514
3516 {
3517 tidrangequals = (List *)
3521 }
3522
3526 tidrangequals);
3527
3529
3531}
3532
3533
3534
3535
3536
3537
3541{
3545 Plan *subplan;
3546
3547
3550
3551
3552
3553
3554
3555
3557
3558
3560
3561
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3575 {
3580 }
3581
3585 subplan);
3586
3588
3590}
3591
3592
3593
3594
3595
3596
3600{
3605
3606
3611
3612
3614
3615
3617
3618
3620 {
3623
3625 }
3626
3629
3631
3633}
3634
3635
3636
3637
3638
3639
3643{
3648
3649
3653 tablefunc = rte->tablefunc;
3654
3655
3657
3658
3660
3661
3663 {
3666
3668 }
3669
3671 tablefunc);
3672
3674
3676}
3677
3678
3679
3680
3681
3682
3686{
3690 List *values_lists;
3691
3692
3696 values_lists = rte->values_lists;
3697
3698
3700
3701
3703
3704
3706 {
3709
3710 values_lists = (List *)
3712 }
3713
3715 values_lists);
3716
3718
3720}
3721
3722
3723
3724
3725
3726
3730{
3735 int plan_id;
3739 int ndx;
3741
3746
3747
3748
3749
3750 levelsup = rte->ctelevelsup;
3752 while (levelsup-- > 0)
3753 {
3755 if ()
3756 elog(ERROR, "bad levelsup for CTE \"%s\"", rte->ctename);
3757 }
3758
3759
3760
3761
3762
3763
3764 ndx = 0;
3765 foreach(lc, cteroot->parse->cteList)
3766 {
3768
3770 break;
3772 }
3774 elog(ERROR, "could not find CTE \"%s\"", rte->ctename);
3776 elog(ERROR, "could not find plan for CTE \"%s\"", rte->ctename);
3778 if (plan_id <= 0)
3779 elog(ERROR, "no plan was made for CTE \"%s\"", rte->ctename);
3780 foreach(lc, cteroot->init_plans)
3781 {
3783 if (ctesplan->plan_id == plan_id)
3784 break;
3785 }
3787 elog(ERROR, "could not find plan for CTE \"%s\"", rte->ctename);
3788
3789
3790
3791
3792
3794
3795
3797
3798
3800
3801
3803 {
3806 }
3807
3810
3812
3814}
3815
3816
3817
3818
3819
3820
3821
3825{
3829
3833
3834
3836
3837
3839
3840
3842 {
3845 }
3846
3848 rte->enrname);
3849
3851
3853}
3854
3855
3856
3857
3858
3859
3860
3864{
3868
3872
3873
3875
3876
3878
3879
3881 {
3884 }
3885
3888
3890
3892}
3893
3894
3895
3896
3897
3898
3902{
3908
3913
3914
3915
3916
3917
3918
3919 levelsup = rte->ctelevelsup;
3920 if (levelsup == 0)
3921 elog(ERROR, "bad levelsup for CTE \"%s\"", rte->ctename);
3922 levelsup--;
3924 while (levelsup-- > 0)
3925 {
3927 if ()
3928 elog(ERROR, "bad levelsup for CTE \"%s\"", rte->ctename);
3929 }
3930 if (cteroot->wt_param_id < 0)
3931 elog(ERROR, "could not find param ID for CTE \"%s\"", rte->ctename);
3932
3933
3935
3936
3938
3939
3941 {
3944 }
3945
3948
3950
3952}
3953
3954
3955
3956
3957
3958
3962{
3968
3970
3971
3975
3976
3977
3978
3979
3981 {
3983
3988 }
3989
3990
3991
3992
3993
3995
3996
3997
3998
3999
4000
4001
4002
4006 outer_plan);
4007
4008
4010
4011
4013
4014
4016
4017
4018
4019
4020
4021
4024 else
4026
4027
4028
4029
4030
4031
4033 root->outer_join_rels);
4034
4035
4036
4037
4038
4039
4041 root->glob->dependsOnRole = true;
4042
4043
4044
4045
4046
4047
4048
4049
4050
4052 {
4060 }
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4073 {
4076 int i;
4077
4078
4079
4080
4081
4082
4084
4085
4087 {
4089
4091 }
4092
4093
4095 {
4097 {
4099 break;
4100 }
4101 }
4102
4104 }
4105
4107}
4108
4109
4110
4111
4112
4113
4117{
4120 List *custom_plans = NIL;
4122
4123
4125 {
4128
4129 custom_plans = lappend(custom_plans, plan);
4130 }
4131
4132
4133
4134
4135
4137
4138
4139
4140
4141
4144 rel,
4146 tlist,
4148 custom_plans));
4149
4150
4151
4152
4153
4155
4156
4158
4159
4160
4161
4162
4163
4164
4165
4166
4168 {
4169 cplan->scan.plan.qual = (List *)
4173 }
4174
4175 return cplan;
4176}
4177
4178
4179
4180
4181
4182
4183
4184
4188{
4190 Plan *outer_plan;
4191 Plan *inner_plan;
4195 List *joinclauses;
4197 List *nestParams;
4198 List *outer_tlist;
4202
4203
4204
4205
4206
4207
4208 best_path->jpath.innerjoinpath =
4211 best_path->jpath.outerjoinpath->parent);
4212
4213
4214
4215
4216
4218
4219
4221
4222
4223 outerrelids = best_path->jpath.outerjoinpath->parent->relids;
4224 root->curOuterRels = bms_union(root->curOuterRels, outerrelids);
4225
4227
4228
4231
4232
4234
4235
4236
4238 {
4240 best_path->jpath.path.parent->relids,
4242 }
4243 else
4244 {
4245
4248 }
4249
4250
4251 if (best_path->jpath.path.param_info)
4252 {
4253 joinclauses = (List *)
4257 }
4258
4259
4260
4261
4262
4264 outerrelids,
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278 outer_tlist = outer_plan->targetlist;
4280 foreach(lc, nestParams)
4281 {
4285
4287 continue;
4288
4290
4292 continue;
4293
4294
4295
4296
4297
4298
4299
4300
4301
4304
4305
4306 if (outer_tlist == outer_plan->targetlist)
4307 outer_tlist = list_copy(outer_tlist);
4308
4312 true);
4313 outer_tlist = lappend(outer_tlist, tle);
4314
4317 }
4318 if (outer_tlist != outer_plan->targetlist)
4321
4322
4324 joinclauses,
4326 nestParams,
4327 outer_plan,
4328 inner_plan,
4331
4333
4335}
4336
4340{
4342 Plan *outer_plan;
4343 Plan *inner_plan;
4345 List *joinclauses;
4347 List *mergeclauses;
4357 int i;
4363
4364
4365
4366
4367
4368
4369
4372
4375
4376
4377
4379
4380
4381
4383 {
4385 best_path->jpath.path.parent->relids,
4387 }
4388 else
4389 {
4390
4393 }
4394
4395
4396
4397
4398
4400 joinclauses = list_difference(joinclauses, mergeclauses);
4401
4402
4403
4404
4405
4406 if (best_path->jpath.path.param_info)
4407 {
4408 joinclauses = (List *)
4412 }
4413
4414
4415
4416
4417
4418
4420 best_path->jpath.outerjoinpath->parent->relids);
4421
4422
4423
4424
4426 {
4429
4430
4431
4432
4433
4434
4437
4438
4439
4440
4441
4443 {
4447 outer_relids,
4448 best_path->outer_presorted_keys);
4449
4453 -1.0);
4454 }
4455 else
4456 {
4460 outer_relids);
4461
4463 }
4464
4467 }
4468 else
4470
4472 {
4473
4474
4475
4476
4477
4480
4481
4482
4483
4484
4485
4488
4492
4496 }
4497 else
4499
4500
4501
4502
4503
4504 if (best_path->materialize_inner)
4505 {
4507
4508
4509
4510
4511
4512
4515
4517 }
4518
4519
4520
4521
4522
4523
4524
4525
4532
4537 i = 0;
4538 foreach(lc, best_path->path_mergeclauses)
4539 {
4546
4547
4548 if (rinfo->outer_is_left)
4549 {
4550 oeclass = rinfo->left_ec;
4551 ieclass = rinfo->right_ec;
4552 }
4553 else
4554 {
4555 oeclass = rinfo->right_ec;
4556 ieclass = rinfo->left_ec;
4557 }
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4577 {
4578
4580 elog(ERROR, "outer pathkeys do not match mergeclauses");
4585 elog(ERROR, "outer pathkeys do not match mergeclauses");
4586 }
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603 if (lip)
4604 {
4608 {
4609
4612 }
4613 }
4615 {
4616
4618
4620 {
4621 if (l2 == lip)
4622 break;
4626 break;
4627 }
4629 elog(ERROR, "inner pathkeys do not match mergeclauses");
4630 }
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4647 opathkey->pk_eclass->ec_collation != ipathkey->pk_eclass->ec_collation)
4648 elog(ERROR, "left and right pathkeys do not match in mergejoin");
4652 elog(ERROR, "left and right pathkeys do not match in mergejoin");
4653
4654
4659 i++;
4660 }
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4672 joinclauses,
4674 mergeclauses,
4679 outer_plan,
4680 inner_plan,
4684
4685
4687
4689}
4690
4694{
4697 Plan *outer_plan;
4698 Plan *inner_plan;
4700 List *joinclauses;
4702 List *hashclauses;
4703 List *hashoperators = NIL;
4704 List *hashcollations = NIL;
4709 bool skewInherit = false;
4711
4712
4713
4714
4715
4716
4717
4718
4721
4724
4725
4727
4728
4729
4730
4732 {
4734 best_path->jpath.path.parent->relids,
4736 }
4737 else
4738 {
4739
4742 }
4743
4744
4745
4746
4747
4749 joinclauses = list_difference(joinclauses, hashclauses);
4750
4751
4752
4753
4754
4755 if (best_path->jpath.path.param_info)
4756 {
4757 joinclauses = (List *)
4761 }
4762
4763
4764
4765
4766
4768 best_path->jpath.outerjoinpath->parent->relids);
4769
4770
4771
4772
4773
4774
4775
4776
4777
4779 {
4782
4788 {
4791
4794 {
4795 skewTable = rte->relid;
4797 skewInherit = rte->inh;
4798 }
4799 }
4800 }
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810 foreach(lc, hashclauses)
4811 {
4813
4818 }
4819
4820
4821
4822
4825 skewTable,
4826 skewColumn,
4827 skewInherit);
4828
4829
4830
4831
4832
4835
4836
4837
4838
4839
4840
4841 if (best_path->jpath.path.parallel_aware)
4842 {
4843 hash_plan->plan.parallel_aware = true;
4845 }
4846
4848 joinclauses,
4850 hashclauses,
4851 hashoperators,
4852 hashcollations,
4854 outer_plan,
4858
4860
4862}
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880static Node *
4886
4887static Node *
4889{
4890 if (node == NULL)
4891 return NULL;
4893 {
4895
4896
4898
4901 return node;
4902
4904 }
4906 {
4908
4909
4911
4912
4914 root->curOuterRels))
4915 {
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4932
4938 }
4939
4941 }
4943}
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965static void
4968{
4973
4975
4977 {
4979 int indexcol = iclause->indexcol;
4981
4983 {
4986
4989 clause, iclause->indexcols);
4991 }
4992 }
4993
4996}
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006static List *
5008{
5013
5015
5017 {
5020
5023 }
5024
5026}
5027
5028
5029
5030
5031
5032
5033
5034
5035static Node *
5038{
5039
5040
5041
5042
5043
5044
5046
5048 {
5050
5051
5054 indexcol);
5055 }
5057 {
5061
5062
5065 {
5069 }
5070 }
5072 {
5074
5075
5078 indexcol);
5079 }
5081 {
5083
5084
5087 indexcol);
5088 }
5089 else
5090 elog(ERROR, "unsupported indexqual type: %d",
5092
5093 return clause;
5094}
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107static Node *
5109{
5110 Var *result;
5111 int pos;
5113
5115
5116
5117
5118
5120
5121
5122
5123
5126
5127 if (index->indexkeys[indexcol] != 0)
5128 {
5129
5131 ((Var *) node)->varno == index->rel->relid &&
5132 ((Var *) node)->varattno == index->indexkeys[indexcol])
5133 {
5136 result->varattno = indexcol + 1;
5137 return (Node *) result;
5138 }
5139 else
5140 elog(ERROR, "index key does not match expected index column");
5141 }
5142
5143
5145 for (pos = 0; pos < index->ncolumns; pos++)
5146 {
5147 if (index->indexkeys[pos] == 0)
5148 {
5150 elog(ERROR, "too few entries in indexprs list");
5151 if (pos == indexcol)
5152 {
5154
5159 {
5163 0);
5164 return (Node *) result;
5165 }
5166 else
5167 elog(ERROR, "index key does not match expected index column");
5168 }
5170 }
5171 }
5172
5173
5174 elog(ERROR, "index key does not match expected index column");
5175 return NULL;
5176}
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187static List *
5189{
5192
5193 foreach(l, clauses)
5194 {
5197
5200 {
5201
5202
5203
5204
5205
5207
5210 temp->opresulttype = clause->opresulttype;
5211 temp->opretset = clause->opretset;
5212 temp->opcollid = clause->opcollid;
5213 temp->inputcollid = clause->inputcollid;
5216
5220 }
5221 else
5222 {
5226 }
5227 }
5229}
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264static List *
5266{
5267 typedef struct
5268 {
5269 Node *clause;
5271 Index security_level;
5276 int i;
5277 List *result;
5278
5279
5281 return clauses;
5282
5283
5284
5285
5286
5288 i = 0;
5289 foreach(lc, clauses)
5290 {
5293
5295 items[i].clause = clause;
5298 {
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5312 items[i].security_level = 0;
5313 else
5315 }
5316 else
5317 items[i].security_level = 0;
5318 i++;
5319 }
5320
5321
5322
5323
5324
5325
5327 {
5329 int j;
5330
5331
5333 {
5335
5336 if (newitem.security_level > olditem->security_level ||
5337 (newitem.security_level == olditem->security_level &&
5338 newitem.cost >= olditem->cost))
5339 break;
5341 }
5343 }
5344
5345
5346 result = NIL;
5349
5350 return result;
5351}
5352
5353
5354
5355
5356
5357
5358static void
5360{
5364 dest->plan_rows = src->rows;
5365 dest->plan_width = src->pathtarget->width;
5368}
5369
5370
5371
5372
5373
5374static void
5376{
5380 dest->plan_rows = src->plan_rows;
5382
5383 dest->parallel_aware = false;
5384
5386}
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397static void
5399{
5402
5404
5406 plan->plan.disabled_nodes,
5410 0.0,
5412 limit_tuples);
5413 plan->plan.startup_cost = sort_path.startup_cost;
5417 plan->plan.parallel_aware = false;
5419}
5420
5421
5422
5423
5424
5425static void
5427 List *pathkeys, double limit_tuples)
5428{
5431
5433
5435 plan->nPresortedCols,
5436 plan->sort.plan.disabled_nodes,
5441 0.0,
5443 limit_tuples);
5444 plan->sort.plan.startup_cost = sort_path.startup_cost;
5445 plan->sort.plan.total_cost = sort_path.total_cost;
5446 plan->sort.plan.plan_rows = lefttree->plan_rows;
5448 plan->sort.plan.parallel_aware = false;
5450}
5451
5452
5453
5454
5455
5456
5457static void
5459{
5463 {
5466 }
5469 else
5471}
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5490 Index scanrelid)
5491{
5494
5500
5501 return node;
5502}
5503
5507 Index scanrelid,
5509{
5512
5519
5520 return node;
5521}
5522
5526 Index scanrelid,
5527 Oid indexid,
5528 List *indexqual,
5529 List *indexqualorig,
5530 List *indexorderby,
5531 List *indexorderbyorig,
5532 List *indexorderbyops,
5534{
5537
5543 node->indexid = indexid;
5550
5551 return node;
5552}
5553
5557 Index scanrelid,
5558 Oid indexid,
5559 List *indexqual,
5560 List *recheckqual,
5561 List *indexorderby,
5562 List *indextlist,
5564{
5567
5573 node->indexid = indexid;
5579
5580 return node;
5581}
5582
5585 Oid indexid,
5586 List *indexqual,
5587 List *indexqualorig)
5588{
5591
5597 node->indexid = indexid;
5600
5601 return node;
5602}
5603
5607 Plan *lefttree,
5608 List *bitmapqualorig,
5609 Index scanrelid)
5610{
5613
5616 plan->lefttree = lefttree;
5620
5621 return node;
5622}
5623
5627 Index scanrelid,
5628 List *tidquals)
5629{
5632
5639
5640 return node;
5641}
5642
5646 Index scanrelid,
5647 List *tidrangequals)
5648{
5651
5658
5659 return node;
5660}
5661
5665 Index scanrelid,
5666 Plan *subplan)
5667{
5670
5676 node->subplan = subplan;
5678
5679 return node;
5680}
5681
5685 Index scanrelid,
5687 bool funcordinality)
5688{
5691
5699
5700 return node;
5701}
5702
5706 Index scanrelid,
5708{
5711
5718
5719 return node;
5720}
5721
5725 Index scanrelid,
5726 List *values_lists)
5727{
5730
5737
5738 return node;
5739}
5740
5744 Index scanrelid,
5745 int ctePlanId,
5746 int cteParam)
5747{
5750
5758
5759 return node;
5760}
5761
5765 Index scanrelid,
5766 char *enrname)
5767{
5770
5771
5777 node->enrname = enrname;
5778
5779 return node;
5780}
5781
5785 Index scanrelid,
5786 int wtParam)
5787{
5790
5796 node->wtParam = wtParam;
5797
5798 return node;
5799}
5800
5804 Index scanrelid,
5805 List *fdw_exprs,
5806 List *fdw_private,
5807 List *fdw_scan_tlist,
5808 List *fdw_recheck_quals,
5809 Plan *outer_plan)
5810{
5813
5814
5817 plan->lefttree = outer_plan;
5820
5821
5824
5825
5832
5835
5837
5838 return node;
5839}
5840
5843 Plan *lefttree,
5844 Plan *righttree,
5845 int wtParam,
5846 List *distinctList,
5848{
5851 int numCols = list_length(distinctList);
5852
5853 plan->targetlist = tlist;
5855 plan->lefttree = lefttree;
5857 node->wtParam = wtParam;
5858
5859
5860
5861
5862
5863 node->numCols = numCols;
5864 if (numCols > 0)
5865 {
5866 int keyno = 0;
5871
5875
5876 foreach(slitem, distinctList)
5877 {
5880 plan->targetlist);
5881
5886 keyno++;
5887 }
5891 }
5893
5894 return node;
5895}
5896
5899{
5902
5908
5909 return node;
5910}
5911
5914{
5917
5923
5924 return node;
5925}
5926
5929 List *joinclauses,
5931 List *nestParams,
5932 Plan *lefttree,
5933 Plan *righttree,
5935 bool inner_unique)
5936{
5939
5940 plan->targetlist = tlist;
5942 plan->lefttree = lefttree;
5948
5949 return node;
5950}
5951
5954 List *joinclauses,
5956 List *hashclauses,
5957 List *hashoperators,
5958 List *hashcollations,
5959 List *hashkeys,
5960 Plan *lefttree,
5961 Plan *righttree,
5963 bool inner_unique)
5964{
5967
5968 plan->targetlist = tlist;
5970 plan->lefttree = lefttree;
5979
5980 return node;
5981}
5982
5983static Hash *
5985 List *hashkeys,
5986 Oid skewTable,
5988 bool skewInherit)
5989{
5992
5995 plan->lefttree = lefttree;
5997
6002
6003 return node;
6004}
6005
6008 List *joinclauses,
6010 List *mergeclauses,
6015 Plan *lefttree,
6016 Plan *righttree,
6018 bool inner_unique,
6019 bool skip_mark_restore)
6020{
6023
6024 plan->targetlist = tlist;
6026 plan->lefttree = lefttree;
6037
6038 return node;
6039}
6040
6041
6042
6043
6044
6045
6046
6047static Sort *
6051{
6054
6056
6061 plan->lefttree = lefttree;
6063 node->numCols = numCols;
6064 node->sortColIdx = sortColIdx;
6065 node->sortOperators = sortOperators;
6066 node->collations = collations;
6068
6069 return node;
6070}
6071
6072
6073
6074
6075
6076
6077
6082{
6085
6087
6091 plan->lefttree = lefttree;
6095 node->sort.sortColIdx = sortColIdx;
6096 node->sort.sortOperators = sortOperators;
6097 node->sort.collations = collations;
6099
6100 return node;
6101}
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144static Plan *
6154{
6159 Oid *sortOperators;
6160 Oid *collations;
6162
6163
6164
6165
6171
6173
6174 foreach(i, pathkeys)
6175 {
6181 Oid sortop;
6183
6185 {
6186
6187
6188
6189
6190
6191 if (ec->ec_sortref == 0)
6192 elog(ERROR, "volatile EquivalenceClass has no sortref");
6197 }
6199 {
6200
6201
6202
6203
6204
6205
6206
6207
6208
6210 if (tle)
6211 {
6213 if (em)
6214 {
6215
6217 }
6218 else
6220 }
6221 }
6222 else
6223 {
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237 foreach(j, tlist)
6238 {
6241 if (em)
6242 {
6243
6245 break;
6246 }
6248 }
6249 }
6250
6251 if ()
6252 {
6253
6254
6255
6257 if ()
6258 elog(ERROR, "could not find pathkey item to sort");
6260
6261
6262
6263
6266 {
6267
6271 }
6272
6273
6275
6276
6277
6278
6282 true);
6284 lefttree->targetlist = tlist;
6285 }
6286
6287
6288
6289
6290
6295 if ((sortop))
6296 elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
6299
6300
6306 }
6307
6308
6314
6315 return lefttree;
6316}
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326static Sort *
6328{
6331 Oid *sortOperators;
6332 Oid *collations;
6334
6335
6337 relids,
6339 false,
6341 &sortColIdx,
6342 &sortOperators,
6343 &collations,
6345
6346
6348 sortColIdx, sortOperators,
6350}
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6363 Relids relids, int nPresortedCols)
6364{
6367 Oid *sortOperators;
6368 Oid *collations;
6370
6371
6373 relids,
6375 false,
6377 &sortColIdx,
6378 &sortOperators,
6379 &collations,
6381
6382
6384 sortColIdx, sortOperators,
6386}
6387
6388
6389
6390
6391
6392
6393
6394
6397{
6402 Oid *sortOperators;
6403 Oid *collations;
6405
6406
6412
6415 {
6418
6424 }
6425
6427 sortColIdx, sortOperators,
6429}
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444static Sort *
6447 Plan *lefttree)
6448{
6453 Oid *sortOperators;
6454 Oid *collations;
6456
6457
6463
6466 {
6469
6470 if ()
6471 elog(ERROR, "could not retrieve tle for sort-from-groupcols");
6472
6478 }
6479
6481 sortColIdx, sortOperators,
6483}
6484
6487{
6490
6493 plan->lefttree = lefttree;
6495
6496 return node;
6497}
6498
6499
6500
6501
6502
6503
6504
6505
6506
6509{
6514
6516
6517
6518
6519
6520
6521
6522
6525
6526
6531
6532
6545 matplan->parallel_aware = false;
6547
6549}
6550
6553 List *param_exprs, bool singlerow, bool binary_mode,
6556 double est_hit_ratio)
6557{
6560
6563 plan->lefttree = lefttree;
6565
6567 node->hashOperators = hashoperators;
6568 node->collations = collations;
6577
6578 return node;
6579}
6580
6586 Size transitionSpace, Plan *lefttree)
6587{
6590
6601 node->chain = chain;
6602
6603 plan->qual = qual;
6604 plan->targetlist = tlist;
6605 plan->lefttree = lefttree;
6607
6608 return node;
6609}
6610
6615 List *runCondition, List *qual, bool topWindow, Plan *lefttree)
6616{
6619
6620 node->winname = wc->name;
6634
6642
6643 plan->targetlist = tlist;
6644 plan->lefttree = lefttree;
6647
6648 return node;
6649}
6650
6658 Plan *lefttree)
6659{
6662
6667
6668 plan->qual = qual;
6669 plan->targetlist = tlist;
6670 plan->lefttree = lefttree;
6672
6673 return node;
6674}
6675
6676
6677
6678
6679
6680
6681
6685{
6688 int keyno = 0;
6693
6696 plan->lefttree = lefttree;
6698
6699
6700
6701
6702
6703
6708
6709 foreach(lc, pathkeys)
6710 {
6716 Oid eqop;
6718
6719
6720 if (keyno >= numCols)
6721 break;
6722
6724 {
6725
6726
6727
6728
6729
6730 if (ec->ec_sortref == 0)
6731 elog(ERROR, "volatile EquivalenceClass has no sortref");
6736 }
6737 else
6738 {
6739
6740
6741
6742
6743
6744 foreach(j, plan->targetlist)
6745 {
6748 if (em)
6749 {
6750
6752 break;
6753 }
6755 }
6756 }
6757
6758 if ()
6759 elog(ERROR, "could not find pathkey item to sort");
6760
6761
6762
6763
6764
6769 if ((eqop))
6770 elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
6773
6777
6778 keyno++;
6779 }
6780
6781 node->numCols = numCols;
6785
6786 return node;
6787}
6788
6792 int nworkers,
6793 int rescan_param,
6794 bool single_copy,
6795 Plan *subplan)
6796{
6799
6802 plan->lefttree = subplan;
6809
6810 return node;
6811}
6812
6813
6814
6815
6816
6817
6820 List *tlist, Plan *lefttree, Plan *righttree,
6822{
6826 int keyno = 0;
6832
6833 plan->targetlist = tlist;
6835 plan->lefttree = lefttree;
6837
6838
6839
6840
6841
6846
6847 foreach(slitem, groupList)
6848 {
6851
6855 else
6860 keyno++;
6861 }
6862
6863 node->cmd = cmd;
6865 node->numCols = numCols;
6871
6872 return node;
6873}
6874
6875
6876
6877
6878
6881{
6884
6887 plan->lefttree = lefttree;
6889
6892
6893 return node;
6894}
6895
6896
6897
6898
6899
6904{
6907
6910 plan->lefttree = lefttree;
6912
6920
6921 return node;
6922}
6923
6924
6925
6926
6927
6928
6931 Node *resconstantqual,
6932 Plan *subplan)
6933{
6936
6938
6939 plan->targetlist = tlist;
6941 plan->lefttree = subplan;
6946
6947 return node;
6948}
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6962 Node *resconstantqual,
6964{
6967
6976
6977 return node;
6978}
6979
6980
6981
6982
6983
6986 Plan *subplan)
6987{
6990
6993 plan->lefttree = subplan;
6995
6996 return node;
6997}
6998
6999
7000
7001
7002
7005 CmdType operation, bool canSetTag,
7006 Index nominalRelation, Index rootRelation,
7007 List *resultRelations,
7008 List *updateColnosLists,
7009 List *withCheckOptionLists, List *returningLists,
7011 List *mergeActionLists, List *mergeJoinConditions,
7012 int epqParam)
7013{
7022 int i;
7023
7027 updateColnosLists == NIL));
7028 Assert(withCheckOptionLists == NIL ||
7032
7036
7038
7044 if (!onconflict)
7045 {
7054 }
7055 else
7056 {
7058
7059
7061
7062
7063
7064
7065
7066
7067
7072
7073
7074
7075
7076
7077
7078
7080
7083 }
7093
7094
7095
7096
7097
7100 i = 0;
7101 foreach(lc, resultRelations)
7102 {
7105 List *fdw_private;
7107
7108
7109
7110
7111
7112
7113
7114
7116 root->simple_rel_array[rti] != NULL)
7117 {
7118 RelOptInfo *resultRel = root->simple_rel_array[rti];
7119
7120 fdwroutine = resultRel->fdwroutine;
7121 }
7122 else
7123 {
7125
7128 {
7129
7131 {
7132
7136 errmsg("access to non-system foreign table is restricted")));
7137 }
7138
7140 }
7141 else
7142 fdwroutine = NULL;
7143 }
7144
7145
7146
7147
7148
7149
7150
7151
7152 if (operation == CMD_MERGE && fdwroutine != NULL)
7153 {
7155
7158 errmsg("cannot execute MERGE on relation \"%s\"",
7161 }
7162
7163
7164
7165
7166
7167
7168
7169
7170
7172 if (fdwroutine != NULL &&
7177 withCheckOptionLists == NIL &&
7180 {
7181
7182
7183
7184
7186 {
7189 root->parse->returningList);
7191 }
7193 {
7195 {
7197 nominalRelation,
7198 operation);
7200 }
7203 rti, i);
7204 }
7205 }
7208
7210 fdwroutine != NULL &&
7213 else
7214 fdw_private = NIL;
7216 i++;
7217 }
7220
7221 return node;
7222}
7223
7224
7225
7226
7227
7228bool
7230{
7231
7233 {
7246 return false;
7249 return true;
7250 return false;
7252
7253
7254
7255
7256
7257
7260
7261
7262
7263
7264
7265
7266
7267 return false;
7268 default:
7269 break;
7270 }
7271 return true;
7272}
7273
7274
7275
7276
7277
7278bool
7280{
7281
7283 {
7296 return false;
7299 return true;
7300 return false;
7302
7303
7304
7305
7306
7307
7308
7309 return false;
7310 default:
7311 break;
7312 }
7313 return true;
7314}
Datum sort(PG_FUNCTION_ARGS)
#define InvalidAttrNumber
Bitmapset * bms_difference(const Bitmapset *a, const Bitmapset *b)
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
void bms_free(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_nonempty_difference(const Bitmapset *a, const Bitmapset *b)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
#define OidIsValid(objectId)
bool contain_mutable_functions(Node *clause)
bool is_parallel_safe(PlannerInfo *root, Node *node)
Bitmapset * pull_paramids(Expr *expr)
void CommuteOpExpr(OpExpr *clause)
void cost_material(Path *path, bool enabled, int input_disabled_nodes, Cost input_startup_cost, Cost input_total_cost, double tuples, int width)
void cost_sort(Path *path, PlannerInfo *root, List *pathkeys, int input_disabled_nodes, Cost input_cost, double tuples, int width, Cost comparison_cost, int sort_mem, double limit_tuples)
void cost_qual_eval_node(QualCost *cost, Node *qual, PlannerInfo *root)
void cost_incremental_sort(Path *path, PlannerInfo *root, List *pathkeys, int presorted_keys, int input_disabled_nodes, Cost input_startup_cost, Cost input_total_cost, double input_tuples, int width, Cost comparison_cost, int sort_mem, double limit_tuples)
double clamp_row_est(double nrows)
bool enable_partition_pruning
bool enable_incremental_sort
static Plan * create_join_plan(PlannerInfo *root, JoinPath *best_path)
static bool use_physical_tlist(PlannerInfo *root, Path *path, int flags)
static ModifyTable * make_modifytable(PlannerInfo *root, Plan *subplan, CmdType operation, bool canSetTag, Index nominalRelation, Index rootRelation, List *resultRelations, List *updateColnosLists, List *withCheckOptionLists, List *returningLists, List *rowMarks, OnConflictExpr *onconflict, List *mergeActionLists, List *mergeJoinConditions, int epqParam)
static SeqScan * create_seqscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static WorkTableScan * make_worktablescan(List *qptlist, List *qpqual, Index scanrelid, int wtParam)
static Plan * create_merge_append_plan(PlannerInfo *root, MergeAppendPath *best_path, int flags)
static List * order_qual_clauses(PlannerInfo *root, List *clauses)
static MergeJoin * make_mergejoin(List *tlist, List *joinclauses, List *otherclauses, List *mergeclauses, Oid *mergefamilies, Oid *mergecollations, bool *mergereversals, bool *mergenullsfirst, Plan *lefttree, Plan *righttree, JoinType jointype, bool inner_unique, bool skip_mark_restore)
static GatherMerge * create_gather_merge_plan(PlannerInfo *root, GatherMergePath *best_path)
static ValuesScan * create_valuesscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static void copy_generic_path_info(Plan *dest, Path *src)
static WindowAgg * make_windowagg(List *tlist, WindowClause *wc, int partNumCols, AttrNumber *partColIdx, Oid *partOperators, Oid *partCollations, int ordNumCols, AttrNumber *ordColIdx, Oid *ordOperators, Oid *ordCollations, List *runCondition, List *qual, bool topWindow, Plan *lefttree)
Sort * make_sort_from_sortclauses(List *sortcls, Plan *lefttree)
static BitmapOr * make_bitmap_or(List *bitmapplans)
static HashJoin * create_hashjoin_plan(PlannerInfo *root, HashPath *best_path)
static SeqScan * make_seqscan(List *qptlist, List *qpqual, Index scanrelid)
static TableFuncScan * create_tablefuncscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static CustomScan * create_customscan_plan(PlannerInfo *root, CustomPath *best_path, List *tlist, List *scan_clauses)
static Node * fix_indexqual_operand(Node *node, IndexOptInfo *index, int indexcol)
static void fix_indexqual_references(PlannerInfo *root, IndexPath *index_path, List **stripped_indexquals_p, List **fixed_indexquals_p)
static List * fix_indexorderby_references(PlannerInfo *root, IndexPath *index_path)
static AttrNumber * remap_groupColIdx(PlannerInfo *root, List *groupClause)
static Plan * create_append_plan(PlannerInfo *root, AppendPath *best_path, int flags)
static void bitmap_subplan_mark_shared(Plan *plan)
static Unique * create_unique_plan(PlannerInfo *root, UniquePath *best_path, int flags)
static Result * make_one_row_result(List *tlist, Node *resconstantqual, RelOptInfo *rel)
static TidScan * make_tidscan(List *qptlist, List *qpqual, Index scanrelid, List *tidquals)
static MergeJoin * create_mergejoin_plan(PlannerInfo *root, MergePath *best_path)
static Plan * create_plan_recurse(PlannerInfo *root, Path *best_path, int flags)
static void label_sort_with_costsize(PlannerInfo *root, Sort *plan, double limit_tuples)
static ForeignScan * create_foreignscan_plan(PlannerInfo *root, ForeignPath *best_path, List *tlist, List *scan_clauses)
static BitmapHeapScan * create_bitmap_scan_plan(PlannerInfo *root, BitmapHeapPath *best_path, List *tlist, List *scan_clauses)
static IncrementalSort * make_incrementalsort(Plan *lefttree, int numCols, int nPresortedCols, AttrNumber *sortColIdx, Oid *sortOperators, Oid *collations, bool *nullsFirst)
static Result * create_group_result_plan(PlannerInfo *root, GroupResultPath *best_path)
static Limit * create_limit_plan(PlannerInfo *root, LimitPath *best_path, int flags)
static Unique * make_unique_from_pathkeys(Plan *lefttree, List *pathkeys, int numCols, Relids relids)
static Agg * create_agg_plan(PlannerInfo *root, AggPath *best_path)
bool is_projection_capable_path(Path *path)
static CteScan * make_ctescan(List *qptlist, List *qpqual, Index scanrelid, int ctePlanId, int cteParam)
static TidScan * create_tidscan_plan(PlannerInfo *root, TidPath *best_path, List *tlist, List *scan_clauses)
static TidRangeScan * make_tidrangescan(List *qptlist, List *qpqual, Index scanrelid, List *tidrangequals)
static Plan * create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual, List **qual, List **indexqual, List **indexECs)
static RecursiveUnion * make_recursive_union(List *tlist, Plan *lefttree, Plan *righttree, int wtParam, List *distinctList, Cardinality numGroups)
static Node * fix_indexqual_clause(PlannerInfo *root, IndexOptInfo *index, int indexcol, Node *clause, List *indexcolnos)
static WorkTableScan * create_worktablescan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static Plan * create_gating_plan(PlannerInfo *root, Path *path, Plan *plan, List *gating_quals)
static Memoize * make_memoize(Plan *lefttree, Oid *hashoperators, Oid *collations, List *param_exprs, bool singlerow, bool binary_mode, uint32 est_entries, Bitmapset *keyparamids, Cardinality est_calls, Cardinality est_unique_keys, double est_hit_ratio)
static FunctionScan * create_functionscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static Result * create_resultscan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static BitmapHeapScan * make_bitmap_heapscan(List *qptlist, List *qpqual, Plan *lefttree, List *bitmapqualorig, Index scanrelid)
static Node * replace_nestloop_params_mutator(Node *node, PlannerInfo *root)
static SetOp * create_setop_plan(PlannerInfo *root, SetOpPath *best_path, int flags)
bool is_projection_capable_plan(Plan *plan)
static CteScan * create_ctescan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static Sort * create_sort_plan(PlannerInfo *root, SortPath *best_path, int flags)
static ProjectSet * make_project_set(List *tlist, Plan *subplan)
static Sort * make_sort_from_pathkeys(Plan *lefttree, List *pathkeys, Relids relids)
static HashJoin * make_hashjoin(List *tlist, List *joinclauses, List *otherclauses, List *hashclauses, List *hashoperators, List *hashcollations, List *hashkeys, Plan *lefttree, Plan *righttree, JoinType jointype, bool inner_unique)
static Gather * make_gather(List *qptlist, List *qpqual, int nworkers, int rescan_param, bool single_copy, Plan *subplan)
static Gather * create_gather_plan(PlannerInfo *root, GatherPath *best_path)
static Sort * make_sort(Plan *lefttree, int numCols, AttrNumber *sortColIdx, Oid *sortOperators, Oid *collations, bool *nullsFirst)
Limit * make_limit(Plan *lefttree, Node *limitOffset, Node *limitCount, LimitOption limitOption, int uniqNumCols, AttrNumber *uniqColIdx, Oid *uniqOperators, Oid *uniqCollations)
static ProjectSet * create_project_set_plan(PlannerInfo *root, ProjectSetPath *best_path)
static void label_incrementalsort_with_costsize(PlannerInfo *root, IncrementalSort *plan, List *pathkeys, double limit_tuples)
static SetOp * make_setop(SetOpCmd cmd, SetOpStrategy strategy, List *tlist, Plan *lefttree, Plan *righttree, List *groupList, Cardinality numGroups)
ForeignScan * make_foreignscan(List *qptlist, List *qpqual, Index scanrelid, List *fdw_exprs, List *fdw_private, List *fdw_scan_tlist, List *fdw_recheck_quals, Plan *outer_plan)
static Group * create_group_plan(PlannerInfo *root, GroupPath *best_path)
static ModifyTable * create_modifytable_plan(PlannerInfo *root, ModifyTablePath *best_path)
static Result * create_minmaxagg_plan(PlannerInfo *root, MinMaxAggPath *best_path)
static LockRows * create_lockrows_plan(PlannerInfo *root, LockRowsPath *best_path, int flags)
static Material * create_material_plan(PlannerInfo *root, MaterialPath *best_path, int flags)
static List * get_gating_quals(PlannerInfo *root, List *quals)
static Plan * create_scan_plan(PlannerInfo *root, Path *best_path, int flags)
static Group * make_group(List *tlist, List *qual, int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators, Oid *grpCollations, Plan *lefttree)
static LockRows * make_lockrows(Plan *lefttree, List *rowMarks, int epqParam)
static IncrementalSort * create_incrementalsort_plan(PlannerInfo *root, IncrementalSortPath *best_path, int flags)
static NamedTuplestoreScan * create_namedtuplestorescan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
static Plan * create_projection_plan(PlannerInfo *root, ProjectionPath *best_path, int flags)
static IndexOnlyScan * make_indexonlyscan(List *qptlist, List *qpqual, Index scanrelid, Oid indexid, List *indexqual, List *recheckqual, List *indexorderby, List *indextlist, ScanDirection indexscandir)
static List * build_path_tlist(PlannerInfo *root, Path *path)
static IndexScan * make_indexscan(List *qptlist, List *qpqual, Index scanrelid, Oid indexid, List *indexqual, List *indexqualorig, List *indexorderby, List *indexorderbyorig, List *indexorderbyops, ScanDirection indexscandir)
static FunctionScan * make_functionscan(List *qptlist, List *qpqual, Index scanrelid, List *functions, bool funcordinality)
static TableFuncScan * make_tablefuncscan(List *qptlist, List *qpqual, Index scanrelid, TableFunc *tablefunc)
static SubqueryScan * create_subqueryscan_plan(PlannerInfo *root, SubqueryScanPath *best_path, List *tlist, List *scan_clauses)
static Plan * inject_projection_plan(Plan *subplan, List *tlist, bool parallel_safe)
static TidRangeScan * create_tidrangescan_plan(PlannerInfo *root, TidRangePath *best_path, List *tlist, List *scan_clauses)
static List * get_switched_clauses(List *clauses, Relids outerrelids)
static void copy_plan_costsize(Plan *dest, Plan *src)
static ValuesScan * make_valuesscan(List *qptlist, List *qpqual, Index scanrelid, List *values_lists)
Plan * materialize_finished_plan(Plan *subplan)
static SampleScan * make_samplescan(List *qptlist, List *qpqual, Index scanrelid, TableSampleClause *tsc)
static NestLoop * create_nestloop_plan(PlannerInfo *root, NestPath *best_path)
static Memoize * create_memoize_plan(PlannerInfo *root, MemoizePath *best_path, int flags)
static Result * make_gating_result(List *tlist, Node *resconstantqual, Plan *subplan)
Agg * make_agg(List *tlist, List *qual, AggStrategy aggstrategy, AggSplit aggsplit, int numGroupCols, AttrNumber *grpColIdx, Oid *grpOperators, Oid *grpCollations, List *groupingSets, List *chain, Cardinality numGroups, Size transitionSpace, Plan *lefttree)
static NamedTuplestoreScan * make_namedtuplestorescan(List *qptlist, List *qpqual, Index scanrelid, char *enrname)
static bool mark_async_capable_plan(Plan *plan, Path *path)
static Material * make_material(Plan *lefttree)
Plan * change_plan_targetlist(Plan *subplan, List *tlist, bool tlist_parallel_safe)
static NestLoop * make_nestloop(List *tlist, List *joinclauses, List *otherclauses, List *nestParams, Plan *lefttree, Plan *righttree, JoinType jointype, bool inner_unique)
static BitmapIndexScan * make_bitmap_indexscan(Index scanrelid, Oid indexid, List *indexqual, List *indexqualorig)
static SubqueryScan * make_subqueryscan(List *qptlist, List *qpqual, Index scanrelid, Plan *subplan)
static Hash * make_hash(Plan *lefttree, List *hashkeys, Oid skewTable, AttrNumber skewColumn, bool skewInherit)
static WindowAgg * create_windowagg_plan(PlannerInfo *root, WindowAggPath *best_path)
static Node * replace_nestloop_params(PlannerInfo *root, Node *expr)
static BitmapAnd * make_bitmap_and(List *bitmapplans)
static Plan * create_groupingsets_plan(PlannerInfo *root, GroupingSetsPath *best_path)
static RecursiveUnion * create_recursiveunion_plan(PlannerInfo *root, RecursiveUnionPath *best_path)
static Sort * make_sort_from_groupcols(List *groupcls, AttrNumber *grpColIdx, Plan *lefttree)
static Scan * create_indexscan_plan(PlannerInfo *root, IndexPath *best_path, List *tlist, List *scan_clauses, bool indexonly)
static Plan * prepare_sort_from_pathkeys(Plan *lefttree, List *pathkeys, Relids relids, const AttrNumber *reqColIdx, bool adjust_tlist_in_place, int *p_numsortkeys, AttrNumber **p_sortColIdx, Oid **p_sortOperators, Oid **p_collations, bool **p_nullsFirst)
static IncrementalSort * make_incrementalsort_from_pathkeys(Plan *lefttree, List *pathkeys, Relids relids, int nPresortedCols)
static SampleScan * create_samplescan_plan(PlannerInfo *root, Path *best_path, List *tlist, List *scan_clauses)
Plan * create_plan(PlannerInfo *root, Path *best_path)
int errcode(int sqlerrcode)
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
bool is_redundant_with_indexclauses(RestrictInfo *rinfo, List *indexclauses)
EquivalenceMember * find_ec_member_matching_expr(EquivalenceClass *ec, Expr *expr, Relids relids)
EquivalenceMember * find_computable_ec_member(PlannerInfo *root, EquivalenceClass *ec, List *exprs, Relids relids, bool require_parallel_safe)
bool is_redundant_derived_clause(RestrictInfo *rinfo, List *clauselist)
#define CUSTOMPATH_SUPPORT_PROJECTION
#define palloc_array(type, count)
#define palloc0_array(type, count)
FdwRoutine * GetFdwRoutineByRelId(Oid relid)
Node * strip_phvs_in_index_operand(Node *operand)
List * list_difference(const List *list1, const List *list2)
List * lappend(List *list, void *datum)
List * list_difference_ptr(const List *list1, const List *list2)
List * list_concat(List *list1, const List *list2)
List * list_concat_copy(const List *list1, const List *list2)
List * list_copy(const List *oldlist)
List * lappend_oid(List *list, Oid datum)
bool list_member_ptr(const List *list, const void *datum)
bool list_member(const List *list, const void *datum)
List * list_copy_head(const List *oldlist, int len)
List * list_concat_unique(List *list1, const List *list2)
char * get_rel_name(Oid relid)
Oid get_opfamily_member_for_cmptype(Oid opfamily, Oid lefttype, Oid righttype, CompareType cmptype)
Datum lca(PG_FUNCTION_ARGS)
Datum subpath(PG_FUNCTION_ARGS)
Expr * make_orclause(List *orclauses)
Expr * make_ands_explicit(List *andclauses)
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
Node * makeBoolConst(bool value, bool isnull)
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
void * palloc0(Size size)
Oid exprType(const Node *expr)
Oid exprCollation(const Node *expr)
#define expression_tree_mutator(n, m, c)
static bool is_opclause(const void *clause)
#define IsA(nodeptr, _type_)
#define IS_OUTER_JOIN(jointype)
#define castNode(_type_, nodeptr)
void process_subquery_nestloop_params(PlannerInfo *root, List *subplan_params)
List * identify_current_nestloop_params(PlannerInfo *root, Relids leftrelids, Relids outerrelids)
Param * replace_nestloop_param_placeholdervar(PlannerInfo *root, PlaceHolderVar *phv)
int assign_special_exec_param(PlannerInfo *root)
Param * replace_nestloop_param_var(PlannerInfo *root, Var *var)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
int make_partition_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel, List *subpaths, List *prunequal)
bool pathkeys_count_contained_in(List *keys1, List *keys2, int *n_common)
bool pathkeys_contained_in(List *keys1, List *keys2)
Path * reparameterize_path_by_child(PlannerInfo *root, Path *path, RelOptInfo *child_rel)
#define IS_DUMMY_APPEND(p)
#define PATH_REQ_OUTER(path)
#define planner_rt_fetch(rti, root)
#define IS_OTHER_REL(rel)
#define IS_UPPER_REL(rel)
int errdetail_relkind_not_supported(char relkind)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
#define for_each_from(cell, lst, N)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
static int list_nth_int(const List *list, int n)
PlaceHolderInfo * find_placeholder_info(PlannerInfo *root, PlaceHolderVar *phv)
bool has_stored_generated_columns(PlannerInfo *root, Index rti)
bool has_row_triggers(PlannerInfo *root, Index rti, CmdType event)
List * build_physical_tlist(PlannerInfo *root, RelOptInfo *rel)
bool has_transition_tables(PlannerInfo *root, Index rti, CmdType event)
List * infer_arbiter_indexes(PlannerInfo *root)
int restrict_nonsystem_relation_kind
bool predicate_implied_by(List *predicate_list, List *clause_list, bool weak)
List * extract_update_targetlist_colnos(List *tlist)
#define IS_SPECIAL_VARNO(varno)
static const struct fns functions
List * extract_actual_clauses(List *restrictinfo_list, bool pseudoconstant)
void extract_actual_join_clauses(List *restrictinfo_list, Relids joinrelids, List **joinquals, List **otherquals)
List * get_actual_clauses(List *restrictinfo_list)
bool trivial_subqueryscan(SubqueryScan *plan)
void check_stack_depth(void)
Bitmapset * custom_relids
const struct CustomScanMethods * methods
BeginDirectModify_function BeginDirectModify
PlanForeignModify_function PlanForeignModify
PlanDirectModify_function PlanDirectModify
IterateDirectModify_function IterateDirectModify
EndDirectModify_function EndDirectModify
IsForeignPathAsyncCapable_function IsForeignPathAsyncCapable
Bitmapset * fs_base_relids
ScanDirection indexorderdir
ScanDirection indexorderdir
Cardinality est_unique_keys
List * child_append_relid_sets
List * mergeJoinConditions
Bitmapset * fdwDirectModifyPlans
List * withCheckOptionLists
LockClauseStrength onConflictLockStrength
OnConflictAction onConflictAction
LockClauseStrength lockStrength
struct PathTarget * reltarget
struct TableSampleClause * tablesample
SubqueryScanStatus scanstatus
void SS_attach_initplans(PlannerInfo *root, Plan *plan)
void SS_compute_initplan_cost(List *init_plans, Cost *initplan_cost_p, bool *unsafe_initplans_p)
void SS_make_initplan_from_plan(PlannerInfo *root, PlannerInfo *subroot, Plan *plan, Param *prm)
#define FirstLowInvalidHeapAttributeNumber
#define RESTRICT_RELKIND_FOREIGN_TABLE
Oid * extract_grouping_ops(List *groupClause)
TargetEntry * tlist_member(Expr *node, List *targetlist)
bool tlist_same_exprs(List *tlist1, List *tlist2)
void apply_tlist_labeling(List *dest_tlist, List *src_tlist)
void apply_pathtarget_labeling_to_tlist(List *tlist, PathTarget *target)
AttrNumber * extract_grouping_cols(List *groupClause, List *tlist)
TargetEntry * get_sortgroupclause_tle(SortGroupClause *sgClause, List *targetList)
TargetEntry * get_sortgroupref_tle(Index sortref, List *targetList)
Oid * extract_grouping_collations(List *groupClause, List *tlist)
#define FirstNormalObjectId
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)
bool contain_vars_returning_old_or_new(Node *node)