Created
July 10, 2024 12:38
-
-
Save spetrunia/5236479b5c4d5cd286ff00f914c759a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -u '--exclude=.*' sql/item.cc sql/item.cc | |
--- sql/item.cc 2024-07-10 15:21:32.686440163 +0300 | |
+++ sql/item.cc 2024-07-10 15:25:11.262066814 +0300 | |
@@ -2176,6 +2176,16 @@ | |
bool Item_name_const::fix_fields(THD *thd, Item **ref) | |
{ | |
+ | |
+ if (value_item->fix_fields_if_needed(thd, &value_item) || | |
+ name_item->fix_fields_if_needed(thd, &name_item) || | |
+ !value_item->const_item() || | |
+ !name_item->const_item()) | |
+ { | |
+ my_error(ER_RESERVED_SYNTAX, MYF(0), "NAME_CONST"); | |
+ return TRUE; | |
+ } | |
+ | |
/* | |
If we have either of the following: | |
... WHERE foo=NAME_CONST(...) | |
@@ -2183,14 +2193,20 @@ | |
then we have an opportunity to unwrap the NAME_CONST and | |
use the enclosed value directly, replacing NAME_CONST in | |
the parse tree with the value it encloses. | |
- */ | |
+ */ | |
if ((thd->where == THD_WHERE::WHERE_CLAUSE || | |
thd->where == THD_WHERE::ON_CLAUSE) && | |
(value_item->type() == FUNC_ITEM || | |
- value_item->type() == CONST_ITEM) && | |
- !value_item->fix_fields_if_needed(thd, &value_item)) | |
+ value_item->type() == CONST_ITEM)) | |
{ | |
thd->change_item_tree(ref, value_item); | |
+ /* | |
+ We're replacing NAME_CONST('name', value_item) with value_item. | |
+ Only a few constants and functions are possible as value_item, see | |
+ Create_func_name_const::create_2_arg. | |
+ Set the value_item's coercibility to be the same as NAME_CONST(...) | |
+ would have (see how it's set a few lines below). | |
+ */ | |
if (value_item->collation.derivation != DERIVATION_NUMERIC) | |
value_item->collation.set(value_item->collation.collation, | |
DERIVATION_IMPLICIT); | |
@@ -2198,14 +2214,6 @@ | |
} | |
// else, could not unwrap, fall back to default handling below. | |
- if (value_item->fix_fields_if_needed(thd, &value_item) || | |
- name_item->fix_fields_if_needed(thd, &name_item) || | |
- !value_item->const_item() || | |
- !name_item->const_item()) | |
- { | |
- my_error(ER_RESERVED_SYNTAX, MYF(0), "NAME_CONST"); | |
- return TRUE; | |
- } | |
if (value_item->collation.derivation == DERIVATION_NUMERIC) | |
collation= DTCollation_numeric(); | |
else | |
diff -u '--exclude=.*' sql/sql_class.h sql/sql_class.h | |
--- sql/sql_class.h 2024-07-10 15:21:32.690440303 +0300 | |
+++ sql/sql_class.h 2024-07-10 15:23:38.710836775 +0300 | |
@@ -2902,6 +2902,7 @@ | |
const char *get_proc_info() const | |
{ return proc_info; } | |
+ // Used by thd_where() when where==USE_WHERE_STRING | |
const char *where_str; | |
/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment