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/sql_prepare.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/sql_prepare.cc')
-rw-r--r-- | sql/sql_prepare.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index aa3301d540f..a638e74dc2f 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1614,6 +1614,7 @@ int mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, cleanup_items(stmt->free_list); close_thread_tables(thd); free_items(thd->free_list); + thd->rollback_item_tree_changes(); thd->free_list= 0; thd->current_arena= thd; @@ -1870,8 +1871,7 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt, transformations of the query tree (i.e. negations elimination). This should be done permanently on the parse tree of this statement. */ - if (stmt->state == Item_arena::PREPARED) - thd->current_arena= stmt; + thd->current_arena= stmt; if (!(specialflag & SPECIAL_NO_PRIOR)) my_pthread_setprio(pthread_self(),QUERY_PRIOR); @@ -1884,11 +1884,10 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt, free_items(thd->free_list); thd->free_list= 0; if (stmt->state == Item_arena::PREPARED) - { - thd->current_arena= thd; stmt->state= Item_arena::EXECUTED; - } + thd->current_arena= thd; cleanup_items(stmt->free_list); + thd->rollback_item_tree_changes(); reset_stmt_params(stmt); close_thread_tables(thd); // to close derived tables thd->set_statement(&thd->stmt_backup); |