[fix](MySQL) implement SHOW CHARSET statement. (#31389)
This commit is contained in:
@ -28,8 +28,29 @@ under the License.
|
||||
|
||||
### Description
|
||||
|
||||
The "SHOW CHARACTER" command is used to display the available character sets in the current database management system,
|
||||
along with some associated properties for each character set. These properties may include the name of the character set,
|
||||
the default collation, and the maximum byte length, among others. By running the "SHOW CHARACTER" command, you can view the list of supported character sets in the system along with their detailed information.
|
||||
|
||||
The "SHOW CHARACTER" command returns the following fields:
|
||||
|
||||
Charset: Character set
|
||||
Description: Description
|
||||
Default Collation: Default collation name
|
||||
Maxlen: Maximum byte length.
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```sql
|
||||
mysql> show chatset;
|
||||
|
||||
| Charset | Description | Default collation | Maxlen |
|
||||
|-----------|-----------------|-------------------|--------|
|
||||
| utf8mb4 | UTF-8 Unicode | utf8mb4_0900_bin | 4 |
|
||||
|
||||
```
|
||||
|
||||
### Keywords
|
||||
|
||||
SHOW, CHARSET
|
||||
|
||||
@ -46,7 +46,7 @@ mysql> show collation;
|
||||
+-----------------+---------+------+---------+----------+---------+
|
||||
| Collation | Charset | Id | Default | Compiled | Sortlen |
|
||||
+-----------------+---------+------+---------+----------+---------+
|
||||
| utf8_general_ci | utf8 | 33 | Yes | Yes | 1 |
|
||||
| utf8mb4_0900_bin | utf8mb4 | 33 | Yes | Yes | 1 |
|
||||
+-----------------+---------+------+---------+----------+---------+
|
||||
```
|
||||
|
||||
|
||||
@ -28,8 +28,27 @@ under the License.
|
||||
|
||||
### Description
|
||||
|
||||
"SHOW CHARACTER" 命令用于显示当前数据库管理系统中可用的字符集(character set)以及与每个字符集相关联的一些属性。这些属性可能包括字符集的名称、默认排序规则、最大字节长度等。通过运行 "SHOW CHARACTER" 命令,可以查看系统中支持的字符集列表及其详细信息。
|
||||
|
||||
SHOW CHARACTER 命令返回以下字段:
|
||||
|
||||
|
||||
Charset:字符集
|
||||
Description:描述
|
||||
Default Collation:默认校对名称
|
||||
Maxlen:最大字节长度
|
||||
|
||||
### Example
|
||||
|
||||
```sql
|
||||
mysql> show chatset;
|
||||
|
||||
| Charset | Description | Default collation | Maxlen |
|
||||
|-----------|-----------------|-------------------|--------|
|
||||
| utf8mb4 | UTF-8 Unicode | utf8mb4_0900_bin | 4 |
|
||||
|
||||
```
|
||||
|
||||
### Keywords
|
||||
|
||||
SHOW, CHARSET
|
||||
|
||||
@ -46,7 +46,7 @@ mysql> show collation;
|
||||
+-----------------+---------+------+---------+----------+---------+
|
||||
| Collation | Charset | Id | Default | Compiled | Sortlen |
|
||||
+-----------------+---------+------+---------+----------+---------+
|
||||
| utf8_general_ci | utf8 | 33 | Yes | Yes | 1 |
|
||||
| utf8mb4_0900_bin | utf8mb4 | 33 | Yes | Yes | 1 |
|
||||
+-----------------+---------+------+---------+----------+---------+
|
||||
```
|
||||
|
||||
|
||||
@ -34,6 +34,8 @@ import org.apache.doris.analysis.ShowBrokerStmt;
|
||||
import org.apache.doris.analysis.ShowBuildIndexStmt;
|
||||
import org.apache.doris.analysis.ShowCatalogRecycleBinStmt;
|
||||
import org.apache.doris.analysis.ShowCatalogStmt;
|
||||
import org.apache.doris.analysis.ShowCharsetStmt;
|
||||
import org.apache.doris.analysis.ShowClusterStmt;
|
||||
import org.apache.doris.analysis.ShowCollationStmt;
|
||||
import org.apache.doris.analysis.ShowColumnHistStmt;
|
||||
import org.apache.doris.analysis.ShowColumnStatsStmt;
|
||||
@ -339,6 +341,8 @@ public class ShowExecutor {
|
||||
handleShowData();
|
||||
} else if (stmt instanceof ShowQueryStatsStmt) {
|
||||
handleShowQueryStats();
|
||||
} else if (stmt instanceof ShowCharsetStmt) {
|
||||
handleShowCharset();
|
||||
} else if (stmt instanceof ShowCollationStmt) {
|
||||
handleShowCollation();
|
||||
} else if (stmt instanceof ShowPartitionsStmt) {
|
||||
@ -1653,14 +1657,28 @@ public class ShowExecutor {
|
||||
resultSet = new ShowResultSet(showStmt.getMetaData(), rows);
|
||||
}
|
||||
|
||||
// Show character set.
|
||||
private void handleShowCharset() throws AnalysisException {
|
||||
ShowCharsetStmt showStmt = (ShowCharsetStmt) stmt;
|
||||
List<List<String>> rows = Lists.newArrayList();
|
||||
List<String> row = Lists.newArrayList();
|
||||
// | utf8mb4 | UTF-8 Unicode | utf8mb4_general_ci | 4|
|
||||
row.add(ctx.getSessionVariable().getCharsetServer());
|
||||
row.add("UTF-8 Unicode");
|
||||
row.add(ctx.getSessionVariable().getCollationConnection());
|
||||
row.add("4");
|
||||
rows.add(row);
|
||||
resultSet = new ShowResultSet(showStmt.getMetaData(), rows);
|
||||
}
|
||||
|
||||
// Show alter statement.
|
||||
private void handleShowCollation() throws AnalysisException {
|
||||
ShowCollationStmt showStmt = (ShowCollationStmt) stmt;
|
||||
List<List<String>> rows = Lists.newArrayList();
|
||||
List<String> row = Lists.newArrayList();
|
||||
// | utf8mb4_0900_bin | utf8mb4 | 309 | Yes | Yes | 1 |
|
||||
row.add("utf8mb4_0900_bin");
|
||||
row.add("utf8mb4");
|
||||
row.add(ctx.getSessionVariable().getCollationConnection());
|
||||
row.add(ctx.getSessionVariable().getCharsetServer());
|
||||
row.add("309");
|
||||
row.add("Yes");
|
||||
row.add("Yes");
|
||||
|
||||
4
regression-test/data/show_p0/test_show_char_set.out
Normal file
4
regression-test/data/show_p0/test_show_char_set.out
Normal file
@ -0,0 +1,4 @@
|
||||
-- This file is automatically generated. You should know what you did if you want to edit this
|
||||
-- !show --
|
||||
utf8mb4 UTF-8 Unicode utf8mb4_0900_bin 4
|
||||
|
||||
20
regression-test/suites/show_p0/test_show_char_set.groovy
Normal file
20
regression-test/suites/show_p0/test_show_char_set.groovy
Normal file
@ -0,0 +1,20 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
suite("test_show_char_set") {
|
||||
qt_show """show charset;"""
|
||||
}
|
||||
Reference in New Issue
Block a user