[FEAT MERGE]charset latin1
This commit is contained in:
@ -1262,8 +1262,8 @@ static int common_string_string(const ObExpr &expr,
|
||||
ObCharset::charset_type_by_coll(out_cs_type))) {
|
||||
// handle !blob->!blob
|
||||
char *buf = NULL;
|
||||
const int64_t factor = 2;
|
||||
int64_t buf_len = in_str.length() * factor;
|
||||
//latin1 1bytes,utf8mb4 4bytes,the factor should be 4
|
||||
int64_t buf_len = in_str.length() * ObCharset::CharConvertFactorNum;
|
||||
uint32_t result_len = 0;
|
||||
buf = expr.get_str_res_mem(ctx, buf_len);
|
||||
if (OB_ISNULL(buf)) {
|
||||
|
||||
@ -22,6 +22,8 @@
|
||||
#include "sql/resolver/expr/ob_raw_expr_util.h"
|
||||
#include "lib/oblog/ob_log_module.h"
|
||||
#include "ob_expr_json_func_helper.h"
|
||||
#include "lib/charset/ob_charset.h"
|
||||
|
||||
// from sql_parser_base.h
|
||||
#define DEFAULT_STR_LENGTH -1
|
||||
|
||||
@ -865,8 +867,7 @@ int ObExprJsonValue::cast_to_string(common::ObIAllocator *allocator,
|
||||
&& (ObCharset::charset_type_by_coll(in_cs_type) !=
|
||||
ObCharset::charset_type_by_coll(dst_cs_type))) {
|
||||
char *buf = NULL;
|
||||
const int64_t factor = 2;
|
||||
int64_t buf_len = temp_str_val.length() * factor;
|
||||
int64_t buf_len = temp_str_val.length() * ObCharset::CharConvertFactorNum;
|
||||
uint32_t result_len = 0;
|
||||
buf = reinterpret_cast<char*>(allocator->alloc(buf_len));
|
||||
if (OB_ISNULL(buf)) {
|
||||
|
||||
@ -75,7 +75,7 @@ int ObExprRowIDToNChar::eval_rowid_to_nchar(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
ObURowIDData rowid_data = arg->get_urowid();
|
||||
char *buf = NULL;
|
||||
char *utf16_buf = NULL;
|
||||
const int32_t CharConvertFactorNum = 4; //最多使用4字节存储一个字符
|
||||
//const int32_t CharConvertFactorNum = 4; //最多使用4字节存储一个字符
|
||||
int64_t size = rowid_data.needed_base64_buffer_size();
|
||||
int64_t pos = 0;
|
||||
uint32_t res_len = 0;
|
||||
@ -86,12 +86,12 @@ int ObExprRowIDToNChar::eval_rowid_to_nchar(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
LOG_WARN("alloc mem failed", K(ret), K(size));
|
||||
} else if (OB_FAIL(rowid_data.get_base64_str(buf, size, pos))) {
|
||||
LOG_WARN("encode rowid obj failed", K(ret));
|
||||
} else if (OB_ISNULL(utf16_buf = (char*)(expr.get_str_res_mem(ctx, pos * CharConvertFactorNum)))) {
|
||||
} else if (OB_ISNULL(utf16_buf = (char*)(expr.get_str_res_mem(ctx, pos * ObCharset::CharConvertFactorNum)))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("alloc mem failed", K(ret), K(pos * CharConvertFactorNum));
|
||||
LOG_WARN("alloc mem failed", K(ret), K(pos * ObCharset::CharConvertFactorNum));
|
||||
} else if (OB_FAIL(ObCharset::charset_convert(CS_TYPE_UTF8MB4_GENERAL_CI,
|
||||
buf, pos, expr.datum_meta_.cs_type_,
|
||||
utf16_buf, pos * CharConvertFactorNum, res_len))) {
|
||||
utf16_buf, pos * ObCharset::CharConvertFactorNum, res_len))) {
|
||||
LOG_WARN("charset convert failed", K(ret));
|
||||
} else {
|
||||
expr_datum.set_string(ObString(res_len, utf16_buf));
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
#include "sql/ob_sql_utils.h"
|
||||
#include "common/ob_smart_call.h"
|
||||
#include "lib/charset/ob_charset.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::sql;
|
||||
@ -527,8 +528,7 @@ int ObExprUtil::convert_string_collation(const ObString &in_str,
|
||||
out_str = in_str;
|
||||
} else {
|
||||
char *buf = NULL;
|
||||
const int32_t CharConvertFactorNum = 4; //最多使用4字节存储一个字符
|
||||
int32_t buf_len = in_str.length() * CharConvertFactorNum;
|
||||
int32_t buf_len = in_str.length() * ObCharset::CharConvertFactorNum;
|
||||
uint32_t result_len = 0;
|
||||
if (OB_ISNULL(buf = static_cast<char*>(alloc.alloc(buf_len)))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
@ -622,7 +622,7 @@ int ObExprUtil::convert_utf8_charset(ObIAllocator& allocator,
|
||||
int ret = OB_SUCCESS;
|
||||
char *buf = NULL;
|
||||
//一个字符最多4个byte
|
||||
int32_t buf_len = from_string.length() * 4;
|
||||
int32_t buf_len = from_string.length() * ObCharset::CharConvertFactorNum;
|
||||
uint32_t result_len = 0;
|
||||
if (0 == buf_len) {
|
||||
} else if (from_collation == CS_TYPE_UTF8MB4_BIN) {
|
||||
|
||||
Reference in New Issue
Block a user