- Notifications
You must be signed in to change notification settings - Fork28
Commit1b19e2c
committed
Fix up handling of simple-form CASE with constant test expression.
eval_const_expressions() can replace CaseTestExprs with constants whenthe surrounding CASE's test expression is a constant. This confusesruleutils.c's heuristic for deparsing simple-form CASEs, leading toAssert failures or "unexpected CASE WHEN clause" errors. I had put ina hack solution for that years ago (see commit514ce7a of 2006-10-01), but bug #5794from Peter Speck shows that that solution failed to cover all cases.Fortunately, there's a much better way, which came to me upon reflectingthat Peter's "CASE TRUE WHEN" seemed pretty redundant: we can "simplify"the simple-form CASE to the general form of CASE, by simply omitting theconstant test expression from the rebuilt CASE construct. This isintuitively valid because there is no need for the executor to evaluatethe test expression at runtime; it will never be referenced, because anyCaseTestExprs that would have referenced it are now replaced by constants.This won't save a whole lot of cycles, since evaluating a Const is prettycheap, but a cycle saved is a cycle earned. In any case it beats klugingruleutils.c still further. So this patch improves const-simplificationand reverts the previous change in ruleutils.c.Back-patch to all supported branches. The bug exists in 8.1 too, but it'sout of warranty.1 parentabc1026 commit1b19e2c
2 files changed
+21
-11
lines changedLines changed: 15 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2583 | 2583 |
| |
2584 | 2584 |
| |
2585 | 2585 |
| |
2586 |
| - | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
2587 | 2598 |
| |
2588 | 2599 |
| |
2589 | 2600 |
| |
| |||
2602 | 2613 |
| |
2603 | 2614 |
| |
2604 | 2615 |
| |
| 2616 | + | |
2605 | 2617 |
| |
| 2618 | + | |
| 2619 | + | |
2606 | 2620 |
| |
2607 | 2621 |
| |
2608 | 2622 |
| |
|
Lines changed: 6 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5146 | 5146 |
| |
5147 | 5147 |
| |
5148 | 5148 |
| |
5149 |
| - | |
5150 |
| - | |
5151 |
| - | |
5152 |
| - | |
5153 |
| - | |
5154 |
| - | |
| 5149 | + | |
| 5150 | + | |
| 5151 | + | |
| 5152 | + | |
5155 | 5153 |
| |
5156 | 5154 |
| |
5157 | 5155 |
| |
5158 | 5156 |
| |
5159 |
| - | |
5160 | 5157 |
| |
5161 | 5158 |
| |
5162 | 5159 |
| |
5163 |
| - | |
5164 |
| - | |
5165 |
| - | |
| 5160 | + | |
| 5161 | + | |
5166 | 5162 |
| |
5167 | 5163 |
| |
5168 | 5164 |
| |
|
0 commit comments
Comments
(0)