This is an automated email from the ASF dual-hosted git repository.
lijibing pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new fc0078e07ca branch-3.0: [fix](show)show tables should be case
insensitive when lowerCaseTableNames is 1 or 2. #46030 (#46057)
fc0078e07ca is described below
commit fc0078e07ca8ca3bfc92e9e8bd981b6251ef945c
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Dec 27 00:06:26 2024 +0800
branch-3.0: [fix](show)show tables should be case insensitive when
lowerCaseTableNames is 1 or 2. #46030 (#46057)
Cherry-picked from #46030
Co-authored-by: James <[email protected]>
---
.../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]