[CP] fix object name length checking in mysql mode
This commit is contained in:
@ -946,9 +946,6 @@ int ObCreateTableResolver::check_column_name_duplicate(const ParseNode* node)
|
||||
if (OB_ISNULL(name_node)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("name node can not be null", K(ret));
|
||||
} else if (name_node->str_len_ > OB_MAX_COLUMN_NAME_LENGTH) {
|
||||
ret = OB_ERR_TOO_LONG_IDENT;
|
||||
LOG_USER_ERROR(OB_ERR_TOO_LONG_IDENT, (int)name_node->str_len_, name_node->str_value_);
|
||||
} else if (0 == name_node->str_len_) {
|
||||
ret = OB_WRONG_COLUMN_NAME;
|
||||
LOG_USER_ERROR(OB_WRONG_COLUMN_NAME, (int)name_node->str_len_, name_node->str_value_);
|
||||
@ -2461,11 +2458,14 @@ int ObCreateTableResolver::resolve_index_name(
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
const int64_t max_user_table_name_length =
|
||||
share::is_oracle_mode() ? OB_MAX_USER_TABLE_NAME_LENGTH_ORACLE : OB_MAX_USER_TABLE_NAME_LENGTH_MYSQL;
|
||||
if (index_name_.length() > max_user_table_name_length) {
|
||||
ret = OB_ERR_TOO_LONG_IDENT;
|
||||
LOG_USER_ERROR(OB_ERR_TOO_LONG_IDENT, index_name_.length(), index_name_.ptr());
|
||||
ObCollationType cs_type = CS_TYPE_INVALID;
|
||||
if (OB_UNLIKELY(NULL == session_info_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("session if NULL", K(ret));
|
||||
} else if (OB_FAIL(session_info_->get_collation_connection(cs_type))) {
|
||||
LOG_WARN("fail to get collation connection", K(ret));
|
||||
} else if (OB_FAIL(ObSQLUtils::check_index_name(cs_type, index_name_))) {
|
||||
LOG_WARN("fail to check index name", K(ret), K(index_name_));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -117,11 +117,13 @@ int ObCreateViewResolver::resolve(const ParseNode& parse_tree)
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
const int64_t max_user_table_name_length =
|
||||
share::is_oracle_mode() ? OB_MAX_USER_TABLE_NAME_LENGTH_ORACLE : OB_MAX_USER_TABLE_NAME_LENGTH_MYSQL;
|
||||
if (view_name.length() > max_user_table_name_length) {
|
||||
ret = OB_ERR_TOO_LONG_IDENT;
|
||||
LOG_USER_ERROR(OB_ERR_TOO_LONG_IDENT, view_name.length(), view_name.ptr());
|
||||
ObNameCaseMode mode = OB_NAME_CASE_INVALID;
|
||||
bool perserve_lettercase = false;
|
||||
if (OB_FAIL(session_info_->get_name_case_mode(mode))) {
|
||||
LOG_WARN("fail to get name case mode", K(ret), K(mode));
|
||||
} else if (FALSE_IT(perserve_lettercase = share::is_oracle_mode() ? true : (mode != OB_LOWERCASE_AND_INSENSITIVE))) {
|
||||
} else if (OB_FAIL(ObSQLUtils::check_and_convert_table_name(CS_TYPE_UTF8MB4_GENERAL_CI, perserve_lettercase, view_name))) {
|
||||
LOG_WARN("fail to check and convert view_name", K(ret), K(view_name));
|
||||
} else {
|
||||
table_schema.set_tenant_id(session_info_->get_effective_tenant_id());
|
||||
table_schema.set_tablegroup_id(combine_id(OB_SYS_TENANT_ID, OB_SYS_TABLEGROUP_ID));
|
||||
@ -304,8 +306,6 @@ int ObCreateViewResolver::resolve(const ParseNode& parse_tree)
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 mysql 模式下列名定义
|
||||
if (share::is_mysql_mode() && !(is_sync_ddl_user && session_info_->is_inner())) {
|
||||
if (OB_FAIL(ret)) {
|
||||
// do nothing
|
||||
|
||||
@ -1799,7 +1799,7 @@ int ObDDLResolver::resolve_column_name(common::ObString& col_name, ParseNode* no
|
||||
col_name.assign_ptr(node->str_value_, node->str_len_);
|
||||
int32_t name_length = col_name.length();
|
||||
const char* name_ptr = col_name.ptr();
|
||||
if (name_length > OB_MAX_COLUMN_NAME_LENGTH) {
|
||||
if (name_length > OB_MAX_COLUMN_NAME_LENGTH * OB_MAX_CHAR_LEN) {
|
||||
ret = OB_ERR_TOO_LONG_IDENT;
|
||||
_SQL_RESV_LOG(
|
||||
WARN, "identifier name '%.*s' is too long, ret=%d", static_cast<int32_t>(name_length), name_ptr, ret);
|
||||
|
||||
Reference in New Issue
Block a user