[CP] [CP] [CP] fix some bugs

This commit is contained in:
wjhh2008 2023-07-11 13:42:28 +00:00 committed by ob-robot
parent 18c3958dbe
commit a73393f0e7
4 changed files with 24 additions and 14 deletions

View File

@ -1234,17 +1234,19 @@ int ObCharset::display_len(ObCollationType collation_type,
ob_wc_t wc;
int bytes = cs->cset->mb_wc(cs, &wc, buf + char_pos, buf + buf_size);
if (OB_UNLIKELY(bytes == OB_CS_ILSEQ)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("Failed to call mb_wc", K(ret), "func_ret", bytes);
} else if (bytes < 0) { // remain buf is too smalll
if (bytes < 0) {
found = true;
} else {
// get displayed width
int w = ObCharset::is_cjk_charset(collation_type) ? mk_wcwidth_cjk(wc) : mk_wcwidth(wc);
int w = 0;
if (bytes > OB_CS_ILSEQ) {
w = ObCharset::is_cjk_charset(collation_type) ? mk_wcwidth_cjk(wc) : mk_wcwidth(wc);
}
if (w <= 0) {
w = 1;
}
if (OB_CS_ILSEQ == bytes) {
bytes = 1;
}
if (char_pos + bytes <= buf_size) {
width += w;
char_pos += bytes;
@ -1283,17 +1285,19 @@ int ObCharset::max_display_width_charpos(ObCollationType collation_type, const c
ob_wc_t wc;
int bytes = cs->cset->mb_wc(cs, &wc, buf + char_pos, buf + mb_size);
if (OB_UNLIKELY(bytes == OB_CS_ILSEQ)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("Failed to call mb_wc", K(ret), "func_ret", bytes);
} else if (bytes < 0) { // remain buf is too smalll
if (bytes < 0) { // remain buf is too smalll
found = true;
} else {
// get displayed width
int w = ObCharset::is_cjk_charset(collation_type) ? mk_wcwidth_cjk(wc) : mk_wcwidth(wc);
int w = 0;
if (bytes > OB_CS_ILSEQ) {
w = ObCharset::is_cjk_charset(collation_type) ? mk_wcwidth_cjk(wc) : mk_wcwidth(wc);
}
if (w <= 0) {
w = 1;
}
if (OB_CS_ILSEQ == bytes) {
bytes = 1;
}
if (char_pos + bytes <= mb_size && total_width + w <= max_width) {
total_width += w;
char_pos += bytes;

View File

@ -996,6 +996,12 @@
res_obj.set_scale(column.get_data_scale());\
ret = (class_obj).set_##column_name(res_obj); \
} \
else if (column.is_generated_column()) { \
res_obj.set_string(data_type, str_value); \
res_obj.meta_.set_collation_type(CS_TYPE_UTF8MB4_BIN); \
res_obj.meta_.set_collation_level(CS_LEVEL_IMPLICIT); \
ret = (class_obj).set_##column_name(res_obj); \
} \
else if (column.is_identity_column() || ob_is_string_type(data_type) || ob_is_geometry(data_type)) \
{ \
res_obj.set_string(data_type, str_value); \

View File

@ -244,7 +244,7 @@ int ObExprToOutfileRow::print_field(char *buf, const int64_t buf_len, int64_t &p
int ret = OB_SUCCESS;
int64_t tmp_pos = 0;
const bool need_enclose = 0 != out_info.wchar_enclose_ &&
(!out_info.is_optional_ || obj.is_string_type());
(!out_info.is_optional_ || obj.is_string_type()) && !obj.is_null();
if (need_enclose) {
OZ(out_info.enclose_.print_plain_str_literal(buf, buf_len, pos, out_info.print_params_));
}

View File

@ -177,7 +177,7 @@ int ObCreateTenantResolver::resolve(const ParseNode &parse_tree)
if (OB_SUCC(ret)) {
if (OB_UNLIKELY(collation_type != ObCharset::get_default_collation_oracle(charset_type))) {
ret = OB_ERR_UNEXPECTED;
ret = OB_ERR_CHARACTER_SET_MISMATCH;
LOG_WARN("collation isn't corresponding to charset in oracle mode", K(ret),
K(collation_type), K(ObCharset::get_default_collation_oracle(charset_type)));
}