Commit 02e46e82 authored by mikael@dator5.(none)'s avatar mikael@dator5.(none)

BUG#17138: Crash in stored procedure after fatal error that wasn't a real fatal error

parent 75f35861
...@@ -977,6 +977,9 @@ public: ...@@ -977,6 +977,9 @@ public:
ignorable than others. E.g. the partition handler can get inserts ignorable than others. E.g. the partition handler can get inserts
into a range where there is no partition and this is an ignorable into a range where there is no partition and this is an ignorable
error. error.
HA_ERR_FOUND_DUPP_UNIQUE is a special case in MyISAM that means the
same thing as HA_ERR_FOUND_DUPP_KEY but can in some cases lead to
a slightly different error message.
*/ */
#define HA_CHECK_DUPP_KEY 1 #define HA_CHECK_DUPP_KEY 1
#define HA_CHECK_DUPP_UNIQUE 2 #define HA_CHECK_DUPP_UNIQUE 2
...@@ -985,9 +988,8 @@ public: ...@@ -985,9 +988,8 @@ public:
{ {
if (!error || if (!error ||
((flags & HA_CHECK_DUPP_KEY) && ((flags & HA_CHECK_DUPP_KEY) &&
error == HA_ERR_FOUND_DUPP_KEY) || (error == HA_ERR_FOUND_DUPP_KEY ||
((flags & HA_CHECK_DUPP_UNIQUE) && error == HA_ERR_FOUND_DUPP_UNIQUE)))
error == HA_ERR_FOUND_DUPP_UNIQUE))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
......
...@@ -2663,8 +2663,7 @@ bool Item_sum_count_distinct::add() ...@@ -2663,8 +2663,7 @@ bool Item_sum_count_distinct::add()
return tree->unique_add(table->record[0] + table->s->null_bytes); return tree->unique_add(table->record[0] + table->s->null_bytes);
} }
if ((error= table->file->ha_write_row(table->record[0])) && if ((error= table->file->ha_write_row(table->record[0])) &&
error != HA_ERR_FOUND_DUPP_KEY && table->file->cannot_ignore_error(error, HA_CHECK_DUPP))
error != HA_ERR_FOUND_DUPP_UNIQUE)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
......
...@@ -9354,8 +9354,8 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param, ...@@ -9354,8 +9354,8 @@ bool create_myisam_from_heap(THD *thd, TABLE *table, TMP_TABLE_PARAM *param,
/* copy row that filled HEAP table */ /* copy row that filled HEAP table */
if ((write_err=new_table.file->write_row(table->record[0]))) if ((write_err=new_table.file->write_row(table->record[0])))
{ {
if (write_err != HA_ERR_FOUND_DUPP_KEY && if (new_table.file->cannot_ignore_error(write_err, HA_CHECK_DUPP) ||
write_err != HA_ERR_FOUND_DUPP_UNIQUE || !ignore_last_dupp_key_error) !ignore_last_dupp_key_error)
goto err; goto err;
} }
...@@ -10777,8 +10777,7 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), ...@@ -10777,8 +10777,7 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
join->found_records++; join->found_records++;
if ((error=table->file->write_row(table->record[0]))) if ((error=table->file->write_row(table->record[0])))
{ {
if (error == HA_ERR_FOUND_DUPP_KEY || if (table->file->cannot_ignore_error(error, HA_CHECK_DUPP))
error == HA_ERR_FOUND_DUPP_UNIQUE)
goto end; goto end;
if (create_myisam_from_heap(join->thd, table, &join->tmp_table_param, if (create_myisam_from_heap(join->thd, table, &join->tmp_table_param,
error,1)) error,1))
......
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