forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf25d061
committed
Fix mishandling of equivalence-class tests in parameterized plans.
Given a three-or-more-way equivalence class, such as X.Y = Y.Y = Z.Z,it was possible for the planner to omit one of the quals needed toenforce that all members of the equivalence class are actually equal.This only happened in the case of a parameterized join node for twoof the relations, that is a plan tree likeNested Loop -> Scan X -> Nested Loop -> Scan Y -> Scan Z Filter: Z.Z = X.XThe eclass machinery normally expects to apply X.X = Y.Y when thosetwo relations are joined, but in this shape of plan tree they aren'tjoined until the top node --- and, if the lower nested loop is markedas parameterized by X, the top node will assume that the relevant eclasscondition(s) got pushed down into the lower node. On the other hand,the scan of Z assumes that it's only responsible for constraining Z.Zto match any one of the other eclass members. So one or another ofthe required quals sometimes fell between the cracks, depending onwhether consideration of the eclass in get_joinrel_parampathinfo()for the lower nested loop chanced to generate X.X = Y.Y or X.X = Z.Zas the appropriate constraint there. If it generated the latter,it'd erroneously suppose that the Z scan would take care of matters.To fix, force X.X = Y.Y to be generated and applied at that join nodewhen this case occurs.This is *extremely* hard to hit in practice, because various plannerbehaviors conspire to mask the problem; starting with the fact that theplanner doesn't really like to generate a parameterized plan of theabove shape. (It might have been impossible to hit it before wetweaked things to allow this plan shape for star-schema cases.) Manythanks to Alexander Kirkouski for submitting a reproducible test case.The bug can be demonstrated in all branches back to 9.2 where parameterizedpaths were introduced, so back-patch that far.1 parenteac3e16 commitf25d061
File tree
5 files changed
+149
-9
lines changed- src
- backend/optimizer
- path
- util
- include/optimizer
- test/regress
- expected
- sql
5 files changed
+149
-9
lines changedLines changed: 20 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
987 | 987 |
| |
988 | 988 |
| |
989 | 989 |
| |
990 |
| - | |
| 990 | + | |
991 | 991 |
| |
992 | 992 |
| |
993 | 993 |
| |
994 | 994 |
| |
995 | 995 |
| |
996 | 996 |
| |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
997 | 1015 |
| |
998 | 1016 |
| |
999 | 1017 |
| |
| |||
1015 | 1033 |
| |
1016 | 1034 |
| |
1017 | 1035 |
| |
1018 |
| - | |
| 1036 | + | |
1019 | 1037 |
| |
1020 | 1038 |
| |
1021 | 1039 |
| |
|
Lines changed: 75 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
982 | 982 |
| |
983 | 983 |
| |
984 | 984 |
| |
| 985 | + | |
985 | 986 |
| |
986 | 987 |
| |
987 | 988 |
| |
| |||
1035 | 1036 |
| |
1036 | 1037 |
| |
1037 | 1038 |
| |
| 1039 | + | |
1038 | 1040 |
| |
1039 | 1041 |
| |
1040 | 1042 |
| |
| |||
1051 | 1053 |
| |
1052 | 1054 |
| |
1053 | 1055 |
| |
1054 |
| - | |
1055 |
| - | |
1056 |
| - | |
1057 |
| - | |
1058 |
| - | |
1059 |
| - | |
1060 |
| - | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
1061 | 1129 |
| |
1062 | 1130 |
| |
1063 | 1131 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
130 | 130 |
| |
131 | 131 |
| |
132 | 132 |
| |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
133 | 138 |
| |
134 | 139 |
| |
135 | 140 |
| |
|
Lines changed: 32 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2236 | 2236 |
| |
2237 | 2237 |
| |
2238 | 2238 |
| |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
| 2265 | + | |
| 2266 | + | |
| 2267 | + | |
| 2268 | + | |
| 2269 | + | |
| 2270 | + | |
2239 | 2271 |
| |
2240 | 2272 |
| |
2241 | 2273 |
| |
|
Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
391 | 391 |
| |
392 | 392 |
| |
393 | 393 |
| |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
394 | 411 |
| |
395 | 412 |
| |
396 | 413 |
| |
|
0 commit comments
Comments
(0)