[feat]obkv adapt generate column refactoring.
This commit is contained in:
parent
27e0ba8ee8
commit
ab7cb46017
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -26,7 +26,7 @@ ObRawExpr* ObTableExprCgService::get_ref_raw_expr(const ObIArray<ObRawExpr *> &a
|
||||
bool found = false;
|
||||
ObColumnRefRawExpr *expr = nullptr;
|
||||
for (int64_t i = 0; i < all_exprs.count() && !found; i++) {
|
||||
if (T_REF_COLUMN == all_exprs.at(i)->get_expr_type()) {
|
||||
if (all_exprs.at(i)->is_column_ref_expr()) {
|
||||
expr = static_cast<ObColumnRefRawExpr*>(all_exprs.at(i));
|
||||
if (0 == col_name.case_compare(expr->get_column_name())) {
|
||||
found = true;
|
||||
@ -77,6 +77,9 @@ int ObTableExprCgService::build_generated_column_expr(ObTableCtx &ctx,
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid column for increment or append", K(ret), K(columns.count()));
|
||||
}
|
||||
ObIArray<ObTableCtx::ObGenDenpendantsPair> &gen_dependants_pairs = ctx.get_gen_dependants_pairs();
|
||||
ObTableCtx::ObGenDenpendantsPair pair;
|
||||
pair.first = &col_expr; // 记录生成列
|
||||
const ObIArray<ObRawExpr *> *src_exprs = &exprs;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < columns.count(); i++) {
|
||||
if (1 == i && is_inc_or_append_replace) {
|
||||
@ -90,6 +93,8 @@ int ObTableExprCgService::build_generated_column_expr(ObTableCtx &ctx,
|
||||
columns.at(i).ref_expr_,
|
||||
real_ref_expr))) {
|
||||
LOG_WARN("fail to replace column reference expr", K(ret));
|
||||
} else if (OB_FAIL(add_var_to_array_no_dup(pair.second, real_ref_expr))) { // 记录依赖的列
|
||||
LOG_WARN("fail to add expr to array", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,6 +115,9 @@ int ObTableExprCgService::build_generated_column_expr(ObTableCtx &ctx,
|
||||
if (OB_SUCC(ret)) {
|
||||
gen_expr->set_for_generated_column();
|
||||
col_expr.set_dependant_expr(gen_expr);
|
||||
if (OB_FAIL(gen_dependants_pairs.push_back(pair))) {
|
||||
LOG_WARN("fail to push back generate ref expr pair", K(ret), K(gen_dependants_pairs));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -124,7 +132,7 @@ int ObTableExprCgService::resolve_generated_column_expr(ObTableCtx &ctx)
|
||||
ctx.get_old_row_exprs() : ctx.get_all_exprs().get_expr_array();
|
||||
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < exprs.count(); i++) {
|
||||
if (T_REF_COLUMN == exprs.at(i)->get_expr_type()) {
|
||||
if (exprs.at(i)->is_column_ref_expr()) {
|
||||
ObColumnRefRawExpr *ref_expr = static_cast<ObColumnRefRawExpr *>(exprs.at(i));
|
||||
if (ref_expr->is_generated_column()) {
|
||||
const ObColumnSchemaV2 *gen_col_schema = nullptr;
|
||||
@ -254,7 +262,7 @@ int ObTableExprCgService::generate_full_assign_raw_exprs(ObTableCtx &ctx)
|
||||
|
||||
if (OB_SUCC(ret) && has_stored_gen_col) {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < full_assign_exprs.count(); i++) {
|
||||
if (T_REF_COLUMN == full_assign_exprs.at(i)->get_expr_type()) {
|
||||
if (full_assign_exprs.at(i)->is_column_ref_expr()) {
|
||||
ObColumnRefRawExpr *ref_expr = static_cast<ObColumnRefRawExpr *>(full_assign_exprs.at(i));
|
||||
if (ref_expr->is_stored_generated_column()) {
|
||||
const ObColumnSchemaV2 *gen_col_schema = nullptr;
|
||||
@ -780,6 +788,12 @@ int ObTableExprCgService::refresh_assign_exprs_frame(ObTableCtx &ctx,
|
||||
assign_ids,
|
||||
*col_schema))) {
|
||||
LOG_WARN("fail to refresh generated column related frame", K(ret));
|
||||
} else { // 计算一次
|
||||
ObExpr *expr = full_assign_row.at(assign_id);
|
||||
ObDatum *tmp_datum = nullptr;
|
||||
if (OB_FAIL(expr->eval(eval_ctx, tmp_datum))) {
|
||||
LOG_WARN("fail to eval datum", K(ret), K(*expr));
|
||||
}
|
||||
}
|
||||
} else if (OB_FAIL(entity.get_property(col_schema->get_column_name_str(), prop_value))) {
|
||||
LOG_WARN("fail to get assign propertity value", K(ret), K(col_schema->get_column_name_str()));
|
||||
@ -838,6 +852,30 @@ int ObTableExprCgService::refresh_delta_exprs_frame(ObTableCtx &ctx,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableDmlCgService::replace_exprs_with_dependant(const ObIArray<ObRawExpr *> &src_exprs,
|
||||
ObIArray<ObRawExpr *> &dst_exprs)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
for (int64_t i = 0; i < src_exprs.count() && OB_SUCC(ret); i++) {
|
||||
ObRawExpr *expr = src_exprs.at(i);
|
||||
if (!expr->is_column_ref_expr()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid expr type", K(ret), K(*expr));
|
||||
} else {
|
||||
ObColumnRefRawExpr *col_ref_expr = static_cast<ObColumnRefRawExpr*>(expr);
|
||||
if (col_ref_expr->is_generated_column()) {
|
||||
expr = col_ref_expr->get_dependant_expr();
|
||||
}
|
||||
if (OB_FAIL(dst_exprs.push_back(expr))) {
|
||||
LOG_WARN("fail to push back expr", K(ret), K(dst_exprs));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableDmlCgService::generate_insert_ctdef(ObTableCtx &ctx,
|
||||
ObIAllocator &allocator,
|
||||
ObTableInsCtDef &ins_ctdef)
|
||||
@ -847,8 +885,10 @@ int ObTableDmlCgService::generate_insert_ctdef(ObTableCtx &ctx,
|
||||
ObSEArray<ObRawExpr*, 64> new_row;
|
||||
const ObIArray<ObRawExpr *> &exprs = ctx.is_for_insertup() ?
|
||||
ctx.get_old_row_exprs() : ctx.get_all_exprs().get_expr_array();
|
||||
|
||||
if (OB_FAIL(new_row.assign(exprs))) {
|
||||
ObSEArray<ObRawExpr*, 64> tmp_exprs;
|
||||
if (OB_FAIL(replace_exprs_with_dependant(exprs, tmp_exprs))) {
|
||||
LOG_WARN("fail to replace exprs with dependant", K(ret), K(exprs));
|
||||
} else if (OB_FAIL(new_row.assign(tmp_exprs))) {
|
||||
LOG_WARN("fail to assign new row", K(ret));
|
||||
} else if (OB_FAIL(generate_base_ctdef(ctx,
|
||||
ins_ctdef,
|
||||
@ -881,8 +921,13 @@ int ObTableDmlCgService::generate_update_ctdef(ObTableCtx &ctx,
|
||||
ObSEArray<ObRawExpr*, 64> full_row;
|
||||
ObSEArray<ObRawExpr*, 8> assign_exprs;
|
||||
ObStaticEngineCG cg(ctx.get_cur_cluster_version());
|
||||
ObIArray<sql::ObRawExpr *> &old_exprs = ctx.get_old_row_exprs();
|
||||
ObSEArray<ObRawExpr*, 64> tmp_old_exprs;
|
||||
ObSEArray<ObRawExpr*, 64> tmp_full_assign_exprs;
|
||||
|
||||
if (OB_FAIL(old_row.assign(ctx.get_old_row_exprs()))) {
|
||||
if (OB_FAIL(replace_exprs_with_dependant(old_exprs, tmp_old_exprs))) {
|
||||
LOG_WARN("fail to replace exprs with dependant", K(ret), K(old_exprs));
|
||||
} else if (OB_FAIL(old_row.assign(tmp_old_exprs))) {
|
||||
LOG_WARN("fail to assign old row expr", K(ret));
|
||||
} else if (OB_FAIL(new_row.assign(old_row))) {
|
||||
LOG_WARN("fail to assign new row", K(ret));
|
||||
@ -891,23 +936,28 @@ int ObTableDmlCgService::generate_update_ctdef(ObTableCtx &ctx,
|
||||
} else if (OB_FAIL(ObTableExprCgService::generate_assign_exprs(ctx, assign_ids, assign_exprs))) {
|
||||
LOG_WARN("fail to generate assign exprs", K(ret), K(ctx), K(assign_ids));
|
||||
} else {
|
||||
ObColumnRefRawExpr *assign_col_expr = nullptr;
|
||||
ObColumnRefRawExpr *col_ref_expr = nullptr;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < assign_exprs.count(); i++) {
|
||||
if (OB_FAIL(full_row.push_back(assign_exprs.at(i)))) {
|
||||
LOG_WARN("fail to add assign expr to full row", K(ret), K(i));
|
||||
} else if (T_REF_COLUMN != assign_exprs.at(i)->get_expr_type()) {
|
||||
ObRawExpr *expr = assign_exprs.at(i);
|
||||
if (!expr->is_column_ref_expr()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected expr type", K(ret), K(assign_exprs.at(i)->get_expr_type()));
|
||||
} else if (FALSE_IT(assign_col_expr = static_cast<ObColumnRefRawExpr*>(assign_exprs.at(i)))) {
|
||||
LOG_WARN("unexpected expr type", K(ret), K(*expr));
|
||||
} else if (FALSE_IT(col_ref_expr = static_cast<ObColumnRefRawExpr*>(expr))) {
|
||||
} else if (col_ref_expr->is_generated_column()) {
|
||||
expr = col_ref_expr->get_dependant_expr();
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(full_row.push_back(expr))) {
|
||||
LOG_WARN("fail to add assign expr to full row", K(ret), K(i));
|
||||
} else {
|
||||
ObColumnRefRawExpr *old_col_expr = nullptr;
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < old_row.count(); j++) {
|
||||
if (T_REF_COLUMN != old_row.at(i)->get_expr_type()) {
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < old_exprs.count(); j++) {
|
||||
if (!old_exprs.at(i)->is_column_ref_expr()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected expr type", K(ret), K(old_row.at(i)->get_expr_type()));
|
||||
} else if (FALSE_IT(old_col_expr = static_cast<ObColumnRefRawExpr*>(old_row.at(j)))) {
|
||||
} else if (old_col_expr->get_column_id() == assign_col_expr->get_column_id()) {
|
||||
new_row.at(j) = assign_col_expr;
|
||||
LOG_WARN("unexpected expr type", K(ret), K(*old_exprs.at(i)));
|
||||
} else if (FALSE_IT(old_col_expr = static_cast<ObColumnRefRawExpr*>(old_exprs.at(j)))) {
|
||||
} else if (old_col_expr->get_column_id() == col_ref_expr->get_column_id()) {
|
||||
new_row.at(j) = expr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -923,7 +973,9 @@ int ObTableDmlCgService::generate_update_ctdef(ObTableCtx &ctx,
|
||||
LOG_WARN("fail to generate dml base ctdef", K(ret));
|
||||
} else if (OB_FAIL(cg.generate_rt_exprs(full_row, upd_ctdef.full_row_))) {
|
||||
LOG_WARN("fail to generate dml update full row exprs", K(ret), K(full_row));
|
||||
} else if (OB_FAIL(cg.generate_rt_exprs(ctx.get_full_assign_exprs(), upd_ctdef.full_assign_row_))) {
|
||||
} else if (OB_FAIL(replace_exprs_with_dependant(ctx.get_full_assign_exprs(), tmp_full_assign_exprs))) {
|
||||
LOG_WARN("fail to replace exprs with dependant", K(ret));
|
||||
} else if (OB_FAIL(cg.generate_rt_exprs(tmp_full_assign_exprs, upd_ctdef.full_assign_row_))) {
|
||||
LOG_WARN("fail to generate full assign row exprs", K(ret));
|
||||
} else if (ctx.is_inc_or_append() && OB_FAIL(cg.generate_rt_exprs(ctx.get_delta_exprs(), upd_ctdef.delta_exprs_))) {
|
||||
LOG_WARN("fail to generate delta exprs", K(ret));
|
||||
@ -1029,7 +1081,7 @@ int ObTableDmlCgService::generate_updated_column_ids(const ObIArray<ObRawExpr *>
|
||||
} else {
|
||||
ObColumnRefRawExpr *col_expr = NULL;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < assign_exprs.count(); i++) {
|
||||
if (T_REF_COLUMN != assign_exprs.at(i)->get_expr_type()) {
|
||||
if (!assign_exprs.at(i)->is_column_ref_expr()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected expr type", K(ret), K(assign_exprs.at(i)->get_expr_type()));
|
||||
} else if (FALSE_IT(col_expr = static_cast<ObColumnRefRawExpr*>(assign_exprs.at(i)))) {
|
||||
@ -1089,7 +1141,11 @@ int ObTableDmlCgService::generate_delete_ctdef(ObTableCtx &ctx,
|
||||
ObSEArray<ObRawExpr*, 64> old_row;
|
||||
ObSEArray<ObRawExpr*, 64> new_row;
|
||||
|
||||
if (OB_FAIL(old_row.assign(ctx.get_all_exprs().get_expr_array()))) {
|
||||
const ObIArray<ObRawExpr *> &exprs = ctx.get_all_exprs().get_expr_array();
|
||||
ObSEArray<ObRawExpr*, 64> tmp_exprs;
|
||||
if (OB_FAIL(replace_exprs_with_dependant(exprs, tmp_exprs))) {
|
||||
LOG_WARN("fail to replace exprs with dependant", K(ret));
|
||||
} else if (OB_FAIL(old_row.assign(tmp_exprs))) {
|
||||
LOG_WARN("fail to assign old row expr", K(ret));
|
||||
} else if (OB_FAIL(generate_base_ctdef(ctx,
|
||||
del_ctdef,
|
||||
@ -1320,7 +1376,7 @@ int ObTableDmlCgService::generate_single_constraint_info(ObTableCtx &ctx,
|
||||
LOG_WARN("fail to get rowkey column id", K(ret));
|
||||
} else {
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < all_exprs.count(); j++) {
|
||||
if (T_REF_COLUMN == all_exprs.at(j)->get_expr_type()) {
|
||||
if (all_exprs.at(j)->is_column_ref_expr()) {
|
||||
ObColumnRefRawExpr *ref_expr = static_cast<ObColumnRefRawExpr *>(all_exprs.at(j));
|
||||
if (ref_expr->get_column_id() == rowkey_column_id
|
||||
&& OB_FAIL(column_exprs.push_back(ref_expr))) {
|
||||
@ -1492,8 +1548,12 @@ int ObTableDmlCgService::generate_lock_ctdef(ObTableCtx &ctx,
|
||||
int ret = OB_SUCCESS;
|
||||
ObStaticEngineCG cg(ctx.get_cur_cluster_version());
|
||||
ObArray<ObRawExpr*> old_row;
|
||||
const ObIArray<ObRawExpr *> &exprs = ctx.get_all_exprs().get_expr_array();
|
||||
ObSEArray<ObRawExpr*, 64> tmp_exprs;
|
||||
|
||||
if (OB_FAIL(old_row.assign(ctx.get_all_exprs().get_expr_array()))) {
|
||||
if (OB_FAIL(replace_exprs_with_dependant(exprs, tmp_exprs))) {
|
||||
LOG_WARN("fail to replace exprs with dependant", K(ret));
|
||||
} else if (OB_FAIL(old_row.assign(tmp_exprs))) {
|
||||
LOG_WARN("fail to assign old row expr", K(ret));
|
||||
} else if (OB_FAIL(cg.generate_rt_exprs(old_row,
|
||||
lock_ctdef.old_row_))) {
|
||||
@ -1910,6 +1970,52 @@ int ObTableTscCgService::generate_rt_exprs(const ObTableCtx &ctx,
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 访问虚拟生成列转换为访问其依赖的列
|
||||
int ObTableTscCgService::replace_gen_col_exprs(const ObTableCtx &ctx,
|
||||
ObIArray<ObRawExpr*> &access_exprs)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (!ctx.get_table_schema()->has_generated_column()) {
|
||||
// do nothing
|
||||
} else {
|
||||
ObArray<ObRawExpr*> res_access_expr;
|
||||
const ObIArray<ObTableCtx::ObGenDenpendantsPair> &pairs = ctx.get_gen_dependants_pairs();
|
||||
ObColumnRefRawExpr *ref_expr = nullptr;
|
||||
const int64_t N = access_exprs.count();
|
||||
|
||||
for (int64_t i = 0; i < N && OB_SUCC(ret); i++) {
|
||||
ObRawExpr *expr = access_exprs.at(i);
|
||||
if (!expr->is_column_ref_expr()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected expr type", K(ret), K(*expr));
|
||||
} else if (FALSE_IT(ref_expr = static_cast<ObColumnRefRawExpr*>(expr))) {
|
||||
} else if (!ref_expr->is_virtual_generated_column()) {
|
||||
if (OB_FAIL(res_access_expr.push_back(expr))) {
|
||||
LOG_WARN("fail to push back expr", K(ret));
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < pairs.count() && OB_SUCC(ret); j++) {
|
||||
if (ref_expr == pairs.at(j).first) {
|
||||
const ObIArray<ObRawExpr*> &ref_exprs = pairs.at(j).second;
|
||||
if (OB_FAIL(append_array_no_dup(res_access_expr, ref_exprs))) {
|
||||
LOG_WARN("fail to append array no dup", K(ret), K(res_access_expr), K(ref_exprs));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
access_exprs.reset();
|
||||
if (OB_FAIL(access_exprs.assign(res_access_expr))) {
|
||||
LOG_WARN("fail to assign access expr", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 非索引扫描: access exprs = select exprs
|
||||
// 索引表: access exprs = [index column exprs][rowkey expr]
|
||||
// 索引回表: access expr = [rowkey expr][select without rowkey exprs]
|
||||
@ -1922,10 +2028,11 @@ int ObTableTscCgService::generate_access_ctdef(const ObTableCtx &ctx,
|
||||
const ObIArray<oceanbase::sql::ObRawExpr *> &select_exprs = ctx.get_select_exprs();
|
||||
const ObIArray<oceanbase::sql::ObRawExpr *> &rowkey_exprs = ctx.get_rowkey_exprs();
|
||||
const ObIArray<oceanbase::sql::ObRawExpr *> &index_exprs = ctx.get_index_exprs();
|
||||
const bool is_index_table = (ctx.is_index_scan() && das_tsc_ctdef.ref_table_id_ == ctx.get_index_table_id());
|
||||
|
||||
if (!ctx.is_index_scan() && OB_FAIL(access_exprs.assign(select_exprs))) { // 非索引扫描
|
||||
LOG_WARN("fail to assign access exprs", K(ret));
|
||||
} else if (ctx.is_index_scan() && das_tsc_ctdef.ref_table_id_ == ctx.get_index_table_id()) { // 索引表
|
||||
} else if (is_index_table) { // 索引表
|
||||
if (OB_FAIL(access_exprs.assign(index_exprs))) {
|
||||
LOG_WARN("fail to assign access exprs", K(ret), K(ctx.get_index_table_id()));
|
||||
} else {
|
||||
@ -1952,14 +2059,16 @@ int ObTableTscCgService::generate_access_ctdef(const ObTableCtx &ctx,
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(generate_rt_exprs(ctx, allocator, access_exprs, das_tsc_ctdef.pd_expr_spec_.access_exprs_))) {
|
||||
if (!is_index_table && OB_FAIL(replace_gen_col_exprs(ctx, access_exprs))) {
|
||||
LOG_WARN("fail to replace generate exprs", K(ret));
|
||||
} else if (OB_FAIL(generate_rt_exprs(ctx, allocator, access_exprs, das_tsc_ctdef.pd_expr_spec_.access_exprs_))) {
|
||||
LOG_WARN("fail to generate access rt exprs", K(ret));
|
||||
} else if (OB_FAIL(das_tsc_ctdef.access_column_ids_.init(access_exprs.count()))) {
|
||||
LOG_WARN("fail to init access column ids", K(ret), K(access_exprs.count()));
|
||||
} else {
|
||||
ObColumnRefRawExpr *col_expr = NULL;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < access_exprs.count(); i++) {
|
||||
if (T_REF_COLUMN != access_exprs.at(i)->get_expr_type()) {
|
||||
if (!access_exprs.at(i)->is_column_ref_expr()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected expr type", K(ret), K(access_exprs.at(i)->get_expr_type()));
|
||||
} else if (FALSE_IT(col_expr = static_cast<ObColumnRefRawExpr*>(access_exprs.at(i)))) {
|
||||
@ -2010,7 +2119,7 @@ int ObTableTscCgService::generate_table_param(const ObTableCtx &ctx,
|
||||
int ret = OB_SUCCESS;
|
||||
ObArray<uint64_t> tsc_out_cols;
|
||||
const ObTableSchema *table_schema = nullptr;
|
||||
const ObIArray<oceanbase::sql::ObRawExpr *> &select_exprs = ctx.get_select_exprs();
|
||||
const ObIArray<ObRawExpr *> &select_exprs = ctx.get_select_exprs();
|
||||
|
||||
if (!ctx.is_index_scan() // 非索引扫描
|
||||
|| (ctx.is_index_scan() && das_tsc_ctdef.ref_table_id_ == ctx.get_ref_table_id()) // 索引扫描回表
|
||||
@ -2022,12 +2131,29 @@ int ObTableTscCgService::generate_table_param(const ObTableCtx &ctx,
|
||||
table_schema = ctx.get_table_schema();
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < select_exprs.count(); i++) {
|
||||
if (T_REF_COLUMN != select_exprs.at(i)->get_expr_type()) {
|
||||
ObRawExpr *expr = select_exprs.at(i);
|
||||
if (!expr->is_column_ref_expr()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected expr type", K(ret), K(select_exprs.at(i)->get_expr_type()));
|
||||
} else if (FALSE_IT(col_expr = static_cast<ObColumnRefRawExpr*>(select_exprs.at(i)))) {
|
||||
} else if (OB_FAIL(tsc_out_cols.push_back(col_expr->get_column_id()))) {
|
||||
LOG_WARN("fail to push back column id", K(ret));
|
||||
LOG_WARN("unexpected expr type", K(ret), K(*expr));
|
||||
} else if (FALSE_IT(col_expr = static_cast<ObColumnRefRawExpr*>(expr))) {
|
||||
} else if (!col_expr->is_virtual_generated_column()) {
|
||||
if (OB_FAIL(tsc_out_cols.push_back(col_expr->get_column_id()))) {
|
||||
LOG_WARN("fail to push back column id", K(ret));
|
||||
}
|
||||
} else {
|
||||
// output虚拟生成列转换为ouput其依赖的列
|
||||
const ObIArray<ObTableCtx::ObGenDenpendantsPair> &pairs = ctx.get_gen_dependants_pairs();
|
||||
for (int64_t j = 0; j < pairs.count() && OB_SUCC(ret); j++) {
|
||||
if (col_expr == pairs.at(j).first) {
|
||||
const ObIArray<ObRawExpr*> &dependant_exprs = pairs.at(j).second;
|
||||
for (int64_t k = 0; k < dependant_exprs.count() && OB_SUCC(ret); k++) {
|
||||
ObColumnRefRawExpr *dep_col_expr = static_cast<ObColumnRefRawExpr*>(dependant_exprs.at(k));
|
||||
if (OB_FAIL(add_var_to_array_no_dup(tsc_out_cols, dep_col_expr->get_column_id()))) {
|
||||
LOG_WARN("fail to add column id", K(ret), K(tsc_out_cols), K(*dep_col_expr));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ctx.is_index_scan() && das_tsc_ctdef.ref_table_id_ == ctx.get_index_table_id()) { // 索引表
|
||||
@ -2070,6 +2196,30 @@ int ObTableTscCgService::generate_das_tsc_ctdef(const ObTableCtx &ctx,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableTscCgService::generate_output_exprs(const ObTableCtx &ctx,
|
||||
ObIArray<ObExpr *> &output_exprs)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObStaticEngineCG cg(ctx.get_cur_cluster_version());
|
||||
const ObIArray<ObRawExpr *> &select_exprs = ctx.get_select_exprs();
|
||||
const int64_t N = select_exprs.count();
|
||||
for (int64_t i = 0; i < N && OB_SUCC(ret); i++) {
|
||||
ObExpr *rt_expr = nullptr;
|
||||
ObRawExpr *expr = select_exprs.at(i);
|
||||
ObColumnRefRawExpr *col_ref_expr = static_cast<ObColumnRefRawExpr*>(expr);
|
||||
if (col_ref_expr->is_virtual_generated_column()) {
|
||||
expr = col_ref_expr->get_dependant_expr();
|
||||
}
|
||||
if (OB_FAIL(cg.generate_rt_expr(*expr, rt_expr))) {
|
||||
LOG_WARN("fail to generate rt expr", K(ret));
|
||||
} else if (OB_FAIL(output_exprs.push_back(rt_expr))) {
|
||||
LOG_WARN("fail to push back rt expr", K(ret), K(output_exprs));
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTableTscCgService::generate_tsc_ctdef(const ObTableCtx &ctx,
|
||||
ObIAllocator &allocator,
|
||||
ObTableApiScanCtDef &tsc_ctdef)
|
||||
@ -2077,8 +2227,11 @@ int ObTableTscCgService::generate_tsc_ctdef(const ObTableCtx &ctx,
|
||||
int ret = OB_SUCCESS;
|
||||
// init scan_ctdef_.ref_table_id_
|
||||
tsc_ctdef.scan_ctdef_.ref_table_id_ = ctx.get_index_table_id();
|
||||
// init scan_ctdef_
|
||||
if (OB_FAIL(generate_das_tsc_ctdef(ctx, allocator, tsc_ctdef.scan_ctdef_))) {
|
||||
if (OB_FAIL(tsc_ctdef.output_exprs_.init(ctx.get_select_exprs().count()))) {
|
||||
LOG_WARN("fail to init output expr", K(ret));
|
||||
} else if (OB_FAIL(generate_output_exprs(ctx, tsc_ctdef.output_exprs_))) {
|
||||
LOG_WARN("fail to generate output exprs", K(ret));
|
||||
} else if (OB_FAIL(generate_das_tsc_ctdef(ctx, allocator, tsc_ctdef.scan_ctdef_))) { // init scan_ctdef_
|
||||
LOG_WARN("fail to generate das scan ctdef", K(ret));
|
||||
} else if (ctx.is_index_back()) {
|
||||
// init lookup_ctdef_,lookup_loc_meta_
|
||||
|
@ -230,6 +230,8 @@ private:
|
||||
static int generate_constraint_ctdefs(ObTableCtx &ctx,
|
||||
ObIAllocator &allocator,
|
||||
sql::ObRowkeyCstCtdefArray &cst_ctdefs);
|
||||
static int replace_exprs_with_dependant(const common::ObIArray<sql::ObRawExpr *> &src_exprs,
|
||||
common::ObIArray<sql::ObRawExpr *> &dst_exprs);
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObTableDmlCgService);
|
||||
};
|
||||
@ -348,6 +350,10 @@ private:
|
||||
static int generate_das_tsc_ctdef(const ObTableCtx &ctx,
|
||||
ObIAllocator &allocator,
|
||||
sql::ObDASScanCtDef &das_tsc_ctdef);
|
||||
static int replace_gen_col_exprs(const ObTableCtx &ctx,
|
||||
common::ObIArray<sql::ObRawExpr*> &access_exprs);
|
||||
static int generate_output_exprs(const ObTableCtx &ctx,
|
||||
common::ObIArray<sql::ObExpr *> &output_exprs);
|
||||
static int generate_access_ctdef(const ObTableCtx &ctx,
|
||||
ObIAllocator &allocator,
|
||||
sql::ObDASScanCtDef &das_tsc_ctdef);
|
||||
|
@ -562,19 +562,14 @@ int ObTableCtx::init_scan(const ObTableQuery &query,
|
||||
} else if (has_exist_in_columns(select_columns, column_schema->get_column_name_str())) {
|
||||
if (OB_FAIL(select_col_ids_.push_back(column_schema->get_column_id()))) {
|
||||
LOG_WARN("fail to add column id", K(ret));
|
||||
} else if (OB_FAIL(select_metas_.push_back(column_schema->get_meta_type()))) {
|
||||
LOG_WARN("fail to add column meta", K(ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (select_col_ids_.count() != select_columns.count() ||
|
||||
select_metas_.count() != select_columns.count()) {
|
||||
if (select_col_ids_.count() != select_columns.count()) {
|
||||
ret = OB_ERR_COLUMN_NOT_FOUND;
|
||||
LOG_WARN("select_col_ids or select_metas count is not equal to select_columns",
|
||||
K(select_columns),
|
||||
K(select_col_ids_),
|
||||
K(select_metas_));
|
||||
K(select_columns), K(select_col_ids_));
|
||||
} else {
|
||||
// init query_col_ids_
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < select_columns.count(); i++) {
|
||||
@ -686,7 +681,7 @@ int ObTableCtx::init_delete()
|
||||
is_get_ = is_htable() ? false : true;
|
||||
scan_order_ = ObQueryFlag::Forward;
|
||||
|
||||
// 2. init select_col_ids_, select_metas_
|
||||
// 2. init select_col_ids_
|
||||
const ObColumnSchemaV2 *column_schema = nullptr;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < column_num; i++) {
|
||||
if (OB_ISNULL(column_schema = table_schema_->get_column_schema_by_idx(i))) {
|
||||
@ -696,8 +691,6 @@ int ObTableCtx::init_delete()
|
||||
// skip
|
||||
} else if (OB_FAIL(select_col_ids_.push_back(column_schema->get_column_id()))) {
|
||||
LOG_WARN("fail to push back column id", K(ret), K(column_schema->get_column_id()));
|
||||
} else if (is_htable() && OB_FAIL(select_metas_.push_back(column_schema->get_meta_type()))) {
|
||||
LOG_WARN("fail to push back meta type", K(ret), K(column_schema->get_meta_type()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -769,7 +762,7 @@ int ObTableCtx::init_get()
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("table scheam is null", K(ret));
|
||||
} else {
|
||||
// init select_col_ids, select_metas_
|
||||
// init select_col_ids
|
||||
for (ObTableSchema::const_column_iterator iter = table_schema_->column_begin();
|
||||
OB_SUCC(ret) && iter != table_schema_->column_end();
|
||||
++iter) {
|
||||
@ -779,9 +772,7 @@ int ObTableCtx::init_get()
|
||||
LOG_WARN("column schema is NULL", K(ret));
|
||||
} else if (OB_FAIL(select_col_ids_.push_back(column_schema->get_column_id()))) {
|
||||
LOG_WARN("fail to add column id", K(ret));
|
||||
} else if (OB_FAIL(select_metas_.push_back(column_schema->get_meta_type()))) {
|
||||
LOG_WARN("fail to add column meta", K(ret));
|
||||
} else { /*do nothing*/ }
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -912,7 +903,7 @@ int ObTableCtx::classify_scan_exprs()
|
||||
// had classify, do nothing
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < exprs_cnt; i++) {
|
||||
if (T_REF_COLUMN == exprs->at(i)->get_expr_type()) {
|
||||
if (exprs->at(i)->is_column_ref_expr()) {
|
||||
ObColumnRefRawExpr *expr = static_cast<ObColumnRefRawExpr *>(exprs->at(i));
|
||||
if (expr->is_rowkey_column() && OB_FAIL(rowkey_exprs_.push_back(expr))) {
|
||||
LOG_WARN("fail to push back rowkey expr", K(ret));
|
||||
@ -1011,9 +1002,7 @@ int ObTableCtx::init_trans(transaction::ObTxDesc *trans_desc,
|
||||
LOG_WARN("trans desc is null", K(ret));
|
||||
} else {
|
||||
get_session_info().get_tx_desc() = trans_desc;
|
||||
// init tx_snapshot_
|
||||
tx_snapshot_ = tx_snapshot;
|
||||
exec_ctx_.get_das_ctx().set_snapshot(tx_snapshot_);
|
||||
exec_ctx_.get_das_ctx().set_snapshot(tx_snapshot);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
uint64_t column_id_;
|
||||
};
|
||||
typedef common::ObFixedArray<ObAssignId, common::ObIAllocator> ObAssignIds;
|
||||
typedef std::pair<sql::ObColumnRefRawExpr*, common::ObArray<sql::ObRawExpr*>> ObGenDenpendantsPair;
|
||||
public:
|
||||
explicit ObTableCtx(common::ObIAllocator &allocator)
|
||||
: allocator_(allocator),
|
||||
@ -128,22 +129,16 @@ public:
|
||||
OB_INLINE common::ObIAllocator& get_allocator() { return allocator_; }
|
||||
OB_INLINE common::ObIAllocator& get_allocator() const { return allocator_; }
|
||||
OB_INLINE uint64_t get_tenant_id() const { return tenant_id_; }
|
||||
OB_INLINE uint64_t get_database_id() const { return database_id_; }
|
||||
OB_INLINE const common::ObString& get_table_name() const { return table_name_; }
|
||||
OB_INLINE common::ObTableID &get_table_id() { return index_table_id_; }
|
||||
OB_INLINE common::ObTableID get_ref_table_id() const { return ref_table_id_; }
|
||||
OB_INLINE common::ObTableID get_index_table_id() const { return index_table_id_; }
|
||||
OB_INLINE common::ObTabletID get_tablet_id() const { return tablet_id_; }
|
||||
OB_INLINE common::ObTabletID& get_tablet_id() { return tablet_id_; }
|
||||
OB_INLINE common::ObTabletID get_index_tablet_id() const { return index_tablet_id_; }
|
||||
OB_INLINE share::ObLSID get_ls_id() const { return ls_id_; }
|
||||
OB_INLINE share::ObLSID& get_ls_id() { return ls_id_; }
|
||||
OB_INLINE int64_t get_timeout_ts() const { return timeout_ts_; }
|
||||
OB_INLINE const share::schema::ObTableSchema* get_table_schema() const { return table_schema_; }
|
||||
OB_INLINE const share::schema::ObSchemaGetterGuard& get_schema_guard() const { return schema_guard_; }
|
||||
OB_INLINE share::schema::ObSchemaGetterGuard& get_schema_guard() { return schema_guard_; }
|
||||
OB_INLINE sql::ObExprFrameInfo* get_expr_frame_info() { return expr_info_; }
|
||||
OB_INLINE const sql::ObExprFrameInfo* get_expr_frame_info() const { return expr_info_; }
|
||||
OB_INLINE sql::ObExecContext& get_exec_ctx() { return exec_ctx_; }
|
||||
OB_INLINE sql::ObRawExprFactory& get_expr_factory() { return expr_factory_; }
|
||||
OB_INLINE sql::ObRawExprUniqueSet& get_all_exprs() { return all_exprs_; }
|
||||
@ -152,8 +147,6 @@ public:
|
||||
OB_INLINE const sql::ObSQLSessionInfo& get_session_info() const
|
||||
{ return sess_guard_.get_sess_info(); }
|
||||
OB_INLINE int64_t get_tenant_schema_version() const { return tenant_schema_version_; }
|
||||
OB_INLINE const transaction::ObTxReadSnapshot& get_tx_snapshot() const { return tx_snapshot_; }
|
||||
OB_INLINE transaction::ObTxReadSnapshot& get_tx_snapshot() { return tx_snapshot_; }
|
||||
OB_INLINE ObTableOperationType::Type get_opertion_type() const { return operation_type_; }
|
||||
OB_INLINE bool is_init() const { return is_init_; }
|
||||
// for scan
|
||||
@ -163,7 +156,6 @@ public:
|
||||
OB_INLINE bool is_index_back() const { return is_index_back_; }
|
||||
OB_INLINE bool is_get() const { return is_get_; }
|
||||
OB_INLINE common::ObQueryFlag::ScanOrder get_scan_order() const { return scan_order_; }
|
||||
OB_INLINE const ObIArray<common::ObObjMeta>& get_select_metas() const { return select_metas_; }
|
||||
OB_INLINE const ObIArray<sql::ObRawExpr *>& get_select_exprs() const { return select_exprs_; }
|
||||
OB_INLINE const ObIArray<sql::ObRawExpr *>& get_rowkey_exprs() const { return rowkey_exprs_; }
|
||||
OB_INLINE const ObIArray<sql::ObRawExpr *>& get_index_exprs() const { return index_exprs_; }
|
||||
@ -183,7 +175,6 @@ public:
|
||||
|| ObTableOperationType::Type::INCREMENT == operation_type_;
|
||||
}
|
||||
OB_INLINE ObIArray<sql::ObRawExpr *>& get_old_row_exprs() { return old_row_exprs_; }
|
||||
OB_INLINE const ObIArray<sql::ObRawExpr *>& get_old_row_exprs() const { return old_row_exprs_; }
|
||||
OB_INLINE ObIArray<sql::ObRawExpr *>& get_full_assign_exprs() { return full_assign_exprs_; }
|
||||
OB_INLINE ObIArray<sql::ObRawExpr *>& get_delta_exprs() { return delta_exprs_; }
|
||||
OB_INLINE const ObAssignIds& get_assign_ids() const { return assign_ids_; }
|
||||
@ -199,33 +190,24 @@ public:
|
||||
OB_INLINE bool return_affected_entity() const { return return_affected_entity_;}
|
||||
OB_INLINE bool return_rowkey() const { return return_rowkey_;}
|
||||
OB_INLINE uint64_t get_cur_cluster_version() const { return cur_cluster_version_;}
|
||||
OB_INLINE common::ObIArray<ObGenDenpendantsPair>& get_gen_dependants_pairs()
|
||||
{
|
||||
return gen_dependants_pairs_;
|
||||
}
|
||||
OB_INLINE const common::ObIArray<ObGenDenpendantsPair>& get_gen_dependants_pairs() const
|
||||
{
|
||||
return gen_dependants_pairs_;
|
||||
}
|
||||
OB_INLINE bool has_generated_column() const { return table_schema_->has_generated_column(); }
|
||||
|
||||
//////////////////////////////////////// setter ////////////////////////////////////////////////
|
||||
// for common
|
||||
OB_INLINE void set_init_flag(bool is_init) { is_init_ = is_init; }
|
||||
OB_INLINE void set_tenant_id(const uint64_t &tenant_id) { tenant_id_ = tenant_id; }
|
||||
OB_INLINE void set_database_id(const uint64_t &database_id) { database_id_ = database_id; }
|
||||
OB_INLINE void set_table_name(const common::ObString &table_name) { table_name_ = table_name; }
|
||||
OB_INLINE void set_ref_table_id(const common::ObTableID &table_id) { ref_table_id_ = table_id; }
|
||||
OB_INLINE void set_index_table_id(const common::ObTableID &index_tid) { index_table_id_ = index_tid; }
|
||||
OB_INLINE void set_tablet_id(const common::ObTabletID &tablet_id) { tablet_id_ = tablet_id; }
|
||||
OB_INLINE void set_index_tablet_id(const common::ObTabletID &tablet_id) { index_tablet_id_ = tablet_id; }
|
||||
OB_INLINE void set_ls_id(const share::ObLSID &ls_id) { ls_id_ = ls_id; }
|
||||
OB_INLINE void set_timeout_ts(const int64_t &timeout_ts) { timeout_ts_ = timeout_ts; }
|
||||
OB_INLINE void set_tenant_schema_version(const int64_t &version) { tenant_schema_version_ = version; }
|
||||
OB_INLINE void set_tx_snapshot(const transaction::ObTxReadSnapshot &snapshot) { tx_snapshot_ = snapshot; }
|
||||
OB_INLINE void set_expr_info(ObExprFrameInfo *expr_info) { expr_info_ = expr_info; }
|
||||
// for scan
|
||||
OB_INLINE void set_scan(const bool &is_scan) { is_scan_ = is_scan; }
|
||||
OB_INLINE void set_index_scan(const bool &is_index_scan) { is_index_scan_ = is_index_scan; }
|
||||
OB_INLINE void set_weak_read(const bool &is_weak_read) { is_weak_read_ = is_weak_read; }
|
||||
OB_INLINE void set_index_back(const bool &is_index_back) { is_index_back_ = is_index_back; }
|
||||
OB_INLINE void set_get(const bool &is_get) { is_get_ = is_get; }
|
||||
OB_INLINE void set_scan_order(const common::ObQueryFlag::ScanOrder &scan_order) { scan_order_ = scan_order; }
|
||||
OB_INLINE void set_limit(const int64_t &limit) { limit_ = limit; }
|
||||
OB_INLINE void set_offset(const int64_t &offset) { offset_ = offset; }
|
||||
// for dml
|
||||
OB_INLINE void set_for_update(const bool &is_for_update) { is_for_update_ = is_for_update; }
|
||||
OB_INLINE void set_entity(const ObITableEntity *entity) { entity_ = entity; }
|
||||
OB_INLINE void set_entity_type(const ObTableEntityType &type) { entity_type_ = type; }
|
||||
OB_INLINE void set_operation_type(const ObTableOperationType::Type op_type) { operation_type_ = op_type; }
|
||||
@ -264,8 +246,6 @@ public:
|
||||
// init exec_ctx_.my_session_.tx_desc_
|
||||
int init_trans(transaction::ObTxDesc *trans_desc,
|
||||
const transaction::ObTxReadSnapshot &tx_snapshot);
|
||||
// insert 表达式
|
||||
int classify_insert_exprs();
|
||||
int init_das_context(ObDASCtx &das_ctx);
|
||||
public:
|
||||
// convert lob的allocator需要保证obj写入表达式后才能析构
|
||||
@ -289,7 +269,6 @@ private:
|
||||
private:
|
||||
int cons_column_type(const share::schema::ObColumnSchemaV2 &column_schema,
|
||||
sql::ObExprResType &column_type);
|
||||
int adjust_lob_obj(ObObj &obj);
|
||||
int adjust_column_type(const ObExprResType &column_type, ObObj &obj);
|
||||
int adjust_column(const ObColumnSchemaV2 &col_schema, ObObj &obj);
|
||||
int adjust_rowkey();
|
||||
@ -320,7 +299,6 @@ private:
|
||||
ObTableApiSessGuard sess_guard_;
|
||||
sql::ObDASTableLocMeta loc_meta_;
|
||||
int64_t tenant_schema_version_;
|
||||
transaction::ObTxReadSnapshot tx_snapshot_;
|
||||
// for scan
|
||||
bool is_scan_;
|
||||
bool is_index_scan_;
|
||||
@ -331,7 +309,6 @@ private:
|
||||
common::ObArray<sql::ObRawExpr*> select_exprs_;
|
||||
common::ObArray<sql::ObRawExpr*> rowkey_exprs_;
|
||||
common::ObArray<sql::ObRawExpr*> index_exprs_;
|
||||
common::ObArray<common::ObObjMeta> select_metas_;
|
||||
common::ObArray<uint64_t> select_col_ids_; // 基于schema序的select column id
|
||||
common::ObArray<uint64_t> query_col_ids_; // 用户查询的select column id
|
||||
common::ObArray<uint64_t> index_col_ids_;
|
||||
@ -339,6 +316,8 @@ private:
|
||||
int64_t offset_;
|
||||
int64_t limit_;
|
||||
common::ObSEArray<common::ObNewRange, 16> key_ranges_;
|
||||
// for generate column
|
||||
common::ObArray<ObGenDenpendantsPair> gen_dependants_pairs_; // 生成列及其依赖列数组
|
||||
// for update
|
||||
bool is_for_update_;
|
||||
ObTableOperationType::Type operation_type_;
|
||||
@ -390,25 +369,18 @@ public:
|
||||
: scan_ctdef_(allocator),
|
||||
lookup_ctdef_(nullptr),
|
||||
lookup_loc_meta_(nullptr),
|
||||
output_exprs_(allocator),
|
||||
allocator_(allocator)
|
||||
{
|
||||
}
|
||||
const sql::ExprFixedArray &get_das_output_exprs() const
|
||||
{
|
||||
return lookup_ctdef_ != nullptr ? lookup_ctdef_->result_output_ : scan_ctdef_.result_output_;
|
||||
}
|
||||
const sql::UIntFixedArray &get_full_acccess_cids() const
|
||||
{
|
||||
return lookup_ctdef_ != nullptr ?
|
||||
lookup_ctdef_->access_column_ids_ :
|
||||
scan_ctdef_.access_column_ids_;
|
||||
}
|
||||
TO_STRING_KV(K_(scan_ctdef),
|
||||
KPC_(lookup_ctdef),
|
||||
KPC_(lookup_loc_meta));
|
||||
sql::ObDASScanCtDef scan_ctdef_;
|
||||
sql::ObDASScanCtDef *lookup_ctdef_;
|
||||
sql::ObDASTableLocMeta *lookup_loc_meta_;
|
||||
|
||||
ExprFixedArray output_exprs_;
|
||||
common::ObIAllocator &allocator_;
|
||||
};
|
||||
|
||||
|
@ -84,7 +84,7 @@ int ObTableOpWrapper::process_affected_entity(ObTableCtx &tb_ctx,
|
||||
const ObIArray<ObExpr *> &ins_exprs = ins_up_spec.get_ctdef().ins_ctdef_.new_row_;
|
||||
const ObTableCtx::ObAssignIds &assign_ids = tb_ctx.get_assign_ids();
|
||||
const int64_t N = assign_ids.count();
|
||||
ObObj* obj_array = static_cast<ObObj*>(allocator.alloc(sizeof(ObObj) * N));
|
||||
ObObj *obj_array = static_cast<ObObj*>(allocator.alloc(sizeof(ObObj) * N));
|
||||
if (OB_ISNULL(obj_array)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("faild to alloc memory for objs", K(ret));
|
||||
|
@ -279,7 +279,7 @@ int ObTableApiScanRowIterator::get_next_row(ObNewRow *&row)
|
||||
ObObj *cells = nullptr;
|
||||
const ObTableCtx &tb_ctx = scan_executor_->get_table_ctx();
|
||||
ObIAllocator &allocator = tb_ctx.get_allocator();
|
||||
const ExprFixedArray &output_exprs = scan_executor_->get_spec().get_ctdef().get_das_output_exprs();
|
||||
const ExprFixedArray &output_exprs = scan_executor_->get_spec().get_ctdef().output_exprs_;
|
||||
const int64_t cells_cnt = output_exprs.count();
|
||||
|
||||
if (OB_ISNULL(scan_executor_)) {
|
||||
@ -300,7 +300,6 @@ int ObTableApiScanRowIterator::get_next_row(ObNewRow *&row)
|
||||
tmp_row = new(row_buf)ObNewRow(cells, cells_cnt);
|
||||
ObDatum *datum = nullptr;
|
||||
ObEvalCtx &eval_ctx = scan_executor_->get_eval_ctx();
|
||||
const ObIArray<common::ObObjMeta> &output_metas = tb_ctx.get_select_metas();
|
||||
if (tb_ctx.is_scan()) { // 转为用户select的顺序
|
||||
const ObIArray<uint64_t> &select_col_ids = tb_ctx.get_select_col_ids();
|
||||
const ObIArray<uint64_t> &query_col_ids = tb_ctx.get_query_col_ids();
|
||||
@ -312,16 +311,16 @@ int ObTableApiScanRowIterator::get_next_row(ObNewRow *&row)
|
||||
LOG_WARN("query column id not found", K(ret), K(select_col_ids), K(col_id), K(query_col_ids));
|
||||
} else if (OB_FAIL(output_exprs.at(idx)->eval(eval_ctx, datum))) {
|
||||
LOG_WARN("fail to eval datum", K(ret));
|
||||
} else if (OB_FAIL(datum->to_obj(cells[i], output_metas.at(idx)))) {
|
||||
LOG_WARN("fail to datum to obj", K(ret), K(output_metas.at(idx)), K(i), K(idx));
|
||||
} else if (OB_FAIL(datum->to_obj(cells[i], output_exprs.at(idx)->obj_meta_))) {
|
||||
LOG_WARN("fail to datum to obj", K(ret), K(output_exprs.at(idx)->obj_meta_), K(i), K(idx));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < cells_cnt; i++) {
|
||||
if (OB_FAIL(output_exprs.at(i)->eval(eval_ctx, datum))) {
|
||||
LOG_WARN("fail to eval datum", K(ret));
|
||||
} else if (OB_FAIL(datum->to_obj(cells[i], output_metas.at(i)))) {
|
||||
LOG_WARN("fail to datum to obj", K(ret), K(output_metas.at(i)));
|
||||
} else if (OB_FAIL(datum->to_obj(cells[i], output_exprs.at(i)->obj_meta_))) {
|
||||
LOG_WARN("fail to datum to obj", K(ret), K(output_exprs.at(i)->obj_meta_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +172,6 @@ TEST_F(TestCreateExecutor, scan)
|
||||
ASSERT_EQ(OB_SUCCESS, fake_ctx.init_get());
|
||||
for (int i = 0; i < 3; i++) {
|
||||
ASSERT_EQ(columns_[i].get_column_id(), fake_ctx.select_col_ids_.at(i));
|
||||
ASSERT_EQ(columns_[i].get_meta_type(), fake_ctx.select_metas_.at(i));
|
||||
}
|
||||
ASSERT_EQ(OB_SUCCESS, ObTableExprCgService::generate_exprs(fake_ctx, allocator_, fake_expr_info));
|
||||
fake_ctx.set_expr_info(&fake_expr_info);
|
||||
|
Loading…
x
Reference in New Issue
Block a user