This fix will improve the error code for unknown table exception cases.
This commit is contained in:
@ -18,6 +18,7 @@
|
||||
package org.apache.doris.alter;
|
||||
|
||||
import org.apache.doris.common.DdlException;
|
||||
import org.apache.doris.common.ErrorCode;
|
||||
|
||||
/*
|
||||
* This exception will be thrown when the alter job(v2) being cancelled due to
|
||||
@ -30,4 +31,9 @@ public class AlterCancelException extends DdlException {
|
||||
public AlterCancelException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public AlterCancelException(String msg, ErrorCode mysqlErrorCode) {
|
||||
super(msg);
|
||||
setMysqlErrorCode(mysqlErrorCode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,11 +151,13 @@ public interface DatabaseIf<T extends TableIf> {
|
||||
}
|
||||
|
||||
default T getTableOrMetaException(String tableName) throws MetaNotFoundException {
|
||||
return getTableOrException(tableName, t -> new MetaNotFoundException("unknown table, tableName=" + t));
|
||||
return getTableOrException(tableName, t -> new MetaNotFoundException("unknown table, tableName=" + t,
|
||||
ErrorCode.ERR_BAD_TABLE_ERROR));
|
||||
}
|
||||
|
||||
default T getTableOrMetaException(long tableId) throws MetaNotFoundException {
|
||||
return getTableOrException(tableId, t -> new MetaNotFoundException("unknown table, tableId=" + t));
|
||||
return getTableOrException(tableId, t -> new MetaNotFoundException("unknown table, tableId=" + t,
|
||||
ErrorCode.ERR_BAD_TABLE_ERROR));
|
||||
}
|
||||
|
||||
default T getTableOrMetaException(String tableName, TableIf.TableType tableType) throws MetaNotFoundException {
|
||||
@ -206,7 +208,8 @@ public interface DatabaseIf<T extends TableIf> {
|
||||
}
|
||||
|
||||
default T getTableOrDdlException(String tableName) throws DdlException {
|
||||
return getTableOrException(tableName, t -> new DdlException(ErrorCode.ERR_BAD_TABLE_ERROR.formatErrorMsg(t)));
|
||||
return getTableOrException(tableName, t -> new DdlException(ErrorCode.ERR_BAD_TABLE_ERROR.formatErrorMsg(t),
|
||||
ErrorCode.ERR_BAD_TABLE_ERROR));
|
||||
}
|
||||
|
||||
default T getTableOrDdlException(String tableName, TableIf.TableType tableType) throws DdlException {
|
||||
@ -220,7 +223,8 @@ public interface DatabaseIf<T extends TableIf> {
|
||||
}
|
||||
|
||||
default T getTableOrDdlException(long tableId) throws DdlException {
|
||||
return getTableOrException(tableId, t -> new DdlException(ErrorCode.ERR_BAD_TABLE_ERROR.formatErrorMsg(t)));
|
||||
return getTableOrException(tableId, t -> new DdlException(ErrorCode.ERR_BAD_TABLE_ERROR.formatErrorMsg(t),
|
||||
ErrorCode.ERR_BAD_TABLE_ERROR));
|
||||
}
|
||||
|
||||
default T getTableOrDdlException(long tableId, TableIf.TableType tableType) throws DdlException {
|
||||
@ -235,12 +239,14 @@ public interface DatabaseIf<T extends TableIf> {
|
||||
|
||||
default T getTableOrAnalysisException(String tableName) throws AnalysisException {
|
||||
return getTableOrException(tableName,
|
||||
t -> new AnalysisException(ErrorCode.ERR_BAD_TABLE_ERROR.formatErrorMsg(t)));
|
||||
t -> new AnalysisException(ErrorCode.ERR_BAD_TABLE_ERROR.formatErrorMsg(t),
|
||||
ErrorCode.ERR_BAD_TABLE_ERROR));
|
||||
}
|
||||
|
||||
default T getTableOrAnalysisException(long tableId) throws AnalysisException {
|
||||
return getTableOrException(tableId,
|
||||
t -> new AnalysisException(ErrorCode.ERR_BAD_TABLE_ERROR.formatErrorMsg(t)));
|
||||
t -> new AnalysisException(ErrorCode.ERR_BAD_TABLE_ERROR.formatErrorMsg(t),
|
||||
ErrorCode.ERR_BAD_TABLE_ERROR));
|
||||
}
|
||||
|
||||
default OlapTable getOlapTableOrDdlException(String tableName) throws DdlException {
|
||||
|
||||
@ -22,6 +22,7 @@ import org.apache.doris.analysis.CreateTableStmt;
|
||||
import org.apache.doris.catalog.constraint.Constraint;
|
||||
import org.apache.doris.common.Config;
|
||||
import org.apache.doris.common.DdlException;
|
||||
import org.apache.doris.common.ErrorCode;
|
||||
import org.apache.doris.common.MetaNotFoundException;
|
||||
import org.apache.doris.common.io.Text;
|
||||
import org.apache.doris.common.io.Writable;
|
||||
@ -257,19 +258,23 @@ public abstract class Table extends MetaObject implements Writable, TableIf {
|
||||
}
|
||||
|
||||
public void writeLockOrDdlException() throws DdlException {
|
||||
writeLockOrException(new DdlException("unknown table, tableName=" + name));
|
||||
writeLockOrException(new DdlException("unknown table, tableName=" + name,
|
||||
ErrorCode.ERR_BAD_TABLE_ERROR));
|
||||
}
|
||||
|
||||
public void writeLockOrMetaException() throws MetaNotFoundException {
|
||||
writeLockOrException(new MetaNotFoundException("unknown table, tableName=" + name));
|
||||
writeLockOrException(new MetaNotFoundException("unknown table, tableName=" + name,
|
||||
ErrorCode.ERR_BAD_TABLE_ERROR));
|
||||
}
|
||||
|
||||
public void writeLockOrAlterCancelException() throws AlterCancelException {
|
||||
writeLockOrException(new AlterCancelException("unknown table, tableName=" + name));
|
||||
writeLockOrException(new AlterCancelException("unknown table, tableName=" + name,
|
||||
ErrorCode.ERR_BAD_TABLE_ERROR));
|
||||
}
|
||||
|
||||
public boolean tryWriteLockOrMetaException(long timeout, TimeUnit unit) throws MetaNotFoundException {
|
||||
return tryWriteLockOrException(timeout, unit, new MetaNotFoundException("unknown table, tableName=" + name));
|
||||
return tryWriteLockOrException(timeout, unit, new MetaNotFoundException("unknown table, tableName=" + name,
|
||||
ErrorCode.ERR_BAD_TABLE_ERROR));
|
||||
}
|
||||
|
||||
public <E extends Exception> boolean tryWriteLockOrException(long timeout, TimeUnit unit, E e) throws E {
|
||||
|
||||
@ -24,6 +24,7 @@ import org.apache.doris.catalog.Env;
|
||||
import org.apache.doris.catalog.TableIf;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.DdlException;
|
||||
import org.apache.doris.common.ErrorCode;
|
||||
import org.apache.doris.common.MetaNotFoundException;
|
||||
import org.apache.doris.common.io.Text;
|
||||
import org.apache.doris.common.io.Writable;
|
||||
@ -186,22 +187,26 @@ public class ExternalTable implements TableIf, Writable, GsonPostProcessable {
|
||||
|
||||
@Override
|
||||
public void writeLockOrDdlException() throws DdlException {
|
||||
writeLockOrException(new DdlException("unknown table, tableName=" + name));
|
||||
writeLockOrException(new DdlException("unknown table, tableName=" + name,
|
||||
ErrorCode.ERR_BAD_TABLE_ERROR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeLockOrMetaException() throws MetaNotFoundException {
|
||||
writeLockOrException(new MetaNotFoundException("unknown table, tableName=" + name));
|
||||
writeLockOrException(new MetaNotFoundException("unknown table, tableName=" + name,
|
||||
ErrorCode.ERR_BAD_TABLE_ERROR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeLockOrAlterCancelException() throws AlterCancelException {
|
||||
writeLockOrException(new AlterCancelException("unknown table, tableName=" + name));
|
||||
writeLockOrException(new AlterCancelException("unknown table, tableName=" + name,
|
||||
ErrorCode.ERR_BAD_TABLE_ERROR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryWriteLockOrMetaException(long timeout, TimeUnit unit) throws MetaNotFoundException {
|
||||
return tryWriteLockOrException(timeout, unit, new MetaNotFoundException("unknown table, tableName=" + name));
|
||||
return tryWriteLockOrException(timeout, unit, new MetaNotFoundException("unknown table, tableName=" + name,
|
||||
ErrorCode.ERR_BAD_TABLE_ERROR));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -65,7 +65,7 @@ public class ErrorReport {
|
||||
|
||||
public static void reportDdlException(String pattern, ErrorCode errorCode, Object... objs)
|
||||
throws DdlException {
|
||||
throw new DdlException(reportCommon(pattern, errorCode, objs));
|
||||
throw new DdlException(reportCommon(pattern, errorCode, objs), errorCode);
|
||||
}
|
||||
|
||||
public static void report(ErrorCode errorCode, Object... objs) {
|
||||
|
||||
@ -912,7 +912,7 @@ public class InternalCatalog implements CatalogIf<Database> {
|
||||
Env.getCurrentEnv().getAnalysisManager().removeTableStats(table.getId());
|
||||
Env.getCurrentEnv().getMtmvService().dropTable(table);
|
||||
} catch (UserException e) {
|
||||
throw new DdlException(e.getMessage(), e);
|
||||
throw new DdlException(e.getMessage(), e.getMysqlErrorCode());
|
||||
} finally {
|
||||
db.writeUnlock();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user