disable implicit cast between gb18030 and gb18030_2022 when insert
This commit is contained in:
13
deps/oblib/src/lib/charset/ob_charset.cpp
vendored
13
deps/oblib/src/lib/charset/ob_charset.cpp
vendored
@ -1391,6 +1391,19 @@ const char *ObCharset::collation_name(ObCollationType collation_type)
|
|||||||
return (NULL == cs) ? "invalid_type" : cs->name;
|
return (NULL == cs) ? "invalid_type" : cs->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ObCharset::check_valid_implicit_convert(ObCollationType src_type, ObCollationType dst_type)
|
||||||
|
{
|
||||||
|
int ret = OB_SUCCESS;
|
||||||
|
ObCharsetType src_cs = ObCharset::charset_type_by_coll(src_type);
|
||||||
|
ObCharsetType dst_cs = ObCharset::charset_type_by_coll(dst_type);
|
||||||
|
if ((src_cs == CHARSET_GB18030 && dst_cs == CHARSET_GB18030_2022) ||
|
||||||
|
(src_cs == CHARSET_GB18030_2022 && dst_cs == CHARSET_GB18030)) {
|
||||||
|
ret = OB_CANT_AGGREGATE_2COLLATIONS;
|
||||||
|
LOG_WARN("implict cast between GB18030 and GB18030_2022 not allowed", K(ret));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int ObCharset::collation_name(ObCollationType collation_type, ObString &coll_name)
|
int ObCharset::collation_name(ObCollationType collation_type, ObString &coll_name)
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
|||||||
1
deps/oblib/src/lib/charset/ob_charset.h
vendored
1
deps/oblib/src/lib/charset/ob_charset.h
vendored
@ -407,6 +407,7 @@ public:
|
|||||||
|| CHARSET_GB18030_2022 == charset_type;
|
|| CHARSET_GB18030_2022 == charset_type;
|
||||||
}
|
}
|
||||||
static ObCharsetType charset_type_by_coll(ObCollationType coll_type);
|
static ObCharsetType charset_type_by_coll(ObCollationType coll_type);
|
||||||
|
static int check_valid_implicit_convert(ObCollationType src_type, ObCollationType dst_type);
|
||||||
static int charset_name_by_coll(const ObString &coll_name, common::ObString &cs_name);
|
static int charset_name_by_coll(const ObString &coll_name, common::ObString &cs_name);
|
||||||
static int charset_name_by_coll(ObCollationType coll_type, common::ObString &cs_name);
|
static int charset_name_by_coll(ObCollationType coll_type, common::ObString &cs_name);
|
||||||
static int calc_collation(const ObCollationLevel level1,
|
static int calc_collation(const ObCollationLevel level1,
|
||||||
|
|||||||
@ -510,6 +510,8 @@ OB_INLINE int ObExprValuesOp::calc_next_row()
|
|||||||
dst_expr->locate_datum_for_write(eval_ctx_) = *datum;
|
dst_expr->locate_datum_for_write(eval_ctx_) = *datum;
|
||||||
dst_expr->set_evaluated_projected(eval_ctx_);
|
dst_expr->set_evaluated_projected(eval_ctx_);
|
||||||
}
|
}
|
||||||
|
} else if (OB_FAIL(ObCharset::check_valid_implicit_convert(src_meta.cs_type_, dst_expr->datum_meta_.cs_type_))) {
|
||||||
|
LOG_WARN("failed to check valid implicit convert", K(ret));
|
||||||
} else {
|
} else {
|
||||||
// 需要动态cast原因:
|
// 需要动态cast原因:
|
||||||
// 对于以下场景:
|
// 对于以下场景:
|
||||||
|
|||||||
@ -265,6 +265,12 @@ int ObExprColumnConv::calc_result_typeN(ObExprResType &type,
|
|||||||
type_ctx.set_cast_mode(type_ctx.get_cast_mode() | CM_CHARSET_CONVERT_IGNORE_ERR);
|
type_ctx.set_cast_mode(type_ctx.get_cast_mode() | CM_CHARSET_CONVERT_IGNORE_ERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (OB_SUCC(ret) &&
|
||||||
|
OB_FAIL(ObCharset::check_valid_implicit_convert(types[4].get_collation_type(),
|
||||||
|
types[1].get_collation_type()))) {
|
||||||
|
LOG_WARN("failed to check valid implicit convert", K(ret));
|
||||||
|
}
|
||||||
|
|
||||||
if (OB_SUCC(ret) && !enumset_to_varchar) {
|
if (OB_SUCC(ret) && !enumset_to_varchar) {
|
||||||
//cast type when type not same.
|
//cast type when type not same.
|
||||||
const ObObjTypeClass value_tc = ob_obj_type_class(types[4].get_type());
|
const ObObjTypeClass value_tc = ob_obj_type_class(types[4].get_type());
|
||||||
|
|||||||
Reference in New Issue
Block a user