Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Drop inexistent table silently (backport #50150) #55894

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,22 @@ public void dropTable(DropTableStmt stmt) throws DdlException {
hmsTable.getDbName(), hmsTable.getTableName(), hmsTable.getTableLocation()));
}
} else {
<<<<<<< HEAD
if (!stmt.isForceDrop()) {
throw new DdlException(String.format("Table location will be cleared." +
" 'Force' must be set when dropping a hive table." +
" Please execute 'drop table %s.%s.%s force'", stmt.getCatalogName(), dbName, tableName));
}

HiveTable hiveTable = (HiveTable) getTable(dbName, tableName);
=======
HiveTable hiveTable = null;
try {
hiveTable = (HiveTable) getTable(dbName, tableName);
} catch (Exception e) {
// ignore not found exception
}
>>>>>>> aeff4a3734 ([BugFix] Drop inexistent table silently (#50150))
if (hiveTable == null && stmt.isSetIfExists()) {
LOG.warn("Table {}.{} doesn't exist", dbName, tableName);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@
import com.starrocks.sql.ast.pipe.DropPipeStmt;
import com.starrocks.sql.ast.pipe.PipeName;
import com.starrocks.sql.ast.pipe.ShowPipeStmt;
<<<<<<< HEAD
=======
import com.starrocks.sql.common.MetaUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
>>>>>>> aeff4a3734 ([BugFix] Drop inexistent table silently (#50150))

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -1432,14 +1438,22 @@ public Void visitDropTableStatement(DropTableStmt statement, ConnectContext cont
PrivilegeType.DROP.name(), ObjectType.VIEW.name(), statement.getTbl().getTbl());
}
} else {
Table table = null;
try {
table = MetaUtils.getTable(context, statement.getTbl());
Authorizer.checkTableAction(context.getCurrentUserIdentity(), context.getCurrentRoleIds(),
statement.getTbl(), PrivilegeType.DROP);
} catch (AccessDeniedException e) {
AccessDeniedException.reportAccessDenied(
statement.getTbl().getCatalog(),
context.getCurrentUserIdentity(), context.getCurrentRoleIds(),
PrivilegeType.DROP.name(), ObjectType.TABLE.name(), statement.getTbl().getTbl());
} catch (Exception e) {
if (table == null && statement.isSetIfExists()) {
// an exception will be thrown if table is not found, ignore it if `if exists` is set.
return null;
}
throw e;
}
}
return null;
Expand Down
Loading