forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita5be406
committed
Don't remove surplus columns from GROUP BY for inheritance parents
d4c3a15 added code to remove columns that were not part of a table'sPRIMARY KEY constraint from the GROUP BY clause when all the primary keycolumns were present in the group by. This is fine to do since we knowthat there will only be one row per group coming from this relation.However, the logic failed to consider inheritance parent relations. Thesecan have child relations without a primary key, but even if they did, theycould duplicate one of the parent's rows or one from another childrelation. In this case, those additional GROUP BY columns are required.Fix this by disabling the optimization for inheritance parent tables.In v11 and beyond, partitioned tables are fine since partitions cannotoverlap and before v11 partitioned tables could not have a primary key.Reported-by: Manuel RiggerDiscussion:http://postgr.es/m/CA+u7OA7VLKf_vEr6kLF3MnWSA9LToJYncgpNX2tQ-oWzYCBQAw@mail.gmail.comBackpatch-through: 9.61 parent2a16121 commita5be406
File tree
3 files changed
+75
-2
lines changed- src
- backend/optimizer/plan
- test/regress
- expected
- sql
3 files changed
+75
-2
lines changedLines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3124 | 3124 |
| |
3125 | 3125 |
| |
3126 | 3126 |
| |
| 3127 | + | |
| 3128 | + | |
| 3129 | + | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
| 3134 | + | |
3127 | 3135 |
| |
3128 | 3136 |
| |
3129 | 3137 |
| |
|
Lines changed: 44 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1147 | 1147 |
| |
1148 | 1148 |
| |
1149 | 1149 |
| |
1150 |
| - | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
1151 | 1193 |
| |
1152 | 1194 |
| |
| 1195 | + | |
1153 | 1196 |
| |
1154 | 1197 |
| |
1155 | 1198 |
| |
|
Lines changed: 23 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
406 | 406 |
| |
407 | 407 |
| |
408 | 408 |
| |
409 |
| - | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
410 | 431 |
| |
411 | 432 |
| |
| 433 | + | |
412 | 434 |
| |
413 | 435 |
| |
414 | 436 |
| |
|
0 commit comments
Comments
(0)