You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/08/23 03:13:15 UTC

[GitHub] [incubator-doris] morningman commented on a change in pull request #6403: [Feature] Supports case-insensitive table names.

morningman commented on a change in pull request #6403:
URL: https://github.com/apache/incubator-doris/pull/6403#discussion_r685687042



##########
File path: docs/zh-CN/administrator-guide/variables.md
##########
@@ -255,7 +255,34 @@ SELECT /*+ SET_VAR(query_timeout = 1, enable_partition_cache=true) */ sleep(3);
     
 * `lower_case_table_names`
 
-    用于兼容 MySQL 客户端。不可设置。当前 Doris 中的表名默认为大小写敏感。
+    用于控制用户表表名大小写是否敏感。
+
+    值为 0 时,表名大小写敏感。默认为0。
+
+    值为 1 时,表名大小写不敏感,doris在存储和查询时会将表名转换为小写。  
+    优点是在一条语句中可以使用表名的任意大小写形式,下面的sql是正确的:  
+    ```
+    mysql> show tables;  
+    +------------------+
+    | Tables_in_testdb |
+    +------------------+
+    | cost             |
+    +------------------+
+
+    mysql> select * from COST where COst.id < 100 order by cost.id;
+    ```
+    缺点是建表后无法获得建表语句中指定的表名,`show tables` 查看的表名为指定表名的小写。
+
+    值为 2 时,表名大小写不敏感,doris存储建表语句中指定的表名,查询时转换为小写进行比较。
+    优点是`show tables` 查看的表名为建表语句中指定的表名;  
+    缺点是同一语句中只能使用表名的一种大小写形式,例如对`cost` 表使用表名 `COST` 进行查询:
+    ```
+    mysql> select * from COST where COST.id < 100 order by COST.id;
+    ```
+
+    该变量兼容MySQL。需在集群初始化时通过fe.conf 指定 `lower_case_table_names=`进行配置,集群初始化完成后无法通过`set` 语句修改该变量,也无法通过重启、升级集群修改该变量。
+
+    information_schema中的系统视图表名不区分大小写,当`lower_case_table_names`值为 0 时,表现为 1。

Review comment:
       information_schema 的表现不是2?mysql里表现也是 1?

##########
File path: fe/fe-core/src/main/java/org/apache/doris/qe/GlobalVariable.java
##########
@@ -85,14 +85,13 @@ private GlobalVariable() {
 
     }
 
-    public static List<String> getAllGlobalVarNames() {
+    public static List<String> getPersistentGlobalVarNames() {
         List<String> varNames = Lists.newArrayList();
         for (Field field : GlobalVariable.class.getDeclaredFields()) {
             VariableMgr.VarAttr attr = field.getAnnotation(VariableMgr.VarAttr.class);
-            if (attr == null || attr.flag() != VariableMgr.GLOBAL) {
-                continue;
+            if (attr != null && (attr.flag() == VariableMgr.GLOBAL || attr.name().equals(LOWER_CASE_TABLE_NAMES))) {

Review comment:
       Why need to handle `LOWER_CASE_TABLE_NAMES` along?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org