bugfix : patch obkv bugfix to master

This commit is contained in:
obdev
2023-12-13 11:13:02 +00:00
committed by ob-robot
parent 739d40b2a6
commit 6676674171
5 changed files with 61 additions and 10 deletions

View File

@ -354,7 +354,9 @@ int ObTableBatchExecuteP::htable_put()
const ObTableOperation &table_operation = batch_operation.at(i); const ObTableOperation &table_operation = batch_operation.at(i);
ObTableOperationResult single_op_result; ObTableOperationResult single_op_result;
tb_ctx_.set_entity(&table_operation.entity()); tb_ctx_.set_entity(&table_operation.entity());
if (OB_FAIL(ObTableOpWrapper::process_op_with_spec(tb_ctx_, spec, single_op_result))) { if (i > 0 && OB_FAIL(tb_ctx_.adjust_entity())) { // first entity adjust in init_single_op_tb_ctx
LOG_WARN("fail to adjust entity", K(ret));
} else if (OB_FAIL(ObTableOpWrapper::process_op_with_spec(tb_ctx_, spec, single_op_result))) {
LOG_WARN("fail to process op with spec", K(ret)); LOG_WARN("fail to process op with spec", K(ret));
} }
table::ObTableApiUtil::replace_ret_code(ret); table::ObTableApiUtil::replace_ret_code(ret);
@ -415,7 +417,9 @@ int ObTableBatchExecuteP::multi_get()
ObTableOperationResult op_result; ObTableOperationResult op_result;
ObITableEntity *result_entity = result_.get_entity_factory()->alloc(); ObITableEntity *result_entity = result_.get_entity_factory()->alloc();
ObNewRow *row = nullptr; ObNewRow *row = nullptr;
if (OB_FAIL(ObTableOpWrapper::process_get_with_spec(tb_ctx_, spec, row))) { if (i > 0 && OB_FAIL(tb_ctx_.adjust_entity())) { // first entity adjust in init_single_op_tb_ctx
LOG_WARN("fail to adjust entity", K(ret));
} else if (OB_FAIL(ObTableOpWrapper::process_get_with_spec(tb_ctx_, spec, row))) {
if (ret == OB_ITER_END) { if (ret == OB_ITER_END) {
ret = OB_SUCCESS; ret = OB_SUCCESS;
} else { } else {
@ -480,7 +484,9 @@ int ObTableBatchExecuteP::multi_delete()
ObTableOperationResult op_result; ObTableOperationResult op_result;
ObTableApiExecutor *executor = nullptr; ObTableApiExecutor *executor = nullptr;
ObITableEntity *result_entity = result_.get_entity_factory()->alloc(); ObITableEntity *result_entity = result_.get_entity_factory()->alloc();
if (OB_ISNULL(result_entity)) { if (i > 0 && OB_FAIL(tb_ctx_.adjust_entity())) { // first entity adjust in init_single_op_tb_ctx
LOG_WARN("fail to adjust entity", K(ret));
} else if (OB_ISNULL(result_entity)) {
ret = OB_ALLOCATE_MEMORY_FAILED; ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("fail to alloc memroy for result_entity", K(ret)); LOG_WARN("fail to alloc memroy for result_entity", K(ret));
} else if (FALSE_IT(op_result.set_entity(*result_entity))) { } else if (FALSE_IT(op_result.set_entity(*result_entity))) {
@ -614,7 +620,9 @@ int ObTableBatchExecuteP::multi_insert()
tb_ctx_.set_entity(&table_operation.entity()); tb_ctx_.set_entity(&table_operation.entity());
ObTableOperationResult op_result; ObTableOperationResult op_result;
ObITableEntity *result_entity = result_.get_entity_factory()->alloc(); ObITableEntity *result_entity = result_.get_entity_factory()->alloc();
if (OB_ISNULL(result_entity)) { if (i > 0 && OB_FAIL(tb_ctx_.adjust_entity())) { // first entity adjust in init_single_op_tb_ctx
LOG_WARN("fail to adjust entity", K(ret));
} else if (OB_ISNULL(result_entity)) {
ret = OB_ALLOCATE_MEMORY_FAILED; ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("fail to alloc entity", K(ret), K(i)); LOG_WARN("fail to alloc entity", K(ret), K(i));
} else if (FALSE_IT(op_result.set_entity(*result_entity))) { } else if (FALSE_IT(op_result.set_entity(*result_entity))) {
@ -670,7 +678,9 @@ int ObTableBatchExecuteP::multi_replace()
tb_ctx_.set_entity(&table_operation.entity()); tb_ctx_.set_entity(&table_operation.entity());
ObTableOperationResult op_result; ObTableOperationResult op_result;
ObITableEntity *result_entity = result_.get_entity_factory()->alloc(); ObITableEntity *result_entity = result_.get_entity_factory()->alloc();
if (OB_ISNULL(result_entity)) { if (i > 0 && OB_FAIL(tb_ctx_.adjust_entity())) { // first entity adjust in init_single_op_tb_ctx
LOG_WARN("fail to adjust entity", K(ret));
} else if (OB_ISNULL(result_entity)) {
ret = OB_ALLOCATE_MEMORY_FAILED; ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("fail to alloc entity", K(ret), K(i)); LOG_WARN("fail to alloc entity", K(ret), K(i));
} else if (FALSE_IT(op_result.set_entity(*result_entity))) { } else if (FALSE_IT(op_result.set_entity(*result_entity))) {

View File

@ -823,12 +823,22 @@ int ObTableCtx::generate_key_range(const ObIArray<ObNewRange> &scan_ranges)
} }
if (0 == j) { // padding for startkey if (0 == j) { // padding for startkey
for (int64_t k = 0; k < padding_num; ++k) { for (int64_t k = 0; k < padding_num; ++k) {
new_objs[k+old_objs_num] = ObObj::make_min_obj(); // if inclusive start, should padding min value. else padding max value
if (index_key_range.border_flag_.inclusive_start()) {
new_objs[k+old_objs_num] = ObObj::make_min_obj();
} else {
new_objs[k+old_objs_num] = ObObj::make_max_obj();
}
} }
index_key_range.start_key_.assign(new_objs, new_objs_num); index_key_range.start_key_.assign(new_objs, new_objs_num);
} else { // padding for endkey } else { // padding for endkey
for (int64_t k = 0; k < padding_num; ++k) { for (int64_t k = 0; k < padding_num; ++k) {
new_objs[k+old_objs_num] = ObObj::make_max_obj(); // if inclusive end, should padding max value. else padding min value
if (index_key_range.border_flag_.inclusive_end()) {
new_objs[k+old_objs_num] = ObObj::make_max_obj();
} else {
new_objs[k+old_objs_num] = ObObj::make_min_obj();
}
} }
index_key_range.end_key_.assign(new_objs, new_objs_num); index_key_range.end_key_.assign(new_objs, new_objs_num);
} }

View File

@ -357,6 +357,7 @@ public:
static int convert_lob(common::ObIAllocator &allocator, ObObj &obj); static int convert_lob(common::ObIAllocator &allocator, ObObj &obj);
// read lob的allocator需要保证obj序列化到rpc buffer后才能析构 // read lob的allocator需要保证obj序列化到rpc buffer后才能析构
static int read_real_lob(common::ObIAllocator &allocator, ObObj &obj); static int read_real_lob(common::ObIAllocator &allocator, ObObj &obj);
int adjust_entity();
private: private:
// for common // for common
int get_tablet_by_rowkey(const common::ObRowkey &rowkey, int get_tablet_by_rowkey(const common::ObRowkey &rowkey,
@ -393,7 +394,6 @@ private:
int adjust_column(const ObColumnSchemaV2 &col_schema, ObObj &obj); int adjust_column(const ObColumnSchemaV2 &col_schema, ObObj &obj);
int adjust_rowkey(); int adjust_rowkey();
int adjust_properties(); int adjust_properties();
int adjust_entity();
bool has_exist_in_columns(const common::ObIArray<common::ObString>& columns, bool has_exist_in_columns(const common::ObIArray<common::ObString>& columns,
const common::ObString &name, const common::ObString &name,
int64_t *idx = nullptr) const; int64_t *idx = nullptr) const;

View File

@ -208,10 +208,20 @@ int ObTableApiUtil::construct_entity_from_row(ObIAllocator &allocator,
ObITableEntity *entity) ObITableEntity *entity)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t N = cnames.count(); int64_t N = cnames.count();
const ObColumnSchemaV2 *column_schema = NULL; const ObColumnSchemaV2 *column_schema = NULL;
ObSEArray<ObString, 32> all_columns;
const ObIArray<ObString>* arr_col = &cnames;
if (N == 0) {
if (OB_FAIL(expand_all_columns(table_schema, all_columns))) {
LOG_WARN("fail to expand all column to cnames", K(ret));
} else {
N = all_columns.count();
arr_col = &all_columns;
}
}
for (int64_t i = 0; OB_SUCC(ret) && i < N; ++i) { for (int64_t i = 0; OB_SUCC(ret) && i < N; ++i) {
const ObString &name = cnames.at(i); const ObString &name = arr_col->at(i);
if (OB_ISNULL(column_schema = table_schema->get_column_schema(name))) { if (OB_ISNULL(column_schema = table_schema->get_column_schema(name))) {
ret = OB_ERR_COLUMN_NOT_FOUND; ret = OB_ERR_COLUMN_NOT_FOUND;
LOG_WARN("column not exist", K(ret), K(name)); LOG_WARN("column not exist", K(ret), K(name));
@ -228,6 +238,25 @@ int ObTableApiUtil::construct_entity_from_row(ObIAllocator &allocator,
return ret; return ret;
} }
int ObTableApiUtil::expand_all_columns(const ObTableSchema *table_schema,
ObIArray<ObString> &cnames)
{
int ret = OB_SUCCESS;
const ObColumnSchemaV2 *column_schema = NULL;
ObTableSchema::const_column_iterator iter = table_schema->column_begin();
ObTableSchema::const_column_iterator end = table_schema->column_end();
for (; OB_SUCC(ret) && iter != end; iter++) {
column_schema = *iter;
if (OB_ISNULL(column_schema)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("column schema is NULL", K(ret));
} else if (OB_FAIL(cnames.push_back(column_schema->get_column_name_str()))) {
LOG_WARN("fail to push back column name", K(ret));
}
}
return ret;
}
int ObHTableDeleteExecutor::open() int ObHTableDeleteExecutor::open()
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;

View File

@ -84,6 +84,8 @@ public:
const ObTableSchema *table_schema, const ObTableSchema *table_schema,
const ObIArray<ObString> &cnames, const ObIArray<ObString> &cnames,
ObITableEntity *entity); ObITableEntity *entity);
static int expand_all_columns(const ObTableSchema *table_schema,
ObIArray<ObString> &cnames);
static void replace_ret_code(int &ret) static void replace_ret_code(int &ret)
{ {
if (OB_ERR_PRIMARY_KEY_DUPLICATE == ret if (OB_ERR_PRIMARY_KEY_DUPLICATE == ret