[CP]opt dml update lob check changed
This commit is contained in:
parent
0bfca5dc0e
commit
8bd8e8fad9
@ -312,18 +312,21 @@ int ObDMLService::check_lob_column_changed(ObEvalCtx &eval_ctx,
|
||||
bool new_set_has_lob_header = new_expr.obj_meta_.has_lob_header() && new_str.length() > 0;
|
||||
ObLobLocatorV2 old_lob(old_str, old_set_has_lob_header);
|
||||
ObLobLocatorV2 new_lob(new_str, new_set_has_lob_header);
|
||||
ObLobCompareParams cmp_params;
|
||||
// binary compare ignore charset
|
||||
cmp_params.collation_left_ = CS_TYPE_BINARY;
|
||||
cmp_params.collation_right_ = CS_TYPE_BINARY;
|
||||
cmp_params.offset_left_ = 0;
|
||||
cmp_params.offset_right_ = 0;
|
||||
cmp_params.compare_len_ = UINT64_MAX;
|
||||
cmp_params.timeout_ = timeout;
|
||||
cmp_params.tx_desc_ = eval_ctx.exec_ctx_.get_my_session()->get_tx_desc();
|
||||
if(old_set_has_lob_header && new_set_has_lob_header) {
|
||||
if(OB_FAIL(lob_mngr->compare(old_lob, new_lob, cmp_params, result))) {
|
||||
if (old_set_has_lob_header && new_set_has_lob_header) {
|
||||
bool is_equal = false;
|
||||
ObLobCompareParams cmp_params;
|
||||
// binary compare ignore charset
|
||||
cmp_params.collation_left_ = CS_TYPE_BINARY;
|
||||
cmp_params.collation_right_ = CS_TYPE_BINARY;
|
||||
cmp_params.offset_left_ = 0;
|
||||
cmp_params.offset_right_ = 0;
|
||||
cmp_params.compare_len_ = UINT64_MAX;
|
||||
cmp_params.timeout_ = timeout;
|
||||
cmp_params.tx_desc_ = eval_ctx.exec_ctx_.get_my_session()->get_tx_desc();
|
||||
if(OB_FAIL(lob_mngr->equal(old_lob, new_lob, cmp_params, is_equal))) {
|
||||
LOG_WARN("fail to compare lob", K(ret), K(old_lob), K(new_lob));
|
||||
} else {
|
||||
result = is_equal ? 0 : 1;
|
||||
}
|
||||
} else {
|
||||
result = ObDatum::binary_equal(old_datum, new_datum) ? 0 : 1;
|
||||
|
@ -393,7 +393,7 @@ int ObLobManager::get_ls_leader(ObLobAccessParam& param, const uint64_t tenant_i
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOG_INFO("get ls leader", K(tenant_id), K(ls_id), K(leader), K(cluster_id));
|
||||
LOG_DEBUG("get ls leader", K(tenant_id), K(ls_id), K(leader), K(cluster_id));
|
||||
}
|
||||
} while (OB_LS_LOCATION_NOT_EXIST == ret && renew_count < max_renew_count);
|
||||
|
||||
@ -763,12 +763,46 @@ int ObLobManager::query(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLobManager::equal(ObLobLocatorV2& lob_left,
|
||||
ObLobLocatorV2& lob_right,
|
||||
ObLobCompareParams& cmp_params,
|
||||
bool& result)
|
||||
{
|
||||
INIT_SUCC(ret);
|
||||
int64_t old_len = 0;
|
||||
int64_t new_len = 0;
|
||||
int64_t cmp_res = 0;
|
||||
if (OB_FAIL(lob_left.get_lob_data_byte_len(old_len))) {
|
||||
LOG_WARN("fail to get old byte len", K(ret), K(lob_left));
|
||||
} else if (OB_FAIL(lob_right.get_lob_data_byte_len(new_len))) {
|
||||
LOG_WARN("fail to get new byte len", K(ret), K(lob_right));
|
||||
} else if (new_len != old_len) {
|
||||
result = false;
|
||||
} else if (lob_left.has_inrow_data() && lob_right.has_inrow_data()) {
|
||||
// do both inrow check
|
||||
ObString left_str;
|
||||
ObString right_str;
|
||||
if (OB_FAIL(lob_left.get_inrow_data(left_str))) {
|
||||
LOG_WARN("fail to get old inrow data", K(ret), K(lob_left));
|
||||
} else if (OB_FAIL(lob_right.get_inrow_data(right_str))) {
|
||||
LOG_WARN("fail to get new inrow data", K(ret), K(lob_left));
|
||||
} else {
|
||||
result = (0 == MEMCMP(left_str.ptr(), right_str.ptr(), left_str.length()));
|
||||
}
|
||||
} else if (OB_FAIL(compare(lob_left, lob_right, cmp_params, cmp_res))) {
|
||||
LOG_WARN("fail to compare lob", K(ret), K(lob_left), K(lob_right));
|
||||
} else {
|
||||
result = (0 == cmp_res);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLobManager::compare(ObLobLocatorV2& lob_left,
|
||||
ObLobLocatorV2& lob_right,
|
||||
ObLobCompareParams& cmp_params,
|
||||
int64_t& result) {
|
||||
INIT_SUCC(ret);
|
||||
ObArenaAllocator tmp_allocator(ObModIds::OB_LOB_READER, OB_MALLOC_NORMAL_BLOCK_SIZE, MTL_ID());
|
||||
ObArenaAllocator tmp_allocator(ObModIds::OB_LOB_READER, OB_MALLOC_MIDDLE_BLOCK_SIZE, MTL_ID());
|
||||
ObLobManager *lob_mngr = MTL(ObLobManager*);
|
||||
if (OB_ISNULL(lob_mngr)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -817,15 +851,18 @@ int ObLobManager::compare(ObLobAccessParam& param_left,
|
||||
} else if (OB_FAIL(query(param_right, iter_right))) {
|
||||
LOG_WARN("query param right by iter failed.", K(ret), K(param_right));
|
||||
} else {
|
||||
uint64_t read_buff_size = ObLobManager::LOB_READ_BUFFER_LEN;
|
||||
uint64_t read_buff_size = OB_MALLOC_MIDDLE_BLOCK_SIZE; // 64KB
|
||||
char *read_buff = nullptr;
|
||||
char *charset_convert_buff_ptr = nullptr;
|
||||
uint64_t charset_convert_buff_size = read_buff_size * ObCharset::CharConvertFactorNum;
|
||||
bool need_convert_charset = (collation_left != CS_TYPE_BINARY);
|
||||
uint64_t charset_convert_buff_size = need_convert_charset ?
|
||||
0 : read_buff_size * ObCharset::CharConvertFactorNum;
|
||||
|
||||
if (OB_ISNULL((read_buff = static_cast<char*>(tmp_allocator->alloc(read_buff_size * 2))))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("alloc read buffer failed.", K(ret), K(read_buff_size));
|
||||
} else if (OB_ISNULL((charset_convert_buff_ptr = static_cast<char*>(tmp_allocator->alloc(charset_convert_buff_size))))) {
|
||||
} else if (need_convert_charset &&
|
||||
OB_ISNULL((charset_convert_buff_ptr = static_cast<char*>(tmp_allocator->alloc(charset_convert_buff_size))))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("alloc charset convert buffer failed.", K(ret), K(charset_convert_buff_size));
|
||||
} else {
|
||||
@ -863,7 +900,7 @@ int ObLobManager::compare(ObLobAccessParam& param_left,
|
||||
} else {
|
||||
ret = OB_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
} else if (need_convert_charset) {
|
||||
// convert right lob to left charset if necessary
|
||||
if(OB_FAIL(ObExprUtil::convert_string_collation(
|
||||
read_buffer_right, collation_right,
|
||||
@ -873,6 +910,8 @@ int ObLobManager::compare(ObLobAccessParam& param_left,
|
||||
K(read_buffer_right), K(collation_right),
|
||||
K(convert_buffer_right), K(cmp_collation));
|
||||
}
|
||||
} else {
|
||||
convert_buffer_right.assign_ptr(read_buffer_right.ptr(), read_buffer_right.length());
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
|
@ -223,7 +223,10 @@ public:
|
||||
ObLobLocatorV2& lob_right,
|
||||
ObLobCompareParams& cmp_params,
|
||||
int64_t& result);
|
||||
|
||||
int equal(ObLobLocatorV2& lob_left,
|
||||
ObLobLocatorV2& lob_right,
|
||||
ObLobCompareParams& cmp_params,
|
||||
bool& result);
|
||||
// int insert(const common::ObTabletID &tablet_id, ObObj *obj, uint64_t offset, char *data, uint64_t len);
|
||||
// int erase(const common::ObTabletID &tablet_id, ObObj *obj, uint64_t offset, uint64_t len);
|
||||
int get_real_data(ObLobAccessParam& param,
|
||||
|
Loading…
x
Reference in New Issue
Block a user