1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Fix for BUG#25843: changing default database between PREPARE and EXECUTE

of statement breaks binlog.

There were two problems discovered by this bug:

  1. Default (current) database is not fixed at the creation time.
     That leads to wrong output of DATABASE() function.

  2. Database attributes (@@collation_database) are not fixed at
     the creation time. That leads to wrong resultset.

Binlog breakage and Query Cache wrong output happened because of
the first problem.

The fix is to remember the current database at the PREPARE-time and
set it each time at EXECUTE.
This commit is contained in:
anozdrin/alik@ibm.opbmk
2007-08-31 20:42:14 +04:00
parent f141ba5e26
commit d6f94b062c
13 changed files with 891 additions and 153 deletions

View File

@ -387,7 +387,6 @@ THD::THD()
init_sql_alloc(&main_mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
stmt_arena= this;
thread_stack= 0;
db= 0;
catalog= (char*)"std"; // the only catalog we have for now
main_security_ctx.init();
security_ctx= &main_security_ctx;
@ -395,7 +394,7 @@ THD::THD()
query_start_used= 0;
count_cuted_fields= CHECK_FIELD_IGNORE;
killed= NOT_KILLED;
db_length= col_access=0;
col_access=0;
query_error= thread_specific_used= FALSE;
hash_clear(&handler_tables_hash);
tmp_table=0;
@ -2040,7 +2039,9 @@ Statement::Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg,
lex(lex_arg),
query(0),
query_length(0),
cursor(0)
cursor(0),
db(NULL),
db_length(0)
{
name.str= NULL;
}