This is an automated email from the ASF dual-hosted git repository.
lijibing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new c3a2edd6ef8 [fix](show)show tables should be case insensitive when
lowerCaseTableNames is 1 or 2. (#46030)
c3a2edd6ef8 is described below
commit c3a2edd6ef81eb6c369c4217757060986c01c01a
Author: James <[email protected]>
AuthorDate: Thu Dec 26 22:18:51 2024 +0800
[fix](show)show tables should be case insensitive when lowerCaseTableNames
is 1 or 2. (#46030)
### What problem does this PR solve?
show tables should be case insensitive when lowerCaseTableNames is 1 or
2.
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
### Release note
None
---
.../src/main/java/org/apache/doris/qe/ShowExecutor.java | 13 +++++++++----
.../src/test/java/org/apache/doris/qe/ShowExecutorTest.java | 13 +++++++++++++
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
index 381ab1a4aa3..babfe4e2265 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
@@ -965,8 +965,7 @@ public class ShowExecutor {
.getDbOrAnalysisException(showTableStmt.getDb());
PatternMatcher matcher = null;
if (showTableStmt.getPattern() != null) {
- matcher =
PatternMatcherWrapper.createMysqlPattern(showTableStmt.getPattern(),
- CaseSensibility.TABLE.getCaseSensibility());
+ matcher =
PatternMatcherWrapper.createMysqlPattern(showTableStmt.getPattern(),
isShowTablesCaseSensitive());
}
for (TableIf tbl : db.getTables()) {
if
(tbl.getName().startsWith(FeConstants.TEMP_MATERIZLIZE_DVIEW_PREFIX)) {
@@ -1005,6 +1004,13 @@ public class ShowExecutor {
resultSet = new ShowResultSet(showTableStmt.getMetaData(), rows);
}
+ public boolean isShowTablesCaseSensitive() {
+ if (GlobalVariable.lowerCaseTableNames == 0) {
+ return CaseSensibility.TABLE.getCaseSensibility();
+ }
+ return false;
+ }
+
// Show table status statement.
private void handleShowTableStatus() throws AnalysisException {
ShowTableStatusStmt showStmt = (ShowTableStatusStmt) stmt;
@@ -1015,8 +1021,7 @@ public class ShowExecutor {
if (db != null) {
PatternMatcher matcher = null;
if (showStmt.getPattern() != null) {
- matcher =
PatternMatcherWrapper.createMysqlPattern(showStmt.getPattern(),
- CaseSensibility.TABLE.getCaseSensibility());
+ matcher =
PatternMatcherWrapper.createMysqlPattern(showStmt.getPattern(),
isShowTablesCaseSensitive());
}
for (TableIf table : db.getTables()) {
if (matcher != null && !matcher.match(table.getName())) {
diff --git a/fe/fe-core/src/test/java/org/apache/doris/qe/ShowExecutorTest.java
b/fe/fe-core/src/test/java/org/apache/doris/qe/ShowExecutorTest.java
index 37d02afaae0..fe15109dce9 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/qe/ShowExecutorTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/qe/ShowExecutorTest.java
@@ -49,6 +49,7 @@ import org.apache.doris.catalog.SinglePartitionInfo;
import org.apache.doris.catalog.Table;
import org.apache.doris.catalog.TableIf.TableType;
import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.CaseSensibility;
import org.apache.doris.common.PatternMatcher;
import org.apache.doris.common.UserException;
import org.apache.doris.common.jmockit.Deencapsulation;
@@ -684,4 +685,16 @@ public class ShowExecutorTest {
Assert.assertEquals("Global",
resultSet.getMetaData().getColumn(6).getName());
Assert.assertEquals("Enable",
resultSet.getMetaData().getColumn(7).getName());
}
+
+ @Test
+ public void testIsShowTablesCaseSensitive() {
+ ShowSqlBlockRuleStmt stmt = new
ShowSqlBlockRuleStmt("test_case_sensitive");
+ ShowExecutor executor = new ShowExecutor(ctx, stmt);
+ GlobalVariable.lowerCaseTableNames = 0;
+ Assert.assertEquals(CaseSensibility.TABLE.getCaseSensibility(),
executor.isShowTablesCaseSensitive());
+ GlobalVariable.lowerCaseTableNames = 1;
+ Assert.assertEquals(false, executor.isShowTablesCaseSensitive());
+ GlobalVariable.lowerCaseTableNames = 2;
+ Assert.assertEquals(false, executor.isShowTablesCaseSensitive());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]