Commit 9f56dd73 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.3 into 10.4

parents 3a269a8b 4e7ee166
...@@ -15,7 +15,7 @@ SET @idx1_id = 0; ...@@ -15,7 +15,7 @@ SET @idx1_id = 0;
CREATE TABLE t1(f1 INT NOT NULL, CREATE TABLE t1(f1 INT NOT NULL,
f2 VARCHAR(100) PRIMARY KEY)ENGINE=InnoDB; f2 VARCHAR(100) PRIMARY KEY)ENGINE=InnoDB;
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200); ALTER TABLE t1 MODIFY f2 VARCHAR(200), ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
SELECT @tbl1_id = @tbl_id; SELECT @tbl1_id = @tbl_id;
@tbl1_id = @tbl_id @tbl1_id = @tbl_id
...@@ -32,7 +32,7 @@ CREATE TABLE t1(f1 INT NOT NULL, ...@@ -32,7 +32,7 @@ CREATE TABLE t1(f1 INT NOT NULL,
f2 VARCHAR(100), f2 VARCHAR(100),
INDEX idx(f2))ENGINE=InnoDB; INDEX idx(f2))ENGINE=InnoDB;
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200); ALTER TABLE t1 MODIFY f2 VARCHAR(200), ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
SELECT @tbl1_id = @tbl_id; SELECT @tbl1_id = @tbl_id;
@tbl1_id = @tbl_id @tbl1_id = @tbl_id
...@@ -49,7 +49,7 @@ CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100), f3 VARCHAR(100), ...@@ -49,7 +49,7 @@ CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100), f3 VARCHAR(100),
INDEX idx(f2, f3), index idx1(f3, f2))ENGINE=InnoDB; INDEX idx(f2, f3), index idx1(f3, f2))ENGINE=InnoDB;
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
CALL get_index_id(@tbl_id, "idx", @idx_id); CALL get_index_id(@tbl_id, "idx", @idx_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200), MODIFY f3 VARCHAR(150); ALTER TABLE t1 MODIFY f2 VARCHAR(200), MODIFY f3 VARCHAR(150), ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
CALL get_index_id(@tbl1_id, "idx", @idx1_id); CALL get_index_id(@tbl1_id, "idx", @idx1_id);
SELECT @tbl1_id = @tbl_id; SELECT @tbl1_id = @tbl_id;
...@@ -72,7 +72,7 @@ CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100), ...@@ -72,7 +72,7 @@ CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100),
INDEX idx(f2(40)))ENGINE=InnoDB; INDEX idx(f2(40)))ENGINE=InnoDB;
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
CALL get_index_id(@tbl_id, "idx", @idx_id); CALL get_index_id(@tbl_id, "idx", @idx_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200); ALTER TABLE t1 MODIFY f2 VARCHAR(200), ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
CALL get_index_id(@tbl1_id, "idx", @idx1_id); CALL get_index_id(@tbl1_id, "idx", @idx1_id);
SELECT @tbl1_id = @tbl_id; SELECT @tbl1_id = @tbl_id;
...@@ -93,7 +93,7 @@ CREATE TABLE t1(f1 INT NOT NULL, ...@@ -93,7 +93,7 @@ CREATE TABLE t1(f1 INT NOT NULL,
f2 VARCHAR(100), FULLTEXT idx(f2))ENGINE=InnoDB; f2 VARCHAR(100), FULLTEXT idx(f2))ENGINE=InnoDB;
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
CALL get_index_id(@tbl_id, "idx", @idx_id); CALL get_index_id(@tbl_id, "idx", @idx_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200); ALTER TABLE t1 MODIFY f2 VARCHAR(200), ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
CALL get_index_id(@tbl1_id, "idx", @idx1_id); CALL get_index_id(@tbl1_id, "idx", @idx1_id);
SELECT @tbl1_id = @tbl_id; SELECT @tbl1_id = @tbl_id;
...@@ -117,7 +117,7 @@ INDEX idx(f3))ENGINE=InnoDB; ...@@ -117,7 +117,7 @@ INDEX idx(f3))ENGINE=InnoDB;
INSERT INTO t1(f1, f2) VALUES(1, repeat('a', 40)); INSERT INTO t1(f1, f2) VALUES(1, repeat('a', 40));
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
CALL get_index_id(@tbl_id, "idx", @idx_id); CALL get_index_id(@tbl_id, "idx", @idx_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(100); ALTER TABLE t1 MODIFY f2 VARCHAR(100), ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
CALL get_index_id(@tbl1_id, "idx", @idx1_id); CALL get_index_id(@tbl1_id, "idx", @idx1_id);
SELECT @tbl1_id = @tbl_id; SELECT @tbl1_id = @tbl_id;
...@@ -163,7 +163,7 @@ f2 VARCHAR(100), ...@@ -163,7 +163,7 @@ f2 VARCHAR(100),
INDEX idx(f2(10)))ENGINE=InnoDB; INDEX idx(f2(10)))ENGINE=InnoDB;
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
CALL get_index_id(@tbl_id, "idx", @idx_id); CALL get_index_id(@tbl_id, "idx", @idx_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200), DROP INDEX idx, ADD INDEX idx(f2(10)); ALTER TABLE t1 MODIFY f2 VARCHAR(200), DROP INDEX idx, ADD INDEX idx(f2(10)), ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
CALL get_index_id(@tbl1_id, "idx", @idx1_id); CALL get_index_id(@tbl1_id, "idx", @idx1_id);
SELECT @tbl1_id = @tbl_id; SELECT @tbl1_id = @tbl_id;
...@@ -251,7 +251,7 @@ CREATE TABLE t1(f1 INT NOT NULL, ...@@ -251,7 +251,7 @@ CREATE TABLE t1(f1 INT NOT NULL,
f2 VARCHAR(100), f2 VARCHAR(100),
INDEX idx(f2))ENGINE=InnoDB; INDEX idx(f2))ENGINE=InnoDB;
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD COLUMN f3 INT; ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD COLUMN f3 INT, ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
SELECT @tbl1_id = @tbl_id; SELECT @tbl1_id = @tbl_id;
@tbl1_id = @tbl_id @tbl1_id = @tbl_id
...@@ -267,7 +267,7 @@ t1 CREATE TABLE `t1` ( ...@@ -267,7 +267,7 @@ t1 CREATE TABLE `t1` (
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100) PRIMARY KEY)ENGINE=InnoDB; CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100) PRIMARY KEY)ENGINE=InnoDB;
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD COLUMN f3 INT; ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD COLUMN f3 INT, ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
SELECT @tbl1_id = @tbl_id; SELECT @tbl1_id = @tbl_id;
@tbl1_id = @tbl_id @tbl1_id = @tbl_id
......
set default_storage_engine=innodb;
#
# MDEV-18295 IMPORT TABLESPACE fails with instant-altered tables
#
create table t2 (x int, z int default 41);
alter table t2 discard tablespace;
create table t1 (x int);
insert into t1 values (1);
alter table t1 add z int default 42, algorithm instant;
select * from t1;
x z
1 42
flush tables t1 for export;
unlock tables;
# The metadata has to be updated to instant ADD COLUMN.
alter table t2 import tablespace;
select * from t2;
x z
1 42
insert into t2 set x=2;
select * from t2;
x z
1 42
2 41
alter table t1 discard tablespace;
flush tables t2 for export;
unlock tables;
# Both the metadata and the data file used instant ADD COLUMN.
alter table t1 import tablespace;
select * from t1;
x z
1 42
2 41
drop table t2;
create table t2 select * from t1;
alter table t1 discard tablespace;
flush tables t2 for export;
unlock tables;
# The instant ADD COLUMN has to be removed from the metadata.
alter table t1 import tablespace;
select * from t1;
x z
1 42
2 41
# Remove metadata for instant DROP COLUMN, then import
alter table t1 drop x, add column x int first, algorithm instant;
select * from t1;
x z
NULL 42
NULL 41
alter table t1 discard tablespace;
alter table t1 import tablespace;
select * from t1;
x z
1 42
2 41
# Import a data file that contains instant DROP COLUMN metadata
alter table t2 drop x;
alter table t1 drop x, force;
alter table t1 discard tablespace;
flush tables t2 for export;
unlock tables;
alter table t1 import tablespace;
ERROR HY000: Schema mismatch (Index field count 4 doesn't match tablespace metadata file value 5)
select * from t1;
ERROR HY000: Tablespace has been discarded for table `t1`
alter table t1 import tablespace;
ERROR HY000: Internal error: Cannot reset LSNs in table `test`.`t1` : Unsupported
select * from t1;
ERROR HY000: Tablespace has been discarded for table `t1`
drop table t2;
drop table t1;
...@@ -26,7 +26,7 @@ CREATE TABLE t1(f1 INT NOT NULL, ...@@ -26,7 +26,7 @@ CREATE TABLE t1(f1 INT NOT NULL,
f2 VARCHAR(100) PRIMARY KEY)ENGINE=InnoDB; f2 VARCHAR(100) PRIMARY KEY)ENGINE=InnoDB;
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200); ALTER TABLE t1 MODIFY f2 VARCHAR(200), ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
SELECT @tbl1_id = @tbl_id; SELECT @tbl1_id = @tbl_id;
...@@ -39,7 +39,7 @@ CREATE TABLE t1(f1 INT NOT NULL, ...@@ -39,7 +39,7 @@ CREATE TABLE t1(f1 INT NOT NULL,
INDEX idx(f2))ENGINE=InnoDB; INDEX idx(f2))ENGINE=InnoDB;
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200); ALTER TABLE t1 MODIFY f2 VARCHAR(200), ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
SELECT @tbl1_id = @tbl_id; SELECT @tbl1_id = @tbl_id;
...@@ -51,7 +51,7 @@ CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100), f3 VARCHAR(100), ...@@ -51,7 +51,7 @@ CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100), f3 VARCHAR(100),
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
CALL get_index_id(@tbl_id, "idx", @idx_id); CALL get_index_id(@tbl_id, "idx", @idx_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200), MODIFY f3 VARCHAR(150); ALTER TABLE t1 MODIFY f2 VARCHAR(200), MODIFY f3 VARCHAR(150), ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
CALL get_index_id(@tbl1_id, "idx", @idx1_id); CALL get_index_id(@tbl1_id, "idx", @idx1_id);
...@@ -65,7 +65,7 @@ CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100), ...@@ -65,7 +65,7 @@ CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100),
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
CALL get_index_id(@tbl_id, "idx", @idx_id); CALL get_index_id(@tbl_id, "idx", @idx_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200); ALTER TABLE t1 MODIFY f2 VARCHAR(200), ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
CALL get_index_id(@tbl1_id, "idx", @idx1_id); CALL get_index_id(@tbl1_id, "idx", @idx1_id);
...@@ -80,7 +80,7 @@ CREATE TABLE t1(f1 INT NOT NULL, ...@@ -80,7 +80,7 @@ CREATE TABLE t1(f1 INT NOT NULL,
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
CALL get_index_id(@tbl_id, "idx", @idx_id); CALL get_index_id(@tbl_id, "idx", @idx_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200); ALTER TABLE t1 MODIFY f2 VARCHAR(200), ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
CALL get_index_id(@tbl1_id, "idx", @idx1_id); CALL get_index_id(@tbl1_id, "idx", @idx1_id);
...@@ -98,7 +98,7 @@ INSERT INTO t1(f1, f2) VALUES(1, repeat('a', 40)); ...@@ -98,7 +98,7 @@ INSERT INTO t1(f1, f2) VALUES(1, repeat('a', 40));
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
CALL get_index_id(@tbl_id, "idx", @idx_id); CALL get_index_id(@tbl_id, "idx", @idx_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(100); ALTER TABLE t1 MODIFY f2 VARCHAR(100), ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
CALL get_index_id(@tbl1_id, "idx", @idx1_id); CALL get_index_id(@tbl1_id, "idx", @idx1_id);
...@@ -129,7 +129,7 @@ CREATE TABLE t1(f1 INT NOT NULL, ...@@ -129,7 +129,7 @@ CREATE TABLE t1(f1 INT NOT NULL,
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
CALL get_index_id(@tbl_id, "idx", @idx_id); CALL get_index_id(@tbl_id, "idx", @idx_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200), DROP INDEX idx, ADD INDEX idx(f2(10)); ALTER TABLE t1 MODIFY f2 VARCHAR(200), DROP INDEX idx, ADD INDEX idx(f2(10)), ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
CALL get_index_id(@tbl1_id, "idx", @idx1_id); CALL get_index_id(@tbl1_id, "idx", @idx1_id);
...@@ -192,7 +192,7 @@ CREATE TABLE t1(f1 INT NOT NULL, ...@@ -192,7 +192,7 @@ CREATE TABLE t1(f1 INT NOT NULL,
INDEX idx(f2))ENGINE=InnoDB; INDEX idx(f2))ENGINE=InnoDB;
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD COLUMN f3 INT; ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD COLUMN f3 INT, ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
SELECT @tbl1_id = @tbl_id; SELECT @tbl1_id = @tbl_id;
...@@ -202,7 +202,7 @@ DROP TABLE t1; ...@@ -202,7 +202,7 @@ DROP TABLE t1;
CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100) PRIMARY KEY)ENGINE=InnoDB; CREATE TABLE t1(f1 INT NOT NULL, f2 VARCHAR(100) PRIMARY KEY)ENGINE=InnoDB;
CALL get_table_id("test/t1", @tbl_id); CALL get_table_id("test/t1", @tbl_id);
ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD COLUMN f3 INT; ALTER TABLE t1 MODIFY f2 VARCHAR(200), ADD COLUMN f3 INT, ALGORITHM=INSTANT;
CALL get_table_id("test/t1", @tbl1_id); CALL get_table_id("test/t1", @tbl1_id);
SELECT @tbl1_id = @tbl_id; SELECT @tbl1_id = @tbl_id;
......
--source include/have_innodb.inc
set default_storage_engine=innodb;
--echo #
--echo # MDEV-18295 IMPORT TABLESPACE fails with instant-altered tables
--echo #
create table t2 (x int, z int default 41);
alter table t2 discard tablespace;
create table t1 (x int);
insert into t1 values (1);
alter table t1 add z int default 42, algorithm instant;
select * from t1;
flush tables t1 for export;
--let $MYSQLD_DATADIR= `select @@datadir`
--move_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/test/t2.cfg
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t2.ibd
unlock tables;
--echo # The metadata has to be updated to instant ADD COLUMN.
alter table t2 import tablespace;
select * from t2;
insert into t2 set x=2;
select * from t2;
alter table t1 discard tablespace;
flush tables t2 for export;
--move_file $MYSQLD_DATADIR/test/t2.cfg $MYSQLD_DATADIR/test/t1.cfg
--copy_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_DATADIR/test/t1.ibd
unlock tables;
--echo # Both the metadata and the data file used instant ADD COLUMN.
alter table t1 import tablespace;
select * from t1;
drop table t2;
create table t2 select * from t1;
alter table t1 discard tablespace;
flush tables t2 for export;
--move_file $MYSQLD_DATADIR/test/t2.cfg $MYSQLD_DATADIR/test/t1.cfg
--copy_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_DATADIR/test/t1.ibd
unlock tables;
--copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/test/t1b.cfg
--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t1b.ibd
--echo # The instant ADD COLUMN has to be removed from the metadata.
alter table t1 import tablespace;
select * from t1;
--echo # Remove metadata for instant DROP COLUMN, then import
alter table t1 drop x, add column x int first, algorithm instant;
select * from t1;
alter table t1 discard tablespace;
--move_file $MYSQLD_DATADIR/test/t1b.cfg $MYSQLD_DATADIR/test/t1.cfg
--move_file $MYSQLD_DATADIR/test/t1b.ibd $MYSQLD_DATADIR/test/t1.ibd
alter table t1 import tablespace;
select * from t1;
--echo # Import a data file that contains instant DROP COLUMN metadata
alter table t2 drop x;
alter table t1 drop x, force;
alter table t1 discard tablespace;
flush tables t2 for export;
--move_file $MYSQLD_DATADIR/test/t2.cfg $MYSQLD_DATADIR/test/t1.cfg
--copy_file $MYSQLD_DATADIR/test/t2.ibd $MYSQLD_DATADIR/test/t1.ibd
unlock tables;
--error ER_TABLE_SCHEMA_MISMATCH
alter table t1 import tablespace;
--error ER_TABLESPACE_DISCARDED
select * from t1;
--remove_file $MYSQLD_DATADIR/test/t1.cfg
--error ER_INTERNAL_ERROR
alter table t1 import tablespace;
--error ER_TABLESPACE_DISCARDED
select * from t1;
drop table t2;
drop table t1;
...@@ -171,10 +171,7 @@ int my_fclose(FILE *fd, myf MyFlags) ...@@ -171,10 +171,7 @@ int my_fclose(FILE *fd, myf MyFlags)
my_file_info[file].type= UNOPEN; my_file_info[file].type= UNOPEN;
} }
#ifndef _WIN32 #ifndef _WIN32
do err= fclose(fd);
{
err= fclose(fd);
} while (err == -1 && errno == EINTR);
#else #else
err= my_win_fclose(fd); err= my_win_fclose(fd);
#endif #endif
......
...@@ -7,7 +7,7 @@ PLUGIN_AUTHOR Sergey Vojtovich ...@@ -7,7 +7,7 @@ PLUGIN_AUTHOR Sergey Vojtovich
PLUGIN_DESCRIPTION User-defined variables PLUGIN_DESCRIPTION User-defined variables
PLUGIN_LICENSE GPL PLUGIN_LICENSE GPL
LOAD_OPTION ON LOAD_OPTION ON
PLUGIN_MATURITY Gamma PLUGIN_MATURITY Stable
SHOW CREATE TABLE INFORMATION_SCHEMA.USER_VARIABLES; SHOW CREATE TABLE INFORMATION_SCHEMA.USER_VARIABLES;
Table Create Table Table Create Table
user_variables CREATE TEMPORARY TABLE `user_variables` ( user_variables CREATE TEMPORARY TABLE `user_variables` (
......
...@@ -135,6 +135,6 @@ maria_declare_plugin(user_variables) ...@@ -135,6 +135,6 @@ maria_declare_plugin(user_variables)
NULL, NULL,
NULL, NULL,
"1.0", "1.0",
MariaDB_PLUGIN_MATURITY_GAMMA MariaDB_PLUGIN_MATURITY_STABLE
} }
maria_declare_plugin_end; maria_declare_plugin_end;
...@@ -443,6 +443,6 @@ maria_declare_plugin(sql_sequence) ...@@ -443,6 +443,6 @@ maria_declare_plugin(sql_sequence)
NULL, /* status variables */ NULL, /* status variables */
NULL, /* system variables */ NULL, /* system variables */
"1.0", /* string version */ "1.0", /* string version */
MariaDB_PLUGIN_MATURITY_ALPHA /* maturity */ MariaDB_PLUGIN_MATURITY_STABLE /* maturity */
} }
maria_declare_plugin_end; maria_declare_plugin_end;
...@@ -4,7 +4,7 @@ Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved. ...@@ -4,7 +4,7 @@ Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2008, 2009 Google Inc.
Copyright (c) 2009, Percona Inc. Copyright (c) 2009, Percona Inc.
Copyright (c) 2012, Facebook Inc. Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2013, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described Google, Inc. Those modifications are gratefully acknowledged and are described
...@@ -12717,10 +12717,7 @@ ha_innobase::discard_or_import_tablespace( ...@@ -12717,10 +12717,7 @@ ha_innobase::discard_or_import_tablespace(
DBUG_RETURN(HA_ERR_TABLE_READONLY); DBUG_RETURN(HA_ERR_TABLE_READONLY);
} }
dict_table_t* dict_table = m_prebuilt->table; if (m_prebuilt->table->is_temporary()) {
if (dict_table->is_temporary()) {
ib_senderrf( ib_senderrf(
m_prebuilt->trx->mysql_thd, IB_LOG_LEVEL_ERROR, m_prebuilt->trx->mysql_thd, IB_LOG_LEVEL_ERROR,
ER_CANNOT_DISCARD_TEMPORARY_TABLE); ER_CANNOT_DISCARD_TEMPORARY_TABLE);
...@@ -12728,11 +12725,11 @@ ha_innobase::discard_or_import_tablespace( ...@@ -12728,11 +12725,11 @@ ha_innobase::discard_or_import_tablespace(
DBUG_RETURN(HA_ERR_TABLE_NEEDS_UPGRADE); DBUG_RETURN(HA_ERR_TABLE_NEEDS_UPGRADE);
} }
if (dict_table->space == fil_system.sys_space) { if (m_prebuilt->table->space == fil_system.sys_space) {
ib_senderrf( ib_senderrf(
m_prebuilt->trx->mysql_thd, IB_LOG_LEVEL_ERROR, m_prebuilt->trx->mysql_thd, IB_LOG_LEVEL_ERROR,
ER_TABLE_IN_SYSTEM_TABLESPACE, ER_TABLE_IN_SYSTEM_TABLESPACE,
dict_table->name.m_name); m_prebuilt->table->name.m_name);
DBUG_RETURN(HA_ERR_TABLE_NEEDS_UPGRADE); DBUG_RETURN(HA_ERR_TABLE_NEEDS_UPGRADE);
} }
...@@ -12741,7 +12738,7 @@ ha_innobase::discard_or_import_tablespace( ...@@ -12741,7 +12738,7 @@ ha_innobase::discard_or_import_tablespace(
/* Obtain an exclusive lock on the table. */ /* Obtain an exclusive lock on the table. */
dberr_t err = row_mysql_lock_table( dberr_t err = row_mysql_lock_table(
m_prebuilt->trx, dict_table, LOCK_X, m_prebuilt->trx, m_prebuilt->table, LOCK_X,
discard ? "setting table lock for DISCARD TABLESPACE" discard ? "setting table lock for DISCARD TABLESPACE"
: "setting table lock for IMPORT TABLESPACE"); : "setting table lock for IMPORT TABLESPACE");
...@@ -12754,32 +12751,32 @@ ha_innobase::discard_or_import_tablespace( ...@@ -12754,32 +12751,32 @@ ha_innobase::discard_or_import_tablespace(
user may want to set the DISCARD flag in order to IMPORT user may want to set the DISCARD flag in order to IMPORT
a new tablespace. */ a new tablespace. */
if (!dict_table->is_readable()) { if (!m_prebuilt->table->is_readable()) {
ib_senderrf( ib_senderrf(
m_prebuilt->trx->mysql_thd, m_prebuilt->trx->mysql_thd,
IB_LOG_LEVEL_WARN, ER_TABLESPACE_MISSING, IB_LOG_LEVEL_WARN, ER_TABLESPACE_MISSING,
dict_table->name.m_name); m_prebuilt->table->name.m_name);
} }
err = row_discard_tablespace_for_mysql( err = row_discard_tablespace_for_mysql(
dict_table->name.m_name, m_prebuilt->trx); m_prebuilt->table->name.m_name, m_prebuilt->trx);
} else if (dict_table->is_readable()) { } else if (m_prebuilt->table->is_readable()) {
/* Commit the transaction in order to /* Commit the transaction in order to
release the table lock. */ release the table lock. */
trx_commit_for_mysql(m_prebuilt->trx); trx_commit_for_mysql(m_prebuilt->trx);
ib::error() << "Unable to import tablespace " ib::error() << "Unable to import tablespace "
<< dict_table->name << " because it already" << m_prebuilt->table->name << " because it already"
" exists. Please DISCARD the tablespace" " exists. Please DISCARD the tablespace"
" before IMPORT."; " before IMPORT.";
ib_senderrf( ib_senderrf(
m_prebuilt->trx->mysql_thd, IB_LOG_LEVEL_ERROR, m_prebuilt->trx->mysql_thd, IB_LOG_LEVEL_ERROR,
ER_TABLESPACE_EXISTS, dict_table->name.m_name); ER_TABLESPACE_EXISTS, m_prebuilt->table->name.m_name);
DBUG_RETURN(HA_ERR_TABLE_EXIST); DBUG_RETURN(HA_ERR_TABLE_EXIST);
} else { } else {
err = row_import_for_mysql(dict_table, m_prebuilt); err = row_import_for_mysql(m_prebuilt->table, m_prebuilt);
if (err == DB_SUCCESS) { if (err == DB_SUCCESS) {
...@@ -12795,12 +12792,35 @@ ha_innobase::discard_or_import_tablespace( ...@@ -12795,12 +12792,35 @@ ha_innobase::discard_or_import_tablespace(
/* Commit the transaction in order to release the table lock. */ /* Commit the transaction in order to release the table lock. */
trx_commit_for_mysql(m_prebuilt->trx); trx_commit_for_mysql(m_prebuilt->trx);
if (err == DB_SUCCESS && !discard if (discard || err != DB_SUCCESS) {
&& dict_stats_is_persistent_enabled(dict_table)) { DBUG_RETURN(convert_error_code_to_mysql(
err, m_prebuilt->table->flags, NULL));
}
/* Evict and reload the table definition in order to invoke
btr_cur_instant_init(). */
table_id_t id = m_prebuilt->table->id;
ut_ad(id);
mutex_enter(&dict_sys->mutex);
dict_table_close(m_prebuilt->table, TRUE, FALSE);
dict_table_remove_from_cache(m_prebuilt->table);
m_prebuilt->table = dict_table_open_on_id(id, TRUE,
DICT_TABLE_OP_NORMAL);
mutex_exit(&dict_sys->mutex);
if (!m_prebuilt->table) {
err = DB_TABLE_NOT_FOUND;
} else {
if (const Field* ai = table->found_next_number_field) {
initialize_auto_increment(m_prebuilt->table, ai);
}
dict_stats_init(m_prebuilt->table);
}
if (dict_stats_is_persistent_enabled(m_prebuilt->table)) {
dberr_t ret; dberr_t ret;
/* Adjust the persistent statistics. */ /* Adjust the persistent statistics. */
ret = dict_stats_update(dict_table, ret = dict_stats_update(m_prebuilt->table,
DICT_STATS_RECALC_PERSISTENT); DICT_STATS_RECALC_PERSISTENT);
if (ret != DB_SUCCESS) { if (ret != DB_SUCCESS) {
...@@ -12810,11 +12830,12 @@ ha_innobase::discard_or_import_tablespace( ...@@ -12810,11 +12830,12 @@ ha_innobase::discard_or_import_tablespace(
ER_ALTER_INFO, ER_ALTER_INFO,
"Error updating stats for table '%s'" "Error updating stats for table '%s'"
" after table rebuild: %s", " after table rebuild: %s",
dict_table->name.m_name, ut_strerr(ret)); m_prebuilt->table->name.m_name,
ut_strerr(ret));
} }
} }
DBUG_RETURN(convert_error_code_to_mysql(err, dict_table->flags, NULL)); DBUG_RETURN(0);
} }
/** /**
......
...@@ -1465,12 +1465,25 @@ instant_alter_column_possible( ...@@ -1465,12 +1465,25 @@ instant_alter_column_possible(
const TABLE* table, const TABLE* table,
const TABLE* altered_table) const TABLE* altered_table)
{ {
if (ha_alter_info->handler_flags
& (ALTER_STORED_COLUMN_ORDER | ALTER_DROP_STORED_COLUMN
| ALTER_ADD_STORED_BASE_COLUMN)) {
#if 1 // MDEV-17459: adjust fts_fetch_doc_from_rec() and friends; remove this #if 1 // MDEV-17459: adjust fts_fetch_doc_from_rec() and friends; remove this
if (ib_table.fts) { if (ib_table.fts) return false;
return false; #endif
} #if 1 // MDEV-17468: fix bugs with indexed virtual columns & remove this
for (const dict_index_t* index = ib_table.indexes.start;
index; index = index->indexes.next) {
if (index->has_virtual()) {
ut_ad(ib_table.n_v_cols);
return false;
}
}
#endif #endif
const dict_index_t* index = ib_table.indexes.start; }
const dict_index_t* const pk = ib_table.indexes.start;
ut_ad(pk->is_primary());
ut_ad(!pk->has_virtual());
if (ha_alter_info->handler_flags & ALTER_ADD_STORED_BASE_COLUMN) { if (ha_alter_info->handler_flags & ALTER_ADD_STORED_BASE_COLUMN) {
List_iterator_fast<Create_field> cf_it( List_iterator_fast<Create_field> cf_it(
ha_alter_info->alter_info->create_list); ha_alter_info->alter_info->create_list);
...@@ -1478,21 +1491,11 @@ instant_alter_column_possible( ...@@ -1478,21 +1491,11 @@ instant_alter_column_possible(
while (const Create_field* cf = cf_it++) { while (const Create_field* cf = cf_it++) {
n_add += !cf->field; n_add += !cf->field;
} }
if (index->n_fields >= REC_MAX_N_USER_FIELDS + DATA_N_SYS_COLS if (pk->n_fields >= REC_MAX_N_USER_FIELDS + DATA_N_SYS_COLS
- n_add) { - n_add) {
return false; return false;
} }
} }
#if 1 // MDEV-17468: fix bugs with indexed virtual columns & remove this
ut_ad(index->is_primary());
ut_ad(!index->has_virtual());
while ((index = index->indexes.next) != NULL) {
if (index->has_virtual()) {
ut_ad(ib_table.n_v_cols);
return false;
}
}
#endif
// Making table system-versioned instantly is not implemented yet. // Making table system-versioned instantly is not implemented yet.
if (ha_alter_info->handler_flags & ALTER_ADD_SYSTEM_VERSIONING) { if (ha_alter_info->handler_flags & ALTER_ADD_SYSTEM_VERSIONING) {
return false; return false;
...@@ -1559,7 +1562,6 @@ instant_alter_column_possible( ...@@ -1559,7 +1562,6 @@ instant_alter_column_possible(
return false; return false;
} }
const dict_index_t* pk = ib_table.indexes.start;
Field** af = altered_table->field; Field** af = altered_table->field;
Field** const end = altered_table->field Field** const end = altered_table->field
+ altered_table->s->fields; + altered_table->s->fields;
......
...@@ -1829,13 +1829,39 @@ PageConverter::update_index_page( ...@@ -1829,13 +1829,39 @@ PageConverter::update_index_page(
if (dict_index_is_clust(m_index->m_srv_index)) { if (dict_index_is_clust(m_index->m_srv_index)) {
if (page_is_root(page)) { if (page_is_root(page)) {
dict_index_t* index = const_cast<dict_index_t*>(
m_index->m_srv_index);
/* Preserve the PAGE_ROOT_AUTO_INC. */ /* Preserve the PAGE_ROOT_AUTO_INC. */
if (m_index->m_srv_index->table->supports_instant() if (index->table->supports_instant()) {
&& btr_cur_instant_root_init( if (btr_cur_instant_root_init(index, page)) {
const_cast<dict_index_t*>( return(DB_CORRUPTION);
m_index->m_srv_index), }
page)) {
return(DB_CORRUPTION); if (index->n_core_fields > index->n_fields) {
/* Some columns have been dropped.
Refuse to IMPORT TABLESPACE for now.
NOTE: This is not an accurate check.
Columns could have been both
added and dropped instantly.
For an accurate check, we must read
the metadata BLOB page pointed to
by the leftmost leaf page.
But we would have to read
those pages in a special way,
bypassing the buffer pool! */
return DB_UNSUPPORTED;
}
/* Provisionally set all instantly
added columns to be DEFAULT NULL. */
for (unsigned i = index->n_core_fields;
i < index->n_fields; i++) {
dict_col_t* col = index->fields[i].col;
col->def_val.len = UNIV_SQL_NULL;
col->def_val.data = NULL;
}
} }
} else { } else {
/* Clear PAGE_MAX_TRX_ID so that it can be /* Clear PAGE_MAX_TRX_ID so that it can be
......
...@@ -3079,13 +3079,14 @@ row_discard_tablespace( ...@@ -3079,13 +3079,14 @@ row_discard_tablespace(
table->flags2 |= DICT_TF2_DISCARDED; table->flags2 |= DICT_TF2_DISCARDED;
dict_table_change_id_in_cache(table, new_id); dict_table_change_id_in_cache(table, new_id);
/* Reset the root page numbers. */ dict_index_t* index = UT_LIST_GET_FIRST(table->indexes);
if (index) index->clear_instant_alter();
for (dict_index_t* index = UT_LIST_GET_FIRST(table->indexes); /* Reset the root page numbers. */
index != 0; for (; index; index = UT_LIST_GET_NEXT(indexes, index)) {
index = UT_LIST_GET_NEXT(indexes, index)) {
index->page = FIL_NULL; index->page = FIL_NULL;
} }
/* If the tablespace did not already exist or we couldn't /* If the tablespace did not already exist or we couldn't
write to it, we treat that as a successful DISCARD. It is write to it, we treat that as a successful DISCARD. It is
unusable anyway. */ unusable anyway. */
......
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