MDEV-37713/MDEV-37714 Fold boolean literals in SELECT-list#4754
MDEV-37713/MDEV-37714 Fold boolean literals in SELECT-list#4754jaeheonshim wants to merge 1 commit intoMariaDB:mainfrom
Conversation
8acdfc3 to
3dc42db
Compare
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for your contribution! This is a preliminary review.
Please also add a test case.
And, the jira mentions one optimization you're not really doing:
SELECT (a > 0 AND a < 0) FROM t1;
SELECT (a > 0 OR a <=0) FROM t1;
Would you consider doing this too? Or, if you wont, we'll need to open a sub-task Jira instead of using the current one.
Unfortunately, I don't think something like that can be added. We would risk breaking the semantics of the sql query. For example, if |
|
There hasn't been any activity for more than 3 weeks now. Closing due to inactivity. If you would like to keep working on that please ping me or anybody else of the MariaDB committers to re-open the PR for you. |
c439d1a to
8003be3
Compare
| SELECT (SELECT MIN(c0) FROM t2)<0 OR true; | ||
| SELECT ((SELECT MIN(c0) FROM t2)<0 AND false) OR (SELECT MAX(c0) FROM t1)>0 AS f; | ||
|
|
||
| ANALYZE SELECT (SELECT MIN(c0) FROM t2)<0 OR true; |
There was a problem hiding this comment.
my only comment is that before these ANALYZE statement is a comment explaining how the MDEV implementation affects results. E.g Here the OR true expression will eliminate the need for the subselect resulting in No tables used
Before you start comment on those, I'll get another reviewer to see if they agree with this approach.
|
@jaeheonshim , generally we try to avoid test files names like |
|
The recursive |
The order of evaluation of the expressions that appear in a SELECT-list is undefined. This change exploits this fact by recursively folding TRUE/FALSE literals in OR/AND expressions which may allow for skipping evaluation of some parts of the expression or even the whole expression.
|
@Olernov , thanks for the suggestions! I added the |
The order of evaluation of the expressions that appear in a SELECT-list is undefined. This change exploits this fact by recursively folding TRUE/FALSE literals in OR/AND expressions which may allow for skipping evaluation of some parts of the expression or even the whole expression.
Example
Setup
Before
After