Skip to content

Commit

Permalink
[BugFix] fix bug for sqlblacklist (#44862)
Browse files Browse the repository at this point in the history
Signed-off-by: before-Sunrise <[email protected]>
  • Loading branch information
before-Sunrise authored Apr 28, 2024
1 parent 408c922 commit 3c881b0
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions fe/fe-core/src/main/java/com/starrocks/qe/StmtExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,19 @@ public void execute() throws Exception {
if (context.isHTTPQueryDump) {
return;
}

// For follower: verify sql in BlackList before forward to leader
// For leader: if this is a proxy sql, no need to verify sql in BlackList because every fe has its own blacklist
if (isQuery && Config.enable_sql_blacklist && !parsedStmt.isExplain() && !isProxy) {
OriginStatement origStmt = parsedStmt.getOrigStmt();
if (origStmt != null) {
String originSql = origStmt.originStmt.trim()
.toLowerCase().replaceAll(" +", " ");
// If this sql is in blacklist, show message.
SqlBlackList.verifying(originSql);
}
}

if (isForwardToLeader()) {
context.setIsForward(true);
forwardToLeader();
Expand All @@ -553,17 +566,6 @@ public void execute() throws Exception {
final boolean isStatisticsJob = AnalyzerUtils.isStatisticsJob(context, parsedStmt);
context.setStatisticsJob(isStatisticsJob);

// sql's blacklist is enabled through enable_sql_blacklist.
if (Config.enable_sql_blacklist && !parsedStmt.isExplain()) {
OriginStatement origStmt = parsedStmt.getOrigStmt();
if (origStmt != null) {
String originSql = origStmt.originStmt.trim()
.toLowerCase().replaceAll(" +", " ");
// If this sql is in blacklist, show message.
SqlBlackList.verifying(originSql);
}
}

// Record planner costs in audit log
Preconditions.checkNotNull(execPlan, "query must has a plan");

Expand Down

0 comments on commit 3c881b0

Please sign in to comment.