forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit14a158f
committed
Fix interaction of CASE and ArrayCoerceExpr.
An array-type coercion appearing within a CASE that has a constant(after const-folding) test expression was mangled by the planner, causingall the elements of the resulting array to be equal to the coerced valueof the CASE's test expression. This is my oversight in commitc12d570:that changed ArrayCoerceExpr to use a subexpression involving aCaseTestExpr, and I didn't notice that eval_const_expressions needed anadjustment to keep from folding such a CaseTestExpr to a constant whenit's inside a suitable CASE.This is another in what's getting to be a depressingly long line of bugsassociated with misidentification of the referent of a CaseTestExpr.We're overdue to redesign that mechanism; but any such fix is unlikelyto be back-patchable into v11. As a stopgap, fix eval_const_expressionsto do what it must here. Also add a bunch of comments pointing out therestrictions and assumptions that are needed to make this work at all.Also fix a related oversight: contain_context_dependent_node() was notaware of the relationship of ArrayCoerceExpr to CaseTestExpr. That wassomewhat fail-soft, in that the outcome of a wrong answer would be toprevent optimizations that could have been made, but let's fix it whilewe're at it.Per bug #15471 from Matt Williams. Back-patch to v11 where the faultylogic came in.Discussion:https://postgr.es/m/15471-1117f49271989bad@postgresql.org1 parentc2c7c26 commit14a158f
File tree
7 files changed
+108
-16
lines changed- src
- backend
- executor
- optimizer/util
- parser
- include/nodes
- test/regress
- expected
- sql
7 files changed
+108
-16
lines changedLines changed: 5 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1516 | 1516 |
| |
1517 | 1517 |
| |
1518 | 1518 |
| |
1519 |
| - | |
1520 |
| - | |
1521 |
| - | |
1522 |
| - | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
1523 | 1524 |
| |
1524 | 1525 |
| |
1525 | 1526 |
| |
|
Lines changed: 49 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1452 | 1452 |
| |
1453 | 1453 |
| |
1454 | 1454 |
| |
1455 |
| - | |
| 1455 | + | |
| 1456 | + | |
1456 | 1457 |
| |
1457 | 1458 |
| |
1458 | 1459 |
| |
| |||
1468 | 1469 |
| |
1469 | 1470 |
| |
1470 | 1471 |
| |
1471 |
| - | |
| 1472 | + | |
1472 | 1473 |
| |
1473 | 1474 |
| |
1474 | 1475 |
| |
1475 | 1476 |
| |
1476 | 1477 |
| |
1477 | 1478 |
| |
1478 | 1479 |
| |
1479 |
| - | |
1480 |
| - | |
| 1480 | + | |
| 1481 | + | |
1481 | 1482 |
| |
1482 | 1483 |
| |
1483 | 1484 |
| |
| |||
1499 | 1500 |
| |
1500 | 1501 |
| |
1501 | 1502 |
| |
1502 |
| - | |
| 1503 | + | |
1503 | 1504 |
| |
1504 | 1505 |
| |
1505 | 1506 |
| |
1506 | 1507 |
| |
1507 | 1508 |
| |
1508 | 1509 |
| |
1509 | 1510 |
| |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
1510 | 1529 |
| |
1511 | 1530 |
| |
1512 | 1531 |
| |
| |||
3125 | 3144 |
| |
3126 | 3145 |
| |
3127 | 3146 |
| |
3128 |
| - | |
| 3147 | + | |
| 3148 | + | |
3129 | 3149 |
| |
3130 |
| - | |
3131 |
| - | |
| 3150 | + | |
| 3151 | + | |
| 3152 | + | |
| 3153 | + | |
| 3154 | + | |
| 3155 | + | |
| 3156 | + | |
| 3157 | + | |
| 3158 | + | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
| 3170 | + | |
| 3171 | + | |
3132 | 3172 |
| |
3133 | 3173 |
| |
3134 | 3174 |
| |
| |||
3142 | 3182 |
| |
3143 | 3183 |
| |
3144 | 3184 |
| |
| 3185 | + | |
3145 | 3186 |
| |
3146 | 3187 |
| |
3147 | 3188 |
| |
|
Lines changed: 6 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
907 | 907 |
| |
908 | 908 |
| |
909 | 909 |
| |
910 |
| - | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
911 | 916 |
| |
912 | 917 |
| |
913 | 918 |
| |
|
Lines changed: 7 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
691 | 691 |
| |
692 | 692 |
| |
693 | 693 |
| |
694 |
| - | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
695 | 701 |
| |
696 | 702 |
| |
697 | 703 |
| |
|
Lines changed: 14 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
934 | 934 |
| |
935 | 935 |
| |
936 | 936 |
| |
937 |
| - | |
938 |
| - | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
939 | 951 |
| |
940 | 952 |
| |
941 | 953 |
| |
|
Lines changed: 14 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
372 | 372 |
| |
373 | 373 |
| |
374 | 374 |
| |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
375 | 389 |
| |
376 | 390 |
| |
377 | 391 |
| |
|
Lines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
233 | 233 |
| |
234 | 234 |
| |
235 | 235 |
| |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
236 | 249 |
| |
237 | 250 |
| |
238 | 251 |
| |
|
0 commit comments
Comments
(0)