Commit 05c7edf6 authored by unknown's avatar unknown

Move reset of insert_values to ensure it's done also during error conditions

This fixed a failure of insert_update.test on some platforms


mysys/thr_alarm.c:
  Fixed problem noticed by valgrind
sql/opt_range.cc:
  Simple optimization for common case
sql/sql_base.cc:
  Safety assert
sql/sql_insert.cc:
  Added comment
parent 2776aa35
...@@ -86,6 +86,7 @@ void init_thr_alarm(uint max_alarms) ...@@ -86,6 +86,7 @@ void init_thr_alarm(uint max_alarms)
{ {
struct sigaction sact; struct sigaction sact;
sact.sa_flags = 0; sact.sa_flags = 0;
bzero((char*) &sact, sizeof(sact));
sact.sa_handler = thread_alarm; sact.sa_handler = thread_alarm;
sigaction(THR_CLIENT_ALARM, &sact, (struct sigaction*) 0); sigaction(THR_CLIENT_ALARM, &sact, (struct sigaction*) 0);
} }
......
...@@ -981,8 +981,7 @@ get_mm_parts(PARAM *param, COND *cond_func, Field *field, ...@@ -981,8 +981,7 @@ get_mm_parts(PARAM *param, COND *cond_func, Field *field,
SEL_TREE *tree2= get_mm_parts(param, cond_func, SEL_TREE *tree2= get_mm_parts(param, cond_func,
field, Item_func::GT_FUNC, field, Item_func::GT_FUNC,
value, cmp_type); value, cmp_type);
if (!tree2) /* tree_or() will return 0 if tree2 is 0 */
DBUG_RETURN(0);
tree= tree_or(param,tree,tree2); tree= tree_or(param,tree,tree2);
} }
DBUG_RETURN(tree); DBUG_RETURN(tree);
......
...@@ -979,6 +979,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name, ...@@ -979,6 +979,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
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();
DBUG_ASSERT(table->key_read == 0); DBUG_ASSERT(table->key_read == 0);
DBUG_ASSERT(table->insert_values == 0);
DBUG_RETURN(table); DBUG_RETURN(table);
} }
......
...@@ -516,6 +516,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, ...@@ -516,6 +516,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
ON DUPLICATE KEY ... ON DUPLICATE KEY ...
we should be able to refer to sum1 in the ON DUPLICATE KEY part we should be able to refer to sum1 in the ON DUPLICATE KEY part
WARNING
You MUST set table->insert_values to 0 after calling this function
before releasing the table object.
RETURN VALUE RETURN VALUE
0 OK 0 OK
-1 error (message is not sent to user) -1 error (message is not sent to user)
......
...@@ -2891,12 +2891,12 @@ mysql_execute_command(THD *thd) ...@@ -2891,12 +2891,12 @@ mysql_execute_command(THD *thd)
/* revert changes for SP */ /* revert changes for SP */
lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE; lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE;
delete result; delete result;
insert_table->insert_values= 0;
if (thd->net.report_error) if (thd->net.report_error)
res= -1; res= -1;
} }
else else
res= -1; res= -1;
insert_table->insert_values= 0; // Set by mysql_prepare_insert()
first_local_table->next= tables; first_local_table->next= tables;
lex->select_lex.table_list.first= (byte*) first_local_table; lex->select_lex.table_list.first= (byte*) first_local_table;
break; break;
......
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