1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-33442 REPAIR TABLE corrupts UUIDs

Problem:
REPAIR TABLE executed for a pre-MDEV-29959 table (with the old UUID format)
updated the server version in the FRM file without rewriting the data,
so it created a new FRM for old UUIDs. After that MariaDB could not
read UUIDs correctly.

Fix:

- Adding a new virtual method in class Type_handler:

      virtual bool type_handler_for_implicit_upgrade() const;

  * For the up-to-date data types it returns "this".
  * For the data types which need to be implicitly upgraded
    during REPAIR TABLE or ALTER TABLE, it returns a pointer
    to a new replacement data type handler.

    Old VARCHAR and old UUID type handlers override this method.
    See more comments below.

- Changing the semantics of the method

    Type_handler::Column_definition_implicit_upgrade(Column_definition *c)

  to the opposite, so now:
    * c->type_handler() references the old data type (to upgrade from)
    * "this" references the new data type (to upgrade to).

  Before this change Column_definition_implicit_upgrade() was supposed
  to be called with the old data type handler (to upgrade from).

  Renaming the method to Column_definition_implicit_upgrade_to_this(),
  to avoid automatic merges in this method.

  Reflecting this change in Create_field::upgrade_data_types().

- Replacing the hard-coded data type tests inside handler::check_old_types()
  to a call for the new virtual method
  Type_handler::type_handler_for_implicit_upgrade()

- Overriding Type_handler_fbt::type_handler_for_implicit_upgrade()
  to call a new method FbtImpl::type_handler_for_implicit_upgrade().

  Reasoning:

  Type_handler_fbt is a template, so it has access only to "this".
  So in case of UUID data types, the type handler for old UUID
  knows nothing about the type handler of new UUID inside sql_type_fixedbin.h.
  So let's have Type_handler_fbt delegate type_handler_for_implicit_upgrade()
  to its Type_collection, which knows both new UUID and old UUID.

- Adding Type_collection_uuid::type_handler_for_implicit_upgrade().
  It returns a pointer to the new UUID type handler.

- Overriding Type_handler_var_string::type_handler_for_implicit_upgrade()
  to return a pointer to type_handler_varchar (true VARCHAR).

- Cleanup: these two methods:
    handler::check_old_types()
    handler::ha_check_for_upgrade()
  were always called consequently.
  So moving the call for check_old_types() inside ha_check_for_upgrade(),
  and making check_old_types() private.

- Cleanup: removing the "bool varchar" parameter from fill_alter_inplace_info(),
  as its not used any more.
This commit is contained in:
Alexander Barkov
2024-02-14 12:21:59 +04:00
parent 74c97a41fc
commit 7246054cbb
17 changed files with 1154 additions and 64 deletions

View File

