1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

Revert MDEV-25292 Atomic CREATE OR REPLACE TABLE

Specifically:

Revert "MDEV-29664 Assertion `!n_mysql_tables_in_use' failed in innobase_close_connection"
This reverts commit ba875e9396.

Revert "MDEV-29620 Assertion `next_insert_id == 0' failed in handler::ha_external_lock"
This reverts commit aa08a7442a.

Revert "MDEV-29628 Memory leak after CREATE OR REPLACE with foreign key"
This reverts commit c579d66ba6.

Revert "MDEV-29609 create_not_windows test fails with different result"
This reverts commit cb583b2f1b.

Revert "MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_locked_tables"
This reverts commit dcd66c3814.

Revert "MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name"
This reverts commit cf6c517632.

Revert "MDEV-28933 Moved RENAME_CONSTRAINT_IDS to include/sql_funcs.h"
This reverts commit f1e1c1335b.

Revert "MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES"
This reverts commit a228ec80e3.

Revert "MDEV-25292 gcol.gcol_bugfixes --ps fix"
This reverts commit 24fff8267d.

Revert "MDEV-25292 Disable atomic replace for slave-generated or-replace"
This reverts commit 2af15914cb.

Revert "MDEV-25292 backup_log improved"
This reverts commit 34398a20b5.

Revert "MDEV-25292 Atomic CREATE OR REPLACE TABLE"
This reverts commit 93c8252f02.

Revert "MDEV-25292 Table_name class for (db, table_name, alias)"
This reverts commit d145dda9c7.

Revert "MDEV-25292 ha_table_exists() cleanup and improvement"
This reverts commit 409b8a86de.

Revert "MDEV-25292 Cleanups"
This reverts commit 595dad83ad.

Revert "MDEV-25292 Refactoring: moved select_field_count into Alter_info."
This reverts commit f02af1d229.
This commit is contained in:
Sergei Golubchik
2022-10-27 22:18:51 +02:00
parent d15260990d
commit 2bd41fc5bf
92 changed files with 1386 additions and 9510 deletions

View File

