提交 ea5bd71d 编写于 作者: Y yb0 提交者: LINGuanRen

fix check text column bug during ctas

上级 9802ffae
......@@ -1583,7 +1583,7 @@ int ObCreateTableResolver::resolve_table_elements_from_select(const ParseNode& p
} else if (is_oracle_mode() && create_table_column_count > 0) {
if (column.is_string_type()) {
if (column.get_meta_type().is_lob()) {
if (OB_FAIL(check_text_column_length_and_promote(column, table_id_))) {
if (OB_FAIL(check_text_column_length_and_promote(column, table_id_, true))) {
LOG_WARN("fail to check text or blob column length", K(ret), K(column));
}
} else if (OB_FAIL(check_string_column_length(column, share::is_oracle_mode()))) {
......@@ -1626,7 +1626,7 @@ int ObCreateTableResolver::resolve_table_elements_from_select(const ParseNode& p
} else {
if (column.is_string_type()) {
if (column.get_meta_type().is_lob()) {
if (OB_FAIL(check_text_column_length_and_promote(column, table_id_))) {
if (OB_FAIL(check_text_column_length_and_promote(column, table_id_, true))) {
LOG_WARN("fail to check text or blob column length", K(ret), K(column));
}
} else if (OB_FAIL(check_string_column_length(column, share::is_oracle_mode()))) {
......
......@@ -2946,7 +2946,7 @@ int ObDDLResolver::check_urowid_column_length(const share::schema::ObColumnSchem
}
int ObDDLResolver::check_text_length(ObCharsetType cs_type, ObCollationType co_type, const char* name, ObObjType& type,
int32_t& length, bool need_rewrite_length)
int32_t& length, bool need_rewrite_length, const bool is_byte_length /* = false */)
{
int ret = OB_SUCCESS;
int64_t mbmaxlen = 0;
......@@ -2954,9 +2954,10 @@ int ObDDLResolver::check_text_length(ObCharsetType cs_type, ObCollationType co_t
if (!ob_is_text_tc(type) || CHARSET_INVALID == cs_type || CS_TYPE_INVALID == co_type) {
ret = OB_ERR_UNEXPECTED;
SQL_RESV_LOG(ERROR, "column infomation is error", K(cs_type), K(co_type), K(ret));
} else if (OB_FAIL(ObCharset::get_mbmaxlen_by_coll(co_type, mbmaxlen))) {
} else if (!is_byte_length && OB_FAIL(ObCharset::get_mbmaxlen_by_coll(co_type, mbmaxlen))) {
ret = OB_ERR_UNEXPECTED;
SQL_RESV_LOG(WARN, "fail to get mbmaxlen", K(ret), K(co_type));
} else if (is_byte_length && OB_FALSE_IT(mbmaxlen = 1)) {
} else if (0 == mbmaxlen) {
ret = OB_ERR_UNEXPECTED;
SQL_RESV_LOG(ERROR, "mbmaxlen can not be 0", K(ret), K(co_type), K(mbmaxlen));
......@@ -3025,7 +3026,8 @@ int ObDDLResolver::rewrite_text_length_mysql(ObObjType& type, int32_t& length)
}
// TODO texttc should care about the the defined length not the actual length
int ObDDLResolver::check_text_column_length_and_promote(ObColumnSchemaV2& column, int64_t table_id)
int ObDDLResolver::check_text_column_length_and_promote(
ObColumnSchemaV2& column, int64_t table_id, const bool is_byte_length /* = false */)
{
int ret = OB_SUCCESS;
bool need_check_length = true;
......@@ -3041,7 +3043,8 @@ int ObDDLResolver::check_text_column_length_and_promote(ObColumnSchemaV2& column
column.get_column_name(),
type,
length,
need_check_length))) {
need_check_length,
is_byte_length))) {
LOG_WARN("failed to check text length", K(ret), K(column));
} else {
column.set_data_type(type);
......
......@@ -142,13 +142,8 @@ public:
static const int64_t DEFAULT_TABLE_DOP = 1;
explicit ObDDLResolver(ObResolverParams& params);
virtual ~ObDDLResolver();
static int check_text_length(ObCharsetType cs_type,
ObCollationType co_type,
const char* name,
ObObjType& type,
int32_t& length,
bool need_rewrite_length);
static int check_text_length(ObCharsetType cs_type, ObCollationType co_type, const char *name, ObObjType &type,
int32_t &length, bool need_rewrite_length, const bool is_byte_length = false);
static int rewrite_text_length_mysql(ObObjType &type, int32_t &length);
static int check_uniq_allow(
share::schema::ObTableSchema& table_schema, obrpc::ObCreateIndexArg& index_arg, bool& allow);
......@@ -187,7 +182,8 @@ public:
static int cast_enum_or_set_default_value(
const share::schema::ObColumnSchemaV2& column, common::ObObjCastParams& params, common::ObObj& def_val);
int check_partition_name_duplicate(ParseNode* node, bool is_oracle_modle = false);
static int check_text_column_length_and_promote(share::schema::ObColumnSchemaV2& column, int64_t table_id);
static int check_text_column_length_and_promote(
share::schema::ObColumnSchemaV2& column, int64_t table_id, const bool is_byte_length = false);
static int get_enable_split_partition(const int64_t tenant_id, bool& enable_split_partition);
typedef common::hash::ObPlacementHashSet<share::schema::ObIndexNameHashWrapper, common::OB_MAX_COLUMN_NUMBER>
IndexNameSet;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册