Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -965,8 +965,7 @@ private void handleShowTable() throws AnalysisException {
.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)) {
Expand Down Expand Up @@ -1005,6 +1004,13 @@ private void handleShowTable() throws AnalysisException {
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;
Expand All @@ -1015,8 +1021,7 @@ private void handleShowTableStatus() throws AnalysisException {
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())) {
Expand Down
13 changes: 13 additions & 0 deletions fe/fe-core/src/test/java/org/apache/doris/qe/ShowExecutorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
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;
Expand Down Expand Up @@ -684,4 +685,16 @@ public void testShowSqlBlockRule() throws AnalysisException {
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());
}
}
Loading