@ -5,7 +5,8 @@
--source include/have_innodb.inc
--source include/have_metadata_lock_info.inc
let $MYSQLD_DATADIR= `SELECT @@datadir`;
SET @save_persistent=@@GLOBAL.innodb_stats_persistent;
SET GLOBAL innodb_stats_persistent=OFF;
#
# Create help table
@ -217,23 +218,18 @@ create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write;
--replace_column 1 #
--sorted_result
select * from information_schema.metadata_lock_info
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
select * from information_schema.metadata_lock_info;
--error ER_TABLE_MUST_HAVE_COLUMNS
create or replace table test.t1;
show tables;
--replace_column 1 #
--sorted_result
select * from information_schema.metadata_lock_info
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
select * from information_schema.metadata_lock_info;
--error ER_TABLE_MUST_HAVE_COLUMNS
create or replace table mysqltest2.t2;
--replace_column 1 #
--sorted_result
select * from information_schema.metadata_lock_info
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
drop table mysqltest2.t2;
drop table t1;
select * from information_schema.metadata_lock_info;
create table t1 (i int);
drop table t1;
@ -242,23 +238,18 @@ create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write;
--replace_column 1 #
--sorted_result
select * from information_schema.metadata_lock_info
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
select * from information_schema.metadata_lock_info;
--error ER_DUP_FIELDNAME
create or replace table test.t1 (a int) select 1 as 'a', 2 as 'a';
show tables;
--replace_column 1 #
--sorted_result
select * from information_schema.metadata_lock_info
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
select * from information_schema.metadata_lock_info;
--error ER_DUP_FIELDNAME
create or replace table mysqltest2.t2 (a int) select 1 as 'a', 2 as 'a';
--replace_column 1 #
--sorted_result
select * from information_schema.metadata_lock_info
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
drop table mysqltest2.t2;
drop table t1;
select * from information_schema.metadata_lock_info;
create table t1 (i int);
drop table t1;
@ -267,8 +258,7 @@ create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write;
--replace_column 1 #
--sorted_result
select * from information_schema.metadata_lock_info
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
select * from information_schema.metadata_lock_info;
unlock tables;
drop table test.t1,mysqltest2.t2;
@ -277,8 +267,7 @@ create table mysqltest2.t2 like test.t1;
lock table test.t1 write, mysqltest2.t2 write;
--replace_column 1 #
--sorted_result
select * from information_schema.metadata_lock_info
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
select * from information_schema.metadata_lock_info;
unlock tables;
drop table t1;
@ -294,16 +283,13 @@ create table t1 (i int);
lock table t1 write;
--replace_column 1 #
--sorted_result
select * from information_schema.metadata_lock_info
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
select * from information_schema.metadata_lock_info;
--error ER_DATA_TOO_LONG
create or replace table t1 (a char(1)) engine=Innodb select 'foo' as a;
drop table t1;
show tables;
--replace_column 1 #
--sorted_result
select * from information_schema.metadata_lock_info
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
select * from information_schema.metadata_lock_info;
create table t1 (i int);
drop table t1;
--enable_view_protocol
@ -381,24 +367,20 @@ create table t1 (a int);
lock table t1 write, t2 read;
--replace_column 1 #
--sorted_result
select * from information_schema.metadata_lock_info
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
select * from information_schema.metadata_lock_info;
create or replace table t1 (i int);
--replace_column 1 #
--sorted_result
select * from information_schema.metadata_lock_info
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
select * from information_schema.metadata_lock_info;
create or replace table t1 like t2;
--replace_column 1 #
--sorted_result
select * from information_schema.metadata_lock_info
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
select * from information_schema.metadata_lock_info;
create or replace table t1 select 1 as f1;
--replace_column 1 #
--sorted_result
select * from information_schema.metadata_lock_info
where table_schema!='mysql' or table_name not like 'innodb_%_stats';
select * from information_schema.metadata_lock_info;
drop table t1;
unlock tables;
@ -546,182 +528,4 @@ DROP TABLE IF EXISTS tm, t;
--echo # End of 10.3 tests
--echo #
--echo # End of 10.4 tests
--echo #
--echo # MDEV-25292 Atomic CREATE OR REPLACE TABLE
--echo #
create table t1 (a int);
insert t1 values (1), (1);
create table t2 (c int);
--error ER_DUP_KEYNAME
create or replace table t2 (a int, b int, key k (a), key k (b));
show create table t2;
--error ER_DUP_KEYNAME
create or replace table t2 (a int, b int, key k (a), key k (b)) as select a, a as b from t1;
show create table t2;
--error ER_DUP_ENTRY
create or replace table t2 (a int primary key) as select * from t1;
show create table t2;
set @old_mode= @@sql_mode;
set @@sql_mode='ALLOW_INVALID_DATES';
create table t3 (dt datetime default '2008-02-31 00:00:00');
set @@sql_mode= @old_mode;
--error ER_INVALID_DEFAULT
create or replace table t2 like t3;
show create table t2;
--echo # LOCK TABLES
lock tables t2 write, t1 write;
flush tables;
show open tables like 't2';
create or replace table t2 (y int);
flush tables;
show open tables like 't2';
create or replace table t2 like t1;
flush tables;
show open tables like 't2';
create or replace table t2 (y int) as select * from t1;
flush tables;
show open tables like 't2';
unlock tables;
--echo # SP
--delimiter $
create or replace procedure sp(n int)
begin
select concat('sp call ', n, ':') as '';
show open tables like 't2';
create or replace table t2 (y int);
select 'create or replace table t2 (y int);' as '';
show open tables like 't2';
insert into t2 values (2);
select 'insert into t2 values (2);' as '';
show open tables like 't2';
create or replace table t2 like t1;
select 'create or replace table t2 like t1;' as '';
show open tables like 't2';
create or replace table t2 (y int) as select * from t1;
select 'create or replace table t2 (y int) as select * from t1;' as '';
show open tables like 't2';
select 'select * from t2;' as '';
select * from t2;
show open tables like 't2';
end $
--delimiter ;
flush tables;
call sp(1); call sp(2);
--echo # SP under LOCK TABLES
lock tables t2 write, t1 write;
call sp(3); call sp(4);
unlock tables;
drop procedure sp;
drop tables t1, t2, t3;
--echo # Trigger
create table t1 (a int);
create trigger a before insert on t1 for each row set @s= 1;
create or replace table t1 (old int);
--error ER_TRG_DOES_NOT_EXIST
show create trigger a;
drop table t1;
--echo # PS: check thd->change_list sanity
create table t1 (a int not null, b char(10) as (concat('', dayname('2020-02-02')))) collate utf8_bin;
prepare stmt from 'insert into t1 (b) values (2)';
create or replace table t1 (x int);
drop table t1;
drop prepare stmt;
--echo # Foreign keys
--list_files $MYSQLD_DATADIR/test *sql*
create table t1 (x int primary key, y int) engine innodb;
create table t2 (x int references t1(x)) engine innodb;
--error ER_ROW_IS_REFERENCED_2
create or replace table t1 (x int primary key);
--list_files $MYSQLD_DATADIR/test *sql*
--error ER_ROW_IS_REFERENCED_2
create or replace table t1 (x int primary key);
create table t3 (x int);
--error ER_ROW_IS_REFERENCED_2
create or replace table t1 like t3;
--list_files $MYSQLD_DATADIR/test *sql*
--error ER_ROW_IS_REFERENCED_2
create or replace table t1 like t3;
--error ER_ROW_IS_REFERENCED_2
create or replace table t1 select * from t3;
--error ER_ROW_IS_REFERENCED_2
create or replace table t1 select * from t3;
--list_files $MYSQLD_DATADIR/test *sql*
show create table t1;
drop tables t3, t2, t1;
--echo # UNIQUE
create table t1 (pk int auto_increment primary key, a varchar(2300), unique (a)) engine aria;
insert into t1 (a) values ('a'), ('b'), ('c');
create table t2 (x int);
create or replace table t2 engine aria select * from t1;
select * from t2;
show create table t2;
drop tables t2, t1;
--echo #
--echo # MDEV-28956 Locking is broken if CREATE OR REPLACE fails under LOCK TABLES
--echo #
--echo # Atomic CREATE OR REPLACE part:
--echo #
--disable_service_connection
create table t1 (pk int primary key) engine=innodb;
create or replace table t2 (a int primary key references t1 (pk)) engine=innodb;
lock tables t1 write, t2 write;
--error ER_DUP_FIELDNAME
create or replace table t2 (c1 int not null, c1 varchar(255) ) engine=innodb;
select * from t1;
select * from t2;
unlock tables;
drop tables t2, t1;
--enable_service_connection
--echo #
--echo # MDEV-28933 CREATE OR REPLACE fails to recreate same constraint name
--echo #
use test;
create table t (a int primary key) engine=innodb;
create or replace table u (
a int primary key,
constraint c foreign key d (a) references t (a)) engine=innodb;
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
create or replace table u (
a int primary key,
constraint c foreign key d (a) references t (a)) engine=innodb;
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
drop tables u, t;
select * from information_schema.innodb_sys_foreign;
select * from information_schema.innodb_sys_foreign_cols;
--echo #
--echo # MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_locked_tables
--echo #
call mtr.add_suppression("mysql.innodb_index_stats");
set sql_mode= '';
create table t (x int) engine innodb;
insert into t values (77);
alter table mysql.innodb_index_stats modify stat_description char(10);
lock table t write;
--replace_regex /#sql-backup-.+-.+-/#sql-backup-/
--replace_result $MYSQLD_DATADIR ./
--error ER_ERROR_ON_RENAME
create or replace table t (y int);
# cleanup
unlock tables;
alter table mysql.innodb_index_stats modify stat_description varchar(1024) not null;
select * from t;
drop table t;
set sql_mode= default;
--echo #
--echo # MDEV-29620 Assertion `next_insert_id == 0' failed in handler::ha_external_lock
--echo #
create or replace table t1 (i serial) as select * from (values(1), (2)) dt;
drop table t1;
SET GLOBAL innodb_stats_persistent=@save_persistent;