summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-12-14 14:28:30 +0100
committerSergei Golubchik <serg@mariadb.org>2018-12-20 08:06:55 +0100
commit7b2e2288e9f784ea12f85dc005503511fe99f796 (patch)
treea64ade4e4d6f7a98e78210b757053e8114a94f4c /sql
parenta79183b01e4e1f3af55abd102715560cecbbddae (diff)
downloadmariadb-git-7b2e2288e9f784ea12f85dc005503511fe99f796.tar.gz
MDEV-16903 Assertion `!auto_increment_field_not_null' failed in TABLE::init after unsuccessful attempt to add CHECK constraint on temporary table
if the CHECK constraint failed in copy_data_between_tables(), the loop was aborted prematurely and to->auto_increment_field_not_null wasn't reset.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_table.cc16
-rw-r--r--sql/temporary_tables.cc11
2 files changed, 12 insertions, 15 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 1765e352b88..9e72278db8d 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -10065,14 +10065,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
error= 1;
break;
}
- if (to->next_number_field)
- {
- if (auto_increment_field_copied)
- to->auto_increment_field_not_null= TRUE;
- else
- to->next_number_field->reset();
- }
-
+
for (Copy_field *copy_ptr=copy ; copy_ptr != copy_end ; copy_ptr++)
{
copy_ptr->do_copy(copy_ptr);
@@ -10091,6 +10084,13 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
error= 1;
break;
}
+ if (to->next_number_field)
+ {
+ if (auto_increment_field_copied)
+ to->auto_increment_field_not_null= TRUE;
+ else
+ to->next_number_field->reset();
+ }
error=to->file->ha_write_row(to->record[0]);
to->auto_increment_field_not_null= FALSE;
if (error)
diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc
index 3201b306fad..87c4671ada4 100644
--- a/sql/temporary_tables.cc
+++ b/sql/temporary_tables.cc
@@ -1140,8 +1140,7 @@ TABLE *THD::open_temporary_table(TMP_TABLE_SHARE *share,
@return Success false
Failure true
*/
-bool THD::find_and_use_tmp_table(const TABLE_LIST *tl,
- TABLE **out_table)
+bool THD::find_and_use_tmp_table(const TABLE_LIST *tl, TABLE **out_table)
{
DBUG_ENTER("THD::find_and_use_tmp_table");
@@ -1151,11 +1150,9 @@ bool THD::find_and_use_tmp_table(const TABLE_LIST *tl,
key_length= create_tmp_table_def_key(key, tl->get_db_name(),
tl->get_table_name());
- result=
- use_temporary_table(find_temporary_table(key, key_length,
- TMP_TABLE_NOT_IN_USE),
- out_table);
-
+ result= use_temporary_table(find_temporary_table(key, key_length,
+ TMP_TABLE_NOT_IN_USE),
+ out_table);
DBUG_RETURN(result);
}