3873 Mattias Jonsson 2012-04-13
Bug#11894100: EXCHANGE PARTITION CAN'T BE EXECUTED
IF ROW_FORMAT WAS SET EXPLICITLY
There was a check for explicitly set ROW_FORMAT when
comparing tables.
Fix was to compare the real used row_type and set the
create_info.row_type to the same as the explicitely set
ROW_FORMAT if both tables used the same row formats.
modified:
mysql-test/r/partition_exchange.result
mysql-test/suite/parts/r/partition_exch_qa_12.result
mysql-test/suite/parts/t/partition_exch_qa_12.test
mysql-test/t/partition_exchange.test
sql/sql_partition_admin.cc
3872 Alexander Barkov 2012-04-12
BUG#12537203 post-fix
1. Splitting NameString into three classes:
- low level SimpleCString without any code specific to identifier handling,
for easier iteraction with basic classes like String, and for possible
future use in other parts of the code.
- NameString, a base class with identifier specific allocation,
copying, comparison methods. It's a base class for all identifiers
(column, table, db, function names, etc)
It's also used in Item_xxx constructors, to pass column name.
Item_splocal, Item_get_user_var, Item_set_user_var,
Item_user_var_as_out_param already use it.
- ItemNameString, for column name handling, with warnings and
"autogenerated" flag handling.
- Changing argument types of methods from "NameString *" to "NameString".
The data type is very small, it's easier to put it on the stack as a whole
instead of putting a pointer and dereferences the pointer later.
2. Renaming eq() to eq_safe(). Introducing a new quick eq() method,
which assumes non-NULL pointers.
3. Fixing to create good m_str and m_length values.
strlen(m_ptr) is now always equal to m_length.
Adding DBUG_ASSERT to prevent out of sync values
to be passed to copy().
Per-file comments:
@ item.cc
- Moving warning code from NameString into ItemNameString
- Fixing NameString::copy() to create a good value:
strlen(m_ptr) is now always equal to m_length.
@ item.h
- Splitting NameString and ItemNameString
@ item_func.h
@ item_func.h
- Using new data types and methods
- Removing get_name() as it's never used.
@ item_xmlfunc.h
- Making sure to create an Item with a good NameString name.
Earlier m_ptr did not point to a null-terminated string.
Revealed by DBUG_ASSERT in SimpleCString::SimpeCString.
@ log_event.cc
- Fixing that Item_func_set_user_var was created with
non null-terminated name string.
@ sp_head.cc
- Using new append() method
- Fixing to use a proper constructor.
Revealed by DBUG_ASSERT in SimpleCString contructor.
@ sql_base.cc
- Renaming eq() to eq_safe()
@ sql_string.cc
- Introducing the low level class SimpleCString
- Adding String::append(), for easier String and SimpleCString interaction
@ sql_view.cc
- Changing data type from pointer to the structure itself.
@ sql_yacc.yy
- Removing my_name(). Using m_name directly.
@ sql_show.h
- Adding helper function append_identifier(), to pass SimpleCString easier
modified:
sql/item.cc
sql/item.h
sql/item_func.cc
sql/item_func.h
sql/item_timefunc.h
sql/item_xmlfunc.cc
sql/log_event.cc
sql/sp_head.cc
sql/sql_analyse.cc
sql/sql_base.cc
sql/sql_executor.cc
sql/sql_show.h
sql/sql_string.h
sql/sql_view.cc
sql/sql_yacc.yy
=== modified file 'mysql-test/r/partition_exchange.result'
--- a/mysql-test/r/partition_exchange.result revid:alexander.barkov@stripped
+++ b/mysql-test/r/partition_exchange.result revid:mattias.jonsson@stripped
@@ -1,5 +1,366 @@
DROP TABLE IF EXISTS t1, t2, t3, t, tp, tsp, tmp;
#
+# Bug#11894100: EXCHANGE PARTITION CAN'T BE EXECUTED IF
+# ROW_FORMAT WAS SET EXPLICITLY
+#
+# Same definition (both have ROW_FORMAT set)
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+year year(2) DEFAULT NULL,
+modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+PRIMARY KEY (id)
+) ENGINE=InnoDB ROW_FORMAT=COMPACT
+PARTITION BY HASH (id)
+PARTITIONS 2;
+CREATE TABLE t2 LIKE t1;
+ALTER TABLE t2 REMOVE PARTITIONING;
+SHOW CREATE TABLE t1;
+Table t1
+Create Table CREATE TABLE `t1` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
+/*!50100 PARTITION BY HASH (id)
+PARTITIONS 2 */
+SHOW CREATE TABLE t2;
+Table t2
+Create Table CREATE TABLE `t2` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+TABLE_NAME t1
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Compact
+CREATE_OPTIONS row_format=COMPACT partitioned
+TABLE_NAME t2
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Compact
+CREATE_OPTIONS row_format=COMPACT
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
+SHOW CREATE TABLE t1;
+Table t1
+Create Table CREATE TABLE `t1` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
+/*!50100 PARTITION BY HASH (id)
+PARTITIONS 2 */
+SHOW CREATE TABLE t2;
+Table t2
+Create Table CREATE TABLE `t2` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+TABLE_NAME t1
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Compact
+CREATE_OPTIONS row_format=COMPACT partitioned
+TABLE_NAME t2
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Compact
+CREATE_OPTIONS row_format=COMPACT
+DROP TABLE t2;
+# Only the partitioned table have ROW_FORMAT set.
+CREATE TABLE t2 (
+id int(11) NOT NULL AUTO_INCREMENT,
+year year(2) DEFAULT NULL,
+modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+PRIMARY KEY (id)
+) ENGINE=InnoDB;
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
+SHOW CREATE TABLE t1;
+Table t1
+Create Table CREATE TABLE `t1` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
+/*!50100 PARTITION BY HASH (id)
+PARTITIONS 2 */
+SHOW CREATE TABLE t2;
+Table t2
+Create Table CREATE TABLE `t2` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+TABLE_NAME t1
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Compact
+CREATE_OPTIONS row_format=COMPACT partitioned
+TABLE_NAME t2
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Compact
+CREATE_OPTIONS
+# Only the non partitioned table have ROW_FORMAT set.
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+year year(2) DEFAULT NULL,
+modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+PRIMARY KEY (id)
+) ENGINE=InnoDB
+PARTITION BY HASH (id)
+PARTITIONS 2;
+CREATE TABLE t2 (
+id int(11) NOT NULL AUTO_INCREMENT,
+year year(2) DEFAULT NULL,
+modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+PRIMARY KEY (id)
+) ENGINE=InnoDB ROW_FORMAT = COMPACT;
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
+SHOW CREATE TABLE t1;
+Table t1
+Create Table CREATE TABLE `t1` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY HASH (id)
+PARTITIONS 2 */
+SHOW CREATE TABLE t2;
+Table t2
+Create Table CREATE TABLE `t2` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+TABLE_NAME t1
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Compact
+CREATE_OPTIONS partitioned
+TABLE_NAME t2
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Compact
+CREATE_OPTIONS row_format=COMPACT
+# No table have ROW_FORMAT set.
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+year year(2) DEFAULT NULL,
+modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+PRIMARY KEY (id)
+) ENGINE=InnoDB
+PARTITION BY HASH (id)
+PARTITIONS 2;
+CREATE TABLE t2 (
+id int(11) NOT NULL AUTO_INCREMENT,
+year year(2) DEFAULT NULL,
+modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+PRIMARY KEY (id)
+) ENGINE=InnoDB;
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
+SHOW CREATE TABLE t1;
+Table t1
+Create Table CREATE TABLE `t1` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY HASH (id)
+PARTITIONS 2 */
+SHOW CREATE TABLE t2;
+Table t2
+Create Table CREATE TABLE `t2` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+TABLE_NAME t1
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Compact
+CREATE_OPTIONS partitioned
+TABLE_NAME t2
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Compact
+CREATE_OPTIONS
+# Not same ROW_FORMAT as default (but same).
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+year year(2) DEFAULT NULL,
+modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+PRIMARY KEY (id)
+) ENGINE=InnoDB ROW_FORMAT = REDUNDANT
+PARTITION BY HASH (id)
+PARTITIONS 2;
+CREATE TABLE t2 (
+id int(11) NOT NULL AUTO_INCREMENT,
+year year(2) DEFAULT NULL,
+modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+PRIMARY KEY (id)
+) ENGINE=InnoDB ROW_FORMAT = REDUNDANT;
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
+SHOW CREATE TABLE t1;
+Table t1
+Create Table CREATE TABLE `t1` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT
+/*!50100 PARTITION BY HASH (id)
+PARTITIONS 2 */
+SHOW CREATE TABLE t2;
+Table t2
+Create Table CREATE TABLE `t2` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+TABLE_NAME t1
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Redundant
+CREATE_OPTIONS row_format=REDUNDANT partitioned
+TABLE_NAME t2
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Redundant
+CREATE_OPTIONS row_format=REDUNDANT
+# Not same ROW_FORMAT as default (tables differs).
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+year year(2) DEFAULT NULL,
+modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+PRIMARY KEY (id)
+) ENGINE=InnoDB
+PARTITION BY HASH (id)
+PARTITIONS 2;
+CREATE TABLE t2 (
+id int(11) NOT NULL AUTO_INCREMENT,
+year year(2) DEFAULT NULL,
+modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+PRIMARY KEY (id)
+) ENGINE=InnoDB ROW_FORMAT = REDUNDANT;
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
+ERROR HY000: Non matching attribute 'ROW_FORMAT' between partition and table
+SHOW CREATE TABLE t1;
+Table t1
+Create Table CREATE TABLE `t1` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+/*!50100 PARTITION BY HASH (id)
+PARTITIONS 2 */
+SHOW CREATE TABLE t2;
+Table t2
+Create Table CREATE TABLE `t2` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+TABLE_NAME t1
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Compact
+CREATE_OPTIONS partitioned
+TABLE_NAME t2
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Redundant
+CREATE_OPTIONS row_format=REDUNDANT
+# Different than default (forced ROW_TYPE)
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+id int(11) NOT NULL AUTO_INCREMENT,
+year year(2) DEFAULT NULL,
+modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+PRIMARY KEY (id)
+) ENGINE=InnoDB ROW_FORMAT = COMPACT
+PARTITION BY HASH (id)
+PARTITIONS 2;
+CREATE TABLE t2 (
+id int(11) NOT NULL AUTO_INCREMENT,
+year year(2) DEFAULT NULL,
+modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+PRIMARY KEY (id)
+) ENGINE=InnoDB ROW_FORMAT = REDUNDANT;
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
+ERROR HY000: Non matching attribute 'ROW_FORMAT' between partition and table
+SHOW CREATE TABLE t1;
+Table t1
+Create Table CREATE TABLE `t1` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
+/*!50100 PARTITION BY HASH (id)
+PARTITIONS 2 */
+SHOW CREATE TABLE t2;
+Table t2
+Create Table CREATE TABLE `t2` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `year` year(2) DEFAULT NULL,
+ `modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+TABLE_NAME t1
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Compact
+CREATE_OPTIONS row_format=COMPACT partitioned
+TABLE_NAME t2
+TABLE_TYPE BASE TABLE
+ENGINE InnoDB
+ROW_FORMAT Redundant
+CREATE_OPTIONS row_format=REDUNDANT
+DROP TABLE t1, t2;
+#
# Bug#56484: !table || (!table->read_set ||
# bitmap_is_set(table->read_set, field_index))
#
=== modified file 'mysql-test/suite/parts/r/partition_exch_qa_12.result'
--- a/mysql-test/suite/parts/r/partition_exch_qa_12.result revid:alexander.barkov@stripped
+++ b/mysql-test/suite/parts/r/partition_exch_qa_12.result revid:mattias.jonsson@stripped
@@ -101,8 +101,12 @@ a b
9 Nine
ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
ERROR HY000: Tables have different definitions
+SELECT TABLE_NAME, ROW_FORMAT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test'
+AND TABLE_NAME IN ('tp', 't_100');
+TABLE_NAME ROW_FORMAT
+t_100 Dynamic
+tp Dynamic
ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
-ERROR HY000: Tables have different definitions
ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_1000;
ERROR HY000: Non matching attribute 'MAX_ROWS' between partition and table
DROP TABLE IF EXISTS t_10;
=== modified file 'mysql-test/suite/parts/t/partition_exch_qa_12.test'
--- a/mysql-test/suite/parts/t/partition_exch_qa_12.test revid:alexander.barkov@stripped
+++ b/mysql-test/suite/parts/t/partition_exch_qa_12.test revid:mattias.jonsson@stripped
@@ -164,7 +164,8 @@ SELECT * FROM tsp_04;
ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10;
#--error ER_TABLES_DIFFERENT_METADATA
#ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10 IGNORE;
---error ER_TABLES_DIFFERENT_METADATA
+SELECT TABLE_NAME, ROW_FORMAT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test'
+AND TABLE_NAME IN ('tp', 't_100');
ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100;
#--error ER_TABLES_DIFFERENT_METADATA
#ALTER TABLE tp EXCHANGE PARTITION p1 WITH TABLE t_100 IGNORE;
=== modified file 'mysql-test/t/partition_exchange.test'
--- a/mysql-test/t/partition_exchange.test revid:alexander.barkov@stripped
+++ b/mysql-test/t/partition_exchange.test revid:mattias.jonsson@stripped
@@ -6,6 +6,180 @@ DROP TABLE IF EXISTS t1, t2, t3, t, tp,
--enable_warnings
--echo #
+--echo # Bug#11894100: EXCHANGE PARTITION CAN'T BE EXECUTED IF
+--echo # ROW_FORMAT WAS SET EXPLICITLY
+--echo #
+
+--echo # Same definition (both have ROW_FORMAT set)
+CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ year year(2) DEFAULT NULL,
+ modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (id)
+) ENGINE=InnoDB ROW_FORMAT=COMPACT
+PARTITION BY HASH (id)
+PARTITIONS 2;
+
+CREATE TABLE t2 LIKE t1;
+ALTER TABLE t2 REMOVE PARTITIONING;
+
+--vertical_results
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+
+DROP TABLE t2;
+
+--echo # Only the partitioned table have ROW_FORMAT set.
+CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ year year(2) DEFAULT NULL,
+ modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (id)
+) ENGINE=InnoDB;
+
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+
+--echo # Only the non partitioned table have ROW_FORMAT set.
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ year year(2) DEFAULT NULL,
+ modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (id)
+) ENGINE=InnoDB
+PARTITION BY HASH (id)
+PARTITIONS 2;
+CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ year year(2) DEFAULT NULL,
+ modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (id)
+) ENGINE=InnoDB ROW_FORMAT = COMPACT;
+
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+
+--echo # No table have ROW_FORMAT set.
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ year year(2) DEFAULT NULL,
+ modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (id)
+) ENGINE=InnoDB
+PARTITION BY HASH (id)
+PARTITIONS 2;
+CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ year year(2) DEFAULT NULL,
+ modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (id)
+) ENGINE=InnoDB;
+
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+
+--echo # Not same ROW_FORMAT as default (but same).
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ year year(2) DEFAULT NULL,
+ modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (id)
+) ENGINE=InnoDB ROW_FORMAT = REDUNDANT
+PARTITION BY HASH (id)
+PARTITIONS 2;
+CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ year year(2) DEFAULT NULL,
+ modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (id)
+) ENGINE=InnoDB ROW_FORMAT = REDUNDANT;
+
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+
+--echo # Not same ROW_FORMAT as default (tables differs).
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ year year(2) DEFAULT NULL,
+ modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (id)
+) ENGINE=InnoDB
+PARTITION BY HASH (id)
+PARTITIONS 2;
+CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ year year(2) DEFAULT NULL,
+ modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (id)
+) ENGINE=InnoDB ROW_FORMAT = REDUNDANT;
+
+--error ER_PARTITION_EXCHANGE_DIFFERENT_OPTION
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+
+--echo # Different than default (forced ROW_TYPE)
+DROP TABLE t1, t2;
+CREATE TABLE t1 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ year year(2) DEFAULT NULL,
+ modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (id)
+) ENGINE=InnoDB ROW_FORMAT = COMPACT
+PARTITION BY HASH (id)
+PARTITIONS 2;
+CREATE TABLE t2 (
+ id int(11) NOT NULL AUTO_INCREMENT,
+ year year(2) DEFAULT NULL,
+ modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ PRIMARY KEY (id)
+) ENGINE=InnoDB ROW_FORMAT = REDUNDANT;
+
+--error ER_PARTITION_EXCHANGE_DIFFERENT_OPTION
+ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t2;
+SHOW CREATE TABLE t1;
+SHOW CREATE TABLE t2;
+SELECT TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, CREATE_OPTIONS
+FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME IN ('t1', 't2');
+--horizontal_results
+DROP TABLE t1, t2;
+
+--echo #
--echo # Bug#56484: !table || (!table->read_set ||
--echo # bitmap_is_set(table->read_set, field_index))
--echo #
=== modified file 'sql/sql_partition_admin.cc'
--- a/sql/sql_partition_admin.cc revid:alexander.barkov@stripped
+++ b/sql/sql_partition_admin.cc revid:mattias.jonsson@stripped
@@ -203,6 +203,19 @@ static bool compare_table_with_partition
part_create_info.auto_increment_value=
table_create_info.auto_increment_value;
+ /* Check compatible row_types and set create_info accordingly. */
+ {
+ enum row_type part_row_type= part_table->file->get_row_type();
+ enum row_type table_row_type= table->file->get_row_type();
+ if (part_row_type != table_row_type)
+ {
+ my_error(ER_PARTITION_EXCHANGE_DIFFERENT_OPTION, MYF(0),
+ "ROW_FORMAT");
+ DBUG_RETURN(true);
+ }
+ part_create_info.row_type= table->s->row_type;
+ }
+
/*
NOTE: ha_blackhole does not support check_if_compatible_data,
so this always fail for blackhole tables.
@@ -222,6 +235,10 @@ static bool compare_table_with_partition
my_error(ER_TABLES_DIFFERENT_METADATA, MYF(0));
DBUG_RETURN(TRUE);
}
+ DBUG_ASSERT(table->s->db_create_options ==
+ part_table->s->db_create_options);
+ DBUG_ASSERT(table->s->db_options_in_use ==
+ part_table->s->db_options_in_use);
if (table_create_info.avg_row_length != part_create_info.avg_row_length)
{
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (mattias.jonsson:3872 to 3873) Bug#11894100 | Mattias Jonsson | 13 Apr |