mariadb/mysql-test/suite/innodb/r/alter_rename_existing.result
Marko Mäkelä e581396b7a MDEV-29983 Deprecate innodb_file_per_table
Before commit 6112853cda in MySQL 4.1.1
introduced the parameter innodb_file_per_table, all InnoDB data was
written to the InnoDB system tablespace (often named ibdata1).
A serious design problem is that once the system tablespace has grown to
some size, it cannot shrink even if the data inside it has been deleted.

There are also other design problems, such as the server hang MDEV-29930
that should only be possible when using innodb_file_per_table=0 and
innodb_undo_tablespaces=0 (storing both tables and undo logs in the
InnoDB system tablespace).

The parameter innodb_change_buffering was deprecated
in commit b5852ffbee.
Starting with commit baf276e6d4
(MDEV-19229) the number of innodb_undo_tablespaces can be increased,
so that the undo logs can be moved out of the system tablespace
of an existing installation.

If all these things (tables, undo logs, and the change buffer) are
removed from the InnoDB system tablespace, the only variable-size
data structure inside it is the InnoDB data dictionary.

DDL operations on .ibd files was optimized in
commit 86dc7b4d4c (MDEV-24626).
That should have removed any thinkable performance advantage of
using innodb_file_per_table=0.

Since there should be no benefit of setting innodb_file_per_table=0,
the parameter should be deprecated. Starting with MySQL 5.6 and
MariaDB Server 10.0, the default value is innodb_file_per_table=1.
2023-01-11 17:55:56 +02:00

101 lines
3.3 KiB
Text

#
# Show what happens during ALTER TABLE when an existing file
# exists in the target location.
#
# Bug #19218794: IF TABLESPACE EXISTS, CAN'T CREATE TABLE,
# BUT CAN ALTER ENGINE=INNODB
#
CREATE TABLE t1 (a SERIAL, b CHAR(10)) ENGINE=Memory;
INSERT INTO t1(b) VALUES('one'), ('two'), ('three');
#
# Create a file called MYSQLD_DATADIR/test/t1.ibd
# Directory listing of test/*.ibd
#
t1.ibd
ALTER TABLE t1 ENGINE = InnoDB;
ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 "Tablespace already exists")
#
# Move the file to InnoDB as t2
#
ALTER TABLE t1 RENAME TO t2, ENGINE = INNODB;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`b` char(10) DEFAULT NULL,
UNIQUE KEY `a` (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * from t2;
a b
1 one
2 two
3 three
ALTER TABLE t2 RENAME TO t1;
ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 "Tablespace already exists")
#
# Create another t1, but in the system tablespace.
#
SET GLOBAL innodb_file_per_table=OFF;
Warnings:
Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release
CREATE TABLE t1 (a SERIAL, b CHAR(20)) ENGINE=InnoDB;
INSERT INTO t1(b) VALUES('one'), ('two'), ('three');
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`b` char(20) DEFAULT NULL,
UNIQUE KEY `a` (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1';
name space=0
test/t1 1
#
# ALTER TABLE from system tablespace to system tablespace
#
ALTER TABLE t1 ADD COLUMN c INT, ALGORITHM=INPLACE;
ALTER TABLE t1 ADD COLUMN d INT, ALGORITHM=COPY;
#
# Try to move t1 from the system tablespace to a file-per-table
# while a blocking t1.ibd file exists.
#
SET GLOBAL innodb_file_per_table=ON;
Warnings:
Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release
ALTER TABLE t1 FORCE, ALGORITHM=INPLACE;
ERROR HY000: Tablespace for table 'test/#sql-ib' exists. Please DISCARD the tablespace before IMPORT
ALTER TABLE t1 FORCE, ALGORITHM=COPY;
ERROR HY000: Error on rename of 'OLD_FILE_NAME' to 'NEW_FILE_NAME' (errno: 184 "Tablespace already exists")
#
# Delete the blocking file called MYSQLD_DATADIR/test/t1.ibd
# Move t1 to file-per-table using ALGORITHM=INPLACE with no blocking t1.ibd.
#
ALTER TABLE t1 FORCE, ALGORITHM=INPLACE;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`b` char(20) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`d` int(11) DEFAULT NULL,
UNIQUE KEY `a` (`a`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1';
name space=0
test/t1 0
DROP TABLE t1;
#
# Rename t2.ibd to t1.ibd.
#
ALTER TABLE t2 RENAME TO t1;
SELECT name, space=0 FROM information_schema.innodb_sys_tables WHERE name = 'test/t1';
name space=0
test/t1 0
SELECT * from t1;
a b
1 one
2 two
3 three
DROP TABLE t1;
Warnings:
Warning 1287 '@@innodb_file_per_table' is deprecated and will be removed in a future release