[compatibility](MySQL) update charset to utf8mb4, collation to utf8mb4_0900_bin (#31046)

Doris's behaviour is more like utf8mb4 and utf8mb4_0900_bin than utf8 and utf8_general_ci
This commit is contained in:
morrySnow
2024-02-21 16:40:26 +08:00
committed by yiguolei
parent f1fbfeba2f
commit 8fc9d80479
7 changed files with 18 additions and 18 deletions

View File

@ -39,7 +39,7 @@ std::vector<SchemaScanner::ColumnDesc> SchemaCharsetsScanner::_s_css_columns = {
};
SchemaCharsetsScanner::CharsetStruct SchemaCharsetsScanner::_s_charsets[] = {
{"utf8", "utf8_general_ci", "UTF-8 Unicode", 3},
{"utf8mb4", "utf8mb4_0900_bin", "UTF-8 Unicode", 4},
{nullptr, nullptr, nullptr, 0},
};

View File

@ -41,7 +41,7 @@ std::vector<SchemaScanner::ColumnDesc> SchemaCollationsScanner::_s_cols_columns
};
SchemaCollationsScanner::CollationStruct SchemaCollationsScanner::_s_collations[] = {
{"utf8_general_ci", "utf8", 33, "Yes", "Yes", 1},
{"utf8mb4_0900_bin", "utf8mb4", 309, "Yes", "Yes", 1},
{nullptr, nullptr, 0, nullptr, nullptr, 0},
};

View File

@ -127,7 +127,7 @@ Status SchemaSchemataScanner::_fill_block_impl(vectorized::Block* block) {
}
// DEFAULT_CHARACTER_SET_NAME
{
std::string src = "utf8";
std::string src = "utf8mb4";
StringRef str = StringRef(src.c_str(), src.size());
for (int i = 0; i < dbs_num; ++i) {
datas[i] = &str;
@ -136,7 +136,7 @@ Status SchemaSchemataScanner::_fill_block_impl(vectorized::Block* block) {
}
// DEFAULT_COLLATION_NAME
{
std::string src = "utf8_general_ci";
std::string src = "utf8mb4_0900_bin";
StringRef str = StringRef(src.c_str(), src.size());
for (int i = 0; i < dbs_num; ++i) {
datas[i] = &str;

View File

@ -650,20 +650,20 @@ public class SessionVariable implements Serializable, Writable {
// this is used to make c3p0 library happy
@VariableMgr.VarAttr(name = CHARACTER_SET_CLIENT)
public String charsetClient = "utf8";
public String charsetClient = "utf8mb4";
@VariableMgr.VarAttr(name = CHARACTER_SET_CONNNECTION)
public String charsetConnection = "utf8";
public String charsetConnection = "utf8mb4";
@VariableMgr.VarAttr(name = CHARACTER_SET_RESULTS)
public String charsetResults = "utf8";
public String charsetResults = "utf8mb4";
@VariableMgr.VarAttr(name = CHARACTER_SET_SERVER)
public String charsetServer = "utf8";
public String charsetServer = "utf8mb4";
@VariableMgr.VarAttr(name = COLLATION_CONNECTION)
public String collationConnection = "utf8_general_ci";
public String collationConnection = "utf8mb4_0900_bin";
@VariableMgr.VarAttr(name = COLLATION_DATABASE)
public String collationDatabase = "utf8_general_ci";
public String collationDatabase = "utf8mb4_0900_bin";
@VariableMgr.VarAttr(name = COLLATION_SERVER)
public String collationServer = "utf8_general_ci";
public String collationServer = "utf8mb4_0900_bin";
// this is used to make c3p0 library happy
@VariableMgr.VarAttr(name = SQL_AUTO_IS_NULL)

View File

@ -1035,7 +1035,7 @@ public class ShowExecutor {
}
if (table instanceof View) {
rows.add(Lists.newArrayList(table.getName(), createTableStmt.get(0), "utf8", "utf8_general_ci"));
rows.add(Lists.newArrayList(table.getName(), createTableStmt.get(0), "utf8mb4", "utf8mb4_0900_bin"));
resultSet = new ShowResultSet(ShowCreateTableStmt.getViewMetaData(), rows);
} else {
if (showStmt.isView()) {
@ -1661,10 +1661,10 @@ public class ShowExecutor {
ShowCollationStmt showStmt = (ShowCollationStmt) stmt;
List<List<String>> rows = Lists.newArrayList();
List<String> row = Lists.newArrayList();
// | utf8_general_ci | utf8 | 33 | Yes | Yes | 1 |
row.add("utf8_general_ci");
row.add("utf8");
row.add("33");
// | utf8mb4_0900_bin | utf8mb4 | 309 | Yes | Yes | 1 |
row.add("utf8mb4_0900_bin");
row.add("utf8mb4");
row.add("309");
row.add("Yes");
row.add("Yes");
row.add("1");

View File

@ -479,7 +479,7 @@ public class SelectStmtTest {
+ "character_set_name,\n"
+ "is_default collate utf8_general_ci = 'Yes' as is_default\n"
+ "is_default collate utf8mb4_0900_bin = 'Yes' as is_default\n"
+ "from information_schema.collations";
dorisAssert.query(sql).explainQuery();
}

View File

@ -24,7 +24,7 @@ show_create_table_and_views_table CREATE TABLE `show_create_table_and_views_tabl
3 1
-- !show --
show_create_table_and_views_view CREATE VIEW `show_create_table_and_views_view` COMMENT 'VIEW' AS SELECT `user_id` AS `user_id`, `cost` AS `cost` FROM `show_create_table_and_views_db`.`show_create_table_and_views_table` WHERE (`good_id` = 2); utf8 utf8_general_ci
show_create_table_and_views_view CREATE VIEW `show_create_table_and_views_view` COMMENT 'VIEW' AS SELECT `user_id` AS `user_id`, `cost` AS `cost` FROM `show_create_table_and_views_db`.`show_create_table_and_views_table` WHERE (`good_id` = 2); utf8mb4 utf8mb4_0900_bin
-- !select --
1 47