-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-37713/MDEV-37714 Fold boolean literals in SELECT-list #4754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8223,6 +8223,23 @@ bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, | |
| DBUG_RETURN(TRUE); /* purecov: inspected */ | ||
| } | ||
| item= *(it.ref()); // Item might have changed in fix_fields() | ||
| /* | ||
| If item is a SELECT-list COND_ITEM, rewrite it on the first time this | ||
| query is optimized to fold boolean expressions | ||
| */ | ||
| if (thd->lex->current_select->context_analysis_place == SELECT_LIST && | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any specific reason why you're doing this only for the SELECT list expressions?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forgot to mention one thing: When doing the optimization you are doing you need to check for NULL-ness!
should return NULL and not true. |
||
| item->type() == Item::COND_ITEM && | ||
| thd->lex->current_select->first_cond_optimization) | ||
| { | ||
| Query_arena_stmt on_stmt_arena(thd); | ||
| Item *new_item= static_cast<Item_cond *>(item)->simplify_cond(thd); | ||
| if (new_item != item) | ||
| { | ||
| new_item->share_name_with(item); | ||
| it.replace(new_item); | ||
| item= new_item; | ||
| } | ||
| } | ||
| if (!ref.is_null()) | ||
| { | ||
| ref[0]= item; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the list ever be empty, given that you're removing one of the branches only if another branch exists?
I'd say no. And then this is dead code. And should be turned into an assert.