branch-2.1:[fix](auth)Delete from should not check select_priv (#49794)
pick: https://github.com/apache/doris/pull/49239
This commit is contained in:
@ -110,7 +110,14 @@ public class DeleteFromCommand extends Command implements ForwardWithSync, Expla
|
||||
LogicalPlanAdapter logicalPlanAdapter = new LogicalPlanAdapter(logicalQuery, ctx.getStatementContext());
|
||||
updateSessionVariableForDelete(ctx.getSessionVariable());
|
||||
NereidsPlanner planner = new NereidsPlanner(ctx.getStatementContext());
|
||||
planner.plan(logicalPlanAdapter, ctx.getSessionVariable().toThrift());
|
||||
boolean originalIsSkipAuth = ctx.isSkipAuth();
|
||||
// delete not need select priv
|
||||
ctx.setSkipAuth(true);
|
||||
try {
|
||||
planner.plan(logicalPlanAdapter, ctx.getSessionVariable().toThrift());
|
||||
} finally {
|
||||
ctx.setSkipAuth(originalIsSkipAuth);
|
||||
}
|
||||
executor.setPlanner(planner);
|
||||
executor.checkBlockRules();
|
||||
// if fe could do fold constant to get delete will do nothing for table, just return.
|
||||
|
||||
@ -64,17 +64,7 @@ suite("test_dml_delete_table_auth","p0,auth_call") {
|
||||
assertTrue(del_res.size() == 0)
|
||||
}
|
||||
sql """grant load_priv on ${dbName}.${tableName} to ${user}"""
|
||||
connect(user=user, password="${pwd}", url=context.config.jdbcUrl) {
|
||||
sql """set enable_fallback_to_original_planner=false;"""
|
||||
test {
|
||||
sql """DELETE FROM ${dbName}.${tableName} WHERE id = 3;"""
|
||||
exception "denied"
|
||||
}
|
||||
def del_res = sql """show DELETE from ${dbName}"""
|
||||
assertTrue(del_res.size() == 0)
|
||||
}
|
||||
sql """grant select_priv on ${dbName}.${tableName} to ${user}"""
|
||||
connect(user=user, password="${pwd}", url=context.config.jdbcUrl) {
|
||||
connect(user, "${pwd}", context.config.jdbcUrl) {
|
||||
sql """DELETE FROM ${dbName}.${tableName} WHERE id = 3;"""
|
||||
def del_res = sql """show DELETE from ${dbName}"""
|
||||
logger.info("del_res: " + del_res)
|
||||
|
||||
Reference in New Issue
Block a user