forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2489d76
committed
Make Vars be outer-join-aware.
Traditionally we used the same Var struct to represent the valueof a table column everywhere in parse and plan trees. This choicepredates our support for SQL outer joins, and it's really a prettybad idea with outer joins, because the Var's value can depend onwhere it is in the tree: it might go to NULL above an outer join.So expression nodes that are equal() per equalfuncs.c might notrepresent the same value, which is a huge correctness hazard forthe planner.To improve this, decorate Var nodes with a bitmapset showingwhich outer joins (identified by RTE indexes) may have nulledthem at the point in the parse tree where the Var appears.This allows us to trust that equal() Vars represent the same value.A certain amount of klugery is still needed to cope with caseswhere we re-order two outer joins, but it's possible to make itwork without sacrificing that core principle. PlaceHolderVarsreceive similar decoration for the same reason.In the planner, we include these outer join bitmapsets into the relidsthat an expression is considered to depend on, and in consequence alsoadd outer-join relids to the relids of join RelOptInfos. This allowsus to correctly perceive whether an expression can be calculated aboveor below a particular outer join.This change affects FDWs that want to plan foreign joins. They *must*follow suit when labeling foreign joins in order to match with thecore planner, but for many purposes (if postgres_fdw is any guide)they'd prefer to consider only base relations within the join.To support both requirements, redefine ForeignScan.fs_relids asbase+OJ relids, and add a new field fs_base_relids that's set up bythe core planner.Large though it is, this commit just does the minimum necessary toinstall the new mechanisms and get check-world passing again.Follow-up patches will perform some cleanup. (The README additionsand comments mention some stuff that will appear in the follow-up.)Patch by me; thanks to Richard Guo for review.Discussion:https://postgr.es/m/830269.1656693747@sss.pgh.pa.us1 parentec7e053 commit2489d76
File tree
60 files changed
+3878
-966
lines changed- contrib/postgres_fdw
- doc/src/sgml
- src
- backend
- commands
- executor
- nodes
- optimizer
- geqo
- path
- plan
- prep
- util
- parser
- rewrite
- utils/adt
- include
- catalog
- nodes
- optimizer
- parser
- rewrite
- test/regress
- expected
- sql
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
60 files changed
+3878
-966
lines changedLines changed: 11 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4026 | 4026 |
| |
4027 | 4027 |
| |
4028 | 4028 |
| |
4029 |
| - | |
| 4029 | + | |
| 4030 | + | |
| 4031 | + | |
| 4032 | + | |
| 4033 | + | |
| 4034 | + | |
| 4035 | + | |
| 4036 | + | |
| 4037 | + | |
| 4038 | + | |
| 4039 | + | |
4030 | 4040 |
| |
4031 | 4041 |
| |
4032 | 4042 |
| |
|
Lines changed: 6 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1517 | 1517 |
| |
1518 | 1518 |
| |
1519 | 1519 |
| |
1520 |
| - | |
| 1520 | + | |
1521 | 1521 |
| |
1522 | 1522 |
| |
1523 | 1523 |
| |
| |||
2414 | 2414 |
| |
2415 | 2415 |
| |
2416 | 2416 |
| |
2417 |
| - | |
| 2417 | + | |
2418 | 2418 |
| |
2419 | 2419 |
| |
2420 | 2420 |
| |
| |||
2838 | 2838 |
| |
2839 | 2839 |
| |
2840 | 2840 |
| |
2841 |
| - | |
2842 |
| - | |
| 2841 | + | |
| 2842 | + | |
2843 | 2843 |
| |
2844 | 2844 |
| |
2845 | 2845 |
| |
| |||
2856 | 2856 |
| |
2857 | 2857 |
| |
2858 | 2858 |
| |
2859 |
| - | |
| 2859 | + | |
2860 | 2860 |
| |
2861 | 2861 |
| |
2862 | 2862 |
| |
| |||
2871 | 2871 |
| |
2872 | 2872 |
| |
2873 | 2873 |
| |
2874 |
| - | |
| 2874 | + | |
2875 | 2875 |
| |
2876 | 2876 |
| |
2877 | 2877 |
| |
|
Lines changed: 11 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
351 | 351 |
| |
352 | 352 |
| |
353 | 353 |
| |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
354 | 365 |
| |
355 | 366 |
| |
356 | 367 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1114 | 1114 |
| |
1115 | 1115 |
| |
1116 | 1116 |
| |
1117 |
| - | |
| 1117 | + | |
1118 | 1118 |
| |
1119 | 1119 |
| |
1120 | 1120 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
325 | 325 |
| |
326 | 326 |
| |
327 | 327 |
| |
328 |
| - | |
| 328 | + | |
329 | 329 |
| |
330 | 330 |
| |
331 | 331 |
| |
|
Lines changed: 6 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
80 | 80 |
| |
81 | 81 |
| |
82 | 82 |
| |
83 |
| - | |
84 |
| - | |
85 |
| - | |
86 |
| - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
87 | 88 |
| |
| 89 | + | |
88 | 90 |
| |
89 | 91 |
| |
90 | 92 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2641 | 2641 |
| |
2642 | 2642 |
| |
2643 | 2643 |
| |
| 2644 | + | |
2644 | 2645 |
| |
2645 | 2646 |
| |
2646 | 2647 |
| |
| |||
3234 | 3235 |
| |
3235 | 3236 |
| |
3236 | 3237 |
| |
3237 |
| - | |
| 3238 | + | |
3238 | 3239 |
| |
3239 | 3240 |
| |
3240 | 3241 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
383 | 383 |
| |
384 | 384 |
| |
385 | 385 |
| |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
386 | 391 |
| |
387 | 392 |
| |
388 | 393 |
| |
|
0 commit comments
Comments
(0)