fix bug, drop hash key has not same error code like mysql and oracle
This commit is contained in:
parent
5586d55073
commit
d4730c71fe
@ -12365,9 +12365,9 @@ static const _error _error_OB_ERR_DEPENDENT_BY_PARTITION_FUNC = {
|
||||
.sqlstate = "HY000",
|
||||
.str_error = "Column has a partitioning function dependency and cannot be dropped or renamed.",
|
||||
.str_user_error = "Column '%.*s' has a partitioning function dependency and cannot be dropped or renamed.",
|
||||
.oracle_errno = 600,
|
||||
.oracle_str_error = "ORA-00600: internal error code, arguments: -5502, Column has a partitioning function dependency and cannot be dropped or renamed.",
|
||||
.oracle_str_user_error = "ORA-00600: internal error code, arguments: -5502, Column '%.*s' has a partitioning function dependency and cannot be dropped or renamed."
|
||||
.oracle_errno = 12984,
|
||||
.oracle_str_error = "ORA-12984: cannot drop partitioning column",
|
||||
.oracle_str_user_error = "ORA-12984: cannot drop partitioning column '%.*s'"
|
||||
};
|
||||
static const _error _error_OB_ERR_VIEW_SELECT_CONTAIN_INTO = {
|
||||
.error_name = "OB_ERR_VIEW_SELECT_CONTAIN_INTO",
|
||||
|
@ -1150,8 +1150,7 @@ DEFINE_ERROR(OB_ERR_GENCOL_LEGIT_CHECK_FAILED, -5500, -1, "HY000", "Legitimacy c
|
||||
|
||||
DEFINE_ORACLE_ERROR(OB_ERR_GROUPING_FUNC_WITHOUT_GROUP_BY, -5501, -1, "42000", "GROUPING function only supported with GROUP BY CUBE or ROLLUP", 30481, "GROUPING function only supported with GROUP BY CUBE or ROLLUP");
|
||||
// for rename column in mysql mode
|
||||
DEFINE_ERROR_EXT(OB_ERR_DEPENDENT_BY_PARTITION_FUNC, -5502, ER_DEPENDENT_BY_PARTITION_FUNC, "HY000", "Column has a partitioning function dependency and cannot be dropped or renamed.", "Column '%.*s' has a partitioning function dependency and cannot be dropped or renamed.");
|
||||
|
||||
DEFINE_ORACLE_ERROR_EXT(OB_ERR_DEPENDENT_BY_PARTITION_FUNC, -5502, ER_DEPENDENT_BY_PARTITION_FUNC, "HY000", "Column has a partitioning function dependency and cannot be dropped or renamed.", "Column '%.*s' has a partitioning function dependency and cannot be dropped or renamed.", 12984, "cannot drop partitioning column", "cannot drop partitioning column '%.*s'");
|
||||
DEFINE_ERROR(OB_ERR_VIEW_SELECT_CONTAIN_INTO, -5503, ER_VIEW_SELECT_CLAUSE, "HY000", "View's SELECT contains a 'INTO' clause.");
|
||||
DEFINE_ORACLE_ERROR(OB_ERR_DEFAULT_NOT_ALLOWED, -5504, -1, "HY000", "Virtual column cannot have a default value", 54025, "Virtual column cannot have a default value");
|
||||
DEFINE_ORACLE_ERROR(OB_ERR_MODIFY_REALCOL_TO_GENCOL, -5505, -1, "HY000", "Real column cannot have an expression", 54026, "Real column cannot have an expression");
|
||||
|
@ -4958,7 +4958,7 @@ constexpr int OB_ERR_INVALID_DATE_MSG_FMT_V2 = -4219;
|
||||
#define OB_ERR_FUNCTIONAL_INDEX_ON_FIELD__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5499, Functional index on a column is not supported. Consider using a regular index instead."
|
||||
#define OB_ERR_GENCOL_LEGIT_CHECK_FAILED__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5500, Legitimacy check failed for generated columns."
|
||||
#define OB_ERR_GROUPING_FUNC_WITHOUT_GROUP_BY__ORA_USER_ERROR_MSG "ORA-30481: GROUPING function only supported with GROUP BY CUBE or ROLLUP"
|
||||
#define OB_ERR_DEPENDENT_BY_PARTITION_FUNC__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5502, Column '%.*s' has a partitioning function dependency and cannot be dropped or renamed."
|
||||
#define OB_ERR_DEPENDENT_BY_PARTITION_FUNC__ORA_USER_ERROR_MSG "ORA-12984: cannot drop partitioning column '%.*s'"
|
||||
#define OB_ERR_VIEW_SELECT_CONTAIN_INTO__ORA_USER_ERROR_MSG "ORA-00600: internal error code, arguments: -5503, View's SELECT contains a 'INTO' clause."
|
||||
#define OB_ERR_DEFAULT_NOT_ALLOWED__ORA_USER_ERROR_MSG "ORA-54025: Virtual column cannot have a default value"
|
||||
#define OB_ERR_MODIFY_REALCOL_TO_GENCOL__ORA_USER_ERROR_MSG "ORA-54026: Real column cannot have an expression"
|
||||
|
@ -5638,6 +5638,9 @@ int ObAlterTableResolver::resolve_drop_column(const ParseNode &node, ObReducedVi
|
||||
alter_column_schema.get_origin_column_name(),
|
||||
alter_table_stmt))) {
|
||||
SQL_RESV_LOG(WARN, "failed to check column in foreign key for oracle mode", K(ret));
|
||||
} else if (OB_FAIL(check_drop_column_is_partition_key(*table_schema_,
|
||||
alter_column_schema.get_origin_column_name()))) {
|
||||
SQL_RESV_LOG(WARN, "failed to check column in parition key", K(ret));
|
||||
} else if (OB_FAIL(check_column_in_check_constraint(
|
||||
*table_schema_,
|
||||
alter_column_schema.get_origin_column_name(),
|
||||
@ -5969,5 +5972,31 @@ int ObAlterTableResolver::check_mysql_rename_column(const AlterColumnSchema &alt
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* chech the droped column is partition key,
|
||||
* if ture, forbid the action
|
||||
*/
|
||||
int ObAlterTableResolver::check_drop_column_is_partition_key(const ObTableSchema &table_schema, const ObString &column_name)
|
||||
{
|
||||
int ret=OB_SUCCESS;
|
||||
if (!table_schema.is_valid()) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
SQL_RESV_LOG(WARN, "invalid arguemnt", K(ret), K(table_schema));
|
||||
} else {
|
||||
const ObColumnSchemaV2 *origin_column = table_schema.get_column_schema(column_name);
|
||||
if (OB_ISNULL(origin_column)) {
|
||||
// do nothing
|
||||
// 根据列名查不到列是因为表中不存在该列,后面会在 RS 端再检查一遍表中是否存在该列,并在 RS 端根据操作的不同报不同的错误
|
||||
} else if (origin_column->is_tbl_part_key_column()){
|
||||
ret = OB_ERR_DEPENDENT_BY_PARTITION_FUNC;
|
||||
LOG_USER_ERROR(OB_ERR_DEPENDENT_BY_PARTITION_FUNC,
|
||||
column_name.length(),
|
||||
column_name.ptr());
|
||||
LOG_WARN("alter column has table part key deps", K(ret), K(origin_column));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} //namespace common
|
||||
} //namespace oceanbase
|
||||
|
@ -88,6 +88,9 @@ private:
|
||||
share::schema::ObSchemaGetterGuard *schema_guard,
|
||||
const obrpc::ObCreateForeignKeyArg &foreign_key_arg);
|
||||
int resolve_alter_table_option_list(const ParseNode &node);
|
||||
int check_drop_column_is_partition_key(const ObTableSchema &table_schema,
|
||||
const ObString &column_name);
|
||||
|
||||
int set_column_collation(share::schema::AlterColumnSchema &alter_column_schema);
|
||||
int resolve_index_column_list(const ParseNode &node,
|
||||
obrpc::ObCreateIndexArg &index_arg,
|
||||
|
Loading…
x
Reference in New Issue
Block a user