forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit232019b
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 parent0ce8e49 commit232019b
File tree
3 files changed
+40
-2
lines changed- src
- backend/optimizer/plan
- test/regress
- expected
- sql
3 files changed
+40
-2
lines changedLines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2849 | 2849 |
| |
2850 | 2850 |
| |
2851 | 2851 |
| |
| 2852 | + | |
| 2853 | + | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
2852 | 2860 |
| |
2853 | 2861 |
| |
2854 | 2862 |
| |
|
Lines changed: 23 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1017 | 1017 |
| |
1018 | 1018 |
| |
1019 | 1019 |
| |
1020 |
| - | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
1021 | 1043 |
| |
1022 | 1044 |
| |
1023 | 1045 |
| |
|
Lines changed: 9 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
362 | 362 |
| |
363 | 363 |
| |
364 | 364 |
| |
365 |
| - | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
366 | 374 |
| |
367 | 375 |
| |
368 | 376 |
| |
|
0 commit comments
Comments
(0)