[Improvement](priv) move check priv out of analyze (#30403)
move check priv out of analyze
This commit is contained in:
@ -126,14 +126,6 @@ public class AlterColumnStatsStmt extends DdlStmt {
|
||||
throw new AnalysisException(optional.get() + " is invalid statistics");
|
||||
}
|
||||
|
||||
// check auth
|
||||
if (!Env.getCurrentEnv().getAccessManager()
|
||||
.checkTblPriv(ConnectContext.get(), tableName.getDb(), tableName.getTbl(), PrivPredicate.ALTER)) {
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_TABLEACCESS_DENIED_ERROR, "ALTER COLUMN STATS",
|
||||
ConnectContext.get().getQualifiedUser(), ConnectContext.get().getRemoteIP(),
|
||||
tableName.getDb() + ": " + tableName.getTbl());
|
||||
}
|
||||
|
||||
// get statsTypeToValue
|
||||
properties.forEach((key, value) -> {
|
||||
StatsType statsType = StatsType.fromString(key);
|
||||
@ -141,6 +133,16 @@ public class AlterColumnStatsStmt extends DdlStmt {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkPriv() throws AnalysisException {
|
||||
if (!Env.getCurrentEnv().getAccessManager().checkTblPriv(ConnectContext.get(), tableName.getDb(),
|
||||
tableName.getTbl(), PrivPredicate.ALTER)) {
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_TABLEACCESS_DENIED_ERROR, "ALTER COLUMN STATS",
|
||||
ConnectContext.get().getQualifiedUser(), ConnectContext.get().getRemoteIP(),
|
||||
tableName.getDb() + ": " + tableName.getTbl());
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPartitionAndColumn() throws AnalysisException {
|
||||
CatalogIf catalog = analyzer.getEnv().getCatalogMgr().getCatalog(tableName.getCtl());
|
||||
DatabaseIf db = catalog.getDbOrAnalysisException(tableName.getDb());
|
||||
|
||||
@ -85,13 +85,6 @@ public class AlterTableStatsStmt extends DdlStmt {
|
||||
throw new AnalysisException(optional.get() + " is invalid statistics");
|
||||
}
|
||||
|
||||
if (!Env.getCurrentEnv().getAccessManager()
|
||||
.checkTblPriv(ConnectContext.get(), tableName.getDb(), tableName.getTbl(), PrivPredicate.ALTER)) {
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_TABLEACCESS_DENIED_ERROR, "ALTER COLUMN STATS",
|
||||
ConnectContext.get().getQualifiedUser(), ConnectContext.get().getRemoteIP(),
|
||||
tableName.getDb() + ": " + tableName.getTbl());
|
||||
}
|
||||
|
||||
properties.forEach((key, value) -> {
|
||||
StatsType statsType = StatsType.fromString(key);
|
||||
statsTypeToValue.put(statsType, value);
|
||||
@ -102,6 +95,16 @@ public class AlterTableStatsStmt extends DdlStmt {
|
||||
tableId = table.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkPriv() throws AnalysisException {
|
||||
if (!Env.getCurrentEnv().getAccessManager().checkTblPriv(ConnectContext.get(), tableName.getDb(),
|
||||
tableName.getTbl(), PrivPredicate.ALTER)) {
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_TABLEACCESS_DENIED_ERROR, "ALTER COLUMN STATS",
|
||||
ConnectContext.get().getQualifiedUser(), ConnectContext.get().getRemoteIP(),
|
||||
tableName.getDb() + ": " + tableName.getTbl());
|
||||
}
|
||||
}
|
||||
|
||||
public long getTableId() {
|
||||
return tableId;
|
||||
}
|
||||
|
||||
@ -232,11 +232,12 @@ public class CreateMaterializedViewStmt extends DdlStmt {
|
||||
throw new AnalysisException("The limit clause is not supported in add materialized view clause, expr:"
|
||||
+ " limit " + selectStmt.getLimit());
|
||||
}
|
||||
}
|
||||
|
||||
// check access
|
||||
if (!isReplay && ConnectContext.get() != null && !Env.getCurrentEnv().getAccessManager()
|
||||
.checkTblPriv(ConnectContext.get(), dbName,
|
||||
baseIndexName, PrivPredicate.ALTER)) {
|
||||
@Override
|
||||
public void checkPriv() throws AnalysisException {
|
||||
if (!Env.getCurrentEnv().getAccessManager().checkTblPriv(ConnectContext.get(), dbName, baseIndexName,
|
||||
PrivPredicate.ALTER)) {
|
||||
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, "ALTER");
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,6 +85,9 @@ public abstract class StatementBase implements ParseNode {
|
||||
}
|
||||
}
|
||||
|
||||
public void checkPriv() throws AnalysisException {
|
||||
}
|
||||
|
||||
public Analyzer getAnalyzer() {
|
||||
return analyzer;
|
||||
}
|
||||
|
||||
@ -750,6 +750,7 @@ public class StmtExecutor {
|
||||
} else {
|
||||
analyzer = new Analyzer(context.getEnv(), context);
|
||||
parsedStmt.analyze(analyzer);
|
||||
parsedStmt.checkPriv();
|
||||
}
|
||||
|
||||
if (prepareStmt instanceof PrepareStmt && !isExecuteStmt) {
|
||||
|
||||
Reference in New Issue
Block a user