@@ -1323,3 +1323,176 @@ SET sql_mode=DEFAULT;
#
# End of 10.4 tests
#
#
# Start of 10.11 tests
#
#
# MDEV-33442 REPAIR TABLE corrupts UUIDs
#
CREATE PROCEDURE show_table()
BEGIN
SHOW CREATE TABLE t1;
SELECT VERSION FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
SELECT * FROM t1 ORDER BY a;
END;
$$
# Upgrade using REPAIR
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` decimal(10,2)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
9
a
123.45
123.46
123.47
CHECK TABLE t1 FOR UPGRADE;
Table Op Msg_type Msg_text
test.t1 check error Upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` decimal(10,2)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
9
a
123.45
123.46
123.47
CHECK TABLE t1 FOR UPGRADE;
Table Op Msg_type Msg_text
test.t1 check error Upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` decimal(10,2)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
9
a
123.45
123.46
123.47
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair status OK
# Expect old decimal, as it does not implicitly upgrade to new decimal
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` decimal(10,2)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a
123.45
123.46
123.47
CHECK TABLE t1 FOR UPGRADE;
Table Op Msg_type Msg_text
test.t1 check status OK
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` decimal(10,2)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a
123.45
123.46
123.47
DROP TABLE t1;
# Upgrade using ALTER, adding a table COMMENT
# Upgrade a 10.11.4 table using ALTER, adding a table COMMENT
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` decimal(10,2)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
9
a
123.45
123.46
123.47
# ALTER..INPLACE should fail - the FRM file is too old and needs upgrade
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test10';
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
ALTER IGNORE TABLE t1 COMMENT 'test11';
# Expect old decimal, as it does not implicitly upgrade to new decimal
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` decimal(10,2)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='test11'
VERSION
10
a
123.45
123.46
123.47
# Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test12';
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` decimal(10,2)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='test12'
VERSION
10
a
123.45
123.46
123.47
DROP TABLE t1;
# Upgrade using ALTER, adding a column DEFAULT
# Upgrade a 10.11.4 table using ALTER, adding a table COMMENT
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` decimal(10,2)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
9
a
123.45
123.46
123.47
# ALTER..INPLACE should fail - the FRM file is too old and needs upgrade
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY a DECIMAL(10,2) DEFAULT 10;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
ALTER IGNORE TABLE t1 MODIFY a DECIMAL(10,2) DEFAULT 11;
# Expect new decimal, as we explicitly redefined the data type
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` decimal(10,2) DEFAULT 11.00
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a
123.45
123.46
123.47
# Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY a DECIMAL(10,2) DEFAULT 12;
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` decimal(10,2) DEFAULT 12.00
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a
123.45
123.46
123.47
DROP TABLE t1;
DROP PROCEDURE show_table;
#
# End of 10.11 tests
#

View File

@@ -826,3 +826,93 @@ SET sql_mode=DEFAULT;
--echo #
--echo # End of 10.4 tests
--echo #
--echo #
--echo # Start of 10.11 tests
--echo #
--echo #
--echo # MDEV-33442 REPAIR TABLE corrupts UUIDs
--echo #
DELIMITER $$;
CREATE PROCEDURE show_table()
BEGIN
SHOW CREATE TABLE t1;
SELECT VERSION FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
SELECT * FROM t1 ORDER BY a;
END;
$$
DELIMITER ;$$
--echo # Upgrade using REPAIR
--copy_file std_data/old_decimal/t1dec102.frm $MYSQLD_DATADIR/test/t1.frm
--copy_file std_data/old_decimal/t1dec102.MYD $MYSQLD_DATADIR/test/t1.MYD
--copy_file std_data/old_decimal/t1dec102.MYI $MYSQLD_DATADIR/test/t1.MYI
CALL show_table;
CHECK TABLE t1 FOR UPGRADE;
CALL show_table;
CHECK TABLE t1 FOR UPGRADE;
CALL show_table;
REPAIR TABLE t1;
--echo # Expect old decimal, as it does not implicitly upgrade to new decimal
CALL show_table;
CHECK TABLE t1 FOR UPGRADE;
CALL show_table;
DROP TABLE t1;
--echo # Upgrade using ALTER, adding a table COMMENT
--echo # Upgrade a 10.11.4 table using ALTER, adding a table COMMENT
--copy_file std_data/old_decimal/t1dec102.frm $MYSQLD_DATADIR/test/t1.frm
--copy_file std_data/old_decimal/t1dec102.MYD $MYSQLD_DATADIR/test/t1.MYD
--copy_file std_data/old_decimal/t1dec102.MYI $MYSQLD_DATADIR/test/t1.MYI
CALL show_table;
--echo # ALTER..INPLACE should fail - the FRM file is too old and needs upgrade
--error ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test10';
ALTER IGNORE TABLE t1 COMMENT 'test11';
-- echo # Expect old decimal, as it does not implicitly upgrade to new decimal
CALL show_table;
--echo # Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test12';
CALL show_table;
DROP TABLE t1;
--echo # Upgrade using ALTER, adding a column DEFAULT
--echo # Upgrade a 10.11.4 table using ALTER, adding a table COMMENT
--copy_file std_data/old_decimal/t1dec102.frm $MYSQLD_DATADIR/test/t1.frm
--copy_file std_data/old_decimal/t1dec102.MYD $MYSQLD_DATADIR/test/t1.MYD
--copy_file std_data/old_decimal/t1dec102.MYI $MYSQLD_DATADIR/test/t1.MYI
CALL show_table;
--echo # ALTER..INPLACE should fail - the FRM file is too old and needs upgrade
--error ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY a DECIMAL(10,2) DEFAULT 10;
ALTER IGNORE TABLE t1 MODIFY a DECIMAL(10,2) DEFAULT 11;
--echo # Expect new decimal, as we explicitly redefined the data type
CALL show_table;
--echo # Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY a DECIMAL(10,2) DEFAULT 12;
CALL show_table;
DROP TABLE t1;
DROP PROCEDURE show_table;
--echo #
--echo # End of 10.11 tests
--echo #

View File

@@ -111,3 +111,152 @@ t2 CREATE TABLE `t2` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1old;
DROP PROCEDURE p1;
#
# Start of 10.11 tests
#
#
# MDEV-33442 REPAIR TABLE corrupts UUIDs
#
CREATE PROCEDURE show_table()
BEGIN
SHOW CREATE TABLE t1;
SELECT VERSION FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
SELECT * FROM t1 ORDER BY a,b;
END;
$$
# Upgrade using REPAIR
TRUNCATE TABLE t1;
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255)/*old*/ DEFAULT NULL,
`b` varchar(255)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
9
a b
CHECK TABLE t1 FOR UPGRADE;
Table Op Msg_type Msg_text
test.t1 check error Upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255)/*old*/ DEFAULT NULL,
`b` varchar(255)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
9
a b
CHECK TABLE t1 FOR UPGRADE;
Table Op Msg_type Msg_text
test.t1 check error Upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255)/*old*/ DEFAULT NULL,
`b` varchar(255)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
9
a b
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair status OK
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255) DEFAULT NULL,
`b` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
CHECK TABLE t1 FOR UPGRADE;
Table Op Msg_type Msg_text
test.t1 check status OK
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255) DEFAULT NULL,
`b` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
DROP TABLE t1;
# Upgrade using ALTER, adding a table COMMENT
TRUNCATE TABLE t1;
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255)/*old*/ DEFAULT NULL,
`b` varchar(255)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
9
a b
# ALTER..INPLACE should fail - the old columns need upgrade
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test10';
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
ALTER IGNORE TABLE t1 COMMENT 'test11';
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255) DEFAULT NULL,
`b` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='test11'
VERSION
10
a b
# Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test12';
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255) DEFAULT NULL,
`b` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='test12'
VERSION
10
a b
DROP TABLE t1;
# Upgrade using ALTER, adding a column DEFAULT
TRUNCATE TABLE t1;
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255)/*old*/ DEFAULT NULL,
`b` varchar(255)/*old*/ DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
9
a b
# ALTER..INPLACE should fail - the old columns need upgrade
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY a VARBINARY(255) DEFAULT 'a10';
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
ALTER IGNORE TABLE t1 MODIFY a VARBINARY(255) DEFAULT 'a11';
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255) DEFAULT 'a11',
`b` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
# Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 MODIFY a VARBINARY(255) DEFAULT 'a12';
CALL show_table;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varbinary(255) DEFAULT 'a12',
`b` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
DROP TABLE t1;
DROP PROCEDURE show_table;
#
# End of 10.11 tests
#

View File

@@ -57,3 +57,88 @@ CALL p1('a');
DROP TABLE t1old;
DROP PROCEDURE p1;
--echo #
--echo # Start of 10.11 tests
--echo #
--echo #
--echo # MDEV-33442 REPAIR TABLE corrupts UUIDs
--echo #
DELIMITER $$;
CREATE PROCEDURE show_table()
BEGIN
SHOW CREATE TABLE t1;
SELECT VERSION FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
SELECT * FROM t1 ORDER BY a,b;
END;
$$
DELIMITER ;$$
--echo # Upgrade using REPAIR
--copy_file $MYSQL_TEST_DIR/std_data/bug19371.frm $MYSQLD_DATADIR/test/t1.frm
TRUNCATE TABLE t1;
CALL show_table;
CHECK TABLE t1 FOR UPGRADE;
CALL show_table;
CHECK TABLE t1 FOR UPGRADE;
CALL show_table;
REPAIR TABLE t1;
CALL show_table;
CHECK TABLE t1 FOR UPGRADE;
CALL show_table;
DROP TABLE t1;
--echo # Upgrade using ALTER, adding a table COMMENT
--copy_file $MYSQL_TEST_DIR/std_data/bug19371.frm $MYSQLD_DATADIR/test/t1.frm
TRUNCATE TABLE t1;
CALL show_table;
--echo # ALTER..INPLACE should fail - the old columns need upgrade
--error ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test10';
ALTER IGNORE TABLE t1 COMMENT 'test11';
CALL show_table;
--echo # Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test12';
CALL show_table;
DROP TABLE t1;
--echo # Upgrade using ALTER, adding a column DEFAULT
--copy_file $MYSQL_TEST_DIR/std_data/bug19371.frm $MYSQLD_DATADIR/test/t1.frm
TRUNCATE TABLE t1;
CALL show_table;
--echo # ALTER..INPLACE should fail - the old columns need upgrade
--error ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY a VARBINARY(255) DEFAULT 'a10';
ALTER IGNORE TABLE t1 MODIFY a VARBINARY(255) DEFAULT 'a11';
CALL show_table;
--echo # Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 MODIFY a VARBINARY(255) DEFAULT 'a12';
CALL show_table;
DROP TABLE t1;
DROP PROCEDURE show_table;
--echo #
--echo # End of 10.11 tests
--echo #

View File

@@ -103,7 +103,19 @@ public:
Field_mysql_timestampf(*name, rec, attr->unireg_check, share,
attr->temporal_dec(MAX_DATETIME_WIDTH));
}
void Column_definition_implicit_upgrade(Column_definition *c) const override
const Type_handler *type_handler_for_implicit_upgrade() const override
{
/*
The derived method as of 10.11.8 does "return this;" anyway.
However, in the future this may change to return a
opt_mysql56_temporal_format dependent handler.
Here in this class we need to make sure to do "return this;"
not to depend on the derived method changes.
*/
return this;
}
void Column_definition_implicit_upgrade_to_this(Column_definition *old)
const override
{
/*
Suppress the automatic upgrade depending on opt_mysql56_temporal_format,

View File

@@ -0,0 +1,422 @@
#
# Start of 10.11 tests
#
#
# MDEV-33442 REPAIR TABLE corrupts UUIDs
#
CREATE PROCEDURE show_table(long_version INT)
BEGIN
SHOW CREATE TABLE t1;
SELECT VERSION FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
IF long_version>0 THEN
SELECT * FROM t1 ORDER BY b;
ELSE
SELECT * FROM t1 ORDER BY a DESC LIMIT 5;
END IF;
END;
$$
# Upgrade a 10.11.4 table using REPAIR
CALL show_table(1);
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
`b` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
00001234-5566-0777-0888-99aabbccddee 0
10101234-5566-0777-8888-99aabbccddee 1
00201234-5566-0777-c888-99aabbccddee 2
10301234-5566-0777-e888-99aabbccddee 3
00401234-5566-1777-0888-99aabbccddee 4
10501234-5566-1777-8888-99aabbccddee 5
00601234-5566-1777-c888-99aabbccddee 6
10701234-5566-1777-e888-99aabbccddee 7
00801234-5566-2777-0888-99aabbccddee 8
10901234-5566-2777-8888-99aabbccddee 9
01001234-5566-2777-c888-99aabbccddee 10
11101234-5566-2777-e888-99aabbccddee 11
01201234-5566-3777-0888-99aabbccddee 12
11301234-5566-3777-8888-99aabbccddee 13
01401234-5566-3777-c888-99aabbccddee 14
11501234-5566-3777-e888-99aabbccddee 15
01601234-5566-4777-0888-99aabbccddee 16
11701234-5566-4777-8888-99aabbccddee 17
01801234-5566-4777-c888-99aabbccddee 18
11901234-5566-4777-e888-99aabbccddee 19
02001234-5566-5777-0888-99aabbccddee 20
12101234-5566-5777-8888-99aabbccddee 21
02201234-5566-5777-c888-99aabbccddee 22
12301234-5566-5777-e888-99aabbccddee 23
02401234-5566-6777-0888-99aabbccddee 24
12501234-5566-6777-8888-99aabbccddee 25
02601234-5566-6777-c888-99aabbccddee 26
12701234-5566-6777-e888-99aabbccddee 27
02801234-5566-7777-0888-99aabbccddee 28
12901234-5566-7777-8888-99aabbccddee 29
03001234-5566-7777-c888-99aabbccddee 30
13101234-5566-7777-e888-99aabbccddee 31
03201234-5566-8777-0888-99aabbccddee 32
13301234-5566-8777-8888-99aabbccddee 33
03401234-5566-8777-c888-99aabbccddee 34
13501234-5566-8777-e888-99aabbccddee 35
03601234-5566-9777-0888-99aabbccddee 36
13701234-5566-9777-8888-99aabbccddee 37
03801234-5566-9777-c888-99aabbccddee 38
13901234-5566-9777-e888-99aabbccddee 39
04001234-5566-a777-0888-99aabbccddee 40
14101234-5566-a777-8888-99aabbccddee 41
04201234-5566-a777-c888-99aabbccddee 42
14301234-5566-a777-e888-99aabbccddee 43
04401234-5566-b777-0888-99aabbccddee 44
14501234-5566-b777-8888-99aabbccddee 45
04601234-5566-b777-c888-99aabbccddee 46
14701234-5566-b777-e888-99aabbccddee 47
04801234-5566-c777-0888-99aabbccddee 48
14901234-5566-c777-8888-99aabbccddee 49
05001234-5566-c777-c888-99aabbccddee 50
15101234-5566-c777-e888-99aabbccddee 51
05201234-5566-d777-0888-99aabbccddee 52
15301234-5566-d777-8888-99aabbccddee 53
05401234-5566-d777-c888-99aabbccddee 54
15501234-5566-d777-e888-99aabbccddee 55
05601234-5566-e777-0888-99aabbccddee 56
15701234-5566-e777-8888-99aabbccddee 57
05801234-5566-e777-c888-99aabbccddee 58
15901234-5566-e777-e888-99aabbccddee 59
06001234-5566-f777-0888-99aabbccddee 60
16101234-5566-f777-8888-99aabbccddee 61
06201234-5566-f777-c888-99aabbccddee 62
16301234-5566-f777-e888-99aabbccddee 63
CHECK TABLE t1 FOR UPGRADE;
Table Op Msg_type Msg_text
test.t1 check error Upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
CALL show_table(0);
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
`b` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
16301234-5566-f777-e888-99aabbccddee 63
15901234-5566-e777-e888-99aabbccddee 59
15501234-5566-d777-e888-99aabbccddee 55
15101234-5566-c777-e888-99aabbccddee 51
14701234-5566-b777-e888-99aabbccddee 47
CHECK TABLE t1 FOR UPGRADE;
Table Op Msg_type Msg_text
test.t1 check error Upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
CALL show_table(0);
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
`b` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
16301234-5566-f777-e888-99aabbccddee 63
15901234-5566-e777-e888-99aabbccddee 59
15501234-5566-d777-e888-99aabbccddee 55
15101234-5566-c777-e888-99aabbccddee 51
14701234-5566-b777-e888-99aabbccddee 47
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair Warning Incorrect uuid value: '03201234-5566-8777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 33
test.t1 repair Warning Incorrect uuid value: '03601234-5566-9777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 37
test.t1 repair Warning Incorrect uuid value: '04001234-5566-a777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 41
test.t1 repair Warning Incorrect uuid value: '04401234-5566-b777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 45
test.t1 repair Warning Incorrect uuid value: '04801234-5566-c777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 49
test.t1 repair Warning Incorrect uuid value: '05201234-5566-d777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 53
test.t1 repair Warning Incorrect uuid value: '05601234-5566-e777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 57
test.t1 repair Warning Incorrect uuid value: '06001234-5566-f777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 61
test.t1 repair status OK
CALL show_table(1);
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
`b` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
00001234-5566-0777-0888-99aabbccddee 0
10101234-5566-0777-8888-99aabbccddee 1
00201234-5566-0777-c888-99aabbccddee 2
10301234-5566-0777-e888-99aabbccddee 3
00401234-5566-1777-0888-99aabbccddee 4
10501234-5566-1777-8888-99aabbccddee 5
00601234-5566-1777-c888-99aabbccddee 6
10701234-5566-1777-e888-99aabbccddee 7
00801234-5566-2777-0888-99aabbccddee 8
10901234-5566-2777-8888-99aabbccddee 9
01001234-5566-2777-c888-99aabbccddee 10
11101234-5566-2777-e888-99aabbccddee 11
01201234-5566-3777-0888-99aabbccddee 12
11301234-5566-3777-8888-99aabbccddee 13
01401234-5566-3777-c888-99aabbccddee 14
11501234-5566-3777-e888-99aabbccddee 15
01601234-5566-4777-0888-99aabbccddee 16
11701234-5566-4777-8888-99aabbccddee 17
01801234-5566-4777-c888-99aabbccddee 18
11901234-5566-4777-e888-99aabbccddee 19
02001234-5566-5777-0888-99aabbccddee 20
12101234-5566-5777-8888-99aabbccddee 21
02201234-5566-5777-c888-99aabbccddee 22
12301234-5566-5777-e888-99aabbccddee 23
02401234-5566-6777-0888-99aabbccddee 24
12501234-5566-6777-8888-99aabbccddee 25
02601234-5566-6777-c888-99aabbccddee 26
12701234-5566-6777-e888-99aabbccddee 27
02801234-5566-7777-0888-99aabbccddee 28
12901234-5566-7777-8888-99aabbccddee 29
03001234-5566-7777-c888-99aabbccddee 30
13101234-5566-7777-e888-99aabbccddee 31
NULL 32
13301234-5566-8777-8888-99aabbccddee 33
03401234-5566-8777-c888-99aabbccddee 34
13501234-5566-8777-e888-99aabbccddee 35
NULL 36
13701234-5566-9777-8888-99aabbccddee 37
03801234-5566-9777-c888-99aabbccddee 38
13901234-5566-9777-e888-99aabbccddee 39
NULL 40
14101234-5566-a777-8888-99aabbccddee 41
04201234-5566-a777-c888-99aabbccddee 42
14301234-5566-a777-e888-99aabbccddee 43
NULL 44
14501234-5566-b777-8888-99aabbccddee 45
04601234-5566-b777-c888-99aabbccddee 46
14701234-5566-b777-e888-99aabbccddee 47
NULL 48
14901234-5566-c777-8888-99aabbccddee 49
05001234-5566-c777-c888-99aabbccddee 50
15101234-5566-c777-e888-99aabbccddee 51
NULL 52
15301234-5566-d777-8888-99aabbccddee 53
05401234-5566-d777-c888-99aabbccddee 54
15501234-5566-d777-e888-99aabbccddee 55
NULL 56
15701234-5566-e777-8888-99aabbccddee 57
05801234-5566-e777-c888-99aabbccddee 58
15901234-5566-e777-e888-99aabbccddee 59
NULL 60
16101234-5566-f777-8888-99aabbccddee 61
06201234-5566-f777-c888-99aabbccddee 62
16301234-5566-f777-e888-99aabbccddee 63
CHECK TABLE t1 FOR UPGRADE;
Table Op Msg_type Msg_text
test.t1 check status OK
CALL show_table(0);
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
`b` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
12301234-5566-5777-e888-99aabbccddee 23
11901234-5566-4777-e888-99aabbccddee 19
11501234-5566-3777-e888-99aabbccddee 15
11101234-5566-2777-e888-99aabbccddee 11
10701234-5566-1777-e888-99aabbccddee 7
DROP TABLE t1;
# Upgrade a 10.11.4 table using ALTER, adding a table COMMENT
CALL show_table(0);
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
`b` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
16301234-5566-f777-e888-99aabbccddee 63
15901234-5566-e777-e888-99aabbccddee 59
15501234-5566-d777-e888-99aabbccddee 55
15101234-5566-c777-e888-99aabbccddee 51
14701234-5566-b777-e888-99aabbccddee 47
# ALTER..INPLACE should fail - the old column 'b UUID' needs upgrade
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test10';
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
ALTER IGNORE TABLE t1 COMMENT 'test11';
Warnings:
Warning 1292 Incorrect uuid value: '03201234-5566-8777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 33
Warning 1292 Incorrect uuid value: '03601234-5566-9777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 37
Warning 1292 Incorrect uuid value: '04001234-5566-a777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 41
Warning 1292 Incorrect uuid value: '04401234-5566-b777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 45
Warning 1292 Incorrect uuid value: '04801234-5566-c777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 49
Warning 1292 Incorrect uuid value: '05201234-5566-d777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 53
Warning 1292 Incorrect uuid value: '05601234-5566-e777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 57
Warning 1292 Incorrect uuid value: '06001234-5566-f777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 61
CALL show_table(0);
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
`b` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='test11'
VERSION
10
a b
12301234-5566-5777-e888-99aabbccddee 23
11901234-5566-4777-e888-99aabbccddee 19
11501234-5566-3777-e888-99aabbccddee 15
11101234-5566-2777-e888-99aabbccddee 11
10701234-5566-1777-e888-99aabbccddee 7
# Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test12';
CALL show_table(0);
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
`b` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='test12'
VERSION
10
a b
12301234-5566-5777-e888-99aabbccddee 23
11901234-5566-4777-e888-99aabbccddee 19
11501234-5566-3777-e888-99aabbccddee 15
11101234-5566-2777-e888-99aabbccddee 11
10701234-5566-1777-e888-99aabbccddee 7
DROP TABLE t1;
# Upgrade a 10.11.4 table using ALTER, adding a DEFAULT for 'b INT'
CALL show_table(0);
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
`b` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
16301234-5566-f777-e888-99aabbccddee 63
15901234-5566-e777-e888-99aabbccddee 59
15501234-5566-d777-e888-99aabbccddee 55
15101234-5566-c777-e888-99aabbccddee 51
14701234-5566-b777-e888-99aabbccddee 47
# ALTER..INPLACE should fail - the old column 'b UUID' needs upgrade
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY b INT NOT NULL DEFAULT 10;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
ALTER IGNORE TABLE t1 MODIFY b INT NOT NULL DEFAULT 11;
Warnings:
Warning 1292 Incorrect uuid value: '03201234-5566-8777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 33
Warning 1292 Incorrect uuid value: '03601234-5566-9777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 37
Warning 1292 Incorrect uuid value: '04001234-5566-a777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 41
Warning 1292 Incorrect uuid value: '04401234-5566-b777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 45
Warning 1292 Incorrect uuid value: '04801234-5566-c777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 49
Warning 1292 Incorrect uuid value: '05201234-5566-d777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 53
Warning 1292 Incorrect uuid value: '05601234-5566-e777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 57
Warning 1292 Incorrect uuid value: '06001234-5566-f777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 61
CALL show_table(0);
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
`b` int(11) NOT NULL DEFAULT 11,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
12301234-5566-5777-e888-99aabbccddee 23
11901234-5566-4777-e888-99aabbccddee 19
11501234-5566-3777-e888-99aabbccddee 15
11101234-5566-2777-e888-99aabbccddee 11
10701234-5566-1777-e888-99aabbccddee 7
# Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY b INT NOT NULL DEFAULT 12;
CALL show_table(0);
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
`b` int(11) NOT NULL DEFAULT 12,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
12301234-5566-5777-e888-99aabbccddee 23
11901234-5566-4777-e888-99aabbccddee 19
11501234-5566-3777-e888-99aabbccddee 15
11101234-5566-2777-e888-99aabbccddee 11
10701234-5566-1777-e888-99aabbccddee 7
DROP TABLE t1;
# Upgrade a 10.11.4 table using ALTER, adding a DEFAULT for 'a UUID'
CALL show_table(0);
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT NULL,
`b` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
16301234-5566-f777-e888-99aabbccddee 63
15901234-5566-e777-e888-99aabbccddee 59
15501234-5566-d777-e888-99aabbccddee 55
15101234-5566-c777-e888-99aabbccddee 51
14701234-5566-b777-e888-99aabbccddee 47
# ALTER..INPLACE should fail - the old column 'b UUID' needs upgrade
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY a UUID DEFAULT '16301234-5566-f777-e888-99aabbccdd00';
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
ALTER IGNORE TABLE t1 MODIFY a UUID DEFAULT '16301234-5566-f777-e888-99aabbccdd01';
Warnings:
Warning 1292 Incorrect uuid value: '03201234-5566-8777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 33
Warning 1292 Incorrect uuid value: '03601234-5566-9777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 37
Warning 1292 Incorrect uuid value: '04001234-5566-a777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 41
Warning 1292 Incorrect uuid value: '04401234-5566-b777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 45
Warning 1292 Incorrect uuid value: '04801234-5566-c777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 49
Warning 1292 Incorrect uuid value: '05201234-5566-d777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 53
Warning 1292 Incorrect uuid value: '05601234-5566-e777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 57
Warning 1292 Incorrect uuid value: '06001234-5566-f777-0888-99aabbccddee' for column `test`.`t1`.`a` at row 61
CALL show_table(0);
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT '16301234-5566-f777-e888-99aabbccdd01',
`b` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
12301234-5566-5777-e888-99aabbccddee 23
11901234-5566-4777-e888-99aabbccddee 19
11501234-5566-3777-e888-99aabbccddee 15
11101234-5566-2777-e888-99aabbccddee 11
10701234-5566-1777-e888-99aabbccddee 7
# Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 MODIFY a UUID DEFAULT '16301234-5566-f777-e888-99aabbccdd02';
CALL show_table(0);
Table Create Table
t1 CREATE TABLE `t1` (
`a` uuid DEFAULT '16301234-5566-f777-e888-99aabbccdd02',
`b` int(11) NOT NULL,
KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
VERSION
10
a b
12301234-5566-5777-e888-99aabbccddee 23
11901234-5566-4777-e888-99aabbccddee 19
11501234-5566-3777-e888-99aabbccddee 15
11101234-5566-2777-e888-99aabbccddee 11
10701234-5566-1777-e888-99aabbccddee 7
DROP TABLE t1;
DROP PROCEDURE show_table;
#
# End of 10.11 tests
#

View File

@@ -0,0 +1,110 @@
let $datadir= `select @@datadir`;
--echo #
--echo # Start of 10.11 tests
--echo #
--echo #
--echo # MDEV-33442 REPAIR TABLE corrupts UUIDs
--echo #
DELIMITER $$;
CREATE PROCEDURE show_table(long_version INT)
BEGIN
SHOW CREATE TABLE t1;
SELECT VERSION FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
IF long_version>0 THEN
SELECT * FROM t1 ORDER BY b;
ELSE
SELECT * FROM t1 ORDER BY a DESC LIMIT 5;
END IF;
END;
$$
DELIMITER ;$$
--echo # Upgrade a 10.11.4 table using REPAIR
--copy_file $MTR_SUITE_DIR/std_data/mdev-29959.frm $datadir/test/t1.frm
--copy_file $MTR_SUITE_DIR/std_data/mdev-29959.MYI $datadir/test/t1.MYI
--copy_file $MTR_SUITE_DIR/std_data/mdev-29959.MYD $datadir/test/t1.MYD
CALL show_table(1);
CHECK TABLE t1 FOR UPGRADE;
CALL show_table(0);
CHECK TABLE t1 FOR UPGRADE;
CALL show_table(0);
REPAIR TABLE t1;
CALL show_table(1);
CHECK TABLE t1 FOR UPGRADE;
CALL show_table(0);
DROP TABLE t1;
--echo # Upgrade a 10.11.4 table using ALTER, adding a table COMMENT
--copy_file $MTR_SUITE_DIR/std_data/mdev-29959.frm $datadir/test/t1.frm
--copy_file $MTR_SUITE_DIR/std_data/mdev-29959.MYI $datadir/test/t1.MYI
--copy_file $MTR_SUITE_DIR/std_data/mdev-29959.MYD $datadir/test/t1.MYD
CALL show_table(0);
--echo # ALTER..INPLACE should fail - the old column 'b UUID' needs upgrade
--error ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test10';
ALTER IGNORE TABLE t1 COMMENT 'test11';
CALL show_table(0);
--echo # Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test12';
CALL show_table(0);
DROP TABLE t1;
--echo # Upgrade a 10.11.4 table using ALTER, adding a DEFAULT for 'b INT'
--copy_file $MTR_SUITE_DIR/std_data/mdev-29959.frm $datadir/test/t1.frm
--copy_file $MTR_SUITE_DIR/std_data/mdev-29959.MYI $datadir/test/t1.MYI
--copy_file $MTR_SUITE_DIR/std_data/mdev-29959.MYD $datadir/test/t1.MYD
CALL show_table(0);
--echo # ALTER..INPLACE should fail - the old column 'b UUID' needs upgrade
--error ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY b INT NOT NULL DEFAULT 10;
ALTER IGNORE TABLE t1 MODIFY b INT NOT NULL DEFAULT 11;
CALL show_table(0);
--echo # Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY b INT NOT NULL DEFAULT 12;
CALL show_table(0);
DROP TABLE t1;
--echo # Upgrade a 10.11.4 table using ALTER, adding a DEFAULT for 'a UUID'
--copy_file $MTR_SUITE_DIR/std_data/mdev-29959.frm $datadir/test/t1.frm
--copy_file $MTR_SUITE_DIR/std_data/mdev-29959.MYI $datadir/test/t1.MYI
--copy_file $MTR_SUITE_DIR/std_data/mdev-29959.MYD $datadir/test/t1.MYD
CALL show_table(0);
--echo # ALTER..INPLACE should fail - the old column 'b UUID' needs upgrade
--error ER_ALTER_OPERATION_NOT_SUPPORTED
ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY a UUID DEFAULT '16301234-5566-f777-e888-99aabbccdd00';
ALTER IGNORE TABLE t1 MODIFY a UUID DEFAULT '16301234-5566-f777-e888-99aabbccdd01';
CALL show_table(0);
--echo # Now ALTER..INPLACE should work
ALTER IGNORE TABLE t1 MODIFY a UUID DEFAULT '16301234-5566-f777-e888-99aabbccdd02';
CALL show_table(0);
DROP TABLE t1;
DROP PROCEDURE show_table;
--echo #
--echo # End of 10.11 tests
--echo #

View File

@@ -98,6 +98,14 @@ const Type_handler *Type_collection_uuid::find_in_array(const Type_handler *a,
return NULL;
}
const Type_handler *Type_collection_uuid::type_handler_for_implicit_upgrade(
const Type_handler *from) const
{
return Type_handler_uuid_new::singleton();
}
/*************************************************************************/
class Create_func_uuid : public Create_func_arg0

View File

@@ -316,6 +316,9 @@ public:
const override
{ return NULL; }
const Type_handler *type_handler_for_implicit_upgrade(
const Type_handler *from) const;
static Type_collection_uuid *singleton()
{
static Type_collection_uuid tc;

View File

@@ -5754,7 +5754,8 @@ public:
{
List_iterator<Create_field> it(list);
while (Create_field *f= it++)
f->type_handler()->Column_definition_implicit_upgrade(f);
f->type_handler()->type_handler_for_implicit_upgrade()->
Column_definition_implicit_upgrade_to_this(f);
}
};

View File

@@ -4767,7 +4767,8 @@ int handler::ha_check_for_upgrade(HA_CHECK_OPT *check_opt)
KEY *keyinfo, *keyend;
KEY_PART_INFO *keypart, *keypartend;
if (table->s->incompatible_version)
if (table->s->incompatible_version ||
check_old_types())
return HA_ADMIN_NEEDS_ALTER;
if (!table->s->mysql_version)
@@ -4793,6 +4794,12 @@ int handler::ha_check_for_upgrade(HA_CHECK_OPT *check_opt)
}
}
}
/*
True VARCHAR appeared in MySQL-5.0.3.
If the FRM is older than 5.0.3, force alter even if the check_old_type()
call above did not find data types that want upgrade.
*/
if (table->s->frm_version < FRM_VER_TRUE_VARCHAR)
return HA_ADMIN_NEEDS_ALTER;
@@ -4806,26 +4813,15 @@ int handler::ha_check_for_upgrade(HA_CHECK_OPT *check_opt)
}
int handler::check_old_types()
bool handler::check_old_types() const
{
Field** field;
if (!table->s->mysql_version)
for (Field **field= table->field; (*field); field++)
{
/* check for bad DECIMAL field */
for (field= table->field; (*field); field++)
{
if ((*field)->type() == MYSQL_TYPE_NEWDECIMAL)
{
return HA_ADMIN_NEEDS_ALTER;
}
if ((*field)->type() == MYSQL_TYPE_VAR_STRING)
{
return HA_ADMIN_NEEDS_ALTER;
}
}
const Type_handler *th= (*field)->type_handler();
if (th != th->type_handler_for_implicit_upgrade())
return true;
}
return 0;
return false;
}
@@ -5026,8 +5022,6 @@ int handler::ha_check(THD *thd, HA_CHECK_OPT *check_opt)
if (table->s->mysql_version < MYSQL_VERSION_ID)
{
if (unlikely((error= check_old_types())))
return error;
error= ha_check_for_upgrade(check_opt);
if (unlikely(error && (error != HA_ADMIN_NEEDS_CHECK)))
return error;

View File

@@ -4093,7 +4093,6 @@ public:
}
virtual void update_create_info(HA_CREATE_INFO *create_info) {}
int check_old_types();
virtual int assign_to_keycache(THD* thd, HA_CHECK_OPT* check_opt)
{ return HA_ADMIN_NOT_IMPLEMENTED; }
virtual int preload_keys(THD* thd, HA_CHECK_OPT* check_opt)
@@ -4801,6 +4800,7 @@ private:
}
private:
bool check_old_types() const;
void mark_trx_read_write_internal();
bool check_table_binlog_row_based_internal();

View File

@@ -863,11 +863,9 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
!(check_opt->sql_flags & TT_USEFRM))
{
handler *file= table->table->file;
int check_old_types= file->check_old_types();
int check_for_upgrade= file->ha_check_for_upgrade(check_opt);
if (check_old_types == HA_ADMIN_NEEDS_ALTER ||
check_for_upgrade == HA_ADMIN_NEEDS_ALTER)
if (check_for_upgrade == HA_ADMIN_NEEDS_ALTER)
{
/* We use extra_open_options to be able to open crashed tables */
thd->open_options|= extra_open_options;
@@ -876,7 +874,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
thd->open_options&= ~extra_open_options;
goto send_result;
}
if (check_old_types || check_for_upgrade)
if (check_for_upgrade)
{
/* If repair is not implemented for the engine, run ALTER TABLE */
need_repair_or_alter= 1;

View File

@@ -6601,8 +6601,6 @@ static KEY *find_key_ci(const char *key_name, KEY *key_start, KEY *key_end)
@param thd Thread
@param table The original table.
@param varchar Indicates that new definition has new
VARCHAR column.
@param[in/out] ha_alter_info Data structure which already contains
basic information about create options,
field and keys for the new version of
@@ -6637,7 +6635,7 @@ static KEY *find_key_ci(const char *key_name, KEY *key_start, KEY *key_end)
@retval false success
*/
static bool fill_alter_inplace_info(THD *thd, TABLE *table, bool varchar,
static bool fill_alter_inplace_info(THD *thd, TABLE *table,
Alter_inplace_info *ha_alter_info)
{
Field **f_ptr, *field;
@@ -6687,13 +6685,6 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table, bool varchar,
if (alter_info->flags & ALTER_CHANGE_COLUMN)
ha_alter_info->handler_flags|= ALTER_COLUMN_DEFAULT;
/*
If we altering table with old VARCHAR fields we will be automatically
upgrading VARCHAR column types.
*/
if (table->s->frm_version < FRM_VER_TRUE_VARCHAR && varchar)
ha_alter_info->handler_flags|= ALTER_STORED_COLUMN_TYPE;
DBUG_PRINT("info", ("handler_flags: %llu", ha_alter_info->handler_flags));
/*
@@ -6735,6 +6726,30 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table, bool varchar,
Check if type of column has changed.
*/
bool is_equal= field->is_equal(*new_field);
if (is_equal)
{
const Type_handler *th= field->type_handler();
if (th != th->type_handler_for_implicit_upgrade())
{
/*
The field data type says it wants upgrade.
This should not be possible:
- if this is a new column definition, e.g. from statements like:
ALTER TABLE t1 ADD a INT;
ALTER TABLE t1 MODIFY a INT;
then it's coming from the parser, which returns
only up-to-date data types.
- if this is an old column definition, e.g. from:
ALTER TABLE t1 COMMENT 'new comment';
it should have ealier called Column_definition_implicit_upgrade(),
which replaces old data types to up-to-date data types.
*/
DBUG_ASSERT(0);
is_equal= false;
}
}
if (!is_equal)
{
if (field->table->file->can_convert_nocopy(*field, *new_field))
@@ -10105,12 +10120,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
*/
KEY *key_info;
uint key_count;
/*
Remember if the new definition has new VARCHAR column;
create_info->varchar will be reset in create_table_impl()/
mysql_prepare_create_table().
*/
bool varchar= create_info->varchar, table_creation_was_logged= 0;
bool table_creation_was_logged= 0;
bool binlog_as_create_select= 0, log_if_exists= 0;
uint tables_opened;
handlerton *new_db_type= create_info->db_type, *old_db_type;
@@ -10928,7 +10938,7 @@ do_continue:;
bool use_inplace= true;
/* Fill the Alter_inplace_info structure. */
if (fill_alter_inplace_info(thd, table, varchar, &ha_alter_info))
if (fill_alter_inplace_info(thd, table, &ha_alter_info))
goto err_new_table_cleanup;
alter_ctx.tmp_storage_engine_name_partitioned=

View File

@@ -8804,41 +8804,48 @@ bool Type_handler_string_result::union_element_finalize(Item_type_holder* item)
/***************************************************************************/
void Type_handler_var_string::
Column_definition_implicit_upgrade(Column_definition *c) const
const Type_handler *
Type_handler_var_string::type_handler_for_implicit_upgrade() const
{
// Change old VARCHAR to new VARCHAR
c->set_handler(&type_handler_varchar);
return &type_handler_varchar;
}
void Type_handler::
Column_definition_implicit_upgrade_to_this(Column_definition *old) const
{
old->set_handler(this);
}
void Type_handler_time_common::
Column_definition_implicit_upgrade(Column_definition *c) const
Column_definition_implicit_upgrade_to_this(Column_definition *old) const
{
if (opt_mysql56_temporal_format)
c->set_handler(&type_handler_time2);
old->set_handler(&type_handler_time2);
else
c->set_handler(&type_handler_time);
old->set_handler(&type_handler_time);
}
void Type_handler_datetime_common::
Column_definition_implicit_upgrade(Column_definition *c) const
Column_definition_implicit_upgrade_to_this(Column_definition *old) const
{
if (opt_mysql56_temporal_format)
c->set_handler(&type_handler_datetime2);
old->set_handler(&type_handler_datetime2);
else
c->set_handler(&type_handler_datetime);
old->set_handler(&type_handler_datetime);
}
void Type_handler_timestamp_common::
Column_definition_implicit_upgrade(Column_definition *c) const
Column_definition_implicit_upgrade_to_this(Column_definition *old) const
{
if (opt_mysql56_temporal_format)
c->set_handler(&type_handler_timestamp2);
old->set_handler(&type_handler_timestamp2);
else
c->set_handler(&type_handler_timestamp);
old->set_handler(&type_handler_timestamp);
}

View File

@@ -3836,6 +3836,16 @@ public:
const Type_handler *res= type_handler_base();
return res ? res : this;
}
/*
In 10.11.8 the semantics of this method has changed to the opposite.
It used to be called with the old data type handler as "this".
Now it's called with the new data type hander as "this".
To avoid problems during merges, the method name was renamed.
*/
virtual const Type_handler *type_handler_for_implicit_upgrade() const
{
return this;
}
virtual const Type_handler *type_handler_for_comparison() const= 0;
virtual const Type_handler *type_handler_for_native_format() const
{
@@ -3981,9 +3991,13 @@ public:
virtual bool validate_implicit_default_value(THD *thd,
const Column_definition &def)
const;
// Automatic upgrade, e.g. for ALTER TABLE t1 FORCE
virtual void Column_definition_implicit_upgrade(Column_definition *c) const
{ }
/*
Automatic upgrade, e.g. for REPAIR or ALTER TABLE t1 FORCE
- from the data type specified in old->type_handler()
- to the data type specified in "this"
*/
virtual void Column_definition_implicit_upgrade_to_this(
Column_definition *old) const;
// Validate CHECK constraint after the parser
virtual bool Column_definition_validate_check_constraint(THD *thd,
Column_definition *c)
@@ -6188,7 +6202,8 @@ public:
const Type_handler *type_handler_for_comparison() const override;
int stored_field_cmp_to_item(THD *thd, Field *field, Item *item)
const override;
void Column_definition_implicit_upgrade(Column_definition *c) const override;
void Column_definition_implicit_upgrade_to_this(
Column_definition *old) const override;
bool Column_definition_fix_attributes(Column_definition *c) const override;
bool
Column_definition_attributes_frm_unpack(Column_definition_attributes *attr,
@@ -6512,7 +6527,8 @@ public:
const Type_cast_attributes &attr) const override;
bool validate_implicit_default_value(THD *thd, const Column_definition &def)
const override;
void Column_definition_implicit_upgrade(Column_definition *c) const override;
void Column_definition_implicit_upgrade_to_this(
Column_definition *old) const override;
bool Column_definition_fix_attributes(Column_definition *c) const override;
bool
Column_definition_attributes_frm_unpack(Column_definition_attributes *attr,
@@ -6650,7 +6666,8 @@ public:
{
return true;
}
void Column_definition_implicit_upgrade(Column_definition *c) const override;
void Column_definition_implicit_upgrade_to_this(
Column_definition *old) const override;
bool
Column_definition_attributes_frm_unpack(Column_definition_attributes *attr,
TABLE_SHARE *share,
@@ -7000,6 +7017,7 @@ public:
{
return MYSQL_TYPE_VARCHAR;
}
const Type_handler *type_handler_for_implicit_upgrade() const override;
const Type_handler *type_handler_for_tmp_table(const Item *item) const override
{
return varstring_type_handler(item);
@@ -7007,7 +7025,6 @@ public:
uint32 max_display_length_for_field(const Conv_source &src) const override;
void show_binlog_type(const Conv_source &src, const Field &dst, String *str)
const override;
void Column_definition_implicit_upgrade(Column_definition *c) const override;
bool Column_definition_fix_attributes(Column_definition *c) const override;
bool Column_definition_prepare_stage2(Column_definition *c,
handler *file,

View File

@@ -1125,6 +1125,11 @@ public:
return FbtImpl::max_char_length();
}
const Type_handler *type_handler_for_implicit_upgrade() const override
{
return TypeCollectionImpl::singleton()->
type_handler_for_implicit_upgrade(this);
}
const Type_handler *type_handler_for_comparison() const override
{
return this;
@@ -1943,6 +1948,12 @@ public:
return NULL;
}
const Type_handler *type_handler_for_implicit_upgrade(
const Type_handler *from) const
{
return from;
}
static Type_collection_fbt *singleton()
{
static Type_collection_fbt tc;