[MDEV-31202] expressions with side effects should not be considered const Created: 2023-05-05 Updated: 2023-07-06 Resolved: 2023-07-06 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | N/A |
| Affects Version/s: | 10.3.38 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Minor |
| Reporter: | Leo Zandvliet | Assignee: | Unassigned |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | compat57 | ||
| Description |
|
Short circuit evaluation in IF() statements appear not to work as expected: Example queries:
Running these in any MySql version outputs are as expected. |
| Comments |
| Comment by Sergei Golubchik [ 2023-05-06 ] | ||
|
short circuit evaluation works here all right:
this prints 0. In your case optimizer notices that @imchanged:=1 is a constant expression, no matter how many rows the result will have, this expression will always have the same result of 1. So it evaluates it early and replaces with 1. It probably shouldn't do it for expressions with side effects, like an assignment. | ||
| Comment by Leo Zandvliet [ 2023-05-06 ] | ||
|
Okay, thanks for your fast response and explanation! |