forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit9094767
committed
Fix incorrect handling of subquery pullup in the presence of grouping sets.
If we flatten a subquery whose target list contains constants orexpressions, when those output columns are used in GROUPING SET columns,the planner was capable of doing the wrong thing by merging a pulled-upexpression into the surrounding expression during const-simplification.Then the late processing that attempts to match subexpressions to groupingsets would fail to match those subexpressions to grouping sets, with theeffect that they'd not go to null when expected.To fix, wrap such subquery outputs in PlaceHolderVars, ensuring thatthey preserve their separate identity throughout the planner's expressionprocessing. This is a bit of a band-aid, because the wrapper defeatsconst-simplification even in places where it would be safe to allow.But a nicer fix would likely be too invasive to back-patch, and theconsequences of the missed optimizations probably aren't large in mostcases.Back-patch to 9.5 where grouping sets were introduced.Heikki Linnakangas, with small mods and better test cases by me;additional review by Andrew GierthDiscussion:https://postgr.es/m/7dbdcf5c-b5a6-ef89-4958-da212fe10176@iki.fi1 parentca4587f commit9094767
File tree
3 files changed
+105
-8
lines changed- src
- backend/optimizer/prep
- test/regress
- expected
- sql
3 files changed
+105
-8
lines changedLines changed: 40 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1003 | 1003 |
| |
1004 | 1004 |
| |
1005 | 1005 |
| |
1006 |
| - | |
1007 |
| - | |
1008 |
| - | |
1009 |
| - | |
1010 |
| - | |
| 1006 | + | |
| 1007 | + | |
1011 | 1008 |
| |
1012 | 1009 |
| |
1013 | 1010 |
| |
| |||
1019 | 1016 |
| |
1020 | 1017 |
| |
1021 | 1018 |
| |
1022 |
| - | |
1023 |
| - | |
1024 |
| - | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
1025 | 1022 |
| |
1026 | 1023 |
| |
1027 | 1024 |
| |
1028 | 1025 |
| |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
1029 | 1061 |
| |
1030 | 1062 |
| |
1031 | 1063 |
| |
|
Lines changed: 45 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
389 | 389 |
| |
390 | 390 |
| |
391 | 391 |
| |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
392 | 437 |
| |
393 | 438 |
| |
394 | 439 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
152 | 152 |
| |
153 | 153 |
| |
154 | 154 |
| |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
155 | 175 |
| |
156 | 176 |
| |
157 | 177 |
| |
|
0 commit comments
Comments
(0)