Commit e055be66 authored by unknown's avatar unknown

Remove clear_insert_values() because it was far from trivial to handle the cleanup in all cases

(Old code failed for INSERT ... ON DUPLICATE with prepared statements) 
Instead, always reset table->insert_values on open.


mysql-test/t/trigger.test:
  Fix test for --ps-protocol
sql/sql_base.cc:
  Clear insert_values on open_table
sql/sql_insert.cc:
  Remove clear_insert_values()
sql/sql_parse.cc:
  Remove clear_insert_values()
sql/sql_prepare.cc:
  Remove clear_insert_values()
sql/table.cc:
  Remove clear_insert_values()
sql/table.h:
  Remove clear_insert_values()
parent 3652c4ed
...@@ -53,6 +53,7 @@ select @a; ...@@ -53,6 +53,7 @@ select @a;
drop trigger t1.trg; drop trigger t1.trg;
drop table t1; drop table t1;
--disable_ps_protocol
# Before update trigger # Before update trigger
# (In future we will achieve this via proper error handling in triggers) # (In future we will achieve this via proper error handling in triggers)
create table t1 (aid int not null primary key, balance int not null default 0); create table t1 (aid int not null primary key, balance int not null default 0);
...@@ -74,6 +75,7 @@ select * from t1| ...@@ -74,6 +75,7 @@ select * from t1|
drop trigger t1.trg| drop trigger t1.trg|
drop table t1| drop table t1|
delimiter ;| delimiter ;|
--enable_ps_protocol
# After update trigger # After update trigger
create table t1 (i int); create table t1 (i int);
......
...@@ -1069,6 +1069,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, ...@@ -1069,6 +1069,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
table->outer_join= table->null_row= table->maybe_null= table->force_index= 0; table->outer_join= table->null_row= table->maybe_null= table->force_index= 0;
table->status=STATUS_NO_RECORD; table->status=STATUS_NO_RECORD;
table->keys_in_use_for_query= table->keys_in_use; table->keys_in_use_for_query= table->keys_in_use;
table->insert_values= 0;
table->used_keys= table->keys_for_keyread; table->used_keys= table->keys_for_keyread;
if (table->timestamp_field) if (table->timestamp_field)
table->timestamp_field_type= table->timestamp_field->get_auto_set_type(); table->timestamp_field_type= table->timestamp_field->get_auto_set_type();
......
...@@ -501,7 +501,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, ...@@ -501,7 +501,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
::send_ok(thd, (ulong) thd->row_count_func, id, buff); ::send_ok(thd, (ulong) thd->row_count_func, id, buff);
} }
free_underlaid_joins(thd, &thd->lex->select_lex); free_underlaid_joins(thd, &thd->lex->select_lex);
table_list->clear_insert_values();
thd->abort_on_warning= 0; thd->abort_on_warning= 0;
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
...@@ -511,7 +510,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, ...@@ -511,7 +510,6 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
end_delayed_insert(thd); end_delayed_insert(thd);
#endif #endif
free_underlaid_joins(thd, &thd->lex->select_lex); free_underlaid_joins(thd, &thd->lex->select_lex);
table_list->clear_insert_values();
thd->abort_on_warning= 0; thd->abort_on_warning= 0;
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
......
...@@ -3009,9 +3009,6 @@ mysql_execute_command(THD *thd) ...@@ -3009,9 +3009,6 @@ mysql_execute_command(THD *thd)
lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE; lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE;
delete result; delete result;
} }
/* in case of error first_table->table can be 0 */
if (first_table->table)
first_table->table->insert_values= 0;
/* revert changes for SP */ /* revert changes for SP */
lex->select_lex.table_list.first= (byte*) first_table; lex->select_lex.table_list.first= (byte*) first_table;
} }
......
...@@ -908,7 +908,11 @@ static bool mysql_test_insert(Prepared_statement *stmt, ...@@ -908,7 +908,11 @@ static bool mysql_test_insert(Prepared_statement *stmt,
Item *unused_conds= 0; Item *unused_conds= 0;
if (table_list->table) if (table_list->table)
table_list->table->insert_values=(byte *)1; // don't allocate insert_values {
// don't allocate insert_values
table_list->table->insert_values=(byte *)1;
}
if ((res= mysql_prepare_insert(thd, table_list, table_list->table, if ((res= mysql_prepare_insert(thd, table_list, table_list->table,
fields, values, update_fields, fields, values, update_fields,
update_values, duplic, update_values, duplic,
...@@ -934,8 +938,7 @@ static bool mysql_test_insert(Prepared_statement *stmt, ...@@ -934,8 +938,7 @@ static bool mysql_test_insert(Prepared_statement *stmt,
res= 0; res= 0;
error: error:
lex->unit.cleanup(); lex->unit.cleanup();
if (table_list->table) /* insert_values is cleared in open_table */
table_list->table->insert_values=0;
DBUG_RETURN(res); DBUG_RETURN(res);
} }
...@@ -1401,6 +1404,11 @@ static int mysql_test_insert_select(Prepared_statement *stmt, ...@@ -1401,6 +1404,11 @@ static int mysql_test_insert_select(Prepared_statement *stmt,
DBUG_ASSERT(first_local_table != 0); DBUG_ASSERT(first_local_table != 0);
/* Skip first table, which is the table we are inserting in */ /* Skip first table, which is the table we are inserting in */
lex->select_lex.table_list.first= (byte*) first_local_table->next_local; lex->select_lex.table_list.first= (byte*) first_local_table->next_local;
if (tables->table)
{
// don't allocate insert_values
tables->table->insert_values=(byte *)1;
}
/* /*
insert/replace from SELECT give its SELECT_LEX for SELECT, insert/replace from SELECT give its SELECT_LEX for SELECT,
......
...@@ -2026,26 +2026,6 @@ bool st_table_list::set_insert_values(MEM_ROOT *mem_root) ...@@ -2026,26 +2026,6 @@ bool st_table_list::set_insert_values(MEM_ROOT *mem_root)
} }
/*
clear insert_values reference
SYNOPSIS
clear_insert_values()
*/
void st_table_list::clear_insert_values()
{
if (table)
table->insert_values= 0;
else
{
DBUG_ASSERT(view && ancestor && ancestor->next_local);
for (TABLE_LIST *tbl= ancestor; tbl; tbl= tbl->next_local)
tbl->clear_insert_values();
}
}
void Field_iterator_view::set(TABLE_LIST *table) void Field_iterator_view::set(TABLE_LIST *table)
{ {
ptr= table->field_translation; ptr= table->field_translation;
......
...@@ -387,7 +387,6 @@ typedef struct st_table_list ...@@ -387,7 +387,6 @@ typedef struct st_table_list
void restore_want_privilege(); void restore_want_privilege();
bool check_single_table(st_table_list **table, table_map map); bool check_single_table(st_table_list **table, table_map map);
bool set_insert_values(MEM_ROOT *mem_root); bool set_insert_values(MEM_ROOT *mem_root);
void clear_insert_values();
} TABLE_LIST; } TABLE_LIST;
class Item; class Item;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment