This is an automated email from the ASF dual-hosted git repository.
lijibing pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 8d3e8feb6e2 branch-2.1: [fix](show)show tables should be case
insensitive when lowerCaseTableNames is 1 or 2. #46030 (#46058)
8d3e8feb6e2 is described below
commit 8d3e8feb6e201a5b64ad48f4a6235002b6a165a0
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Dec 27 07:18:41 2024 +0800
branch-2.1: [fix](show)show tables should be case insensitive when
lowerCaseTableNames is 1 or 2. #46030 (#46058)
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 fc92efd7f1c..ef3534da388 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
@@ -861,8 +861,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)) {
@@ -901,6 +900,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;
@@ -911,8 +917,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 c68715c17b7..af8cabca621 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;
@@ -683,4 +684,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]