diff options
author | unknown <konstantin@mysql.com> | 2004-10-08 02:21:19 +0400 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2004-10-08 02:21:19 +0400 |
commit | 8fa6f37a2963ad95c985f09ae26e8ed301ea03b9 (patch) | |
tree | a5dc36f841657f3f8e88422732495d2f85a82a86 /sql/item_cmpfunc.cc | |
parent | e82d3d49342f4be222252f22b7f8cb7399baec6f (diff) | |
download | mariadb-git-8fa6f37a2963ad95c985f09ae26e8ed301ea03b9.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.
mysql-test/r/ps.result:
A fix for bug#5748, test results fixed.
mysql-test/t/ps.test:
A test case for Bug#5748 "Prepared statement with BETWEEN and bigint
values crashes mysqld"
sql/item.cc:
Fix for Bug#5748 "Prepared statement with BETWEEN and bigint values
crashes mysqld":
First step in removing up item-specific cleanups: now all such
tree modifications should be done using the genericm mechanism implemented
in this changeset.
sql/item.h:
Fix for Bug#5748 "Prepared statement with BETWEEN and bigint values
crashes mysqld": no need for an item-specific change record any more.
sql/item_cmpfunc.cc:
A fix for Bug#5748 "Prepared statement with BETWEEN and bigint
values crashes mysqld": register item tree transformation performed by
convert_constant_item.
sql/sql_class.cc:
Implementation for item tree transformations registry.
sql/sql_class.h:
Declarations, necessary for the tree transformations registry.
sql/sql_parse.cc:
Assert that the item tree transformations registry is not used for
conventional execution.
sql/sql_prepare.cc:
Use of the item tree modifications registry in prepared statements:
rollback all modifications in the end of statement prepare and execute.
Also we now always set thd->current_arena to be able to determine that
this is an execution of prepared statement inside the registry code.
tests/client_test.c:
A typo fixed.
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. } } |