From a30449081049e3a51cabc1067e76f267db0c00f7 Mon Sep 17 00:00:00 2001 From: lance6716 Date: Fri, 18 Mar 2022 17:28:33 +0800 Subject: [PATCH] parser: add collations from MySQL 8.0 (#33212) ref pingcap/tidb#7968 --- parser/charset/charset.go | 52 +++++++++++++++++++++++++++++++++++++++ parser/parser_test.go | 1 + 2 files changed, 53 insertions(+) diff --git a/parser/charset/charset.go b/parser/charset/charset.go index 7c40767a33f22..728b21dd56d94 100644 --- a/parser/charset/charset.go +++ b/parser/charset/charset.go @@ -331,6 +331,7 @@ var collations = []*Collation{ {73, "keybcs2", "keybcs2_bin", false}, {74, "koi8r", "koi8r_bin", false}, {75, "koi8u", "koi8u_bin", false}, + {76, "utf8", "utf8_tolower_ci", false}, {77, "latin2", "latin2_bin", false}, {78, "latin5", "latin5_bin", false}, {79, "latin7", "latin7_bin", false}, @@ -476,7 +477,58 @@ var collations = []*Collation{ {245, "utf8mb4", "utf8mb4_croatian_ci", false}, {246, "utf8mb4", "utf8mb4_unicode_520_ci", false}, {247, "utf8mb4", "utf8mb4_vietnamese_ci", false}, + {248, "gb18030", "gb18030_chinese_ci", false}, + {249, "gb18030", "gb18030_bin", true}, + {250, "gb18030", "gb18030_unicode_520_ci", false}, {255, "utf8mb4", "utf8mb4_0900_ai_ci", false}, + {256, "utf8mb4", "utf8mb4_de_pb_0900_ai_ci", false}, + {257, "utf8mb4", "utf8mb4_is_0900_ai_ci", false}, + {258, "utf8mb4", "utf8mb4_lv_0900_ai_ci", false}, + {259, "utf8mb4", "utf8mb4_ro_0900_ai_ci", false}, + {260, "utf8mb4", "utf8mb4_sl_0900_ai_ci", false}, + {261, "utf8mb4", "utf8mb4_pl_0900_ai_ci", false}, + {262, "utf8mb4", "utf8mb4_et_0900_ai_ci", false}, + {263, "utf8mb4", "utf8mb4_es_0900_ai_ci", false}, + {264, "utf8mb4", "utf8mb4_sv_0900_ai_ci", false}, + {265, "utf8mb4", "utf8mb4_tr_0900_ai_ci", false}, + {266, "utf8mb4", "utf8mb4_cs_0900_ai_ci", false}, + {267, "utf8mb4", "utf8mb4_da_0900_ai_ci", false}, + {268, "utf8mb4", "utf8mb4_lt_0900_ai_ci", false}, + {269, "utf8mb4", "utf8mb4_sk_0900_ai_ci", false}, + {270, "utf8mb4", "utf8mb4_es_trad_0900_ai_ci", false}, + {271, "utf8mb4", "utf8mb4_la_0900_ai_ci", false}, + {273, "utf8mb4", "utf8mb4_eo_0900_ai_ci", false}, + {274, "utf8mb4", "utf8mb4_hu_0900_ai_ci", false}, + {275, "utf8mb4", "utf8mb4_hr_0900_ai_ci", false}, + {277, "utf8mb4", "utf8mb4_vi_0900_ai_ci", false}, + {278, "utf8mb4", "utf8mb4_0900_as_cs", false}, + {279, "utf8mb4", "utf8mb4_de_pb_0900_as_cs", false}, + {280, "utf8mb4", "utf8mb4_is_0900_as_cs", false}, + {281, "utf8mb4", "utf8mb4_lv_0900_as_cs", false}, + {282, "utf8mb4", "utf8mb4_ro_0900_as_cs", false}, + {283, "utf8mb4", "utf8mb4_sl_0900_as_cs", false}, + {284, "utf8mb4", "utf8mb4_pl_0900_as_cs", false}, + {285, "utf8mb4", "utf8mb4_et_0900_as_cs", false}, + {286, "utf8mb4", "utf8mb4_es_0900_as_cs", false}, + {287, "utf8mb4", "utf8mb4_sv_0900_as_cs", false}, + {288, "utf8mb4", "utf8mb4_tr_0900_as_cs", false}, + {289, "utf8mb4", "utf8mb4_cs_0900_as_cs", false}, + {290, "utf8mb4", "utf8mb4_da_0900_as_cs", false}, + {291, "utf8mb4", "utf8mb4_lt_0900_as_cs", false}, + {292, "utf8mb4", "utf8mb4_sk_0900_as_cs", false}, + {293, "utf8mb4", "utf8mb4_es_trad_0900_as_cs", false}, + {294, "utf8mb4", "utf8mb4_la_0900_as_cs", false}, + {296, "utf8mb4", "utf8mb4_eo_0900_as_cs", false}, + {297, "utf8mb4", "utf8mb4_hu_0900_as_cs", false}, + {298, "utf8mb4", "utf8mb4_hr_0900_as_cs", false}, + {300, "utf8mb4", "utf8mb4_vi_0900_as_cs", false}, + {303, "utf8mb4", "utf8mb4_ja_0900_as_cs", false}, + {304, "utf8mb4", "utf8mb4_ja_0900_as_cs_ks", false}, + {305, "utf8mb4", "utf8mb4_0900_as_ci", false}, + {306, "utf8mb4", "utf8mb4_ru_0900_ai_ci", false}, + {307, "utf8mb4", "utf8mb4_ru_0900_as_cs", false}, + {308, "utf8mb4", "utf8mb4_zh_0900_as_cs", false}, + {309, "utf8mb4", "utf8mb4_0900_bin", false}, {2048, "utf8mb4", "utf8mb4_zh_pinyin_tidb_as_cs", false}, } diff --git a/parser/parser_test.go b/parser/parser_test.go index 2632d7d17c4e6..b9a8d5e0f9e5b 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -2402,6 +2402,7 @@ func TestDDL(t *testing.T) { {`create table testTableCompression (c VARCHAR(15000)) compression="ZLIB";`, true, "CREATE TABLE `testTableCompression` (`c` VARCHAR(15000)) COMPRESSION = 'ZLIB'"}, {`create table t1 (c1 int) compression="zlib";`, true, "CREATE TABLE `t1` (`c1` INT) COMPRESSION = 'zlib'"}, {`create table t1 (c1 int) collate=binary;`, true, "CREATE TABLE `t1` (`c1` INT) DEFAULT COLLATE = BINARY"}, + {`create table t1 (c1 int) collate=utf8mb4_0900_as_cs;`, true, "CREATE TABLE `t1` (`c1` INT) DEFAULT COLLATE = UTF8MB4_0900_AS_CS"}, {`create table t1 (c1 int) default charset=binary collate=binary;`, true, "CREATE TABLE `t1` (`c1` INT) DEFAULT CHARACTER SET = BINARY DEFAULT COLLATE = BINARY"}, // for table option `UNION`