diff options
author | konstantin@mysql.com <> | 2004-10-08 02:21:19 +0400 |
---|---|---|
committer | konstantin@mysql.com <> | 2004-10-08 02:21:19 +0400 |
commit | 2aa7ec0d9da32c9fe0ea8bea6e21b9905fbdb487 (patch) | |
tree | a5dc36f841657f3f8e88422732495d2f85a82a86 /sql/item_cmpfunc.cc | |
parent | 66923bf9685734ebec22af1a2a9a63e68ccdc24b (diff) | |
download | mariadb-git-2aa7ec0d9da32c9fe0ea8bea6e21b9905fbdb487.tar.gz |
A fix for Bug#5748 "Prepared statement with BETWEEN and bigint values
crashes mysqld": implementation for a generic item tree modifications
registry. Every item tree modification which should be rolled back for
subsequent execution of a prepared statement or stored procedure should
be saved in the registry. All such modifications are rolled back at once
during cleanup stage of PS.
Actual fix for the bug just adds a call to register modifications to
convert_constant_item.
Post review fixes implemented.
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index bb1ea09d6bc..a2bee632017 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -145,7 +145,7 @@ void Item_func_not_all::print(String *str) 1 Item was replaced with an integer version of the item */ -static bool convert_constant_item(Field *field, Item **item) +static bool convert_constant_item(THD *thd, Field *field, Item **item) { if ((*item)->const_item()) { @@ -153,7 +153,10 @@ static bool convert_constant_item(Field *field, Item **item) { Item *tmp=new Item_int_with_ref(field->val_int(), *item); if (tmp) + { + thd->register_item_tree_change(item, *item, &thd->mem_root); *item=tmp; + } return 1; // Item was replaced } } @@ -164,6 +167,7 @@ static bool convert_constant_item(Field *field, Item **item) void Item_bool_func2::fix_length_and_dec() { max_length= 1; // Function returns 0 or 1 + THD *thd= current_thd; /* As some compare functions are generated after sql_yacc, @@ -199,7 +203,6 @@ void Item_bool_func2::fix_length_and_dec() !coll.set(args[0]->collation, args[1]->collation, TRUE)) { Item* conv= 0; - THD *thd= current_thd; Item_arena *arena= thd->current_arena, backup; strong= coll.strong; weak= strong ? 0 : 1; @@ -245,7 +248,7 @@ void Item_bool_func2::fix_length_and_dec() Field *field=((Item_field*) args[0])->field; if (field->can_be_compared_as_longlong()) { - if (convert_constant_item(field,&args[1])) + if (convert_constant_item(thd, field,&args[1])) { cmp.set_cmp_func(this, tmp_arg, tmp_arg+1, INT_RESULT); // Works for all types. @@ -258,7 +261,7 @@ void Item_bool_func2::fix_length_and_dec() Field *field=((Item_field*) args[1])->field; if (field->can_be_compared_as_longlong()) { - if (convert_constant_item(field,&args[0])) + if (convert_constant_item(thd, field,&args[0])) { cmp.set_cmp_func(this, tmp_arg, tmp_arg+1, INT_RESULT); // Works for all types. @@ -836,6 +839,7 @@ longlong Item_func_interval::val_int() void Item_func_between::fix_length_and_dec() { max_length= 1; + THD *thd= current_thd; /* As some compare functions are generated after sql_yacc, @@ -858,9 +862,9 @@ void Item_func_between::fix_length_and_dec() Field *field=((Item_field*) args[0])->field; if (field->can_be_compared_as_longlong()) { - if (convert_constant_item(field,&args[1])) + if (convert_constant_item(thd, field,&args[1])) cmp_type=INT_RESULT; // Works for all types. - if (convert_constant_item(field,&args[2])) + if (convert_constant_item(thd, field,&args[2])) cmp_type=INT_RESULT; // Works for all types. } } |