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
4 changes: 4 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
Original file line number Diff line number Diff line change
Expand Up @@ -5921,6 +5921,10 @@ public static boolean isTableNamesCaseInsensitive() {
return GlobalVariable.lowerCaseTableNames == 2;
}

public static boolean isTableNamesCaseSensitive() {
return GlobalVariable.lowerCaseTableNames == 0;
}

private static void getTableMeta(OlapTable olapTable, TGetMetaDBMeta dbMeta) {
if (LOG.isDebugEnabled()) {
LOG.debug("get table meta. table: {}", olapTable.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.doris.mysql.privilege;

import org.apache.doris.catalog.Env;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.CaseSensibility;
import org.apache.doris.common.PatternMatcher;
Expand Down Expand Up @@ -58,7 +59,7 @@ public static TablePrivEntry create(
ctl, CaseSensibility.CATALOG.getCaseSensibility(), ctl.equals(ANY_CTL));

PatternMatcher tblPattern = PatternMatcher.createFlatPattern(
tbl, CaseSensibility.TABLE.getCaseSensibility(), tbl.equals(ANY_TBL));
tbl, Env.isTableNamesCaseSensitive(), tbl.equals(ANY_TBL));

if (privs.containsNodePriv() || privs.containsResourcePriv()) {
throw new AnalysisException("Table privilege can not contains global or resource privileges: " + privs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2373,6 +2373,56 @@ public void testShowViewPriv() throws UserException {
revoke(revokeStmt);
}

@Test
public void testTableNamesCaseSensitive() throws UserException {
new Expectations() {
{
Env.isTableNamesCaseSensitive();
minTimes = 0;
result = true;
}
};
UserIdentity userIdentity = new UserIdentity("sensitiveUser", "%");
createUser(userIdentity);
// `load_priv` and `select_priv` can not `show create view`
GrantStmt grantStmt = new GrantStmt(userIdentity, null, new TablePattern("sensitivedb", "sensitiveTable"),
Lists.newArrayList(new AccessPrivilegeWithCols(AccessPrivilege.SELECT_PRIV)));
grant(grantStmt);
Assert.assertTrue(accessManager
.checkTblPriv(userIdentity, InternalCatalog.INTERNAL_CATALOG_NAME, "sensitivedb", "sensitiveTable",
PrivPredicate.SELECT));

Assert.assertFalse(accessManager
.checkTblPriv(userIdentity, InternalCatalog.INTERNAL_CATALOG_NAME, "sensitivedb", "sensitivetable",
PrivPredicate.SELECT));
dropUser(userIdentity);
}

@Test
public void testTableNamesCaseInsensitive() throws UserException {
new Expectations() {
{
Env.isTableNamesCaseSensitive();
minTimes = 0;
result = false;
}
};
UserIdentity userIdentity = new UserIdentity("sensitiveUser1", "%");
createUser(userIdentity);
// `load_priv` and `select_priv` can not `show create view`
GrantStmt grantStmt = new GrantStmt(userIdentity, null, new TablePattern("sensitivedb1", "sensitiveTable"),
Lists.newArrayList(new AccessPrivilegeWithCols(AccessPrivilege.SELECT_PRIV)));
grant(grantStmt);
Assert.assertTrue(accessManager
.checkTblPriv(userIdentity, InternalCatalog.INTERNAL_CATALOG_NAME, "sensitivedb1", "sensitiveTable",
PrivPredicate.SELECT));

Assert.assertTrue(accessManager
.checkTblPriv(userIdentity, InternalCatalog.INTERNAL_CATALOG_NAME, "sensitivedb1", "sensitivetable",
PrivPredicate.SELECT));
dropUser(userIdentity);
}

@Test
public void testSetInitialRootPassword() {
// Skip set root password if `initial_root_password` set to empty string
Expand Down