1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
# Bug #22477433: TABLE WITH UNKNOWN COLLATION CRASHES MYSQL
#
# Create a table with a certain collation. Restart
# the server with a new --character-sets-dir where
# the collation is not supported. Verify that we
# can do DROP and RENAME TABLE, and that CHECK TABLE
# will report a warning.
#
# New character sets dir:
SHOW VARIABLES LIKE 'character_sets_dir%';
Variable_name Value
character_sets_dir MYSQL_TEST_DIR/std_data/
#
# Show new collation available in the new character sets dir:
SHOW COLLATION LIKE 'utf8_phone_ci';
Collation Charset Id Default Compiled Sortlen Pad_attribute
utf8_phone_ci utf8mb3 352 8 PAD SPACE
#
# Create two tables using the new collation:
CREATE TABLE t1 (i INTEGER, a VARCHAR(10) COLLATE utf8_phone_ci) COLLATE utf8_phone_ci;
Warnings:
Warning 3778 'utf8_phone_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
Warning 4162 'utf8_phone_ci' is a user defined collation. User defined collations are deprecated and will be removed in a future release. Consider using a compiled collation instead.
Warning 3778 'utf8_phone_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
Warning 4162 'utf8_phone_ci' is a user defined collation. User defined collations are deprecated and will be removed in a future release. Consider using a compiled collation instead.
CREATE TABLE t2 (i INTEGER, a VARCHAR(10) COLLATE utf8_phone_ci) COLLATE utf8_phone_ci;
Warnings:
Warning 3778 'utf8_phone_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
Warning 4162 'utf8_phone_ci' is a user defined collation. User defined collations are deprecated and will be removed in a future release. Consider using a compiled collation instead.
Warning 3778 'utf8_phone_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
Warning 4162 'utf8_phone_ci' is a user defined collation. User defined collations are deprecated and will be removed in a future release. Consider using a compiled collation instead.
#
# Restart server with original character sets dir:
# restart:--character-sets-dir=MYSQL_CHARSETSDIR
SET @@global.log_error_verbosity = 1;
#
# Reverted to old character sets dir:
SHOW VARIABLES LIKE 'character_sets_dir%';
Variable_name Value
character_sets_dir MYSQL_CHARSETSDIR/
#
# The newly added collation has been deleted:
SHOW COLLATION LIKE 'utf8_phone_ci';
Collation Charset Id Default Compiled Sortlen Pad_attribute
#
# Check behavior of CHECK TABLE (succeed, but report error):
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check Error invalid collation id 352 for table t1, column i
test.t1 check error Corrupt
#
# Check behavior of RENAME TABLE (succeed):
RENAME TABLE t1 TO t1_new;
RENAME TABLE t1_new TO t1;
#
# Check behavior of ALTER TABLE w. COPY (fail):
ALTER TABLE t1 ADD COLUMN (j INTEGER);
ERROR HY000: invalid collation id 352 for table t1, column i
#
# Check behavior of SELECT (fail):
SELECT * FROM t1;
ERROR HY000: invalid collation id 352 for table t1, column i
#
# Check behavior of INSERT (fail):
INSERT INTO t1 VALUES (1);
ERROR HY000: invalid collation id 352 for table t1, column i
#
# Check behavior of SHOW CREATE (fail):
SHOW CREATE TABLE t1;
ERROR HY000: invalid collation id 352 for table t1, column i
#
# Check behavior of DROP TABLE (succeed):
DROP TABLE t1;
DROP TABLE t2;
SET @@global.log_error_verbosity= 3;
#
# Bug#29904087: WHEN DEFAULT_COLLATION_FOR_UTF8MB4 IS CHANGED,
# MYSQLPUMP MAY FAIL DUE TO ILLEGAL MIX OF
# COLLATIONS
#
CREATE TABLE t1 (a CHAR(1)) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
CREATE TABLE t2 (a CHAR(1)) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
CREATE FUNCTION f1 (a CHAR(1)) RETURNS CHAR(1) CHARSET utf8mb4 RETURN a;
CREATE VIEW v1 AS SELECT f1(a) AS a FROM t1;
CREATE VIEW v2 AS SELECT 1 FROM v1 JOIN t2 WHERE v1.a = t2.a;
SET @@session.default_collation_for_utf8mb4 = utf8mb4_general_ci;
Warnings:
Warning 1681 Updating 'default_collation_for_utf8mb4' is deprecated. It will be made read-only in a future release.
SHOW CREATE VIEW v2;
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select 1 AS `1` from (`v1` join `t2`) where (`v1`.`a` = `t2`.`a`) utf8mb4 utf8mb4_0900_ai_ci
DROP TABLE t1, t2;
DROP VIEW v1, v2;
DROP FUNCTION f1;
# restart:
|