mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
MDEV-39846 UNIQUE BLOB contains duplicate records after ALTER IGNORE with READ COMMITTED
Force REPEATABLE READ isolation for the duration of mysql_alter_table,
so HA_CHECK_UNIQUE_AFTER_WRITE never triggers during ALTER's exclusive table copy.
(cherry-pick of 46ee272a10 - online ALTER TABLE (MDEV-32100))
This commit is contained in:
@@ -169,4 +169,15 @@ id f
|
||||
1 foo
|
||||
2 foo
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-39846 UNIQUE BLOB contains duplicate records after ALTER IGNORE with READ COMMITTED
|
||||
#
|
||||
create table t1 (pk int primary key, b blob) engine=innodb;
|
||||
insert into t1 values (1,'foo'),(2,'foo');
|
||||
set transaction isolation level read committed;
|
||||
alter ignore table t1 add unique (b);
|
||||
select * from t1;
|
||||
pk b
|
||||
1 foo
|
||||
drop table t1;
|
||||
# End of 10.6 tests
|
||||
|
||||
@@ -176,4 +176,14 @@ update ignore t1 set id = 2;
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-39846 UNIQUE BLOB contains duplicate records after ALTER IGNORE with READ COMMITTED
|
||||
--echo #
|
||||
create table t1 (pk int primary key, b blob) engine=innodb;
|
||||
insert into t1 values (1,'foo'),(2,'foo');
|
||||
set transaction isolation level read committed;
|
||||
alter ignore table t1 add unique (b);
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # End of 10.6 tests
|
||||
|
||||
@@ -94,6 +94,7 @@ class Enable_wsrep_ctas_guard
|
||||
#endif /* WITH_WSREP */
|
||||
|
||||
#include "sql_debug.h"
|
||||
#include "scope.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
@@ -10647,6 +10648,12 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
|
||||
*/
|
||||
table_list->required_type= TABLE_TYPE_NORMAL;
|
||||
|
||||
enum_tx_isolation iso_level_initial= thd->tx_isolation;
|
||||
SCOPE_EXIT([thd, iso_level_initial](){
|
||||
thd->tx_isolation= iso_level_initial;
|
||||
});
|
||||
thd->tx_isolation= ISO_REPEATABLE_READ;
|
||||
|
||||
DEBUG_SYNC(thd, "alter_table_before_open_tables");
|
||||
|
||||
thd->open_options|= HA_OPEN_FOR_ALTER;
|
||||
|
||||
Reference in New Issue
Block a user