forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit179c054
Mark expressions nullable by grouping sets
When generating window_pathkeys, distinct_pathkeys, or sort_pathkeys,we failed to realize that the grouping/ordering expressions might benullable by grouping sets. As a result, we may incorrectly deem thatthe PathKeys are redundant by EquivalenceClass processing and thusremove them from the pathkeys list. That would lead to wrong resultsin some cases.To fix this issue, we mark the grouping expressions nullable bygrouping sets if that is the case. If the grouping expression is aVar or PlaceHolderVar or constructed from those, we can just add theRT index of the RTE_GROUP RTE to the existing nullingrels field(s);otherwise we have to add a PlaceHolderVar to carry on the nullingrelbit.However, we have to manually remove this nullingrel bit fromexpressions in various cases where these expressions are logicallybelow the grouping step, such as when we generate groupClause pathkeysfor grouping sets, or when we generate PathTarget for initial input togrouping nodes.Furthermore, in set_upper_references, the targetlist and quals of anAgg node should have nullingrels that include the effects of thegrouping step, ie they will have nullingrels equal to the inputVars/PHVs' nullingrels plus the nullingrel bit that references thegrouping RTE. In order to perform exact nullingrels matches, we alsoneed to manually remove this nullingrel bit.Bump catversion because this changes the querytree produced by theparser.Thanks to Tom Lane for the idea to invent a new kind of RTE.Per reports from Geoff Winkless, Tobias Wendorff, Richard Guo fromvarious threads.Author: Richard GuoReviewed-by: Ashutosh Bapat, Sutou KouheiDiscussion:https://postgr.es/m/CAMbWs4_dp7e7oTwaiZeBX8+P1rXw4ThkZxh1QG81rhu9Z47VsQ@mail.gmail.com1 parentc250dfb commit179c054
File tree
11 files changed
+411
-33
lines changed- src
- backend
- optimizer
- path
- plan
- util
- parser
- include
- catalog
- optimizer
- test/regress
- expected
- sql
11 files changed
+411
-33
lines changedLines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
726 | 726 |
| |
727 | 727 |
| |
728 | 728 |
| |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
729 | 733 |
| |
730 | 734 |
| |
731 | 735 |
| |
| |||
1087 | 1091 |
| |
1088 | 1092 |
| |
1089 | 1093 |
| |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
1090 | 1098 |
| |
1091 | 1099 |
| |
1092 | 1100 |
| |
| |||
3354 | 3362 |
| |
3355 | 3363 |
| |
3356 | 3364 |
| |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
| 3368 | + | |
3357 | 3369 |
| |
3358 | 3370 |
| |
3359 | 3371 |
| |
|
Lines changed: 14 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
25 | 25 |
| |
26 | 26 |
| |
27 | 27 |
| |
| 28 | + | |
28 | 29 |
| |
29 | 30 |
| |
30 | 31 |
| |
| |||
1341 | 1342 |
| |
1342 | 1343 |
| |
1343 | 1344 |
| |
| 1345 | + | |
1344 | 1346 |
| |
1345 | 1347 |
| |
1346 | 1348 |
| |
| |||
1359 | 1361 |
| |
1360 | 1362 |
| |
1361 | 1363 |
| |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
1362 | 1367 |
| |
1363 | 1368 |
| |
1364 | 1369 |
| |
| |||
1375 | 1380 |
| |
1376 | 1381 |
| |
1377 | 1382 |
| |
| 1383 | + | |
1378 | 1384 |
| |
1379 | 1385 |
| |
1380 | 1386 |
| |
| |||
1394 | 1400 |
| |
1395 | 1401 |
| |
1396 | 1402 |
| |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
1397 | 1411 |
| |
1398 | 1412 |
| |
1399 | 1413 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1328 | 1328 |
| |
1329 | 1329 |
| |
1330 | 1330 |
| |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
1331 | 1335 |
| |
1332 | 1336 |
| |
1333 | 1337 |
| |
|
Lines changed: 46 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
58 | 58 |
| |
59 | 59 |
| |
60 | 60 |
| |
| 61 | + | |
61 | 62 |
| |
62 | 63 |
| |
63 | 64 |
| |
| |||
3506 | 3507 |
| |
3507 | 3508 |
| |
3508 | 3509 |
| |
3509 |
| - | |
3510 |
| - | |
3511 |
| - | |
| 3510 | + | |
| 3511 | + | |
| 3512 | + | |
| 3513 | + | |
| 3514 | + | |
| 3515 | + | |
| 3516 | + | |
| 3517 | + | |
| 3518 | + | |
| 3519 | + | |
| 3520 | + | |
| 3521 | + | |
| 3522 | + | |
| 3523 | + | |
| 3524 | + | |
| 3525 | + | |
| 3526 | + | |
3512 | 3527 |
| |
3513 | 3528 |
| |
3514 | 3529 |
| |
| |||
3538 | 3553 |
| |
3539 | 3554 |
| |
3540 | 3555 |
| |
| 3556 | + | |
3541 | 3557 |
| |
3542 | 3558 |
| |
3543 | 3559 |
| |
| |||
3589 | 3605 |
| |
3590 | 3606 |
| |
3591 | 3607 |
| |
| 3608 | + | |
3592 | 3609 |
| |
3593 | 3610 |
| |
3594 | 3611 |
| |
| |||
3616 | 3633 |
| |
3617 | 3634 |
| |
3618 | 3635 |
| |
| 3636 | + | |
3619 | 3637 |
| |
3620 | 3638 |
| |
3621 | 3639 |
| |
| |||
5526 | 5544 |
| |
5527 | 5545 |
| |
5528 | 5546 |
| |
| 5547 | + | |
| 5548 | + | |
| 5549 | + | |
| 5550 | + | |
5529 | 5551 |
| |
| 5552 | + | |
| 5553 | + | |
| 5554 | + | |
| 5555 | + | |
| 5556 | + | |
| 5557 | + | |
| 5558 | + | |
| 5559 | + | |
5530 | 5560 |
| |
5531 | 5561 |
| |
5532 | 5562 |
| |
| |||
5554 | 5584 |
| |
5555 | 5585 |
| |
5556 | 5586 |
| |
| 5587 | + | |
| 5588 | + | |
| 5589 | + | |
| 5590 | + | |
5557 | 5591 |
| |
5558 | 5592 |
| |
5559 | 5593 |
| |
5560 | 5594 |
| |
5561 | 5595 |
| |
| 5596 | + | |
| 5597 | + | |
| 5598 | + | |
| 5599 | + | |
| 5600 | + | |
| 5601 | + | |
| 5602 | + | |
| 5603 | + | |
5562 | 5604 |
| |
5563 | 5605 |
| |
5564 | 5606 |
| |
| |||
6207 | 6249 |
| |
6208 | 6250 |
| |
6209 | 6251 |
| |
| 6252 | + | |
6210 | 6253 |
| |
6211 | 6254 |
| |
6212 | 6255 |
| |
|
Lines changed: 23 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
26 | 26 |
| |
27 | 27 |
| |
28 | 28 |
| |
| 29 | + | |
29 | 30 |
| |
30 | 31 |
| |
31 | 32 |
| |
| |||
2426 | 2427 |
| |
2427 | 2428 |
| |
2428 | 2429 |
| |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
2429 | 2452 |
| |
2430 | 2453 |
| |
2431 | 2454 |
| |
|
Lines changed: 87 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
22 | 22 |
| |
23 | 23 |
| |
24 | 24 |
| |
| 25 | + | |
25 | 26 |
| |
26 | 27 |
| |
27 | 28 |
| |
| |||
83 | 84 |
| |
84 | 85 |
| |
85 | 86 |
| |
| 87 | + | |
| 88 | + | |
86 | 89 |
| |
87 | 90 |
| |
88 | 91 |
| |
| |||
909 | 912 |
| |
910 | 913 |
| |
911 | 914 |
| |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
912 | 927 |
| |
913 | 928 |
| |
914 | 929 |
| |
| |||
973 | 988 |
| |
974 | 989 |
| |
975 | 990 |
| |
976 |
| - | |
| 991 | + | |
| 992 | + | |
977 | 993 |
| |
978 | 994 |
| |
979 | 995 |
| |
| |||
1040 | 1056 |
| |
1041 | 1057 |
| |
1042 | 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 | + | |
1043 | 1129 |
| |
1044 | 1130 |
| |
1045 | 1131 |
| |
|
Lines changed: 10 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1333 | 1333 |
| |
1334 | 1334 |
| |
1335 | 1335 |
| |
1336 |
| - | |
1337 |
| - | |
1338 |
| - | |
1339 | 1336 |
| |
1340 | 1337 |
| |
1341 | 1338 |
| |
| |||
1409 | 1406 |
| |
1410 | 1407 |
| |
1411 | 1408 |
| |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
1412 | 1419 |
| |
1413 | 1420 |
| |
1414 | 1421 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
57 | 57 |
| |
58 | 58 |
| |
59 | 59 |
| |
60 |
| - | |
| 60 | + | |
61 | 61 |
| |
62 | 62 |
|
0 commit comments
Comments
(0)