summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMattias Jonsson <mattias.jonsson@sun.com>2010-03-11 14:00:36 +0100
committerMattias Jonsson <mattias.jonsson@sun.com>2010-03-11 14:00:36 +0100
commit90c200a216506ed5309d2bc4a20385875eb7d1a8 (patch)
tree8590a09a3c6ca29906488b2e35ef75794b82bce0
parent2e9045c8fdf2cf07eb2b1b5655ee40bd43a02f77 (diff)
downloadmariadb-git-90c200a216506ed5309d2bc4a20385875eb7d1a8.tar.gz
Bug#42954: SQL MODE 'NO_DIR_IN_CREATE' does not work with subpartitions
There was no check for DATA/INDEX DIRECTORY for subpartitions Added the same check as for partitions.
-rw-r--r--mysql-test/r/partition_error.result70
-rw-r--r--mysql-test/t/partition_error.test36
-rw-r--r--sql/partition_info.cc40
3 files changed, 131 insertions, 15 deletions
diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result
index b692203823d..c03d5e16a48 100644
--- a/mysql-test/r/partition_error.result
+++ b/mysql-test/r/partition_error.result
@@ -1,4 +1,74 @@
drop table if exists t1;
+#
+# Bug#42954: SQL MODE 'NO_DIR_IN_CREATE' does not work with
+# subpartitions
+SET @org_mode=@@sql_mode;
+SET @@sql_mode='NO_DIR_IN_CREATE';
+SELECT @@sql_mode;
+@@sql_mode
+NO_DIR_IN_CREATE
+CREATE TABLE t1 (id INT, purchased DATE)
+PARTITION BY RANGE(YEAR(purchased))
+SUBPARTITION BY HASH(TO_DAYS(purchased))
+(PARTITION p0 VALUES LESS THAN MAXVALUE
+DATA DIRECTORY = '/tmp/not-existing'
+INDEX DIRECTORY = '/tmp/not-existing');
+Warnings:
+Warning 1618 <DATA DIRECTORY> option ignored
+Warning 1618 <INDEX DIRECTORY> option ignored
+Warning 1618 <DATA DIRECTORY> option ignored
+Warning 1618 <INDEX DIRECTORY> option ignored
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) DEFAULT NULL,
+ `purchased` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (YEAR(purchased))
+SUBPARTITION BY HASH (TO_DAYS(purchased))
+(PARTITION p0 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
+DROP TABLE t1;
+CREATE TABLE t1 (id INT, purchased DATE)
+PARTITION BY RANGE(YEAR(purchased))
+SUBPARTITION BY HASH(TO_DAYS(purchased)) SUBPARTITIONS 2
+(PARTITION p0 VALUES LESS THAN MAXVALUE
+(SUBPARTITION sp0
+DATA DIRECTORY = '/tmp/not-existing'
+INDEX DIRECTORY = '/tmp/not-existing',
+SUBPARTITION sp1));
+Warnings:
+Warning 1618 <DATA DIRECTORY> option ignored
+Warning 1618 <INDEX DIRECTORY> option ignored
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) DEFAULT NULL,
+ `purchased` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (YEAR(purchased))
+SUBPARTITION BY HASH (TO_DAYS(purchased))
+(PARTITION p0 VALUES LESS THAN MAXVALUE
+ (SUBPARTITION sp0 ENGINE = MyISAM,
+ SUBPARTITION sp1 ENGINE = MyISAM)) */
+DROP TABLE t1;
+CREATE TABLE t1 (id INT, purchased DATE)
+PARTITION BY RANGE(YEAR(purchased))
+(PARTITION p0 VALUES LESS THAN MAXVALUE
+DATA DIRECTORY = '/tmp/not-existing'
+INDEX DIRECTORY = '/tmp/not-existing');
+Warnings:
+Warning 1618 <DATA DIRECTORY> option ignored
+Warning 1618 <INDEX DIRECTORY> option ignored
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `id` int(11) DEFAULT NULL,
+ `purchased` date DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY RANGE (YEAR(purchased))
+(PARTITION p0 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */
+DROP TABLE t1;
+SET @@sql_mode= @org_mode;
CREATE TABLE t1 (a INTEGER NOT NULL, PRIMARY KEY (a));
INSERT INTO t1 VALUES (1),(1);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test
index 1f011f36257..1f430c49a0f 100644
--- a/mysql-test/t/partition_error.test
+++ b/mysql-test/t/partition_error.test
@@ -7,7 +7,41 @@
--disable_warnings
drop table if exists t1;
--enable_warnings
-
+
+--echo #
+--echo # Bug#42954: SQL MODE 'NO_DIR_IN_CREATE' does not work with
+--echo # subpartitions
+SET @org_mode=@@sql_mode;
+SET @@sql_mode='NO_DIR_IN_CREATE';
+SELECT @@sql_mode;
+CREATE TABLE t1 (id INT, purchased DATE)
+PARTITION BY RANGE(YEAR(purchased))
+SUBPARTITION BY HASH(TO_DAYS(purchased))
+(PARTITION p0 VALUES LESS THAN MAXVALUE
+ DATA DIRECTORY = '/tmp/not-existing'
+ INDEX DIRECTORY = '/tmp/not-existing');
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+CREATE TABLE t1 (id INT, purchased DATE)
+PARTITION BY RANGE(YEAR(purchased))
+SUBPARTITION BY HASH(TO_DAYS(purchased)) SUBPARTITIONS 2
+(PARTITION p0 VALUES LESS THAN MAXVALUE
+ (SUBPARTITION sp0
+ DATA DIRECTORY = '/tmp/not-existing'
+ INDEX DIRECTORY = '/tmp/not-existing',
+ SUBPARTITION sp1));
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+CREATE TABLE t1 (id INT, purchased DATE)
+PARTITION BY RANGE(YEAR(purchased))
+(PARTITION p0 VALUES LESS THAN MAXVALUE
+ DATA DIRECTORY = '/tmp/not-existing'
+ INDEX DIRECTORY = '/tmp/not-existing');
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+SET @@sql_mode= @org_mode;
+
#
# Bug#38719: Partitioning returns a different error code for a
# duplicate key error
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index ba9ea0e876e..7a6250afbad 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -823,6 +823,30 @@ end:
DBUG_RETURN(result);
}
+/**
+ Check if we allow DATA/INDEX DIRECTORY, if not warn and set them to NULL.
+
+ @param thd THD also containing sql_mode (looks from MODE_NO_DIR_IN_CREATE).
+ @param part_elem partition_element to check.
+*/
+static void warn_if_dir_in_part_elem(THD *thd, partition_element *part_elem)
+{
+#ifdef HAVE_READLINK
+ if (!my_use_symdir || (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE))
+#endif
+ {
+ if (part_elem->data_file_name)
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED),
+ "DATA DIRECTORY");
+ if (part_elem->index_file_name)
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED),
+ "INDEX DIRECTORY");
+ part_elem->data_file_name= part_elem->index_file_name= NULL;
+ }
+}
+
/*
This code is used early in the CREATE TABLE and ALTER TABLE process.
@@ -950,20 +974,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
do
{
partition_element *part_elem= part_it++;
-#ifdef HAVE_READLINK
- if (!my_use_symdir || (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE))
-#endif
- {
- if (part_elem->data_file_name)
- push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED),
- "DATA DIRECTORY");
- if (part_elem->index_file_name)
- push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- WARN_OPTION_IGNORED, ER(WARN_OPTION_IGNORED),
- "INDEX DIRECTORY");
- part_elem->data_file_name= part_elem->index_file_name= NULL;
- }
+ warn_if_dir_in_part_elem(thd, part_elem);
if (!is_sub_partitioned())
{
if (part_elem->engine_type == NULL)
@@ -989,6 +1000,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
do
{
sub_elem= sub_it++;
+ warn_if_dir_in_part_elem(thd, sub_elem);
if (check_table_name(sub_elem->partition_name,
strlen(sub_elem->partition_name)))
{