diff options
-rw-r--r-- | mysql-test/main/binary_to_hex.result | 2 | ||||
-rw-r--r-- | mysql-test/main/ctype_binary.result | 52 | ||||
-rw-r--r-- | mysql-test/main/ctype_binary.test | 32 | ||||
-rw-r--r-- | mysql-test/main/ctype_utf16_uca.result | 6 | ||||
-rw-r--r-- | mysql-test/main/ctype_utf32.result | 2 | ||||
-rw-r--r-- | sql/sp.cc | 7 | ||||
-rw-r--r-- | sql/sql_show.cc | 25 | ||||
-rw-r--r-- | sql/sql_string.h | 4 |
8 files changed, 110 insertions, 20 deletions
diff --git a/mysql-test/main/binary_to_hex.result b/mysql-test/main/binary_to_hex.result index 6ea17e4ec93..0438f89332b 100644 --- a/mysql-test/main/binary_to_hex.result +++ b/mysql-test/main/binary_to_hex.result @@ -21,7 +21,7 @@ t1 CREATE TABLE `t1` ( `c7` binary(1) DEFAULT NULL, `c8` varbinary(10) DEFAULT NULL, `c9` geometry DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=binary COLLATE=binary +) ENGINE=MyISAM DEFAULT CHARSET=binary INSERT INTO t1 VALUES ('tinyblob-text readable', 'blob-text readable', 'mediumblob-text readable', 'longblob-text readable', 'text readable', b'1', 'c', 'variable', diff --git a/mysql-test/main/ctype_binary.result b/mysql-test/main/ctype_binary.result index c35d96fd2a2..6bfb15437c6 100644 --- a/mysql-test/main/ctype_binary.result +++ b/mysql-test/main/ctype_binary.result @@ -3178,7 +3178,7 @@ CREATE TABLE t1(a ENUM(0x6100,0x6200,0x6300) CHARACTER SET 'Binary'); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` enum('a\0','b\0','c\0') CHARACTER SET binary COLLATE binary DEFAULT NULL + `a` enum('a\0','b\0','c\0') CHARACTER SET binary DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1 VALUES (1),(2),(3); SELECT HEX(a) FROM t1 ORDER BY a; @@ -3279,7 +3279,7 @@ CREATE TABLE t1(c ENUM(0x0061) CHARACTER SET 'Binary', d JSON); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c` enum('\0a') CHARACTER SET binary COLLATE binary DEFAULT NULL, + `c` enum('\0a') CHARACTER SET binary DEFAULT NULL, `d` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1 (c) VALUES (1); @@ -3294,7 +3294,7 @@ d INT DEFAULT NULL CHECK (d>0) SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c` enum('\0a') CHARACTER SET binary COLLATE binary DEFAULT NULL, + `c` enum('\0a') CHARACTER SET binary DEFAULT NULL, `d` int(11) DEFAULT NULL CHECK (`d` > 0) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1 VALUES (1,1); @@ -3306,7 +3306,7 @@ CREATE TABLE t1(c ENUM(0x0061) CHARACTER SET 'Binary' CHECK (c>0)); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c` enum('\0a') CHARACTER SET binary COLLATE binary DEFAULT NULL CHECK (`c` > 0) + `c` enum('\0a') CHARACTER SET binary DEFAULT NULL CHECK (`c` > 0) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1 VALUES (1); SELECT HEX(c) FROM t1; @@ -3316,3 +3316,47 @@ DROP TABLE t1; # # End of 10.2 tests # +# +# Start of 10.3 tests +# +# +# MDEV-29561 SHOW CREATE TABLE produces syntactically incorrect structure +# +CREATE TABLE t1 (a ENUM('x') CHARACTER SET BINARY); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` enum('x') CHARACTER SET binary DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +DROP TABLE t1; +CREATE TABLE `t1` ( + `a` enum('x') CHARACTER SET binary DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +DROP TABLE t1; +CREATE TABLE t1 (a INT ) CHARSET=binary; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=binary +DROP TABLE t1; +CREATE DATABASE db1 CHARACTER SET BINARY; +SHOW CREATE DATABASE db1; +Database Create Database +db1 CREATE DATABASE `db1` /*!40100 DEFAULT CHARACTER SET binary */ +DROP DATABASE db1; +CREATE FUNCTION f1() RETURNS ENUM('a') CHARACTER SET binary RETURN NULL; +SHOW CREATE FUNCTION f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS enum('a') CHARSET binary +RETURN NULL latin1 latin1_swedish_ci latin1_swedish_ci +DROP FUNCTION f1; +CREATE FUNCTION f1(a ENUM('a') CHARACTER SET binary) RETURNS INT RETURN NULL; +SHOW CREATE FUNCTION f1; +Function sql_mode Create Function character_set_client collation_connection Database Collation +f1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f1`(a ENUM('a') CHARACTER SET binary) RETURNS int(11) +RETURN NULL latin1 latin1_swedish_ci latin1_swedish_ci +DROP FUNCTION f1; +# +# End of 10.3 tests +# diff --git a/mysql-test/main/ctype_binary.test b/mysql-test/main/ctype_binary.test index b871a41309b..27870a9fc54 100644 --- a/mysql-test/main/ctype_binary.test +++ b/mysql-test/main/ctype_binary.test @@ -169,12 +169,42 @@ INSERT INTO t1 VALUES (1); SELECT HEX(c) FROM t1; DROP TABLE t1; +--echo # +--echo # End of 10.2 tests +--echo # + + +--echo # +--echo # Start of 10.3 tests +--echo # + +--echo # +--echo # MDEV-29561 SHOW CREATE TABLE produces syntactically incorrect structure +--echo # +CREATE TABLE t1 (a ENUM('x') CHARACTER SET BINARY); +SHOW CREATE TABLE t1; +let $def= query_get_value(show create table t1,'Create Table',1); +DROP TABLE t1; +eval $def; +DROP TABLE t1; +CREATE TABLE t1 (a INT ) CHARSET=binary; +SHOW CREATE TABLE t1; +DROP TABLE t1; +CREATE DATABASE db1 CHARACTER SET BINARY; +SHOW CREATE DATABASE db1; +DROP DATABASE db1; +CREATE FUNCTION f1() RETURNS ENUM('a') CHARACTER SET binary RETURN NULL; +SHOW CREATE FUNCTION f1; +DROP FUNCTION f1; +CREATE FUNCTION f1(a ENUM('a') CHARACTER SET binary) RETURNS INT RETURN NULL; +SHOW CREATE FUNCTION f1; +DROP FUNCTION f1; --echo # ---echo # End of 10.2 tests +--echo # End of 10.3 tests --echo # diff --git a/mysql-test/main/ctype_utf16_uca.result b/mysql-test/main/ctype_utf16_uca.result index b67c117f7f8..d49da1f8e1b 100644 --- a/mysql-test/main/ctype_utf16_uca.result +++ b/mysql-test/main/ctype_utf16_uca.result @@ -7907,7 +7907,7 @@ CREATE TABLE t1(c ENUM('aaaaaaaa') CHARACTER SET 'Binary',d JSON); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c` enum('\0a\0a\0a\0a\0a\0a\0a\0a') CHARACTER SET binary COLLATE binary DEFAULT NULL, + `c` enum('\0a\0a\0a\0a\0a\0a\0a\0a') CHARACTER SET binary DEFAULT NULL, `d` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1 (c) VALUES (1); @@ -7919,7 +7919,7 @@ CREATE OR REPLACE TABLE t1(c ENUM('aaaaaaaaa') CHARACTER SET 'Binary',d JSON); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c` enum('\0a\0a\0a\0a\0a\0a\0a\0a\0a') CHARACTER SET binary COLLATE binary DEFAULT NULL, + `c` enum('\0a\0a\0a\0a\0a\0a\0a\0a\0a') CHARACTER SET binary DEFAULT NULL, `d` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1 (c) VALUES (1); @@ -7931,7 +7931,7 @@ CREATE OR REPLACE TABLE t1(c ENUM('aaaaaaaaaa') CHARACTER SET 'Binary',d JSON); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c` enum('\0a\0a\0a\0a\0a\0a\0a\0a\0a\0a') CHARACTER SET binary COLLATE binary DEFAULT NULL, + `c` enum('\0a\0a\0a\0a\0a\0a\0a\0a\0a\0a') CHARACTER SET binary DEFAULT NULL, `d` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1 (c) VALUES (1); diff --git a/mysql-test/main/ctype_utf32.result b/mysql-test/main/ctype_utf32.result index ad5cf184663..8989d09a7e2 100644 --- a/mysql-test/main/ctype_utf32.result +++ b/mysql-test/main/ctype_utf32.result @@ -2878,7 +2878,7 @@ CREATE TABLE t1(c1 ENUM('a','b','ac') CHARACTER SET 'Binary',c2 JSON,c3 INT); SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `c1` enum('\0\0\0a','\0\0\0b','\0\0\0a\0\0\0c') CHARACTER SET binary COLLATE binary DEFAULT NULL, + `c1` enum('\0\0\0a','\0\0\0b','\0\0\0a\0\0\0c') CHARACTER SET binary DEFAULT NULL, `c2` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL, `c3` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci diff --git a/sql/sp.cc b/sql/sp.cc index 3626e845d88..52a04455683 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -1052,8 +1052,11 @@ sp_returns_type(THD *thd, String &result, const sp_head *sp) { result.append(STRING_WITH_LEN(" CHARSET ")); result.append(field->charset()->csname); - result.append(STRING_WITH_LEN(" COLLATE ")); - result.append(field->charset()->name); + if (Charset(field->charset()).can_have_collate_clause()) + { + result.append(STRING_WITH_LEN(" COLLATE ")); + result.append(field->charset()->name); + } } delete field; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index a54b777705a..b2851d7defc 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1551,8 +1551,11 @@ bool mysqld_show_create_db(THD *thd, LEX_CSTRING *dbname, buffer.append(STRING_WITH_LEN(" /*!40100")); buffer.append(STRING_WITH_LEN(" DEFAULT CHARACTER SET ")); buffer.append(create.default_table_charset->csname); - buffer.append(STRING_WITH_LEN(" COLLATE ")); - buffer.append(create.default_table_charset->name); + if (Charset(create.default_table_charset).can_have_collate_clause()) + { + buffer.append(STRING_WITH_LEN(" COLLATE ")); + buffer.append(create.default_table_charset->name); + } buffer.append(STRING_WITH_LEN(" */")); } protocol->store(buffer.ptr(), buffer.length(), buffer.charset()); @@ -2010,8 +2013,11 @@ static void add_table_options(THD *thd, TABLE *table, { packet->append(STRING_WITH_LEN(" DEFAULT CHARSET=")); packet->append(share->table_charset->csname); - packet->append(STRING_WITH_LEN(" COLLATE=")); - packet->append(table->s->table_charset->name); + if (Charset(table->s->table_charset).can_have_collate_clause()) + { + packet->append(STRING_WITH_LEN(" COLLATE=")); + packet->append(table->s->table_charset->name); + } } } @@ -2245,10 +2251,13 @@ int show_create_table(THD *thd, TABLE_LIST *table_list, String *packet, { if (field->charset() != share->table_charset) { - packet->append(STRING_WITH_LEN(" CHARACTER SET ")); - packet->append(field->charset()->csname); - packet->append(STRING_WITH_LEN(" COLLATE ")); - packet->append(field->charset()->name); + packet->append(STRING_WITH_LEN(" CHARACTER SET ")); + packet->append(field->charset()->csname); + if (Charset(field->charset()).can_have_collate_clause()) + { + packet->append(STRING_WITH_LEN(" COLLATE ")); + packet->append(field->charset()->name); + } } } diff --git a/sql/sql_string.h b/sql/sql_string.h index 4f9a68acbb4..6d782e9b0a9 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -147,6 +147,10 @@ public: LEX_CSTRING collation_specific_name() const; bool encoding_allows_reinterpret_as(CHARSET_INFO *cs) const; bool eq_collation_specific_names(CHARSET_INFO *cs) const; + bool can_have_collate_clause() const + { + return m_charset != &my_charset_bin; + } }; class String : public Sql_alloc |