mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
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.
This commit is contained in:
@ -85,3 +85,13 @@ t1 CREATE TABLE `t1` (
|
||||
`c` int(11) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE t1;
|
||||
create temporary table t1 (
|
||||
id int not null auto_increment primary key,
|
||||
f int not null default 0
|
||||
);
|
||||
insert into t1 () values ();
|
||||
alter ignore table t1 add constraint check (f > 0);
|
||||
Warnings:
|
||||
Warning 4025 CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1`
|
||||
alter table t1;
|
||||
drop table t1;
|
||||
|
@ -103,3 +103,15 @@ CREATE OR REPLACE TABLE t1 (a INT, b INT, c INT, CHECK (a+b>0)) ENGINE=MyISAM;
|
||||
ALTER TABLE t1 DROP COLUMN b, DROP CONSTRAINT `CONSTRAINT_1`;
|
||||
SHOW CREATE TABLE t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# MDEV-16903 Assertion `!auto_increment_field_not_null' failed in TABLE::init after unsuccessful attempt to add CHECK constraint on temporary table
|
||||
#
|
||||
create temporary table t1 (
|
||||
id int not null auto_increment primary key,
|
||||
f int not null default 0
|
||||
);
|
||||
insert into t1 () values ();
|
||||
alter ignore table t1 add constraint check (f > 0);
|
||||
alter table t1;
|
||||
drop table t1;
|
||||
|
@ -10065,13 +10065,6 @@ 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++)
|
||||
{
|
||||
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user