[CP] fix select into outfile with gbk encoding bug
This commit is contained in:
18
deps/oblib/src/lib/charset/ob_charset.h
vendored
18
deps/oblib/src/lib/charset/ob_charset.h
vendored
@ -578,7 +578,8 @@ public:
|
||||
template<typename foreach_char_func>
|
||||
static int foreach_char(const common::ObString &str,
|
||||
common::ObCollationType collation_type,
|
||||
foreach_char_func &func)
|
||||
foreach_char_func &func,
|
||||
bool ignore_invalid_character = false)
|
||||
{
|
||||
int ret = common::OB_SUCCESS;
|
||||
int32_t wchar = 0;
|
||||
@ -587,8 +588,19 @@ public:
|
||||
|
||||
for (common::ObString temp_str = str; OB_SUCC(ret) && !temp_str.empty(); temp_str+=length) {
|
||||
if (OB_FAIL(ObCharset::mb_wc(collation_type, temp_str.ptr(), temp_str.length(), length, wchar))) {
|
||||
COMMON_LOG(WARN, "fail to call mb_wc", K(ret), KPHEX(temp_str.ptr(), temp_str.length()));
|
||||
} else {
|
||||
COMMON_LOG(WARN, "fail to call mb_wc", K(ret), KPHEX(temp_str.ptr(), temp_str.length()), K(ignore_invalid_character));
|
||||
if (OB_ERR_INCORRECT_STRING_VALUE == ret && ignore_invalid_character) {
|
||||
ret = common::OB_SUCCESS;
|
||||
wchar = INT32_MAX;
|
||||
length = ObCharset::is_mbchar(collation_type, temp_str.ptr(), temp_str.ptr() + temp_str.length());
|
||||
if (length <= 0) {
|
||||
int64_t min_len = 0;
|
||||
ObCharset::get_mbminlen_by_coll(collation_type, min_len);
|
||||
length = static_cast<int32_t>(min_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
encoding.assign_ptr(temp_str.ptr(), length);
|
||||
if (OB_FAIL(func(encoding, wchar))) {
|
||||
COMMON_LOG(WARN, "fail to call func", K(ret), K(encoding),
|
||||
|
||||
@ -277,7 +277,7 @@ int ObExprToOutfileRow::print_field(char *buf, const int64_t buf_len, int64_t &p
|
||||
return ret;
|
||||
};
|
||||
ObString tmp_str(out_info.tmp_buf_len_, tmp_pos, out_info.tmp_buf_);
|
||||
OZ(ObCharsetUtils::foreach_char(tmp_str, out_info.print_params_.cs_type_, escape_func));
|
||||
OZ(ObCharsetUtils::foreach_char(tmp_str, out_info.print_params_.cs_type_, escape_func, true));
|
||||
}
|
||||
if (need_enclose) {
|
||||
OZ(out_info.enclose_.print_plain_str_literal(buf, buf_len, pos, out_info.print_params_));
|
||||
|
||||
Reference in New Issue
Block a user