diff options
author | unknown <bell@sanja.is.com.ua> | 2004-03-23 14:26:54 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-03-23 14:26:54 +0200 |
commit | a36185af9a9c3da71a7e58772e494df91e3a6a8a (patch) | |
tree | 0ee4c065678c0345c7f253128ee7b46a70fde77f /sql/sql_union.cc | |
parent | 78b4ba746b79ea7d89044e3eecd56338a8f4eb6f (diff) | |
download | mariadb-git-a36185af9a9c3da71a7e58772e494df91e3a6a8a.tar.gz |
fixed union with prepared statement bug found by Konstantin
sql/sql_lex.cc:
initialisation for safety
sql/sql_union.cc:
item list should be saved in statement memory
tests/client_test.c:
test suite
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r-- | sql/sql_union.cc | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 87f70bcbd3a..1ad783649f3 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -226,13 +226,23 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, thd_arg->lex->current_select= lex_select_save; { + Statement *stmt= thd->current_statement; + Statement backup; + if (stmt) + thd->set_n_backup_item_arena(stmt, &backup); Field **field; for (field= table->field; *field; field++) { Item_field *item= new Item_field(*field); if (!item || item_list.push_back(item)) + { + if (stmt) + thd->restore_backup_item_arena(stmt, &backup); DBUG_RETURN(-1); + } } + if (stmt) + thd->restore_backup_item_arena(stmt, &backup); } } else @@ -427,7 +437,7 @@ int st_select_lex_unit::cleanup() { DBUG_RETURN(0); } - cleaned= 0; + cleaned= 1; if (union_result) { @@ -461,16 +471,19 @@ void st_select_lex_unit::reinit_exec_mechanism() { prepared= optimized= executed= 0; #ifndef DBUG_OFF - List_iterator_fast<Item> it(item_list); - Item_field *field; - while ((field= (Item_field *)it++)) + if (first_select()->next_select()) { - /* - we can't cleanup here, because it broke link to temporary table field, - but have to drop fixed flag to allow next fix_field of this field - during re-executing - */ - field->fixed= 0; + List_iterator_fast<Item> it(item_list); + Item *field; + while ((field= it++)) + { + /* + we can't cleanup here, because it broke link to temporary table field, + but have to drop fixed flag to allow next fix_field of this field + during re-executing + */ + field->fixed= 0; + } } #endif } |