Commit c1d7b457 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-26870 --skip-symbolic-links does not disallow .isl file creation

The InnoDB DATA DIRECTORY attribute is not implemented via
symbolic links but something similar, *.isl files that contain
the names of data files.

InnoDB failed to ignore the DATA DIRECTORY attribute even though
the server was started with --skip-symbolic-links.

Native ALTER TABLE in InnoDB will retain the DATA DIRECTORY attribute
of the table, no matter if the table will be rebuilt or not.

Generic ALTER TABLE (with ALGORITHM=COPY) as well as TRUNCATE TABLE
will discard the DATA DIRECTORY attribute.

All tests have been run with and without the ./mtr option
--mysqld=--skip-symbolic-links
and some tests that use the InnoDB DATA DIRECTORY attribute
have been adjusted for this.
parent fa7a67ff
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
Copyright (c) 2010, 2021, MariaDB Corporation.
Copyright (c) 2010, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -276,7 +276,7 @@ extern int my_umask_dir,
my_recived_signals, /* Signals we have got */
my_safe_to_handle_signal, /* Set when allowed to SIGTSTP */
my_dont_interrupt; /* call remember_intr when set */
extern my_bool my_use_symdir;
extern MYSQL_PLUGIN_IMPORT my_bool my_use_symdir;
extern ulong my_default_record_cache_size;
extern MYSQL_PLUGIN_IMPORT my_bool my_disable_locking;
......
DROP TABLE IF EXISTS t1,t2,t3;
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id, id),
FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE,
......
-- source include/have_innodb.inc
-- source include/have_file_key_management_plugin.inc
-- source include/not_embedded.inc
-- source include/have_symlink.inc
--disable_warnings
SET GLOBAL innodb_file_format = `Barracuda`;
......
SELECT @@have_symlink;
@@have_symlink
DISABLED
CREATE TABLE t1(a INT) ENGINE=InnoDB DATA DIRECTORY 'MYSQL_TMP_DIR';
Warnings:
Warning 1618 <DATA DIRECTORY> option ignored
DROP TABLE t1;
CREATE TABLE t1(a INT) ENGINE=InnoDB;
ALTER TABLE t1 DATA DIRECTORY 'MYSQL_TMP_DIR';
Warnings:
Warning 1618 <DATA DIRECTORY> option ignored
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1(a INT PRIMARY KEY, b INT) ENGINE=InnoDB
DATA DIRECTORY 'MYSQL_TMP_DIR';
CREATE TABLE t2(a INT PRIMARY KEY, b INT) ENGINE=InnoDB
DATA DIRECTORY 'MYSQL_TMP_DIR';
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
ALTER TABLE t1 FORCE, ALGORITHM=INPLACE;
Warnings:
Warning 1618 <DATA DIRECTORY> option ignored
ALTER TABLE t2 FORCE, ALGORITHM=COPY;
Warnings:
Warning 1618 <DATA DIRECTORY> option ignored
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
test.t1 optimize status OK
Warnings:
Warning 1618 <DATA DIRECTORY> option ignored
t1.ibd
DROP TABLE t2;
RENAME TABLE t1 TO t2;
ALTER TABLE t2 ADD UNIQUE INDEX(b), RENAME TO t3;
Warnings:
Warning 1618 <DATA DIRECTORY> option ignored
ALTER TABLE t3 RENAME TO t2;
ALTER TABLE t2 DROP INDEX b, RENAME TO t1;
Warnings:
Warning 1618 <DATA DIRECTORY> option ignored
ALTER TABLE t1 CHANGE b c INT;
Warnings:
Warning 1618 <DATA DIRECTORY> option ignored
ALTER TABLE t1 CHANGE c b INT NOT NULL;
Warnings:
Warning 1618 <DATA DIRECTORY> option ignored
t1.ibd
TRUNCATE TABLE t1;
DROP TABLE t1;
--source include/innodb_page_size.inc
--source include/not_embedded.inc
--source include/have_symlink.inc
-- echo #
-- echo # MDEV-11623 MariaDB 10.1 fails to start datadir created with
......
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/have_symlink.inc
--disable_query_log
CALL mtr.add_suppression(".*Failed to set O_DIRECT on file.*");
......
......@@ -4,6 +4,7 @@
--echo #
--source include/have_innodb.inc
--source include/have_symlink.inc
--disable_query_log
# These values can change during the test
......
......@@ -8,6 +8,7 @@
--source include/not_embedded.inc
--source include/have_debug.inc
--source include/have_innodb.inc
--source include/have_symlink.inc
# These messages are expected in the log
call mtr.add_suppression("Cannot find space id [0-9]+ in the tablespace memory cache");
......
--source include/innodb_page_size.inc
--source include/not_embedded.inc
--source include/have_symlink.inc
let datadir= `select @@datadir`;
let page_size= `select @@innodb_page_size`;
......
--source include/have_innodb.inc
--source include/not_windows.inc
SELECT @@have_symlink;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE t1(a INT) ENGINE=InnoDB DATA DIRECTORY '$MYSQL_TMP_DIR';
DROP TABLE t1;
CREATE TABLE t1(a INT) ENGINE=InnoDB;
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval ALTER TABLE t1 DATA DIRECTORY '$MYSQL_TMP_DIR';
SHOW CREATE TABLE t1;
DROP TABLE t1;
--let $restart_parameters=--symbolic-links
--source include/restart_mysqld.inc
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE t1(a INT PRIMARY KEY, b INT) ENGINE=InnoDB
DATA DIRECTORY '$MYSQL_TMP_DIR';
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval CREATE TABLE t2(a INT PRIMARY KEY, b INT) ENGINE=InnoDB
DATA DIRECTORY '$MYSQL_TMP_DIR';
TRUNCATE TABLE t1;
TRUNCATE TABLE t2;
--let $restart_parameters=
--source include/restart_mysqld.inc
# Native ALTER will retain DATA DIRECTORY
ALTER TABLE t1 FORCE, ALGORITHM=INPLACE;
ALTER TABLE t2 FORCE, ALGORITHM=COPY;
OPTIMIZE TABLE t1;
--list_files $MYSQL_TMP_DIR/test
DROP TABLE t2;
RENAME TABLE t1 TO t2;
ALTER TABLE t2 ADD UNIQUE INDEX(b), RENAME TO t3;
ALTER TABLE t3 RENAME TO t2;
ALTER TABLE t2 DROP INDEX b, RENAME TO t1;
ALTER TABLE t1 CHANGE b c INT;
ALTER TABLE t1 CHANGE c b INT NOT NULL;
--list_files $MYSQL_TMP_DIR/test
# TRUNCATE TABLE will discard DATA DIRECTORY.
TRUNCATE TABLE t1;
--list_files $MYSQL_TMP_DIR/test
DROP TABLE t1;
......@@ -4,6 +4,7 @@
--source include/innodb_page_size_small.inc
--source include/have_partition.inc
--source include/not_embedded.inc
--source include/have_symlink.inc
SET default_storage_engine=InnoDB;
LET $MYSQLD_DATADIR = `select @@datadir`;
LET $INNODB_PAGE_SIZE = `select @@innodb_page_size`;
......
--source include/have_debug.inc
--source include/have_symlink.inc
let $table_data_dir=$MYSQLTEST_VARDIR/tmp/ddir;
let $targetdir=$MYSQLTEST_VARDIR/tmp/backup;
mkdir $table_data_dir;
......
--source include/have_symlink.inc
let $table_data_dir=$MYSQLTEST_VARDIR/ddir;
mkdir $table_data_dir;
--replace_result $table_data_dir table_data_dir
......
--source include/have_partition.inc
--source include/have_symlink.inc
let $targetdir=$MYSQLTEST_VARDIR/backup;
mkdir $targetdir;
mkdir $MYSQLTEST_VARDIR/partitdata;
......
--source include/have_innodb.inc
--source include/have_partition.inc
--source include/have_symlink.inc
--echo #
--echo # MDEV-15953 Alter InnoDB Partitioned Table Moves Files (which were originally not in the datadir) to the datadir
......
--source include/have_innodb.inc
--source include/have_partition.inc
--source include/have_symlink.inc
--echo #
--echo # MDEV-15953 Alter InnoDB Partitioned Table Moves Files (which were originally not in the datadir) to the datadir
......
-- source include/testdb_only.inc
-- source include/have_innodb.inc
--disable_warnings
DROP TABLE IF EXISTS t1,t2,t3;
--enable_warnings
-- source include/have_symlink.inc
#
# Test for KEY_COLUMN_USAGE & TABLE_CONSTRAINTS tables
......
......@@ -4,7 +4,7 @@ Copyright (c) 2000, 2020, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, 2009 Google Inc.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2021, MariaDB Corporation.
Copyright (c) 2013, 2022, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
......@@ -11710,9 +11710,12 @@ create_table_info_t::create_options_are_invalid()
break;
}
if (m_create_info->data_file_name
&& m_create_info->data_file_name[0] != '\0'
&& !create_option_data_directory_is_valid()) {
if (!m_create_info->data_file_name
|| !m_create_info->data_file_name[0]) {
} else if (!my_use_symdir) {
my_error(WARN_OPTION_IGNORED, MYF(ME_JUST_WARNING),
"DATA DIRECTORY");
} else if (!create_option_data_directory_is_valid()) {
ret = "DATA DIRECTORY";
}
......@@ -11986,7 +11989,8 @@ create_table_info_t::parse_table_name(
CREATE TABLE ... DATA DIRECTORY={path} TABLESPACE={name}... ;
we ignore the DATA DIRECTORY. */
if (m_create_info->data_file_name
&& m_create_info->data_file_name[0] != '\0') {
&& m_create_info->data_file_name[0]
&& my_use_symdir) {
if (!create_option_data_directory_is_valid()) {
push_warning_printf(
m_thd, Sql_condition::WARN_LEVEL_WARN,
......@@ -12457,8 +12461,9 @@ create_table_info_t::set_tablespace_type(
used with TEMPORARY tables. */
m_use_data_dir =
m_use_file_per_table
&& (m_create_info->data_file_name != NULL)
&& (m_create_info->data_file_name[0] != '\0');
&& m_create_info->data_file_name
&& m_create_info->data_file_name[0]
&& my_use_symdir;
}
/** Initialize the create_table_info_t object.
......
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