Skip to content

Commit e4facdf

Browse files
seawindeCopilot
andcommitted
[fix](fe) Skip auth for DeleteFromUsingCommand fallback in DeleteFromCommand
### What problem does this PR solve? Problem Summary: Moving privChecked from StatementContext to CascadesContext (for the CTE privilege bypass fix) caused a regression in DELETE commands with complex WHERE clauses (e.g. NOT EXISTS subquery). DeleteFromCommand sets skipAuth=true during initial Nereids planning because DELETE does not need SELECT privilege. Previously, the privChecked flag on StatementContext was shared across planners, so when DeleteFromUsingCommand created a new planner, CheckPrivileges would see privChecked=true and skip. After moving privChecked to CascadesContext, the new planner gets a fresh CascadesContext with privChecked=false, causing CheckPrivileges to run auth checks without skipAuth=true, failing on tables the user only has LOAD privilege for. Fix: Wrap both DeleteFromUsingCommand.run() call sites in skipAuth=true, consistent with the initial planning phase's auth policy. ### Release note None ### Check List (For Author) - Test: Regression test (test_dml_delete_table_auth) - Behavior changed: No - Does this need documentation: No Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent fae0768 commit e4facdf

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DeleteFromCommand.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,14 @@ public void run(ConnectContext ctx, StmtExecutor executor) throws Exception {
207207
}
208208
} catch (Exception e) {
209209
try {
210-
new DeleteFromUsingCommand(nameParts, tableAlias, isTempPart, partitions,
211-
logicalQuery, Optional.empty(), false).run(ctx, executor);
210+
// delete not need select priv, skip auth for the fallback planner
211+
ctx.setSkipAuth(true);
212+
try {
213+
new DeleteFromUsingCommand(nameParts, tableAlias, isTempPart, partitions,
214+
logicalQuery, Optional.empty(), false).run(ctx, executor);
215+
} finally {
216+
ctx.setSkipAuth(originalIsSkipAuth);
217+
}
212218
return;
213219
} catch (Exception e2) {
214220
LOG.warn("delete from command failed", e2);
@@ -219,8 +225,14 @@ public void run(ConnectContext ctx, StmtExecutor executor) throws Exception {
219225
// if table's enable_mow_light_delete is false, use `DeleteFromUsingCommand`
220226
if (olapTable.getKeysType() == KeysType.UNIQUE_KEYS && olapTable.getEnableUniqueKeyMergeOnWrite()
221227
&& !olapTable.getEnableMowLightDelete()) {
222-
new DeleteFromUsingCommand(nameParts, tableAlias, isTempPart, partitions, logicalQuery,
223-
Optional.empty(), false).run(ctx, executor);
228+
// delete not need select priv, skip auth for the fallback planner
229+
ctx.setSkipAuth(true);
230+
try {
231+
new DeleteFromUsingCommand(nameParts, tableAlias, isTempPart, partitions, logicalQuery,
232+
Optional.empty(), false).run(ctx, executor);
233+
} finally {
234+
ctx.setSkipAuth(originalIsSkipAuth);
235+
}
224236
return;
225237
}
226238

0 commit comments

Comments
 (0)