diff options
author | Sergei Golubchik <serg@mariadb.org> | 2017-03-10 19:41:48 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-03-31 19:22:20 +0200 |
commit | 9ce639af5217f877fd9e4b93d1b0ecd0ef0dfd80 (patch) | |
tree | a4b32e33dfdff3d780715790fcba7d5dfe74da0a | |
parent | 76a262cdf879c9f496f3026e15d251ad33df5516 (diff) | |
download | mariadb-git-9ce639af5217f877fd9e4b93d1b0ecd0ef0dfd80.tar.gz |
don't export all charsets to plugins
don't use internal server collation symbol names, use collation
properties and collation IDs, they are much more stable.
-rw-r--r-- | include/m_ctype.h | 156 | ||||
-rw-r--r-- | storage/rocksdb/ha_rocksdb.cc | 8 | ||||
-rw-r--r-- | storage/rocksdb/ha_rocksdb.h | 11 | ||||
-rw-r--r-- | storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace.result | 2 | ||||
-rw-r--r-- | storage/rocksdb/mysql-test/rocksdb/r/collation.result | 40 | ||||
-rw-r--r-- | storage/rocksdb/rdb_datadic.cc | 21 |
6 files changed, 125 insertions, 113 deletions
diff --git a/include/m_ctype.h b/include/m_ctype.h index 1639332f5f7..04a82953f0a 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -360,7 +360,7 @@ struct my_collation_handler_st }; extern MY_COLLATION_HANDLER my_collation_8bit_bin_handler; -extern MYSQL_PLUGIN_IMPORT MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler; +extern MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler; extern MY_COLLATION_HANDLER my_collation_8bit_nopad_bin_handler; extern MY_COLLATION_HANDLER my_collation_8bit_simple_nopad_ci_handler; extern MY_COLLATION_HANDLER my_collation_ucs2_uca_handler; @@ -586,83 +586,83 @@ extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_latin1_nopad; extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_filename; extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8_general_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_big5_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_big5_chinese_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_big5_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_big5_chinese_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_cp1250_czech_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_cp932_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_cp932_japanese_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_cp932_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_cp932_japanese_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_eucjpms_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_eucjpms_japanese_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_eucjpms_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_eucjpms_japanese_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_euckr_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_euckr_korean_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_euckr_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_euckr_korean_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_gb2312_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_gb2312_chinese_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_gb2312_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_gb2312_chinese_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_gbk_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_gbk_chinese_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_gbk_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_gbk_chinese_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_latin1_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_latin1_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_latin1_german2_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_latin2_czech_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_sjis_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_sjis_japanese_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_sjis_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_sjis_japanese_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_tis620_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_tis620_thai_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_tis620_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_tis620_thai_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_ucs2_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_ucs2_general_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_ucs2_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_ucs2_general_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_ucs2_general_mysql500_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_ucs2_unicode_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_ucs2_unicode_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_ucs2_general_mysql500_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_ujis_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_ujis_japanese_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_ujis_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_ujis_japanese_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf16_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf16_general_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf16_unicode_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf16_unicode_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf16le_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf16le_general_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf16_general_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf16_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf16le_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf16le_general_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf32_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf32_general_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf32_unicode_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf32_unicode_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf32_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf32_general_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8_general_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8_general_mysql500_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8_unicode_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8_unicode_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8mb4_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8mb4_general_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8mb4_nopad_bin; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8mb4_general_nopad_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8mb4_unicode_ci; -extern MYSQL_PLUGIN_IMPORT struct charset_info_st my_charset_utf8mb4_unicode_nopad_ci; +extern struct charset_info_st my_charset_big5_bin; +extern struct charset_info_st my_charset_big5_chinese_ci; +extern struct charset_info_st my_charset_big5_nopad_bin; +extern struct charset_info_st my_charset_big5_chinese_nopad_ci; +extern struct charset_info_st my_charset_cp1250_czech_ci; +extern struct charset_info_st my_charset_cp932_bin; +extern struct charset_info_st my_charset_cp932_japanese_ci; +extern struct charset_info_st my_charset_cp932_nopad_bin; +extern struct charset_info_st my_charset_cp932_japanese_nopad_ci; +extern struct charset_info_st my_charset_eucjpms_bin; +extern struct charset_info_st my_charset_eucjpms_japanese_ci; +extern struct charset_info_st my_charset_eucjpms_nopad_bin; +extern struct charset_info_st my_charset_eucjpms_japanese_nopad_ci; +extern struct charset_info_st my_charset_euckr_bin; +extern struct charset_info_st my_charset_euckr_korean_ci; +extern struct charset_info_st my_charset_euckr_nopad_bin; +extern struct charset_info_st my_charset_euckr_korean_nopad_ci; +extern struct charset_info_st my_charset_gb2312_bin; +extern struct charset_info_st my_charset_gb2312_chinese_ci; +extern struct charset_info_st my_charset_gb2312_nopad_bin; +extern struct charset_info_st my_charset_gb2312_chinese_nopad_ci; +extern struct charset_info_st my_charset_gbk_bin; +extern struct charset_info_st my_charset_gbk_chinese_ci; +extern struct charset_info_st my_charset_gbk_nopad_bin; +extern struct charset_info_st my_charset_gbk_chinese_nopad_ci; +extern struct charset_info_st my_charset_latin1_bin; +extern struct charset_info_st my_charset_latin1_nopad_bin; +extern struct charset_info_st my_charset_latin1_german2_ci; +extern struct charset_info_st my_charset_latin2_czech_ci; +extern struct charset_info_st my_charset_sjis_bin; +extern struct charset_info_st my_charset_sjis_japanese_ci; +extern struct charset_info_st my_charset_sjis_nopad_bin; +extern struct charset_info_st my_charset_sjis_japanese_nopad_ci; +extern struct charset_info_st my_charset_tis620_bin; +extern struct charset_info_st my_charset_tis620_thai_ci; +extern struct charset_info_st my_charset_tis620_nopad_bin; +extern struct charset_info_st my_charset_tis620_thai_nopad_ci; +extern struct charset_info_st my_charset_ucs2_bin; +extern struct charset_info_st my_charset_ucs2_general_ci; +extern struct charset_info_st my_charset_ucs2_nopad_bin; +extern struct charset_info_st my_charset_ucs2_general_nopad_ci; +extern struct charset_info_st my_charset_ucs2_general_mysql500_ci; +extern struct charset_info_st my_charset_ucs2_unicode_ci; +extern struct charset_info_st my_charset_ucs2_unicode_nopad_ci; +extern struct charset_info_st my_charset_ucs2_general_mysql500_ci; +extern struct charset_info_st my_charset_ujis_bin; +extern struct charset_info_st my_charset_ujis_japanese_ci; +extern struct charset_info_st my_charset_ujis_nopad_bin; +extern struct charset_info_st my_charset_ujis_japanese_nopad_ci; +extern struct charset_info_st my_charset_utf16_bin; +extern struct charset_info_st my_charset_utf16_general_ci; +extern struct charset_info_st my_charset_utf16_unicode_ci; +extern struct charset_info_st my_charset_utf16_unicode_nopad_ci; +extern struct charset_info_st my_charset_utf16le_bin; +extern struct charset_info_st my_charset_utf16le_general_ci; +extern struct charset_info_st my_charset_utf16_general_nopad_ci; +extern struct charset_info_st my_charset_utf16_nopad_bin; +extern struct charset_info_st my_charset_utf16le_nopad_bin; +extern struct charset_info_st my_charset_utf16le_general_nopad_ci; +extern struct charset_info_st my_charset_utf32_bin; +extern struct charset_info_st my_charset_utf32_general_ci; +extern struct charset_info_st my_charset_utf32_unicode_ci; +extern struct charset_info_st my_charset_utf32_unicode_nopad_ci; +extern struct charset_info_st my_charset_utf32_nopad_bin; +extern struct charset_info_st my_charset_utf32_general_nopad_ci; +extern struct charset_info_st my_charset_utf8_bin; +extern struct charset_info_st my_charset_utf8_nopad_bin; +extern struct charset_info_st my_charset_utf8_general_nopad_ci; +extern struct charset_info_st my_charset_utf8_general_mysql500_ci; +extern struct charset_info_st my_charset_utf8_unicode_ci; +extern struct charset_info_st my_charset_utf8_unicode_nopad_ci; +extern struct charset_info_st my_charset_utf8mb4_bin; +extern struct charset_info_st my_charset_utf8mb4_general_ci; +extern struct charset_info_st my_charset_utf8mb4_nopad_bin; +extern struct charset_info_st my_charset_utf8mb4_general_nopad_ci; +extern struct charset_info_st my_charset_utf8mb4_unicode_ci; +extern struct charset_info_st my_charset_utf8mb4_unicode_nopad_ci; #define MY_UTF8MB3 "utf8" #define MY_UTF8MB4 "utf8mb4" diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 8028df53a45..c27835ac1be 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -4827,8 +4827,8 @@ bool ha_rocksdb::get_error_message(const int error, String *const buf) { } /* MyRocks supports only the following collations for indexed columns */ -static const std::set<const my_core::CHARSET_INFO *> RDB_INDEX_COLLATIONS = { - &my_charset_bin, &my_charset_utf8_bin, &my_charset_latin1_bin}; +static const std::set<uint> RDB_INDEX_COLLATIONS = { + COLLATION_BINARY, COLLATION_UTF8_BIN, COLLATION_LATIN1_BIN}; static bool rdb_is_index_collation_supported(const my_core::Field *const field) { @@ -4836,7 +4836,7 @@ rdb_is_index_collation_supported(const my_core::Field *const field) { /* Handle [VAR](CHAR|BINARY) or TEXT|BLOB */ if (type == MYSQL_TYPE_VARCHAR || type == MYSQL_TYPE_STRING || type == MYSQL_TYPE_BLOB) { - return RDB_INDEX_COLLATIONS.find(field->charset()) != + return RDB_INDEX_COLLATIONS.find(field->charset()->number) != RDB_INDEX_COLLATIONS.end(); } return true; @@ -4971,7 +4971,7 @@ int ha_rocksdb::create_cfs( if (collation_err != "") { collation_err += ", "; } - collation_err += coll->name; + collation_err += get_charset_name(coll); } my_printf_error( ER_UNKNOWN_ERROR, "Unsupported collation on string indexed " diff --git a/storage/rocksdb/ha_rocksdb.h b/storage/rocksdb/ha_rocksdb.h index 093dd007580..6e9f6b41afe 100644 --- a/storage/rocksdb/ha_rocksdb.h +++ b/storage/rocksdb/ha_rocksdb.h @@ -201,6 +201,17 @@ const char *const RDB_CF_NAME_QUALIFIER = "cfname"; #define RDB_BQUAL_SZ 1 #define RDB_XIDHDR_LEN (RDB_FORMATID_SZ + RDB_GTRID_SZ + RDB_BQUAL_SZ) +/* collations, used in MariaRocks */ +enum collations_used { + COLLATION_UTF8MB4_BIN = 46, + COLLATION_LATIN1_BIN = 47, + COLLATION_UTF16LE_BIN = 55, + COLLATION_UTF32_BIN = 61, + COLLATION_UTF16_BIN = 62, + COLLATION_BINARY = 63, + COLLATION_UTF8_BIN = 83 +}; + /* To fix an unhandled exception we specify the upper bound as LONGLONGMAX instead of ULONGLONGMAX because the latter is -1 and causes an exception when diff --git a/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace.result b/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace.result index 099356a6969..2aeeda4cfe6 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/add_index_inplace.result @@ -280,7 +280,7 @@ set @tmp_rocksdb_strict_collation_check= @@rocksdb_strict_collation_check; set global rocksdb_strict_collation_check=1; CREATE TABLE t1 (a INT, b TEXT); ALTER TABLE t1 ADD KEY kb(b(10)); -ERROR HY000: Unsupported collation on string indexed column test.t1.b Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.t1.b Use binary collation (latin1_bin, binary, utf8_bin). ALTER TABLE t1 ADD PRIMARY KEY(a); DROP TABLE t1; set global rocksdb_strict_collation_check= @tmp_rocksdb_strict_collation_check; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/collation.result b/storage/rocksdb/mysql-test/rocksdb/r/collation.result index 71fc2b98a16..8b1246b49d7 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/collation.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/collation.result @@ -3,9 +3,9 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text) engine=rocksdb charset utf8; DROP TABLE t1; CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.t1.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.t1.value Use binary collation (latin1_bin, binary, utf8_bin). CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value3(50))) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.t1.value3 Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.t1.value3 Use binary collation (latin1_bin, binary, utf8_bin). SET GLOBAL rocksdb_strict_collation_check=0; CREATE TABLE t1 (id INT primary key, value varchar(50), value2 varbinary(50), value3 text, index(value3(50))) engine=rocksdb charset utf8; DROP TABLE t1; @@ -22,109 +22,109 @@ SET GLOBAL rocksdb_strict_collation_exceptions=t1; CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE t1; CREATE TABLE t2 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.t2.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.t2.value Use binary collation (latin1_bin, binary, utf8_bin). SET GLOBAL rocksdb_strict_collation_exceptions="t.*"; CREATE TABLE t123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE t123; CREATE TABLE s123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.s123.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.s123.value Use binary collation (latin1_bin, binary, utf8_bin). SET GLOBAL rocksdb_strict_collation_exceptions=".t.*"; CREATE TABLE xt123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE xt123; CREATE TABLE t123 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.t123.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.t123.value Use binary collation (latin1_bin, binary, utf8_bin). SET GLOBAL rocksdb_strict_collation_exceptions="s.*,t.*"; CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE s1; CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE t1; CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin). SET GLOBAL rocksdb_strict_collation_exceptions="s.*|t.*"; CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE s1; CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE t1; CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin). SET GLOBAL rocksdb_strict_collation_exceptions=",s.*,t.*"; CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE s1; CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE t1; CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin). SET GLOBAL rocksdb_strict_collation_exceptions="|s.*|t.*"; CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE s1; CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE t1; CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin). SET GLOBAL rocksdb_strict_collation_exceptions="s.*,,t.*"; CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE s1; CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE t1; CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin). SET GLOBAL rocksdb_strict_collation_exceptions="s.*||t.*"; CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE s1; CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE t1; CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin). SET GLOBAL rocksdb_strict_collation_exceptions="s.*,t.*,"; CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE s1; CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE t1; CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin). SET GLOBAL rocksdb_strict_collation_exceptions="s.*|t.*|"; CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE s1; CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE t1; CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin). SET GLOBAL rocksdb_strict_collation_exceptions="||||,,,,s.*,,|,,||,t.*,,|||,,,"; CREATE TABLE s1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE s1; CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; DROP TABLE t1; CREATE TABLE u1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.u1.value Use binary collation (latin1_bin, binary, utf8_bin). SET GLOBAL rocksdb_strict_collation_exceptions='t1'; CREATE TABLE t1 (id INT primary key, value varchar(50), index(value)) engine=rocksdb; ALTER TABLE t1 AUTO_INCREMENT=1; DROP TABLE t1; CREATE TABLE t2 (id INT primary key, value varchar(50), index(value)) engine=rocksdb; -ERROR HY000: Unsupported collation on string indexed column test.t2.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.t2.value Use binary collation (latin1_bin, binary, utf8_bin). CREATE TABLE t2 (id INT primary key, value varchar(50)) engine=rocksdb; ALTER TABLE t2 ADD INDEX(value); -ERROR HY000: Unsupported collation on string indexed column test.t2.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.t2.value Use binary collation (latin1_bin, binary, utf8_bin). DROP TABLE t2; SET GLOBAL rocksdb_strict_collation_exceptions="[a-b"; Invalid pattern in strict_collation_exceptions: [a-b CREATE TABLE a (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.a.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.a.value Use binary collation (latin1_bin, binary, utf8_bin). SET GLOBAL rocksdb_strict_collation_exceptions="[a-b]"; CREATE TABLE a (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8; CREATE TABLE b (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8; CREATE TABLE c (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.c.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.c.value Use binary collation (latin1_bin, binary, utf8_bin). DROP TABLE a, b; call mtr.add_suppression("Invalid pattern in strict_collation_exceptions:"); SET GLOBAL rocksdb_strict_collation_exceptions="abc\\"; Invalid pattern in strict_collation_exceptions: abc\ CREATE TABLE abc (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.abc.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.abc.value Use binary collation (latin1_bin, binary, utf8_bin). SET GLOBAL rocksdb_strict_collation_exceptions="abc"; CREATE TABLE abc (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8; CREATE TABLE abcd (id INT PRIMARY KEY, value varchar(50), index(value)) engine=rocksdb charset utf8; -ERROR HY000: Unsupported collation on string indexed column test.abcd.value Use binary collation (binary, latin1_bin, utf8_bin). +ERROR HY000: Unsupported collation on string indexed column test.abcd.value Use binary collation (latin1_bin, binary, utf8_bin). DROP TABLE abc; SET GLOBAL rocksdb_strict_collation_exceptions=null; SET GLOBAL rocksdb_strict_collation_exceptions=@start_global_value; diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc index c2862724773..255a54cbdce 100644 --- a/storage/rocksdb/rdb_datadic.cc +++ b/storage/rocksdb/rdb_datadic.cc @@ -1690,7 +1690,7 @@ static int rdb_unpack_binary_or_utf8_varchar( /* Now, we need to decode used_bytes of data and append them to the value. */ - if (fpi->m_varchar_charset == &my_charset_utf8_bin) { + if (fpi->m_varchar_charset->number == COLLATION_UTF8_BIN) { if (used_bytes & 1) { /* UTF-8 characters are encoded into two-byte entities. There is no way @@ -1793,7 +1793,7 @@ static int rdb_unpack_binary_or_utf8_varchar_space_pad( } // Now, need to decode used_bytes of data and append them to the value. - if (fpi->m_varchar_charset == &my_charset_utf8_bin) { + if (fpi->m_varchar_charset->number == COLLATION_UTF8_BIN) { if (used_bytes & 1) { /* UTF-8 characters are encoded into two-byte entities. There is no way @@ -2239,7 +2239,8 @@ std::array<const Rdb_collation_codec *, MY_ALL_CHARSETS_SIZE> mysql_mutex_t rdb_collation_data_mutex; static bool rdb_is_collation_supported(const my_core::CHARSET_INFO *const cs) { - return (cs->coll == &my_collation_8bit_simple_ci_handler); + return cs->strxfrm_multiply==1 && cs->mbmaxlen == 1 && + !(cs->state & (MY_CS_BINSORT | MY_CS_NOPAD)); } static const Rdb_collation_codec * @@ -2255,7 +2256,7 @@ rdb_init_collation_mapping(const my_core::CHARSET_INFO *const cs) { Rdb_collation_codec *cur = nullptr; // Compute reverse mapping for simple collations. - if (cs->coll == &my_collation_8bit_simple_ci_handler) { + if (rdb_is_collation_supported(cs)) { cur = new Rdb_collation_codec; std::map<uchar, std::vector<uchar>> rev_map; size_t max_conflict_size = 0; @@ -2302,8 +2303,8 @@ rdb_init_collation_mapping(const my_core::CHARSET_INFO *const cs) { static int get_segment_size_from_collation(const CHARSET_INFO *const cs) { int ret; - if (cs == &my_charset_utf8mb4_bin || cs == &my_charset_utf16_bin || - cs == &my_charset_utf16le_bin || cs == &my_charset_utf32_bin) { + if (cs->number == COLLATION_UTF8MB4_BIN || cs->number == COLLATION_UTF16_BIN || + cs->number == COLLATION_UTF16LE_BIN || cs->number == COLLATION_UTF32_BIN) { /* In these collations, a character produces one weight, which is 3 bytes. Segment has 3 characters, add one byte for VARCHAR_CMP_* marker, and we @@ -2424,7 +2425,7 @@ bool Rdb_field_packing::setup(const Rdb_key_def *const key_descr, // // See Field_blob::make_sort_key for details. m_max_image_len = - key_length + (field->charset() == &my_charset_bin + key_length + (field->charset()->number == COLLATION_BINARY ? reinterpret_cast<const Field_blob *>(field) ->pack_length_no_ptr() : 0); @@ -2475,7 +2476,7 @@ bool Rdb_field_packing::setup(const Rdb_key_def *const key_descr, DBUG_EXECUTE_IF("myrocks_enable_unknown_collation_index_only_scans", use_unknown_collation = true;); - if (cs == &my_charset_bin) { + if (cs->number == COLLATION_BINARY) { // - SQL layer pads BINARY(N) so that it always is N bytes long. // - For VARBINARY(N), values may have different lengths, so we're using // variable-length encoding. This is also the only charset where the @@ -2483,7 +2484,7 @@ bool Rdb_field_packing::setup(const Rdb_key_def *const key_descr, m_unpack_func = is_varchar ? rdb_unpack_binary_or_utf8_varchar : rdb_unpack_binary_str; res = true; - } else if (cs == &my_charset_latin1_bin || cs == &my_charset_utf8_bin) { + } else if (cs->number == COLLATION_LATIN1_BIN || cs->number == COLLATION_UTF8_BIN) { // For _bin collations, mem-comparable form of the string is the string // itself. @@ -2504,7 +2505,7 @@ bool Rdb_field_packing::setup(const Rdb_key_def *const key_descr, } else { // SQL layer pads CHAR(N) values to their maximum length. // We just store that and restore it back. - m_unpack_func = (cs == &my_charset_latin1_bin) ? rdb_unpack_binary_str + m_unpack_func = (cs->number == COLLATION_LATIN1_BIN) ? rdb_unpack_binary_str : rdb_unpack_utf8_str; } res = true; |