diff --git a/src/observer/table/ob_table_batch_execute_processor.cpp b/src/observer/table/ob_table_batch_execute_processor.cpp index 968f9b67f..8791f188a 100644 --- a/src/observer/table/ob_table_batch_execute_processor.cpp +++ b/src/observer/table/ob_table_batch_execute_processor.cpp @@ -354,7 +354,9 @@ int ObTableBatchExecuteP::htable_put() const ObTableOperation &table_operation = batch_operation.at(i); ObTableOperationResult single_op_result; 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)); } table::ObTableApiUtil::replace_ret_code(ret); @@ -415,7 +417,9 @@ int ObTableBatchExecuteP::multi_get() ObTableOperationResult op_result; ObITableEntity *result_entity = result_.get_entity_factory()->alloc(); 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) { ret = OB_SUCCESS; } else { @@ -480,7 +484,9 @@ int ObTableBatchExecuteP::multi_delete() ObTableOperationResult op_result; ObTableApiExecutor *executor = nullptr; 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; LOG_WARN("fail to alloc memroy for result_entity", K(ret)); } 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()); ObTableOperationResult op_result; 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; LOG_WARN("fail to alloc entity", K(ret), K(i)); } 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()); ObTableOperationResult op_result; 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; LOG_WARN("fail to alloc entity", K(ret), K(i)); } else if (FALSE_IT(op_result.set_entity(*result_entity))) { diff --git a/src/observer/table/ob_table_context.cpp b/src/observer/table/ob_table_context.cpp index 9b431b2e4..2667b4591 100644 --- a/src/observer/table/ob_table_context.cpp +++ b/src/observer/table/ob_table_context.cpp @@ -823,12 +823,22 @@ int ObTableCtx::generate_key_range(const ObIArray &scan_ranges) } if (0 == j) { // padding for startkey 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); } else { // padding for endkey 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); } diff --git a/src/observer/table/ob_table_context.h b/src/observer/table/ob_table_context.h index 01e2b18d0..a30f899e8 100644 --- a/src/observer/table/ob_table_context.h +++ b/src/observer/table/ob_table_context.h @@ -357,6 +357,7 @@ public: static int convert_lob(common::ObIAllocator &allocator, ObObj &obj); // read lob的allocator需要保证obj序列化到rpc buffer后才能析构 static int read_real_lob(common::ObIAllocator &allocator, ObObj &obj); + int adjust_entity(); private: // for common 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_rowkey(); int adjust_properties(); - int adjust_entity(); bool has_exist_in_columns(const common::ObIArray& columns, const common::ObString &name, int64_t *idx = nullptr) const; diff --git a/src/observer/table/ob_table_op_wrapper.cpp b/src/observer/table/ob_table_op_wrapper.cpp index a5632ac1c..ef1760c23 100644 --- a/src/observer/table/ob_table_op_wrapper.cpp +++ b/src/observer/table/ob_table_op_wrapper.cpp @@ -208,10 +208,20 @@ int ObTableApiUtil::construct_entity_from_row(ObIAllocator &allocator, ObITableEntity *entity) { int ret = OB_SUCCESS; - const int64_t N = cnames.count(); + int64_t N = cnames.count(); const ObColumnSchemaV2 *column_schema = NULL; + ObSEArray all_columns; + const ObIArray* 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) { - const ObString &name = cnames.at(i); + const ObString &name = arr_col->at(i); if (OB_ISNULL(column_schema = table_schema->get_column_schema(name))) { ret = OB_ERR_COLUMN_NOT_FOUND; LOG_WARN("column not exist", K(ret), K(name)); @@ -228,6 +238,25 @@ int ObTableApiUtil::construct_entity_from_row(ObIAllocator &allocator, return ret; } +int ObTableApiUtil::expand_all_columns(const ObTableSchema *table_schema, + ObIArray &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 ret = OB_SUCCESS; diff --git a/src/observer/table/ob_table_op_wrapper.h b/src/observer/table/ob_table_op_wrapper.h index 21d0cb54d..9d5858552 100644 --- a/src/observer/table/ob_table_op_wrapper.h +++ b/src/observer/table/ob_table_op_wrapper.h @@ -84,6 +84,8 @@ public: const ObTableSchema *table_schema, const ObIArray &cnames, ObITableEntity *entity); + static int expand_all_columns(const ObTableSchema *table_schema, + ObIArray &cnames); static void replace_ret_code(int &ret) { if (OB_ERR_PRIMARY_KEY_DUPLICATE == ret