forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb7e2121
committed
Postpone reparameterization of paths until create_plan().
When considering nestloop paths for individual partitions withina partitionwise join, if the inner path is parameterized, it isparameterized by the topmost parent of the outer rel, not thecorresponding outer rel itself. Therefore, we need to translate theparameterization so that the inner path is parameterized by thecorresponding outer rel.Up to now, we did this while generating join paths. However, that'sproblematic because we must also translate some expressions that areshared across all paths for a relation, such as restriction clauses(kept in the RelOptInfo and/or IndexOptInfo) and TableSampleClauses(kept in the RangeTblEntry). The existing code fails to translatethese at all, leading to wrong answers, odd failures such as"variable not found in subplan target list", or executor crashes.But we can't modify them during path generation, because that wouldbreak things if we end up choosing some non-partitioned-join path.So this patch postpones reparameterization of the inner path untilcreateplan.c, where it is safe to modify the referenced RangeTblEntry,RelOptInfo or IndexOptInfo, because we have made a final choice of whichPath to use. We do still have to check during path generation thatthe reparameterization will be possible. So we introduce a newfunction path_is_reparameterizable_by_child() to detect that.The duplication between path_is_reparameterizable_by_child() andreparameterize_path_by_child() is a bit annoying, but there seemsno other good answer. A small benefit is that we can avoid buildinguseless reparameterized trees in cases where a non-partitioned joinis ultimately chosen. Also, reparameterize_path_by_child() can nowbe allowed to scribble on the input paths, saving a few cycles.This fix repairs the same problems previously addressed in theback branches by commits62f1202 et al.Richard Guo, reviewed at various times by Ashutosh Bapat, AndreiLepikhov, Alena Rybakina, Robert Haas, and myselfDiscussion:https://postgr.es/m/CAMbWs496+N=UAjOc=rcD3P7B6oJe4rZw08e_TZRUsWbPxZW3Tw@mail.gmail.com1 parent605721f commitb7e2121
File tree
6 files changed
+485
-101
lines changed- src
- backend/optimizer
- path
- plan
- util
- include/optimizer
- test/regress
- expected
- sql
6 files changed
+485
-101
lines changedLines changed: 28 additions & 39 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
33 |
| - | |
34 |
| - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
35 | 36 |
| |
36 | 37 |
| |
37 | 38 |
| |
| |||
784 | 785 |
| |
785 | 786 |
| |
786 | 787 |
| |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
787 | 802 |
| |
788 | 803 |
| |
789 | 804 |
| |
| |||
800 | 815 |
| |
801 | 816 |
| |
802 | 817 |
| |
803 |
| - | |
804 |
| - | |
805 |
| - | |
806 |
| - | |
807 |
| - | |
808 |
| - | |
809 |
| - | |
810 |
| - | |
811 |
| - | |
812 |
| - | |
813 |
| - | |
814 |
| - | |
815 |
| - | |
816 |
| - | |
817 |
| - | |
818 |
| - | |
819 |
| - | |
820 |
| - | |
821 |
| - | |
822 |
| - | |
823 |
| - | |
824 | 818 |
| |
825 | 819 |
| |
826 | 820 |
| |
| |||
883 | 877 |
| |
884 | 878 |
| |
885 | 879 |
| |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
886 | 891 |
| |
887 | 892 |
| |
888 | 893 |
| |
| |||
892 | 897 |
| |
893 | 898 |
| |
894 | 899 |
| |
895 |
| - | |
896 |
| - | |
897 |
| - | |
898 |
| - | |
899 |
| - | |
900 |
| - | |
901 |
| - | |
902 |
| - | |
903 |
| - | |
904 |
| - | |
905 |
| - | |
906 |
| - | |
907 |
| - | |
908 |
| - | |
909 |
| - | |
910 |
| - | |
911 | 900 |
| |
912 | 901 |
| |
913 | 902 |
| |
|
Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
| 32 | + | |
32 | 33 |
| |
33 | 34 |
| |
34 | 35 |
| |
| |||
4355 | 4356 |
| |
4356 | 4357 |
| |
4357 | 4358 |
| |
| 4359 | + | |
| 4360 | + | |
| 4361 | + | |
| 4362 | + | |
| 4363 | + | |
| 4364 | + | |
| 4365 | + | |
| 4366 | + | |
| 4367 | + | |
| 4368 | + | |
| 4369 | + | |
| 4370 | + | |
| 4371 | + | |
| 4372 | + | |
| 4373 | + | |
| 4374 | + | |
4358 | 4375 |
| |
4359 | 4376 |
| |
4360 | 4377 |
| |
|
0 commit comments
Comments
(0)