Fix enum/set insert into values in irregular order
This commit is contained in:
@ -1243,8 +1243,8 @@ int ObStaticEngineCG::generate_spec(ObLogExprValues& op, ObExprValuesSpec& spec,
|
||||
if (!op.get_value_exprs().empty()) {
|
||||
if (OB_FAIL(spec.values_.prepare_allocate(op.get_value_exprs().count()))) {
|
||||
LOG_WARN("init fixed array failed", K(ret), K(op.get_value_exprs().count()));
|
||||
} else if (OB_FAIL(spec.str_values_array_.prepare_allocate(op.get_str_values_array().count()))) {
|
||||
LOG_WARN("init fixed array failed", K(ret), K(op.get_str_values_array().count()));
|
||||
} else if (OB_FAIL(spec.str_values_array_.prepare_allocate(op.get_output_exprs().count()))) {
|
||||
LOG_WARN("init fixed array failed", K(ret), K(op.get_output_exprs().count()));
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < op.get_value_exprs().count(); i++) {
|
||||
ObRawExpr* raw_expr = op.get_value_exprs().at(i);
|
||||
@ -1263,13 +1263,17 @@ int ObStaticEngineCG::generate_spec(ObLogExprValues& op, ObExprValuesSpec& spec,
|
||||
spec.values_.at(i) = expr;
|
||||
}
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < op.get_str_values_array().count(); i++) {
|
||||
const ObStrValues& str_values = op.get_str_values_array().at(i);
|
||||
// Add str_values to spec: str_values_ is worked for enum/set type for type conversion.
|
||||
// According to code in ob_expr_values_op.cpp, it should be in the same order as output_exprs.
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < op.get_output_exprs().count(); i++) {
|
||||
ObRawExpr *output_raw_expr = op.get_output_exprs().at(i);
|
||||
const common::ObIArray<common::ObString> &str_values =
|
||||
output_raw_expr->get_enum_set_values();
|
||||
if (OB_FAIL(spec.str_values_array_.at(i).assign(str_values))) {
|
||||
LOG_WARN("fail to assign", K(ret), K(i), K(str_values));
|
||||
}
|
||||
}
|
||||
LOG_DEBUG("finish assign str_values_array", K(ret), K(op.get_str_values_array()), K(spec.str_values_array_));
|
||||
LOG_DEBUG("finish assign str_values_array", K(ret), K(spec.str_values_array_));
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
|
||||
@ -493,10 +493,6 @@ int ObInsertLogPlan::generate_values_op_as_child(ObLogicalOperator*& top)
|
||||
/*do nothing*/
|
||||
} else if (OB_FAIL(values_op->add_values_expr(insert_stmt->get_value_vectors()))) {
|
||||
LOG_WARN("failed to add values expr", K(ret));
|
||||
} else if (NULL != exec_ctx && NULL != exec_ctx->get_my_session() &&
|
||||
exec_ctx->get_my_session()->use_static_typing_engine() &&
|
||||
OB_FAIL(values_op->add_str_values_array(insert_stmt->get_column_conv_functions()))) {
|
||||
LOG_WARN("fail to add_str_values_array", K(ret));
|
||||
} else { /*do nothing*/
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,63 +97,6 @@ int ObLogExprValues::add_values_expr(const common::ObIArray<ObRawExpr*>& value_e
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogExprValues::add_str_values_array(const common::ObIArray<ObRawExpr*>& expr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(str_values_array_.reserve(expr.count()))) {
|
||||
LOG_WARN("fail to prepare_allocate", K(ret), K(expr.count()));
|
||||
} else {
|
||||
for (int64_t i = 0; i < expr.count() && OB_SUCC(ret); ++i) {
|
||||
ObRawExpr* raw_expr = expr.at(i);
|
||||
if (OB_ISNULL(raw_expr)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("raw_exprr is null", K(ret), K(raw_expr));
|
||||
} else if (T_FUN_COLUMN_CONV != raw_expr->get_expr_type()) {
|
||||
// do nothing
|
||||
LOG_DEBUG("ignore", K(ret), K(i), KPC(raw_expr));
|
||||
} else if (OB_UNLIKELY(raw_expr->get_param_count() != ObExprColumnConv::PARAMS_COUNT_WITH_COLUMN_INFO &&
|
||||
raw_expr->get_param_count() != ObExprColumnConv::PARAMS_COUNT_WITHOUT_COLUMN_INFO)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("convert expr have invalid param number", K(ret));
|
||||
} else if (raw_expr->get_param_expr(4)->is_column_ref_expr()) {
|
||||
ObStrValues str_values(&my_plan_->get_allocator());
|
||||
if (raw_expr->get_result_type().is_enum_or_set()) {
|
||||
ObExprOperator* op = NULL;
|
||||
if (OB_ISNULL(op = static_cast<ObSysFunRawExpr*>(raw_expr)->get_op())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("failed to get_op", K(ret), K(expr));
|
||||
} else {
|
||||
ObExprColumnConv* column_conv = static_cast<ObExprColumnConv*>(op);
|
||||
str_values.assign(column_conv->get_str_values());
|
||||
if (OB_FAIL(str_values.assign(column_conv->get_str_values()))) {
|
||||
LOG_WARN("failed to push_back", K(ret), KPC(column_conv));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(str_values_array_.push_back(str_values))) {
|
||||
LOG_WARN("failed to push_back", K(ret), K(str_values));
|
||||
}
|
||||
}
|
||||
} else if (raw_expr->get_param_expr(4)->has_flag(CNT_COLUMN)) {
|
||||
ObStrValues str_values(&my_plan_->get_allocator());
|
||||
if (OB_FAIL(str_values_array_.push_back(str_values))) {
|
||||
LOG_WARN("failed to push_back", K(ret), K(str_values));
|
||||
}
|
||||
LOG_DEBUG("ignore", K(ret), K(i), KPC(raw_expr->get_param_expr(4)));
|
||||
}
|
||||
}
|
||||
LOG_DEBUG("finish add_str_values_array",
|
||||
K(ret),
|
||||
K(expr.count()),
|
||||
"count",
|
||||
str_values_array_.count(),
|
||||
K(str_values_array_));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLogExprValues::compute_fd_item_set()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
@ -34,7 +34,6 @@ public:
|
||||
return need_columnlized_;
|
||||
}
|
||||
int add_values_expr(const common::ObIArray<ObRawExpr*>& value_exprs);
|
||||
int add_str_values_array(const common::ObIArray<ObRawExpr*>& expr);
|
||||
|
||||
const common::ObIArray<ObRawExpr*>& get_value_exprs() const
|
||||
{
|
||||
@ -44,10 +43,6 @@ public:
|
||||
{
|
||||
return value_exprs_;
|
||||
}
|
||||
const common::ObIArray<ObStrValues>& get_str_values_array() const
|
||||
{
|
||||
return str_values_array_;
|
||||
}
|
||||
int check_range_param_continuous(bool& use_range_param) const;
|
||||
int get_value_param_range(int64_t row_index, int64_t& param_idx_start, int64_t& param_idx_end) const;
|
||||
virtual int est_cost() override;
|
||||
@ -67,8 +62,6 @@ private:
|
||||
private:
|
||||
bool need_columnlized_;
|
||||
common::ObSEArray<ObRawExpr*, 4, common::ModulePageAllocator, true> value_exprs_;
|
||||
// only engine 3.0 used
|
||||
common::ObSEArray<ObStrValues, 4, common::ModulePageAllocator, true> str_values_array_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObLogExprValues);
|
||||
};
|
||||
} // namespace sql
|
||||
|
||||
Reference in New Issue
Block a user