cp bug fix to open source branch
This commit is contained in:
parent
91bb0da2ae
commit
f45d2cdbe2
2
deps/oblib/src/lib/charset/ob_charset.cpp
vendored
2
deps/oblib/src/lib/charset/ob_charset.cpp
vendored
@ -1593,7 +1593,7 @@ int ObCharset::aggregate_collation(const ObCollationLevel collation_level1, cons
|
||||
if (OB_UNLIKELY(CS_LEVEL_INVALID == collation_level1 || CS_LEVEL_INVALID == collation_level2 ||
|
||||
CS_TYPE_INVALID == collation_type1 || CS_TYPE_INVALID == collation_type2)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_ERROR("invalid collation level or type",
|
||||
LOG_WARN("invalid collation level or type",
|
||||
K(ret),
|
||||
K(collation_level1),
|
||||
K(collation_type1),
|
||||
|
@ -98,7 +98,7 @@ struct InitStrCmpArray {
|
||||
funcs[IDX][0][0] = StrCmp<0, 0>::defined_ ? &StrCmp<0, 0>::cmp : NULL;
|
||||
funcs[IDX][0][1] = StrCmp<0, 1>::defined_ ? &StrCmp<0, 1>::cmp : NULL;
|
||||
funcs[IDX][1][0] = StrCmp<1, 0>::defined_ ? &StrCmp<1, 0>::cmp : NULL;
|
||||
funcs[IDX][1][1] = StrCmp<1, 1>::defined_ ? &StrCmp<1, 0>::cmp : NULL;
|
||||
funcs[IDX][1][1] = StrCmp<1, 1>::defined_ ? &StrCmp<1, 1>::cmp : NULL;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -6021,11 +6021,10 @@ int ObStaticEngineCG::fill_aggr_info(ObAggFunRawExpr& raw_expr, ObExpr& expr, Ob
|
||||
if (OB_SUCC(ret) && !raw_expr.get_order_items().empty()) {
|
||||
aggr_info.has_order_by_ = true;
|
||||
if (OB_FAIL(fil_sort_info(raw_expr.get_order_items(),
|
||||
all_param_exprs,
|
||||
NULL,
|
||||
aggr_info.sort_collations_,
|
||||
aggr_info.sort_cmp_funcs_,
|
||||
raw_expr.get_expr_type()))) {
|
||||
all_param_exprs,
|
||||
NULL,
|
||||
aggr_info.sort_collations_,
|
||||
aggr_info.sort_cmp_funcs_))) {
|
||||
LOG_WARN("failed to fil_sort_info", K(ret));
|
||||
} else { /*do nothing*/
|
||||
}
|
||||
@ -6272,9 +6271,9 @@ int ObStaticEngineCG::fill_wf_info(ObIArray<ObExpr*>& all_expr, ObWinFunRawExpr&
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObStaticEngineCG::fil_sort_info(const ObIArray<OrderItem>& sort_keys, ObIArray<ObExpr*>& all_exprs,
|
||||
ObIArray<ObExpr*>* sort_exprs, ObSortCollations& sort_collations, ObSortFuncs& sort_cmp_funcs,
|
||||
const ObItemType aggr_type)
|
||||
int ObStaticEngineCG::fil_sort_info(const ObIArray<OrderItem> &sort_keys,
|
||||
ObIArray<ObExpr *> &all_exprs, ObIArray<ObExpr *> *sort_exprs,
|
||||
ObSortCollations &sort_collations, ObSortFuncs &sort_cmp_funcs)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(sort_collations.init(sort_keys.count()))) {
|
||||
@ -6308,20 +6307,11 @@ int ObStaticEngineCG::fil_sort_info(const ObIArray<OrderItem>& sort_keys, ObIArr
|
||||
order_item.is_ascending(),
|
||||
(order_item.is_null_first() ^ order_item.is_ascending()) ? NULL_LAST : NULL_FIRST);
|
||||
ObSortCmpFunc cmp_func;
|
||||
if (lib::is_oracle_mode() && ObDatumFuncs::is_string_type(expr->datum_meta_.type_) &&
|
||||
T_FUN_GROUP_PERCENTILE_DISC == aggr_type) {
|
||||
cmp_func.cmp_func_ = ObDatumFuncs::get_nullsafe_cmp_func(expr->datum_meta_.type_,
|
||||
expr->datum_meta_.type_,
|
||||
field_collation.null_pos_,
|
||||
field_collation.cs_type_,
|
||||
false);
|
||||
} else {
|
||||
cmp_func.cmp_func_ = ObDatumFuncs::get_nullsafe_cmp_func(expr->datum_meta_.type_,
|
||||
expr->datum_meta_.type_,
|
||||
field_collation.null_pos_,
|
||||
field_collation.cs_type_,
|
||||
lib::is_oracle_mode());
|
||||
}
|
||||
cmp_func.cmp_func_ = ObDatumFuncs::get_nullsafe_cmp_func(expr->datum_meta_.type_,
|
||||
expr->datum_meta_.type_,
|
||||
field_collation.null_pos_,
|
||||
field_collation.cs_type_,
|
||||
lib::is_oracle_mode());
|
||||
if (OB_ISNULL(cmp_func.cmp_func_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("cmp_func is null, check datatype is valid", K(ret));
|
||||
|
@ -395,7 +395,7 @@ private:
|
||||
|
||||
int fill_wf_info(ObIArray<ObExpr*>& all_expr, ObWinFunRawExpr& win_expr, WinFuncInfo& wf_info);
|
||||
int fil_sort_info(const ObIArray<OrderItem>& sort_keys, ObIArray<ObExpr*>& all_exprs, ObIArray<ObExpr*>* sort_exprs,
|
||||
ObSortCollations& sort_collations, ObSortFuncs& sort_cmp_funcs, const ObItemType aggr_type = T_INVALID);
|
||||
ObSortCollations& sort_collations, ObSortFuncs& sort_cmp_funcs);
|
||||
int get_pdml_partition_id_column_idx(const ObIArray<ObExpr*>& dml_exprs, int64_t& idx);
|
||||
|
||||
int do_gi_partition_pruning(ObLogJoin& op, ObBasicNestedLoopJoinSpec& spec);
|
||||
|
@ -1128,7 +1128,7 @@ int ObLogPlan::generate_semi_join_detectors(const ObIArray<SemiInfo*>& semi_info
|
||||
LOG_WARN("unexpect null conflict detector", K(ret));
|
||||
} else if (OB_FAIL(detector->L_DS_.add_members(left_rel_ids))) {
|
||||
LOG_WARN("failed to add members", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, info->right_table_id_, right_rel_ids))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(info->right_table_id_, right_rel_ids))) {
|
||||
LOG_WARN("failed to get table ids", K(ret));
|
||||
} else if (OB_FAIL(detector->R_DS_.add_members(right_rel_ids))) {
|
||||
LOG_WARN("failed to add members", K(ret));
|
||||
@ -2382,7 +2382,7 @@ int ObLogPlan::init_leading_info_from_tables(
|
||||
right_rel_ids.reuse();
|
||||
if (OB_ISNULL(semi_info)) {
|
||||
LOG_WARN("unexpect null semi info", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, semi_info->right_table_id_, right_rel_ids))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(semi_info->right_table_id_, right_rel_ids))) {
|
||||
LOG_WARN("failed to get table ids", K(ret));
|
||||
} else if (OB_FAIL(hint_info.left_table_set_.add_members(leading_tables_))) {
|
||||
LOG_WARN("failed to add table ids", K(ret));
|
||||
|
@ -143,6 +143,12 @@ int ObMergeLogPlan::allocate_merge_subquery()
|
||||
LOG_WARN("failed to allocate delete condition subquery", K(ret));
|
||||
} else if (OB_FAIL(merge_stmt->formalize_stmt_expr_reference())) {
|
||||
LOG_WARN("failed to formalize stmt expr reference", K(ret));
|
||||
} else if (condition_subquery_exprs.empty() && target_subquery_exprs.empty() &&
|
||||
delete_subquery_exprs.empty() && !merge_stmt->get_match_condition_exprs().empty()) {
|
||||
// alloc subplan filter for subquery in match condition
|
||||
if (OB_FAIL(candi_allocate_subplan_filter(merge_stmt->get_match_condition_exprs(), false))) {
|
||||
LOG_WARN("failed to allocate subplan filter", K(ret));
|
||||
}
|
||||
} else if (!condition_subquery_exprs.empty() &&
|
||||
OB_FAIL(candi_allocate_subplan_filter(condition_subquery_exprs, false))) {
|
||||
LOG_WARN("failed to allocate subplan filter", K(ret));
|
||||
|
@ -4961,28 +4961,38 @@ int ObOptimizerUtil::get_set_res_types(ObIAllocator* allocator, ObSQLSessionInfo
|
||||
ObExprResType res_type;
|
||||
const int64_t child_num = child_querys.count();
|
||||
const int64_t select_num = select_stmt->get_select_item_size();
|
||||
ObRawExpr* expr = NULL;
|
||||
for (int64_t i = 1; OB_SUCC(ret) && i < child_num; ++i) {
|
||||
if (OB_ISNULL(child_querys.at(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected set stmt", K(ret), K(child_querys), K(select_stmt));
|
||||
} else if (OB_UNLIKELY(select_num != child_querys.at(i)->get_select_item_size())) {
|
||||
ret = OB_ERR_COLUMN_SIZE;
|
||||
LOG_WARN("The used SELECT statements have a different number of columns",
|
||||
K(select_num),
|
||||
K(select_stmt->get_select_item_size()));
|
||||
}
|
||||
}
|
||||
ObSelectStmt *cur_stmt = NULL;
|
||||
bool is_all_not_null = true;
|
||||
bool is_on_null_side = false;
|
||||
ObColumnRefRawExpr *col_expr = NULL;
|
||||
ObRawExpr *expr = NULL;
|
||||
for (int64_t idx = 0; OB_SUCC(ret) && idx < select_num; ++idx) {
|
||||
bool is_all_not_null = true;
|
||||
types.reuse();
|
||||
is_all_not_null = true;
|
||||
res_type.unset_result_flag(NOT_NULL_FLAG);
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < child_num; ++i) {
|
||||
types.reuse();
|
||||
if (OB_ISNULL(expr = select_stmt->get_select_item(idx).expr_)) {
|
||||
if (OB_ISNULL(cur_stmt = child_querys.at(i)) ||
|
||||
OB_UNLIKELY(idx >= cur_stmt->get_select_item_size()) ||
|
||||
OB_ISNULL(expr = cur_stmt->get_select_item(idx).expr_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret), K(expr));
|
||||
LOG_WARN("unexpected child stmt", K(ret), K(cur_stmt), K(expr));
|
||||
} else if (OB_FAIL(add_var_to_array_no_dup(types, expr->get_result_type()))) {
|
||||
LOG_WARN("unexpected null", K(ret), K(expr->get_result_type()));
|
||||
} else if (is_all_not_null && !expr->get_result_type().has_result_flag(OB_MYSQL_NOT_NULL_FLAG)) {
|
||||
LOG_WARN("failed to add var", K(ret), K(expr->get_result_type()));
|
||||
} else if (!is_all_not_null) {
|
||||
/* do nothing */
|
||||
} else if (!expr->is_column_ref_expr()) {
|
||||
is_all_not_null = false;
|
||||
} else if (OB_FALSE_IT(col_expr = static_cast<ObColumnRefRawExpr*>(expr))) {
|
||||
} else if (!col_expr->get_result_type().has_result_flag(NOT_NULL_FLAG)) {
|
||||
is_all_not_null = false;
|
||||
} else if (NULL == cur_stmt->get_table_item_by_id(col_expr->get_table_id())) {
|
||||
// column expr from upper stmt, ignore NOT NULL FLAG
|
||||
is_all_not_null = false;
|
||||
} else if (OB_FAIL(ObOptimizerUtil::is_table_on_null_side(cur_stmt,
|
||||
col_expr->get_table_id(),
|
||||
is_on_null_side))) {
|
||||
LOG_WARN("check is table on null side failed", K(ret));
|
||||
} else if (is_on_null_side) {
|
||||
is_all_not_null = false;
|
||||
}
|
||||
}
|
||||
@ -5006,9 +5016,11 @@ int ObOptimizerUtil::get_set_res_types(ObIAllocator* allocator, ObSQLSessionInfo
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_UNLIKELY(res_types.empty())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected empty", K(ret), K(types.empty()));
|
||||
} else if (!is_all_not_null) {
|
||||
res_types.at(res_types.count() - 1).unset_result_flag(OB_MYSQL_NOT_NULL_FLAG);
|
||||
LOG_WARN("unexpected empty", K(ret), K(res_types.empty()));
|
||||
} else if (is_all_not_null) {
|
||||
res_types.at(res_types.count()-1).set_result_flag(NOT_NULL_FLAG);
|
||||
} else {
|
||||
res_types.at(res_types.count()-1).unset_result_flag(NOT_NULL_FLAG);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5093,7 +5105,7 @@ int ObOptimizerUtil::try_add_cast_to_set_child_list(ObIAllocator* allocator, ObS
|
||||
}
|
||||
const ObLengthSemantics length_semantics = session_info->get_actual_nls_length_semantics();
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(types.push_back(left_type) || OB_FAIL(types.push_back(right_type)))) {
|
||||
} else if (OB_FAIL(types.push_back(left_type)) || OB_FAIL(types.push_back(right_type))) {
|
||||
LOG_WARN("failed to push back", K(ret));
|
||||
} else if (OB_FAIL(session_info->get_collation_connection(coll_type))) {
|
||||
LOG_WARN("failed to get collation connection", K(ret));
|
||||
|
@ -291,6 +291,7 @@ public:
|
||||
INDEX_STORE_RELATED = -2, // has column not index column, but storing column
|
||||
MUL_INDEX_COL = -1, // has more than one index columns in expr not row.some case present not prefix filter
|
||||
};
|
||||
|
||||
static int get_subquery_id(const ObDMLStmt* upper_stmt, const ObSelectStmt* stmt, uint64_t& id);
|
||||
|
||||
static int get_child_corresponding_exprs(const ObDMLStmt* upper_stmt, const ObSelectStmt* stmt,
|
||||
|
@ -2848,7 +2848,133 @@ int ObDMLStmt::set_table_bit_index(uint64_t table_id)
|
||||
return tables_hash_.add_column_desc(table_id, OB_INVALID_ID);
|
||||
}
|
||||
|
||||
ColumnItem* ObDMLStmt::get_column_item(uint64_t table_id, const ObString& col_name)
|
||||
int ObDMLStmt::relids_to_table_ids(const ObSqlBitSet<> &table_set,
|
||||
ObIArray<uint64_t> &table_ids) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
TableItem *table = NULL;
|
||||
int64_t idx = OB_INVALID_INDEX;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < table_items_.count(); ++i) {
|
||||
if (OB_ISNULL(table = table_items_.at(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("table item is null", K(ret));
|
||||
} else if (OB_UNLIKELY((idx = get_table_bit_index(table->table_id_)) == OB_INVALID_INDEX)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get table item invalid idx", K(idx), K(table->table_id_));
|
||||
} else if (table_set.has_member(idx)) {
|
||||
ret = table_ids.push_back(table->table_id_);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDMLStmt::get_table_rel_ids(const TableItem &target,
|
||||
ObSqlBitSet<> &table_set) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (target.is_joined_table()) {
|
||||
const JoinedTable &cur_table = static_cast<const JoinedTable &>(target);
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < cur_table.single_table_ids_.count(); ++i) {
|
||||
if (OB_FAIL(table_set.add_member(get_table_bit_index(cur_table.single_table_ids_.at(i))))) {
|
||||
LOG_WARN("failed to add member", K(ret), K(cur_table.single_table_ids_.at(i)));
|
||||
}
|
||||
}
|
||||
} else if (OB_FAIL(table_set.add_member(get_table_bit_index(target.table_id_)))) {
|
||||
LOG_WARN("failed to add member", K(ret), K(target.table_id_));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDMLStmt::get_table_rel_ids(const ObIArray<uint64_t> &table_ids,
|
||||
ObSqlBitSet<> &table_set) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int32_t idx = OB_INVALID_INDEX;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < table_ids.count(); ++i) {
|
||||
idx = get_table_bit_index(table_ids.at(i));
|
||||
if (OB_UNLIKELY(OB_INVALID_INDEX == idx)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpect idx", K(ret));
|
||||
} else if (OB_FAIL(table_set.add_member(idx))) {
|
||||
LOG_WARN("failed to add members", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDMLStmt::get_table_rel_ids(const uint64_t table_id,
|
||||
ObSqlBitSet<> &table_set) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int32_t idx = get_table_bit_index(table_id);
|
||||
if (OB_UNLIKELY(OB_INVALID_INDEX == idx)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpect idx", K(ret));
|
||||
} else if (OB_FAIL(table_set.add_member(idx))) {
|
||||
LOG_WARN("failed to add members", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDMLStmt::get_table_rel_ids(const ObIArray<TableItem*> &tables,
|
||||
ObSqlBitSet<> &table_set) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < tables.count(); ++i) {
|
||||
if (OB_ISNULL(tables.at(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpect null", K(ret));
|
||||
} else if (OB_FAIL(get_table_rel_ids(*tables.at(i), table_set))) {
|
||||
LOG_WARN("failed to get table rel ids", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDMLStmt::get_from_tables(ObRelIds &table_set) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSqlBitSet<> tmp_table_set;
|
||||
if (OB_FAIL(get_from_tables(tmp_table_set))) {
|
||||
LOG_WARN("failed to get from tables", K(ret));
|
||||
} else if (OB_FAIL(table_set.add_members(tmp_table_set))) {
|
||||
LOG_WARN("failed to add members", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDMLStmt::get_from_tables(ObSqlBitSet<> &table_set) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int32_t bit_id = OB_INVALID_INDEX;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < from_items_.count(); ++i) {
|
||||
if (from_items_.at(i).is_joined_) {
|
||||
const JoinedTable *table = get_joined_table(from_items_.at(i).table_id_);
|
||||
if (OB_ISNULL(table)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("failed to get joined table", K(ret));
|
||||
}
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < table->single_table_ids_.count(); ++j) {
|
||||
uint64_t table_id = table->single_table_ids_.at(j);
|
||||
if (OB_UNLIKELY(OB_INVALID_INDEX == (bit_id = get_table_bit_index(table_id)))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid table bit index", K(ret), K(table_id), K(bit_id));
|
||||
} else if (OB_FAIL(table_set.add_member(bit_id))) {
|
||||
LOG_WARN("failed to add member", K(ret));
|
||||
}
|
||||
}
|
||||
} else if (OB_UNLIKELY(OB_INVALID_INDEX ==
|
||||
(bit_id = get_table_bit_index(from_items_.at(i).table_id_)))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid table bit index", K(ret), K(from_items_.at(i).table_id_), K(bit_id));
|
||||
} else if (OB_FAIL(table_set.add_member(bit_id))) {
|
||||
LOG_WARN("failed to add member", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ColumnItem *ObDMLStmt::get_column_item(uint64_t table_id, const ObString &col_name)
|
||||
{
|
||||
ColumnItem* item = NULL;
|
||||
common::ObCollationType cs_type = common::CS_TYPE_UTF8MB4_GENERAL_CI;
|
||||
@ -3084,23 +3210,6 @@ bool ObDMLStmt::has_link_table() const
|
||||
return bret;
|
||||
}
|
||||
|
||||
int ObDMLStmt::get_table_rel_ids(const TableItem &target,
|
||||
ObSqlBitSet<> &table_set) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (target.is_joined_table()) {
|
||||
const JoinedTable &cur_table = static_cast<const JoinedTable &>(target);
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < cur_table.single_table_ids_.count(); ++i) {
|
||||
if (OB_FAIL(table_set.add_member(get_table_bit_index(cur_table.single_table_ids_.at(i))))) {
|
||||
LOG_WARN("failed to add member", K(ret), K(cur_table.single_table_ids_.at(i)));
|
||||
}
|
||||
}
|
||||
} else if (OB_FAIL(table_set.add_member(get_table_bit_index(target.table_id_)))) {
|
||||
LOG_WARN("failed to add member", K(ret), K(target.table_id_));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObDMLStmt::get_relation_exprs(ObIArray<ObRawExpr*>& rel_array, int32_t ignore_scope /* = 0*/) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -887,7 +887,6 @@ public:
|
||||
virtual int clear_sharable_expr_reference();
|
||||
virtual int get_from_subquery_stmts(common::ObIArray<ObSelectStmt*>& child_stmts) const;
|
||||
int is_referred_by_partitioning_expr(const ObRawExpr* expr, bool& is_referred);
|
||||
int get_table_rel_ids(const TableItem &target, ObSqlBitSet<> &table_set) const;
|
||||
int64_t get_table_size() const
|
||||
{
|
||||
return table_items_.count();
|
||||
@ -994,6 +993,15 @@ public:
|
||||
TableItem* get_table_item(const FromItem item);
|
||||
const TableItem* get_table_item(const FromItem item) const;
|
||||
int get_table_item_idx(const TableItem* child_table, int64_t& idx) const;
|
||||
|
||||
int relids_to_table_ids(const ObSqlBitSet<> &table_set, ObIArray<uint64_t> &table_ids) const;
|
||||
int get_table_rel_ids(const TableItem &target, ObSqlBitSet<> &table_set) const;
|
||||
int get_table_rel_ids(const ObIArray<uint64_t> &table_ids, ObSqlBitSet<> &table_set) const;
|
||||
int get_table_rel_ids(const uint64_t table_id, ObSqlBitSet<> &table_set) const;
|
||||
int get_table_rel_ids(const ObIArray<TableItem*> &tables, ObSqlBitSet<> &table_set) const;
|
||||
int get_from_tables(ObRelIds &table_set) const;
|
||||
int get_from_tables(ObSqlBitSet<> &table_set) const;
|
||||
|
||||
int add_table_item(const ObSQLSessionInfo* session_info, TableItem* table_item);
|
||||
int add_table_item(const ObSQLSessionInfo* session_info, ObIArray<TableItem*>& table_items);
|
||||
int add_table_item(const ObSQLSessionInfo* session_info, TableItem* table_item, bool& have_same_table_name);
|
||||
|
@ -3456,7 +3456,45 @@ int Bound::replace_expr(const common::ObIArray<ObRawExpr*>& other_exprs, const c
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObFrame::assign(const ObFrame& other)
|
||||
bool Bound::same_as(const Bound &other, ObExprEqualCheckContext *check_context) const
|
||||
{
|
||||
bool bret = true;
|
||||
if (type_ != other.type_ ||
|
||||
is_preceding_ != other.is_preceding_ ||
|
||||
is_nmb_literal_ != other.is_nmb_literal_) {
|
||||
bret = false;
|
||||
}
|
||||
if (bret) {
|
||||
if ((interval_expr_ == NULL && other.interval_expr_ == NULL) ||
|
||||
(interval_expr_ != NULL && other.interval_expr_ != NULL &&
|
||||
interval_expr_->same_as(*(other.interval_expr_), check_context))) {
|
||||
bret = true;
|
||||
} else {
|
||||
bret = false;
|
||||
}
|
||||
}
|
||||
if (bret) {
|
||||
if ((date_unit_expr_ == NULL && other.date_unit_expr_ == NULL) ||
|
||||
(date_unit_expr_ != NULL && other.date_unit_expr_ != NULL &&
|
||||
date_unit_expr_->same_as(*(other.date_unit_expr_), check_context))) {
|
||||
bret = true;
|
||||
} else {
|
||||
bret = false;
|
||||
}
|
||||
}
|
||||
for (int64_t i = 0; bret && i < BOUND_EXPR_MAX; ++i) {
|
||||
if ((exprs_[i] == NULL && other.exprs_[i] == NULL) ||
|
||||
(exprs_[i] != NULL && other.exprs_[i] != NULL &&
|
||||
exprs_[i]->same_as(*(other.exprs_[i]), check_context))) {
|
||||
bret = true;
|
||||
} else {
|
||||
bret = false;
|
||||
}
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
|
||||
int ObFrame::assign(const ObFrame &other)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_LIKELY(this != &other)) {
|
||||
@ -3600,8 +3638,10 @@ bool ObWinFunRawExpr::same_as(const ObRawExpr& expr, ObExprEqualCheckContext* ch
|
||||
bool bret = false;
|
||||
if (expr.is_win_func_expr()) {
|
||||
bret = true;
|
||||
const ObWinFunRawExpr& other_ma = static_cast<const ObWinFunRawExpr&>(expr);
|
||||
if (other_ma.get_func_type() != get_func_type()) {
|
||||
const ObWinFunRawExpr &other_ma = static_cast<const ObWinFunRawExpr&>(expr);
|
||||
if (other_ma.get_func_type() != get_func_type() ||
|
||||
other_ma.get_window_type() != get_window_type() ||
|
||||
other_ma.is_between() != is_between()) {
|
||||
bret = false;
|
||||
// Because name window will construct a window function of count(1) over,
|
||||
// here we need to compare the name of name Windows
|
||||
@ -3621,22 +3661,43 @@ bool ObWinFunRawExpr::same_as(const ObRawExpr& expr, ObExprEqualCheckContext* ch
|
||||
} else { /* do nothing. */
|
||||
}
|
||||
|
||||
if (bret &&
|
||||
(other_ma.get_param_count() != get_param_count() || other_ma.func_params_.count() != func_params_.count() ||
|
||||
other_ma.partition_exprs_.count() != partition_exprs_.count() ||
|
||||
other_ma.order_items_.count() != order_items_.count())) {
|
||||
if (!bret) {
|
||||
} else if (other_ma.get_param_count() != get_param_count()
|
||||
|| other_ma.func_params_.count() != func_params_.count()
|
||||
|| other_ma.partition_exprs_.count() != partition_exprs_.count()
|
||||
|| other_ma.order_items_.count() != order_items_.count()
|
||||
|| !other_ma.upper_.same_as(upper_, check_context)
|
||||
|| !other_ma.lower_.same_as(lower_, check_context)) {
|
||||
bret = false;
|
||||
} else {
|
||||
for (int64_t i = 0; bret && i < other_ma.get_param_count(); ++i) {
|
||||
if (OB_ISNULL(other_ma.get_param_expr(i)) || OB_ISNULL(get_param_expr(i))) {
|
||||
bret = false;
|
||||
if (bret) {
|
||||
if ((agg_expr_ == NULL && other_ma.agg_expr_ == NULL) ||
|
||||
(agg_expr_ != NULL && other_ma.agg_expr_ != NULL &&
|
||||
agg_expr_->same_as(*other_ma.agg_expr_, check_context))) {
|
||||
bret = true;
|
||||
} else {
|
||||
bret = get_param_expr(i)->same_as(*(other_ma.get_param_expr(i)), check_context);
|
||||
bret = false;
|
||||
}
|
||||
}
|
||||
for (int64_t i = 0; bret && i < other_ma.func_params_.count(); ++i) {
|
||||
if (other_ma.func_params_.at(i) == NULL || func_params_.at(i) == NULL ||
|
||||
!other_ma.func_params_.at(i)->same_as(*func_params_.at(i), check_context)) {
|
||||
bret = false;
|
||||
}
|
||||
}
|
||||
for (int64_t i = 0; bret && i < other_ma.partition_exprs_.count(); ++i) {
|
||||
if (other_ma.partition_exprs_.at(i) == NULL || partition_exprs_.at(i) == NULL ||
|
||||
!other_ma.partition_exprs_.at(i)->same_as(*partition_exprs_.at(i), check_context)) {
|
||||
bret = false;
|
||||
}
|
||||
}
|
||||
for (int64_t i = 0; bret && i < other_ma.order_items_.count(); ++i) {
|
||||
if (other_ma.order_items_.at(i).order_type_ != order_items_.at(i).order_type_) {
|
||||
bret = false;
|
||||
} else if (other_ma.order_items_.at(i).expr_ == NULL || order_items_.at(i).expr_ == NULL ||
|
||||
!other_ma.order_items_.at(i).expr_->same_as(*order_items_.at(i).expr_,
|
||||
check_context)) {
|
||||
bret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3596,6 +3596,8 @@ public:
|
||||
virtual int replace_expr(
|
||||
const common::ObIArray<ObRawExpr*>& other_exprs, const common::ObIArray<ObRawExpr*>& new_exprs);
|
||||
|
||||
bool same_as(const Bound &other, ObExprEqualCheckContext *check_context) const;
|
||||
|
||||
BoundType type_;
|
||||
bool is_preceding_;
|
||||
bool is_nmb_literal_;
|
||||
@ -3628,11 +3630,11 @@ public:
|
||||
{
|
||||
lower_ = lower;
|
||||
}
|
||||
inline WindowType get_window_type()
|
||||
inline WindowType get_window_type() const
|
||||
{
|
||||
return win_type_;
|
||||
}
|
||||
inline bool is_between()
|
||||
inline bool is_between() const
|
||||
{
|
||||
return is_between_;
|
||||
}
|
||||
|
@ -2579,9 +2579,11 @@ int ObRawExprResolverImpl::process_agg_node(const ParseNode* node, ObRawExpr*& e
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid node children", K(node->num_child_));
|
||||
} else {
|
||||
ctx_.parents_expr_info_.add_member(IS_AGG);
|
||||
bool need_add_flag = !ctx_.parents_expr_info_.has_member(IS_AGG);
|
||||
AggNestedCheckerGuard agg_guard(ctx_);
|
||||
if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
|
||||
if (need_add_flag && OB_FAIL(ctx_.parents_expr_info_.add_member(IS_AGG))) {
|
||||
LOG_WARN("failed to add member", K(ret));
|
||||
} else if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
|
||||
LOG_WARN("failed to check agg nested.", K(ret));
|
||||
} else if (T_FUN_COUNT == node->type_ && 1 == node->num_child_) {
|
||||
if (OB_UNLIKELY(T_STAR != node->children_[0]->type_)) {
|
||||
@ -2692,11 +2694,12 @@ int ObRawExprResolverImpl::process_agg_node(const ParseNode* node, ObRawExpr*& e
|
||||
// add invalid table bit index, avoid aggregate function expressions are used as filters
|
||||
if (OB_FAIL(agg_expr->get_relation_ids().add_member(0))) {
|
||||
LOG_WARN("failed to add member", K(ret));
|
||||
} else if (need_add_flag && (ctx_.parents_expr_info_.del_member(IS_AGG))) {
|
||||
LOG_WARN("failed to del member", K(ret));
|
||||
} else {
|
||||
expr = agg_expr;
|
||||
}
|
||||
}
|
||||
ctx_.parents_expr_info_.del_member(IS_AGG);
|
||||
}
|
||||
// set the expr in nested agg.
|
||||
if (OB_SUCC(ret) && is_in_nested_aggr) {
|
||||
@ -2726,10 +2729,12 @@ int ObRawExprResolverImpl::process_group_aggr_node(const ParseNode* node, ObRawE
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("inalid group concat node", K(ret), K(node->children_));
|
||||
} else {
|
||||
ctx_.parents_expr_info_.add_member(IS_AGG);
|
||||
ParseNode* expr_list_node = node->children_[1];
|
||||
bool need_add_flag = !ctx_.parents_expr_info_.has_member(IS_AGG);
|
||||
ParseNode *expr_list_node = node->children_[1];
|
||||
AggNestedCheckerGuard agg_guard(ctx_);
|
||||
if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
|
||||
if (need_add_flag && OB_FAIL(ctx_.parents_expr_info_.add_member(IS_AGG))) {
|
||||
LOG_WARN("failed to add member", K(ret));
|
||||
} else if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
|
||||
LOG_WARN("failed to check agg nested.", K(ret));
|
||||
} else if (share::is_mysql_mode() && is_in_nested_aggr) {
|
||||
ret = OB_ERR_INVALID_GROUP_FUNC_USE;
|
||||
@ -2810,8 +2815,11 @@ int ObRawExprResolverImpl::process_group_aggr_node(const ParseNode* node, ObRawE
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
ctx_.parents_expr_info_.del_member(IS_AGG);
|
||||
expr = agg_expr;
|
||||
if (need_add_flag && (ctx_.parents_expr_info_.del_member(IS_AGG))) {
|
||||
LOG_WARN("failed to del member", K(ret));
|
||||
} else {
|
||||
expr = agg_expr;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && is_in_nested_aggr) {
|
||||
@ -2847,9 +2855,11 @@ int ObRawExprResolverImpl::process_keep_aggr_node(const ParseNode* node, ObRawEx
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("inalid group concat node", K(ret), K(node->children_));
|
||||
} else {
|
||||
ctx_.parents_expr_info_.add_member(IS_AGG);
|
||||
bool need_add_flag = !ctx_.parents_expr_info_.has_member(IS_AGG);
|
||||
AggNestedCheckerGuard agg_guard(ctx_);
|
||||
if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
|
||||
if (need_add_flag && OB_FAIL(ctx_.parents_expr_info_.add_member(IS_AGG))) {
|
||||
LOG_WARN("failed to add member", K(ret));
|
||||
} else if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
|
||||
LOG_WARN("failed to check agg nested.", K(ret));
|
||||
} else if (NULL != node->children_[0] && T_DISTINCT == node->children_[0]->type_) {
|
||||
ret = OB_DISTINCT_NOT_ALLOWED;
|
||||
@ -2897,8 +2907,11 @@ int ObRawExprResolverImpl::process_keep_aggr_node(const ParseNode* node, ObRawEx
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
ctx_.parents_expr_info_.del_member(IS_AGG);
|
||||
expr = agg_expr;
|
||||
if (need_add_flag && (ctx_.parents_expr_info_.del_member(IS_AGG))) {
|
||||
LOG_WARN("failed to del member", K(ret));
|
||||
} else {
|
||||
expr = agg_expr;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && is_in_nested_aggr) {
|
||||
@ -4345,14 +4358,17 @@ int ObRawExprResolverImpl::check_and_canonicalize_window_expr(ObRawExpr* expr)
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret) && share::is_mysql_mode() && w_expr->has_frame_orig() &&
|
||||
WINDOW_RANGE == win_type && 0 == order_items.count()) {
|
||||
ret = OB_ERR_MISS_ORDER_BY_EXPR;
|
||||
LOG_WARN("missing ORDER BY expression in the window specification", K(ret));
|
||||
}
|
||||
|
||||
// reset frame
|
||||
if (OB_SUCC(ret)) {
|
||||
if (0 == order_items.count() ||
|
||||
(ObRawExprResolverImpl::should_not_contain_window_clause(func_type) && win_type != WINDOW_MAX)) {
|
||||
win_type = WINDOW_MAX;
|
||||
upper = Bound();
|
||||
lower = Bound();
|
||||
}
|
||||
if (OB_SUCC(ret) && win_type != WINDOW_MAX && should_not_contain_window_clause(func_type)) {
|
||||
win_type = WINDOW_MAX;
|
||||
upper = Bound();
|
||||
lower = Bound();
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
@ -4641,7 +4657,10 @@ int ObRawExprResolverImpl::process_agg_udf_node(
|
||||
ctx_.parents_expr_info_.add_member(IS_AGG);
|
||||
AggNestedCheckerGuard agg_guard(ctx_);
|
||||
bool is_in_nested_aggr = false;
|
||||
if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
|
||||
bool need_add_flag = !ctx_.parents_expr_info_.has_member(IS_AGG);
|
||||
if (need_add_flag && OB_FAIL(ctx_.parents_expr_info_.add_member(IS_AGG))) {
|
||||
LOG_WARN("failed to add member", K(ret));
|
||||
} else if (OB_FAIL(agg_guard.check_agg_nested(is_in_nested_aggr))) {
|
||||
LOG_WARN("failed to check agg nested.", K(ret));
|
||||
} else if (is_in_nested_aggr) {
|
||||
ret = OB_ERR_INVALID_GROUP_FUNC_USE;
|
||||
@ -4673,13 +4692,12 @@ int ObRawExprResolverImpl::process_agg_udf_node(
|
||||
// add invalid table bit index, avoid aggregate function expressions are used as filters
|
||||
if (OB_FAIL(agg_expr->get_relation_ids().add_member(0))) {
|
||||
LOG_WARN("failed to add member", K(ret));
|
||||
} else if (need_add_flag && (ctx_.parents_expr_info_.del_member(IS_AGG))) {
|
||||
LOG_WARN("failed to del member", K(ret));
|
||||
} else {
|
||||
expr = agg_expr;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME WHY?
|
||||
ctx_.parents_expr_info_.del_member(IS_AGG);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2063,6 +2063,7 @@ int ObRawExprUtils::copy_expr(ObRawExprFactory& expr_factory, const ObRawExpr* o
|
||||
int ret = OB_SUCCESS;
|
||||
bool need_copy = true;
|
||||
bool copy_share_expr = (COPY_REF_SHARED == copy_types) || use_new_allocator;
|
||||
bool is_stack_overflow = false;
|
||||
if (NULL == origin) {
|
||||
need_copy = false;
|
||||
dest = NULL;
|
||||
@ -2076,7 +2077,13 @@ int ObRawExprUtils::copy_expr(ObRawExprFactory& expr_factory, const ObRawExpr* o
|
||||
need_copy = false;
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret) && need_copy) {
|
||||
if (OB_FAIL(ret) || !need_copy) {
|
||||
} else if (OB_FAIL(check_stack_overflow(is_stack_overflow))) {
|
||||
LOG_WARN("check stack overflow failed", K(ret));
|
||||
} else if (is_stack_overflow) {
|
||||
ret = OB_SIZE_OVERFLOW;
|
||||
LOG_WARN("too deep recursive", K(ret));
|
||||
} else {
|
||||
// deep copy here
|
||||
ObRawExpr::ExprClass expr_class = origin->get_expr_class();
|
||||
switch (expr_class) {
|
||||
|
@ -611,18 +611,16 @@ int ObStmtComparer::compare_basic_table_item(ObDMLStmt* first, const TableItem*
|
||||
} else if (OB_ISNULL(second_table_hint)) {
|
||||
relation = QueryRelation::LEFT_SUBSET;
|
||||
} else {
|
||||
ObSqlBitSet<> first_set, second_set;
|
||||
for (int64_t i = 0; i < first_table_hint->part_ids_.count(); ++i) {
|
||||
first_set.add_member(first_table_hint->part_ids_.at(i));
|
||||
}
|
||||
for (int64_t i = 0; i < second_table_hint->part_ids_.count(); ++i) {
|
||||
second_set.add_member(second_table_hint->part_ids_.at(i));
|
||||
}
|
||||
if (first_set.equal(second_set)) {
|
||||
// part ids for subpartition is a large int64_t number, here can not use bit set.
|
||||
bool left_subset = ObOptimizerUtil::is_subset(first_table_hint->part_ids_,
|
||||
second_table_hint->part_ids_);
|
||||
bool right_subset = ObOptimizerUtil::is_subset(second_table_hint->part_ids_,
|
||||
first_table_hint->part_ids_);
|
||||
if (left_subset && right_subset) {
|
||||
relation = QueryRelation::EQUAL;
|
||||
} else if (first_set.is_subset(second_set)) {
|
||||
} else if (left_subset) {
|
||||
relation = QueryRelation::LEFT_SUBSET;
|
||||
} else if (first_set.is_superset(second_set)) {
|
||||
} else if (right_subset) {
|
||||
relation = QueryRelation::RIGHT_SUBSET;
|
||||
} else {
|
||||
relation = QueryRelation::UNCOMPARABLE;
|
||||
|
@ -856,10 +856,10 @@ int ObTransformAggrSubquery::check_stmt_valid(ObDMLStmt& stmt, bool& is_valid)
|
||||
int ret = OB_SUCCESS;
|
||||
is_valid = true;
|
||||
int32_t bit_id = OB_INVALID_INDEX;
|
||||
ObRelIds output_rel_ids;
|
||||
ObSqlBitSet<> output_rel_ids;
|
||||
if (stmt.is_set_stmt() || stmt.is_hierarchical_query() || !stmt.is_sel_del_upd()) {
|
||||
is_valid = false;
|
||||
} else if (OB_FAIL(ObTransformUtils::get_from_tables(stmt, output_rel_ids))) {
|
||||
} else if (OB_FAIL(stmt.get_from_tables(output_rel_ids))) {
|
||||
LOG_WARN("failed to get output rel ids", K(ret));
|
||||
}
|
||||
// check all output table is basic table
|
||||
@ -1057,17 +1057,15 @@ int ObTransformAggrSubquery::do_join_first_transform(
|
||||
ObSelectStmt& select_stmt, TransformParam& trans_param, ObRawExpr* root_expr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObQueryRefRawExpr* query_ref_expr = NULL;
|
||||
ObSelectStmt* subquery = NULL;
|
||||
ObRawExprFactory* expr_factory = NULL;
|
||||
ObRelIds from_tables;
|
||||
if (OB_ISNULL(ctx_) || OB_ISNULL(ctx_->session_info_) || OB_ISNULL(root_expr) ||
|
||||
OB_ISNULL(expr_factory = ctx_->expr_factory_) || OB_ISNULL(query_ref_expr = trans_param.ja_query_ref_) ||
|
||||
OB_ISNULL(subquery = trans_param.ja_query_ref_->get_ref_stmt())) {
|
||||
ObQueryRefRawExpr *query_ref_expr = NULL;
|
||||
ObSelectStmt *subquery = NULL;
|
||||
ObRawExprFactory *expr_factory = NULL;
|
||||
if (OB_ISNULL(ctx_) || OB_ISNULL(ctx_->session_info_) || OB_ISNULL(root_expr)
|
||||
|| OB_ISNULL(expr_factory = ctx_->expr_factory_)
|
||||
|| OB_ISNULL(query_ref_expr = trans_param.ja_query_ref_)
|
||||
|| OB_ISNULL(subquery = trans_param.ja_query_ref_->get_ref_stmt())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid argument", K(ret), K(ctx_), K(root_expr), K(query_ref_expr), K(subquery));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_from_tables(select_stmt, from_tables))) {
|
||||
LOG_WARN("failed to get output rel ids", K(ret));
|
||||
} else if (OB_FAIL(get_unique_keys(select_stmt, select_stmt.get_group_exprs()))) {
|
||||
LOG_WARN("failed to get unique exprs", K(ret));
|
||||
}
|
||||
@ -1143,10 +1141,10 @@ int ObTransformAggrSubquery::do_join_first_transform(
|
||||
int ObTransformAggrSubquery::get_unique_keys(ObDMLStmt& stmt, ObIArray<ObRawExpr*>& pkeys)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObRelIds from_tables;
|
||||
ObSEArray<ObRawExpr*, 2> tmp_pkeys;
|
||||
ObSqlBitSet<> from_tables;
|
||||
ObSEArray<ObRawExpr *, 2> tmp_pkeys;
|
||||
int32_t bit_id = OB_INVALID_INDEX;
|
||||
if (OB_FAIL(ObTransformUtils::get_from_tables(stmt, from_tables))) {
|
||||
if (OB_FAIL(stmt.get_from_tables(from_tables))) {
|
||||
LOG_WARN("failed to get from table set", K(ret));
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < stmt.get_table_items().count(); ++i) {
|
||||
|
@ -344,7 +344,7 @@ int ObTransformEliminateOuterJoin::can_be_eliminated_with_null_reject(
|
||||
} else if (OB_ISNULL(right_table = joined_table->right_table_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("right table is null", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, *(joined_table->right_table_), right_table_ids))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(*(joined_table->right_table_), right_table_ids))) {
|
||||
LOG_WARN("failed to get right table relation ids", K(ret));
|
||||
}
|
||||
|
||||
@ -394,10 +394,10 @@ int ObTransformEliminateOuterJoin::can_be_eliminated_with_foreign_primary_join(
|
||||
is_simple_condition))) {
|
||||
LOG_WARN("check is simple join condition failed", K(ret));
|
||||
} else if (!is_simple_condition) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, *(joined_table->left_table_), left_table_ids))) {
|
||||
/*on condition不是简单的列相等连接,不能消除,do nothing*/
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(*(joined_table->left_table_),left_table_ids))) {
|
||||
LOG_WARN("failed to get left table rel ids", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, *(joined_table->right_table_), right_table_ids))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(*(joined_table->right_table_), right_table_ids))) {
|
||||
LOG_WARN("failed to get right table relation ids", K(ret));
|
||||
} else if (OB_FAIL(extract_columns_from_join_conditions(
|
||||
joined_table->join_conditions_, left_table_ids, stmt->get_current_level(), left_col_exprs))) {
|
||||
|
@ -288,7 +288,7 @@ int ObTransformGroupByPlacement::compute_push_down_param(
|
||||
if (OB_ISNULL(joined_table)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("joined table is null", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, *joined_table, table_bit_set))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(*joined_table, table_bit_set))) {
|
||||
LOG_WARN("failed to convert table id array to bit set", K(ret));
|
||||
} else {
|
||||
for (int64_t j = 0; OB_SUCC(ret) && !should_merge && j < params.count(); ++j) {
|
||||
@ -378,7 +378,7 @@ int ObTransformGroupByPlacement::get_null_side_tables(
|
||||
null_table = &joined_table;
|
||||
}
|
||||
if (OB_SUCC(ret) && NULL != null_table) {
|
||||
if (OB_FAIL(ObTransformUtils::get_table_rel_ids(stmt, *null_table, table_set))) {
|
||||
if (OB_FAIL(stmt.get_table_rel_ids(*null_table, table_set))) {
|
||||
LOG_WARN("failed to get table relation ids", K(ret));
|
||||
}
|
||||
}
|
||||
@ -702,9 +702,9 @@ int ObTransformGroupByPlacement::distribute_joined_on_conds(
|
||||
} else if (is_stack_overflow) {
|
||||
ret = OB_SIZE_OVERFLOW;
|
||||
LOG_WARN("too deep recursive", K(ret), K(is_stack_overflow));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, *joined_table->left_table_, left_table_set))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(*joined_table->left_table_, left_table_set))) {
|
||||
LOG_WARN("failed to get left table set", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, *joined_table->right_table_, right_table_set))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(*joined_table->right_table_, right_table_set))) {
|
||||
LOG_WARN("failed to get right table set", K(ret));
|
||||
}
|
||||
ObSEArray<ObRawExpr*, 4> filter_conds;
|
||||
@ -1503,8 +1503,8 @@ int ObTransformGroupByPlacement::check_groupby_pullup_validity(ObDMLStmt* stmt,
|
||||
if (OB_ISNULL(stmt->get_semi_infos().at(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("semi info is null", K(ret), K(stmt->get_semi_infos().at(i)));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(
|
||||
*stmt, stmt->get_semi_infos().at(i)->left_table_ids_, ignore_tables))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(stmt->get_semi_infos().at(i)->left_table_ids_,
|
||||
ignore_tables))) {
|
||||
LOG_WARN("failed to get table rel ids", K(ret));
|
||||
}
|
||||
}
|
||||
@ -1758,16 +1758,13 @@ int ObTransformGroupByPlacement::check_null_propagate(
|
||||
if (OB_ISNULL(child_stmt) || OB_ISNULL(parent_stmt)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else if (helper.need_check_null_propagate_) {
|
||||
ObRelIds rel_ids;
|
||||
} else if (helper.need_check_null_propagate_){
|
||||
ObSqlBitSet<> from_tables;
|
||||
ObColumnRefRawExpr* col_expr = NULL;
|
||||
ObSEArray<ObRawExpr*, 4> columns;
|
||||
ObSEArray<ObRawExpr*, 4> column_exprs;
|
||||
if (OB_FAIL(ObTransformUtils::get_from_tables(*child_stmt, rel_ids))) {
|
||||
if (OB_FAIL(child_stmt->get_from_tables(from_tables))) {
|
||||
LOG_WARN("failed to get from tables", K(ret));
|
||||
} else if (OB_FAIL(from_tables.add_members2(rel_ids))) {
|
||||
LOG_WARN("failed to add members", K(ret));
|
||||
} else if (OB_FAIL(child_stmt->get_column_exprs(columns))) {
|
||||
LOG_WARN("failed to get column exprs", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_table_exprs(*child_stmt, columns, from_tables, column_exprs))) {
|
||||
@ -2066,17 +2063,14 @@ int ObTransformGroupByPlacement::wrap_case_when_if_necessary(
|
||||
ObSelectStmt& child_stmt, PullupHelper& helper, ObIArray<ObRawExpr*>& exprs)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObRelIds rel_ids;
|
||||
ObSqlBitSet<> from_tables;
|
||||
ObRawExpr* not_null_column = NULL;
|
||||
ObSEArray<ObRawExpr*, 4> columns;
|
||||
ObSEArray<ObRawExpr*, 4> column_exprs;
|
||||
if (helper.not_null_column_id_ == OB_INVALID) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(ObTransformUtils::get_from_tables(child_stmt, rel_ids))) {
|
||||
//do nothing
|
||||
} else if (OB_FAIL(child_stmt.get_from_tables(from_tables))) {
|
||||
LOG_WARN("failed to get from tables", K(ret));
|
||||
} else if (OB_FAIL(from_tables.add_members2(rel_ids))) {
|
||||
LOG_WARN("failed to add members", K(ret));
|
||||
} else if (OB_FAIL(child_stmt.get_column_exprs(columns))) {
|
||||
LOG_WARN("failed to get column exprs", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_table_exprs(child_stmt, columns, from_tables, column_exprs))) {
|
||||
|
@ -1058,7 +1058,9 @@ int ObTransformJoinElimination::check_transform_validity_semi_self_key(ObDMLStmt
|
||||
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_table_exprs(*stmt, candi_conds, left_tables, left_table_conditions))) {
|
||||
LOG_WARN("failed to extract table exprs", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_table_exprs(*stmt, candi_conds, right_tables, right_table_conditions))) {
|
||||
} else if (!semi_info->is_anti_join() && // anti join do not use right filter
|
||||
OB_FAIL(ObTransformUtils::extract_table_exprs(*stmt, candi_conds, right_tables,
|
||||
right_table_conditions))) {
|
||||
LOG_WARN("failed to extract table exprs", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::check_exprs_unique_on_table_items(stmt,
|
||||
ctx_->session_info_,
|
||||
@ -1102,7 +1104,7 @@ int ObTransformJoinElimination::check_semi_join_condition(ObDMLStmt* stmt, SemiI
|
||||
if (OB_ISNULL(stmt) || OB_ISNULL(semi_info)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("param has null", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, target_tables, right_tables))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(target_tables, right_tables))) {
|
||||
LOG_WARN("failed to get rel ids", K(ret));
|
||||
} else {
|
||||
ObRawExpr* expr = NULL;
|
||||
@ -1320,9 +1322,9 @@ int ObTransformJoinElimination::trans_semi_condition_exprs(ObDMLStmt* stmt, Semi
|
||||
LOG_WARN("param has null", K(stmt), K(ctx_), K(ret));
|
||||
} else if (semi_info->is_semi_join()) {
|
||||
ret = append(stmt->get_condition_exprs(), semi_info->semi_conditions_);
|
||||
} else if (ObTransformUtils::get_table_rel_ids(*stmt, semi_info->left_table_ids_, left_rel_ids)) {
|
||||
} else if (stmt->get_table_rel_ids(semi_info->left_table_ids_, left_rel_ids)) {
|
||||
LOG_WARN("failed to get table rel ids", K(ret));
|
||||
} else if (ObTransformUtils::get_table_rel_ids(*stmt, semi_info->right_table_id_, right_rel_ids)) {
|
||||
} else if (stmt->get_table_rel_ids(semi_info->right_table_id_, right_rel_ids)) {
|
||||
LOG_WARN("failed to get table rel ids", K(ret));
|
||||
} else {
|
||||
const int64_t count = semi_info->semi_conditions_.count();
|
||||
@ -1434,7 +1436,7 @@ int ObTransformJoinElimination::check_transform_validity_semi_foreign_key(ObDMLS
|
||||
stmt, conds, left_table, right_table, can_be_eliminated, is_first_table_parent, foreign_key_info))) {
|
||||
LOG_WARN("check transform validity with foreign key failed", K(ret));
|
||||
} else if (is_first_table_parent) {
|
||||
/*do nothing*/
|
||||
can_be_eliminated = false;
|
||||
} else if (!can_be_eliminated) {
|
||||
/*do nothing*/
|
||||
} else if (!semi_info->is_anti_join()) {
|
||||
@ -1800,7 +1802,7 @@ int ObTransformJoinElimination::rebuild_joined_tables(ObDMLStmt* stmt, TableItem
|
||||
LOG_WARN("empty tables", K(ret), K(tables));
|
||||
} else if (1 == tables.count()) {
|
||||
top_table = tables.at(0);
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, *tables.at(0), table_set))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(*tables.at(0), table_set))) {
|
||||
LOG_WARN("failed to get table rel ids", K(ret));
|
||||
} else {
|
||||
TableItem* left_table = NULL;
|
||||
@ -1813,7 +1815,7 @@ int ObTransformJoinElimination::rebuild_joined_tables(ObDMLStmt* stmt, TableItem
|
||||
if (OB_ISNULL(left_table = tables.at(i)) || OB_ISNULL(right_table = cur_table)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret), K(left_table), K(right_table));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, *left_table, table_set))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(*left_table, table_set))) {
|
||||
LOG_WARN("failed to get table rel ids", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_table_exprs(*stmt, join_conds, table_set, cur_join_conds))) {
|
||||
LOG_WARN("failed to extract table exprs", K(ret));
|
||||
|
@ -358,7 +358,7 @@ int ObTransformOuterJoinLimitPushDown::find_target_table(
|
||||
while (OB_SUCC(ret) && OB_NOT_NULL(table) && !found) {
|
||||
// find target joined_table based on order by column relation_ids
|
||||
ObSqlBitSet<> cur_table_ids;
|
||||
if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*select_stmt, *table, cur_table_ids))) {
|
||||
if (OB_FAIL(select_stmt->get_table_rel_ids(*table, cur_table_ids))) {
|
||||
LOG_WARN("failed to get table rel ids", K(ret));
|
||||
} else if (cur_table_ids.equal(table_ids)) {
|
||||
found = true;
|
||||
|
@ -605,15 +605,15 @@ int ObTransformPreProcess::replace_with_set_stmt_view(
|
||||
ObSelectStmt* origin_stmt, ObSelectStmt* set_view_stmt, ObSelectStmt*& union_stmt)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObRelIds rel_ids;
|
||||
TableItem* view_table_item = NULL;
|
||||
ObSEArray<ObRawExpr*, 4> old_exprs;
|
||||
ObSEArray<ObRawExpr*, 4> new_exprs;
|
||||
ObSqlBitSet<> rel_ids;
|
||||
TableItem *view_table_item = NULL;
|
||||
ObSEArray<ObRawExpr *, 4> old_exprs;
|
||||
ObSEArray<ObRawExpr *, 4> new_exprs;
|
||||
ObSEArray<ColumnItem, 4> temp_column_items;
|
||||
if (OB_ISNULL(origin_stmt) || OB_ISNULL(set_view_stmt)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("origin stmt is null", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_from_tables(*origin_stmt, rel_ids))) {
|
||||
} else if (OB_FAIL(origin_stmt->get_from_tables(rel_ids))) {
|
||||
LOG_WARN("failed to get from tables.", K(ret));
|
||||
} else if (FALSE_IT(origin_stmt->get_table_items().reset())) {
|
||||
} else if (FALSE_IT(origin_stmt->get_from_items().reset())) {
|
||||
@ -1157,14 +1157,11 @@ int ObTransformPreProcess::create_connect_by_view(ObSelectStmt& stmt)
|
||||
// 5. finish creating the child stmts
|
||||
if (OB_SUCC(ret)) {
|
||||
// create select list
|
||||
ObSEArray<ObRawExpr*, 4> columns;
|
||||
ObRelIds rel_ids;
|
||||
ObSEArray<ObRawExpr *, 4> columns;
|
||||
ObSqlBitSet<> from_tables;
|
||||
ObSEArray<ObRawExpr*, 16> shared_exprs;
|
||||
if (OB_FAIL(ObTransformUtils::get_from_tables(*view_stmt, rel_ids))) {
|
||||
if (OB_FAIL(view_stmt->get_from_tables(from_tables))) {
|
||||
LOG_WARN("failed to get from tables", K(ret));
|
||||
} else if (OB_FAIL(from_tables.add_members2(rel_ids))) {
|
||||
LOG_WARN("failed to add members", K(ret));
|
||||
} else if (OB_FAIL(view_stmt->get_column_exprs(columns))) {
|
||||
LOG_WARN("failed to get column exprs", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_table_exprs(*view_stmt, columns, from_tables, select_list))) {
|
||||
@ -1287,15 +1284,12 @@ int ObTransformPreProcess::create_and_mock_join_view(ObSelectStmt& stmt)
|
||||
// 4. finish creating the left child stmts
|
||||
if (OB_SUCC(ret)) {
|
||||
// create select list
|
||||
ObSEArray<ObRawExpr*, 4> columns;
|
||||
ObSEArray<ObQueryRefRawExpr*, 4> query_refs;
|
||||
ObRelIds rel_ids;
|
||||
ObSEArray<ObRawExpr *, 4> columns;
|
||||
ObSEArray<ObQueryRefRawExpr *, 4> query_refs;
|
||||
ObSqlBitSet<> from_tables;
|
||||
ObSEArray<ObRawExpr*, 16> shared_exprs;
|
||||
if (OB_FAIL(ObTransformUtils::get_from_tables(*left_view_stmt, rel_ids))) {
|
||||
if (OB_FAIL(left_view_stmt->get_from_tables(from_tables))) {
|
||||
LOG_WARN("failed to get from tables", K(ret));
|
||||
} else if (OB_FAIL(from_tables.add_members2(rel_ids))) {
|
||||
LOG_WARN("failed to add members", K(ret));
|
||||
} else if (OB_FAIL(left_view_stmt->get_column_exprs(columns))) {
|
||||
LOG_WARN("failed to get column exprs", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_table_exprs(*left_view_stmt, columns, from_tables, select_list))) {
|
||||
@ -1452,8 +1446,10 @@ int ObTransformPreProcess::is_cond_in_one_from_item(ObSelectStmt& stmt, ObRawExp
|
||||
if (OB_ISNULL(table)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpect null table item", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(
|
||||
stmt, table->is_joined_table() ? *(static_cast<JoinedTable*>(table)) : *table, table_ids))) {
|
||||
} else if (OB_FAIL(stmt.get_table_rel_ids(table->is_joined_table() ?
|
||||
*(static_cast<JoinedTable*>(table)) :
|
||||
*table,
|
||||
table_ids))) {
|
||||
LOG_WARN("failed to get table rel ids", K(ret));
|
||||
} else if (expr->get_relation_ids().is_subset(table_ids)) {
|
||||
in_from_item = true;
|
||||
|
@ -202,7 +202,7 @@ int ObTransformPredicateMoveAround::preprocess_semi_info(
|
||||
LOG_WARN("semi info is null", K(ret));
|
||||
} else if (semi_info->is_anti_join()) {
|
||||
// do not pull up anti conditions to upper conds
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(stmt, semi_info->left_table_ids_, left_rel_ids))) {
|
||||
} else if (OB_FAIL(stmt.get_table_rel_ids(semi_info->left_table_ids_, left_rel_ids))) {
|
||||
LOG_WARN("failed to get table rel ids", K(ret));
|
||||
} else {
|
||||
ObRawExpr* expr = NULL;
|
||||
@ -900,16 +900,24 @@ int ObTransformPredicateMoveAround::pushdown_into_having(
|
||||
ObSelectStmt& sel_stmt, ObIArray<ObRawExpr*>& pullup_preds, ObIArray<ObRawExpr*>& pushdown_preds)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSEArray<ObRawExpr*, 4> new_having_exprs;
|
||||
ObSEArray<ObRawExpr*, 4> target_exprs;
|
||||
ObSEArray<ObRawExpr*, 4> input_preds;
|
||||
ObSEArray<ObRawExpr*, 4> columns;
|
||||
ObSEArray<ObRawExpr *, 4> new_having_exprs;
|
||||
ObSEArray<ObRawExpr *, 4> target_exprs;
|
||||
ObSEArray<ObRawExpr *, 4> input_preds;
|
||||
ObSEArray<ObRawExpr *, 4> all_columns;
|
||||
ObSEArray<ObRawExpr *, 4> columns;
|
||||
ObSqlBitSet<> table_set;
|
||||
if (sel_stmt.get_having_exprs().empty() && pushdown_preds.empty()) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(sel_stmt.get_column_exprs(columns))) {
|
||||
} else if (OB_FAIL(sel_stmt.get_column_exprs(all_columns))) {
|
||||
LOG_WARN("failed to get column exprs", K(ret));
|
||||
} else if (OB_FAIL(append(input_preds, pullup_preds))) {
|
||||
LOG_WARN("failed to append predicates", K(ret));
|
||||
} else if (OB_FAIL(sel_stmt.get_from_tables(table_set))) {
|
||||
LOG_WARN("failed to get from items rel ids", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_table_exprs(sel_stmt, all_columns,
|
||||
table_set, columns))) {
|
||||
LOG_WARN("failed to get related columns", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_table_exprs(sel_stmt, pullup_preds,
|
||||
table_set, input_preds))) {
|
||||
LOG_WARN("failed to get related pullup preds", K(ret));
|
||||
} else if (OB_FAIL(append(input_preds, sel_stmt.get_having_exprs()))) {
|
||||
LOG_WARN("failed to append having predicates", K(ret));
|
||||
} else if (OB_FAIL(append(input_preds, pushdown_preds))) {
|
||||
@ -930,17 +938,25 @@ int ObTransformPredicateMoveAround::pushdown_into_where(
|
||||
ObDMLStmt& stmt, ObIArray<ObRawExpr*>& pullup_preds, ObIArray<ObRawExpr*>& predicates)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSEArray<ObRawExpr*, 4> new_conds;
|
||||
ObSEArray<ObRawExpr*, 4> all_conds;
|
||||
ObSEArray<ObRawExpr*, 4> columns;
|
||||
ObSEArray<ObRawExpr *, 4> new_conds;
|
||||
ObSEArray<ObRawExpr *, 4> all_conds;
|
||||
ObSEArray<ObRawExpr *, 4> all_columns;
|
||||
ObSEArray<ObRawExpr *, 4> columns;
|
||||
ObSqlBitSet<> table_set;
|
||||
if (stmt.get_condition_exprs().empty() && predicates.empty()) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(stmt.get_column_exprs(columns))) {
|
||||
} else if (OB_FAIL(stmt.get_column_exprs(all_columns))) {
|
||||
LOG_WARN("failed to get column exprs", K(ret));
|
||||
} else if (OB_FAIL(stmt.get_from_tables(table_set))) {
|
||||
LOG_WARN("failed to get from items rel ids", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_table_exprs(stmt, all_columns,
|
||||
table_set, columns))) {
|
||||
LOG_WARN("failed to get related columns", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_table_exprs(stmt, pullup_preds,
|
||||
table_set, all_conds))) {
|
||||
LOG_WARN("failed to get related pullup preds", K(ret));
|
||||
} else if (OB_FAIL(append(all_conds, predicates))) {
|
||||
LOG_WARN("failed to append push down predicates", K(ret));
|
||||
} else if (OB_FAIL(append(all_conds, pullup_preds))) {
|
||||
LOG_WARN("failed to append pullup predicates", K(ret));
|
||||
} else if (OB_FAIL(append(all_conds, stmt.get_condition_exprs()))) {
|
||||
LOG_WARN("failed to append where conditions", K(ret));
|
||||
} else if (OB_FAIL(transform_predicates(stmt, all_conds, columns, new_conds))) {
|
||||
@ -1151,7 +1167,7 @@ int ObTransformPredicateMoveAround::pushdown_into_joined_table(ObDMLStmt* stmt,
|
||||
filterable_table = joined_table;
|
||||
}
|
||||
if (NULL != filterable_table) {
|
||||
if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, *filterable_table, filter_table_set))) {
|
||||
if (OB_FAIL(stmt->get_table_rel_ids(*filterable_table, filter_table_set))) {
|
||||
LOG_WARN("failed to get table relation ids", K(ret));
|
||||
}
|
||||
}
|
||||
@ -1320,7 +1336,7 @@ int ObTransformPredicateMoveAround::get_pushdown_predicates(
|
||||
target_table = &table;
|
||||
}
|
||||
if (OB_FAIL(ret) || NULL == target_table) {
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(stmt, *target_table, table_set))) {
|
||||
} else if (OB_FAIL(stmt.get_table_rel_ids(*target_table, table_set))) {
|
||||
LOG_WARN("failed to get table set", K(ret));
|
||||
} else if (OB_FAIL(get_pushdown_predicates(stmt, table_set, preds, table_filters))) {
|
||||
LOG_WARN("failed to get push down predicates", K(ret));
|
||||
@ -1377,9 +1393,9 @@ int ObTransformPredicateMoveAround::pushdown_into_semi_info(
|
||||
LOG_WARN("params have null", K(ret), K(stmt), K(semi_info), K(right_table));
|
||||
} else if (OB_FAIL(old_semi_conds.assign(semi_info->semi_conditions_))) {
|
||||
LOG_WARN("failed to assign exprs", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, semi_info->left_table_ids_, left_rel_ids))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(semi_info->left_table_ids_, left_rel_ids))) {
|
||||
LOG_WARN("failed to get left rel ids", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, semi_info->right_table_id_, right_rel_ids))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(semi_info->right_table_id_, right_rel_ids))) {
|
||||
LOG_WARN("failed to get right semi rel ids", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_table_exprs(*stmt, pullup_preds, left_rel_ids, properites)) ||
|
||||
OB_FAIL(get_pushdown_predicates(*stmt, left_rel_ids, pushdown_preds, properites))) {
|
||||
@ -1400,17 +1416,17 @@ int ObTransformPredicateMoveAround::pushdown_into_semi_info(
|
||||
LOG_WARN("failed to check different", K(ret));
|
||||
} else if (OB_FAIL(pushdown_into_table(stmt, right_table, pullup_preds, semi_info->semi_conditions_))) {
|
||||
LOG_WARN("failed to push down predicates", K(ret));
|
||||
} else if (OB_FAIL(get_pushdown_predicates(*stmt, *right_table, semi_info->semi_conditions_, table_preds))) {
|
||||
} else if (OB_FAIL(get_pushdown_predicates(*stmt, right_rel_ids, semi_info->semi_conditions_,
|
||||
table_preds))) {
|
||||
LOG_WARN("failed to get push down predicates", K(ret));
|
||||
} else if (table_preds.empty()) {
|
||||
/* do nothing */
|
||||
} else if (OB_FAIL(ObTransformUtils::pushdown_semi_info_right_filter(stmt, ctx_, semi_info, table_preds))) {
|
||||
LOG_WARN("failed to pushdown semi info right filter", K(ret));
|
||||
} else if (OB_FAIL(ObOptimizerUtil::remove_item(semi_info->semi_conditions_, table_preds))) {
|
||||
LOG_WARN("failed to remove item", K(ret));
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret) && OB_FAIL(check_transform_happened(old_semi_conds, semi_info->semi_conditions_))) {
|
||||
if (OB_SUCC(ret) && OB_FAIL(check_transform_happened(old_semi_conds,
|
||||
semi_info->semi_conditions_))) {
|
||||
LOG_WARN("failed to check transform happened", K(ret));
|
||||
}
|
||||
return ret;
|
||||
|
@ -345,7 +345,7 @@ int ObTransformQueryPushDown::check_select_item_push_down(ObSelectStmt* select_s
|
||||
} else if (OB_FAIL(check_select_item_subquery(*select_stmt, *view_stmt, check_status))) {
|
||||
LOG_WARN("failed to check select item has subquery", K(ret));
|
||||
} else if (!check_status) {
|
||||
can_be = false;
|
||||
can_be = false;
|
||||
} else if (view_stmt->is_contains_assignment() || select_stmt->is_contains_assignment()) {
|
||||
can_be = false;
|
||||
} else if (OB_FAIL(is_select_item_same(select_stmt, view_stmt, check_status, select_offset, const_select_items))) {
|
||||
|
@ -260,9 +260,9 @@ int ObTransformSemiToInner::check_semi_join_condition(ObDMLStmt& stmt, SemiInfo&
|
||||
ObSqlBitSet<> right_table_set;
|
||||
ObIArray<ObRawExpr*>& semi_conditions = semi_info.semi_conditions_;
|
||||
is_all_equal_cond = true;
|
||||
if (OB_FAIL(ObTransformUtils::get_table_rel_ids(stmt, semi_info.left_table_ids_, left_table_set))) {
|
||||
if (OB_FAIL(stmt.get_table_rel_ids(semi_info.left_table_ids_, left_table_set))) {
|
||||
LOG_WARN("failed to get table rel ids", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(stmt, semi_info.right_table_id_, right_table_set))) {
|
||||
} else if (OB_FAIL(stmt.get_table_rel_ids(semi_info.right_table_id_, right_table_set))) {
|
||||
LOG_WARN("failed to get table rel ids", K(ret));
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < semi_conditions.count(); ++i) {
|
||||
@ -400,7 +400,7 @@ int ObTransformSemiToInner::check_join_condition_match_index(ObDMLStmt* root_stm
|
||||
if (OB_ISNULL(ctx_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("ctx is null", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(stmt, semi_info.left_table_ids_, left_table_set))) {
|
||||
} else if (OB_FAIL(stmt.get_table_rel_ids(semi_info.left_table_ids_, left_table_set))) {
|
||||
LOG_WARN("failed to get table rel ids", K(ret));
|
||||
}
|
||||
// check semi condition is match left table
|
||||
|
@ -269,7 +269,7 @@ int ObTransformSimplify::try_push_down_outer_join_conds(ObDMLStmt* stmt, JoinedT
|
||||
} else if (!join_table->right_table_->is_basic_table() && !join_table->right_table_->is_generated_table() &&
|
||||
!join_table->right_table_->is_joined_table()) {
|
||||
/*do nothing*/
|
||||
} else if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*stmt, *join_table->right_table_, right_table_ids))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(*join_table->right_table_, right_table_ids))) {
|
||||
LOG_WARN("failed to get target table rel ids", K(ret));
|
||||
} else {
|
||||
ObSEArray<ObRawExpr*, 16> push_down_conds;
|
||||
@ -300,13 +300,20 @@ int ObTransformSimplify::try_push_down_outer_join_conds(ObDMLStmt* stmt, JoinedT
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTransformSimplify::push_down_on_condition(ObDMLStmt* stmt, JoinedTable* join_table, ObIArray<ObRawExpr*>& conds)
|
||||
{
|
||||
int ObTransformSimplify::push_down_on_condition(ObDMLStmt *stmt,
|
||||
JoinedTable *join_table,
|
||||
ObIArray<ObRawExpr*> &conds) {
|
||||
int ret = OB_SUCCESS;
|
||||
ObSEArray<ObRawExpr*, 16> old_column_exprs;
|
||||
ObSEArray<ObRawExpr*, 16> new_column_exprs;
|
||||
ObSelectStmt* child_stmt = NULL;
|
||||
if (OB_ISNULL(stmt) || OB_ISNULL(ctx_) || OB_ISNULL(join_table) || OB_ISNULL(join_table->right_table_)) {
|
||||
ObSEArray<ObRawExpr *, 16> new_conds;
|
||||
ObSEArray<ObRawExpr *, 16> old_column_exprs;
|
||||
ObSEArray<ObRawExpr *, 16> new_column_exprs;
|
||||
ObSEArray<ObQueryRefRawExpr*, 2> subqueries;
|
||||
ObSEArray<ObRawExpr *, 16> new_select_list;
|
||||
ObSEArray<ObRawExpr *, 16> new_column_list;
|
||||
ObSelectStmt *child_stmt = NULL;
|
||||
if (OB_ISNULL(stmt) || OB_ISNULL(ctx_) || OB_ISNULL(join_table) ||
|
||||
OB_ISNULL(ctx_->expr_factory_) || OB_ISNULL(ctx_->allocator_) ||
|
||||
OB_ISNULL(join_table->right_table_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected NULL", K(ret));
|
||||
} else if (!join_table->is_left_join() || !join_table->right_table_->is_generated_table() ||
|
||||
@ -315,12 +322,41 @@ int ObTransformSimplify::push_down_on_condition(ObDMLStmt* stmt, JoinedTable* jo
|
||||
LOG_WARN("unexpected join table", K(ret));
|
||||
} else if (OB_FAIL(ObOptimizerUtil::remove_item(join_table->get_join_conditions(), conds))) {
|
||||
LOG_WARN("failed to remove item", K(ret));
|
||||
} else if (OB_FAIL(child_stmt->add_condition_exprs(conds))) {
|
||||
} else if (OB_FAIL(ObRawExprUtils::copy_exprs(*ctx_->expr_factory_, conds,
|
||||
new_conds, COPY_REF_DEFAULT))) {
|
||||
LOG_WARN("failed to copy exprs", K(ret));
|
||||
} else if (OB_FAIL(child_stmt->add_condition_exprs(new_conds))) {
|
||||
LOG_WARN("failed to add condotion exprs", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_query_ref_expr(conds, child_stmt->get_subquery_exprs()))) {
|
||||
LOG_WARN("failed to adjust subquery list", K(ret));
|
||||
} else if (OB_FAIL(stmt->adjust_subquery_list())) {
|
||||
LOG_WARN("failed to adjust subquery list", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_query_ref_expr(new_conds, subqueries))) {
|
||||
LOG_WARN("failed to extract subquery", K(ret));
|
||||
} else if (OB_FAIL(append(child_stmt->get_subquery_exprs(), subqueries))) {
|
||||
LOG_WARN("failed to append subquery list", K(ret));
|
||||
} else if (OB_FAIL(ObOptimizerUtil::remove_item(stmt->get_subquery_exprs(), subqueries))) {
|
||||
LOG_WARN("failed to remove subqueries", K(ret));
|
||||
} else if (!stmt->is_merge_stmt()) {
|
||||
/* do nothing */
|
||||
} else if (OB_FAIL(append(new_select_list, subqueries))) {
|
||||
LOG_WARN("failed to append exprs", K(ret));
|
||||
/* for merge into, subqueries in join condition are shared by match condition,
|
||||
here add subqueries to child select items. */
|
||||
} else if (OB_FAIL(ObTransformUtils::create_select_item(*ctx_->allocator_, new_select_list,
|
||||
child_stmt))) {
|
||||
LOG_WARN("failed to create select item", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::create_columns_for_view(ctx_, *join_table->right_table_,
|
||||
stmt, new_select_list,
|
||||
new_column_list))) {
|
||||
LOG_WARN("failed to create columns for table item", K(ret));
|
||||
} else if (OB_FAIL(stmt->remove_table_item(join_table->right_table_))) {
|
||||
LOG_WARN("failed to remove table item", K(ret));
|
||||
} else if (OB_FAIL(stmt->replace_inner_stmt_expr(new_select_list, new_column_list))) {
|
||||
LOG_WARN("failed to replace inner stmt expr", K(ret));
|
||||
} else if (OB_FAIL(stmt->get_table_items().push_back(join_table->right_table_))) {
|
||||
LOG_WARN("failed to push back table item", K(ret));
|
||||
} else if (OB_FAIL(stmt->update_column_item_rel_id())) {
|
||||
LOG_WARN("failed to update column item rel id", K(ret));
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(child_stmt->adjust_subquery_stmt_parent(stmt, child_stmt))) {
|
||||
LOG_WARN("failed to adjust subquery stmt parent", K(ret));
|
||||
} else if (OB_FAIL(stmt->get_column_exprs(join_table->right_table_->table_id_, old_column_exprs))) {
|
||||
@ -330,7 +366,7 @@ int ObTransformSimplify::push_down_on_condition(ObDMLStmt* stmt, JoinedTable* jo
|
||||
LOG_WARN("failed to conver column exprs", K(ret));
|
||||
} else if (OB_FAIL(child_stmt->replace_inner_stmt_expr(old_column_exprs, new_column_exprs))) {
|
||||
LOG_WARN("failed to replace stmt exprs", K(ret));
|
||||
} else if (OB_FAIL(child_stmt->formalize_stmt(ctx_->session_info_))) {
|
||||
} else if (OB_FAIL(stmt->formalize_stmt(ctx_->session_info_))) {
|
||||
LOG_WARN("failed to formalize stmt", K(ret));
|
||||
}
|
||||
return ret;
|
||||
@ -542,14 +578,11 @@ int ObTransformSimplify::get_upper_column_exprs(ObSelectStmt& upper_stmt, ObSele
|
||||
if (OB_ISNULL(stmt_select_expr = stmt.get_select_item(i).expr_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null", K(ret));
|
||||
} else if (OB_ISNULL(
|
||||
column_item = upper_stmt.get_column_item_by_id(table_item->table_id_, i + OB_APP_MIN_COLUMN_ID))) {
|
||||
// disable these aggr expr which can not be found in upper stmt,
|
||||
// otherwise, following elimination will meet unexpected, such as
|
||||
// inner stmt count(1) cnt with upper stmt max.
|
||||
if (stmt_select_expr->is_aggr_expr()) {
|
||||
is_valid = false;
|
||||
}
|
||||
} else if (OB_ISNULL(column_item = upper_stmt.get_column_item_by_id(table_item->table_id_,
|
||||
i + OB_APP_MIN_COLUMN_ID))) {
|
||||
// a select expr contains aggr function, it's not used by upper stmt.
|
||||
// project pruning will remove it, do not transform here.
|
||||
is_valid = !stmt_select_expr->has_flag(CNT_AGG);
|
||||
} else if (OB_ISNULL(column_item->expr_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null expr", K(ret));
|
||||
|
@ -975,7 +975,7 @@ int ObTransformUtils::replace_expr(
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(expr->replace_expr(other_exprs, new_exprs))) {
|
||||
if (OB_FAIL(SMART_CALL(expr->replace_expr(other_exprs, new_exprs)))) {
|
||||
LOG_WARN("failed to replace expr", K(ret));
|
||||
} else if (NULL != temp_old_expr) {
|
||||
const_cast<ObIArray<ObRawExpr*>&>(other_exprs).at(idx) = temp_old_expr;
|
||||
@ -1700,8 +1700,8 @@ int ObTransformUtils::check_stmt_output_nullable(const ObSelectStmt* stmt, const
|
||||
int ObTransformUtils::find_not_null_expr(ObDMLStmt& stmt, ObRawExpr*& not_null_expr, bool& is_valid)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObRelIds from_tables;
|
||||
if (OB_FAIL(get_from_tables(stmt, from_tables))) {
|
||||
ObSqlBitSet<> from_tables;
|
||||
if (OB_FAIL(stmt.get_from_tables(from_tables))) {
|
||||
LOG_WARN("failed to get from tables", K(ret));
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < stmt.get_column_size(); ++i) {
|
||||
@ -2977,7 +2977,7 @@ int ObTransformUtils::check_stmt_unique(ObSelectStmt* stmt, ObSQLSessionInfo* se
|
||||
ObRelIds all_tables;
|
||||
if (OB_FAIL(compute_stmt_property(stmt, check_helper, res_info, extra_flags))) {
|
||||
LOG_WARN("failed to compute stmt property", K(ret));
|
||||
} else if (OB_FAIL(get_from_tables(*stmt, all_tables))) {
|
||||
} else if (OB_FAIL(stmt->get_from_tables(all_tables))) {
|
||||
LOG_WARN("failed to get from tables", K(ret));
|
||||
} else if (!is_strict && OB_FAIL(append(res_info.fd_sets_, res_info.candi_fd_sets_))) {
|
||||
// is strict, use fd_item_set & candi_fd_set check unique
|
||||
@ -3019,7 +3019,7 @@ int ObTransformUtils::compute_stmt_property(ObSelectStmt* stmt, UniqueCheckHelpe
|
||||
ObTableFdItem* group_unique_fd = NULL;
|
||||
ObRelIds table_set;
|
||||
ObSEArray<ObRawExpr*, 4> select_exprs;
|
||||
if (OB_FAIL(get_from_tables(*stmt, table_set))) {
|
||||
if (OB_FAIL(stmt->get_from_tables(table_set))) {
|
||||
LOG_WARN("failed to get from tables", K(ret));
|
||||
} else if (OB_FAIL(stmt->get_select_exprs(select_exprs))) {
|
||||
LOG_WARN("failed to get select exprs", K(ret));
|
||||
@ -3266,7 +3266,7 @@ int ObTransformUtils::compute_path_property(ObDMLStmt* stmt, UniqueCheckHelper&
|
||||
} else if (OB_ISNULL(table)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected from item", K(ret), K(from_item));
|
||||
} else if (OB_FAIL(get_table_rel_ids(*stmt, *table, rel_ids))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(*table, rel_ids))) {
|
||||
LOG_WARN("failed to get table relids", K(ret));
|
||||
} else if (OB_FAIL(compute_table_property(stmt, check_helper, table, cond_exprs, right_info))) {
|
||||
LOG_WARN("failed to compute table property", K(ret));
|
||||
@ -3421,8 +3421,8 @@ int ObTransformUtils::compute_basic_table_property(ObDMLStmt* stmt, UniqueCheckH
|
||||
} else if (!table->is_basic_table()) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected table", K(ret), K(*table));
|
||||
} else if (OB_FAIL(get_table_rel_ids(*stmt, *table, table_set)) ||
|
||||
OB_FAIL(res_info.table_set_.add_members(table_set))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(*table, table_set))
|
||||
|| OB_FAIL(res_info.table_set_.add_members(table_set))) {
|
||||
LOG_WARN("failed to get table relids", K(ret));
|
||||
} else if (OB_FAIL(extract_table_exprs(*stmt, cond_exprs, *table, cur_cond_exprs))) {
|
||||
LOG_WARN("failed to extract table exprs", K(ret));
|
||||
@ -3492,8 +3492,8 @@ int ObTransformUtils::compute_generate_table_property(ObDMLStmt* stmt, UniqueChe
|
||||
LOG_WARN("get unexpected table", K(ret), K(*table));
|
||||
} else if (OB_FAIL(SMART_CALL(compute_stmt_property(ref_query, check_helper, child_info)))) {
|
||||
LOG_WARN("failed to compute stmt property", K(ret));
|
||||
} else if (OB_FAIL(get_table_rel_ids(*stmt, *table, table_set)) ||
|
||||
OB_FAIL(res_info.table_set_.add_members(table_set))) {
|
||||
} else if (OB_FAIL(stmt->get_table_rel_ids(*table, table_set))
|
||||
|| OB_FAIL(res_info.table_set_.add_members(table_set))) {
|
||||
LOG_WARN("failed to get table relids", K(ret));
|
||||
} else if (OB_FAIL(ObOptimizerUtil::convert_subplan_scan_expr(*check_helper.expr_factory_,
|
||||
child_info.equal_sets_,
|
||||
@ -3768,7 +3768,7 @@ int ObTransformUtils::extract_table_exprs(const ObDMLStmt& stmt, const ObIArray<
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSqlBitSet<> table_set;
|
||||
if (OB_FAIL(get_table_rel_ids(stmt, target, table_set))) {
|
||||
if (OB_FAIL(stmt.get_table_rel_ids(target, table_set))) {
|
||||
LOG_WARN("failed to get table rel ids", K(ret));
|
||||
} else if (OB_FAIL(extract_table_exprs(stmt, source_exprs, table_set, exprs))) {
|
||||
LOG_WARN("failed to extract table exprs", K(ret));
|
||||
@ -3781,7 +3781,7 @@ int ObTransformUtils::extract_table_exprs(const ObDMLStmt& stmt, const ObIArray<
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSqlBitSet<> table_set;
|
||||
if (OB_FAIL(get_table_rel_ids(stmt, tables, table_set))) {
|
||||
if (OB_FAIL(stmt.get_table_rel_ids(tables, table_set))) {
|
||||
LOG_WARN("failed to get table rel ids", K(ret));
|
||||
} else if (OB_FAIL(extract_table_exprs(stmt, source_exprs, table_set, exprs))) {
|
||||
LOG_WARN("failed to extract table exprs", K(ret));
|
||||
@ -3816,9 +3816,9 @@ int ObTransformUtils::get_table_joined_exprs(const ObDMLStmt& stmt, const TableI
|
||||
int ret = OB_SUCCESS;
|
||||
ObSqlBitSet<> source_table_ids;
|
||||
ObSqlBitSet<> target_table_ids;
|
||||
if (OB_FAIL(get_table_rel_ids(stmt, source, source_table_ids))) {
|
||||
if (OB_FAIL(stmt.get_table_rel_ids(source, source_table_ids))) {
|
||||
LOG_WARN("failed to get source table rel ids", K(ret));
|
||||
} else if (OB_FAIL(get_table_rel_ids(stmt, target, target_table_ids))) {
|
||||
} else if (OB_FAIL(stmt.get_table_rel_ids(target, target_table_ids))) {
|
||||
LOG_WARN("failed to get target table rel ids", K(ret));
|
||||
} else if (OB_FAIL(get_table_joined_exprs(
|
||||
source_table_ids, target_table_ids, conditions, target_exprs, join_source_ids, join_target_ids))) {
|
||||
@ -3840,14 +3840,14 @@ int ObTransformUtils::get_table_joined_exprs(const ObDMLStmt& stmt, const ObIArr
|
||||
if (OB_ISNULL(table)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("table item is null", K(ret));
|
||||
} else if (OB_FAIL(get_table_rel_ids(stmt, *table, source_table_ids))) {
|
||||
} else if (OB_FAIL(stmt.get_table_rel_ids(*table, source_table_ids))) {
|
||||
LOG_WARN("failed to get source table rel ids", K(ret));
|
||||
} else { /*do nothing*/
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
/*do nothing*/
|
||||
} else if (OB_FAIL(get_table_rel_ids(stmt, target, target_table_ids))) {
|
||||
} else if (OB_FAIL(stmt.get_table_rel_ids(target, target_table_ids))) {
|
||||
LOG_WARN("failed to get target table rel ids", K(ret));
|
||||
} else if (OB_FAIL(get_table_joined_exprs(
|
||||
source_table_ids, target_table_ids, conditions, target_exprs, join_source_ids, join_target_ids))) {
|
||||
@ -3944,117 +3944,7 @@ int ObTransformUtils::get_table_joined_exprs(const ObSqlBitSet<>& source_ids, co
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTransformUtils::relids_to_table_items(ObDMLStmt* stmt, const ObRelIds& rel_ids, ObIArray<TableItem*>& rel_array)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(stmt)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("stmt is null", K(ret));
|
||||
} else {
|
||||
TableItem* table = NULL;
|
||||
int64_t idx = OB_INVALID_INDEX;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < stmt->get_table_items().count(); ++i) {
|
||||
if (OB_ISNULL(table = stmt->get_table_items().at(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("table item is null", K(ret));
|
||||
} else if (OB_UNLIKELY((idx = stmt->get_table_bit_index(table->table_id_)) == OB_INVALID_INDEX)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get table item invalid idx", K(idx), K(table->table_id_));
|
||||
} else if (rel_ids.has_member(idx)) {
|
||||
ret = rel_array.push_back(table);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTransformUtils::relids_to_table_ids(
|
||||
ObDMLStmt* stmt, const ObSqlBitSet<>& table_set, ObIArray<uint64_t>& table_ids)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_ISNULL(stmt)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("stmt is null", K(ret));
|
||||
} else {
|
||||
TableItem* table = NULL;
|
||||
int64_t idx = OB_INVALID_INDEX;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < stmt->get_table_items().count(); ++i) {
|
||||
if (OB_ISNULL(table = stmt->get_table_items().at(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("table item is null", K(ret));
|
||||
} else if (OB_UNLIKELY((idx = stmt->get_table_bit_index(table->table_id_)) == OB_INVALID_INDEX)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get table item invalid idx", K(idx), K(table->table_id_));
|
||||
} else if (table_set.has_member(idx)) {
|
||||
ret = table_ids.push_back(table->table_id_);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTransformUtils::get_table_rel_ids(const ObDMLStmt& stmt, const TableItem& target, ObSqlBitSet<>& table_set)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (target.is_joined_table()) {
|
||||
const JoinedTable& joined_table = static_cast<const JoinedTable&>(target);
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < joined_table.single_table_ids_.count(); ++i) {
|
||||
if (OB_FAIL(table_set.add_member(stmt.get_table_bit_index(joined_table.single_table_ids_.at(i))))) {
|
||||
LOG_WARN("failed to add member", K(ret), K(joined_table.single_table_ids_.at(i)));
|
||||
}
|
||||
}
|
||||
} else if (OB_FAIL(table_set.add_member(stmt.get_table_bit_index(target.table_id_)))) {
|
||||
LOG_WARN("failed to add member", K(ret), K(target.table_id_));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTransformUtils::get_table_rel_ids(
|
||||
const ObDMLStmt& stmt, const ObIArray<uint64_t>& table_ids, ObSqlBitSet<>& table_set)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int32_t idx = OB_INVALID_INDEX;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < table_ids.count(); ++i) {
|
||||
idx = stmt.get_table_bit_index(table_ids.at(i));
|
||||
if (OB_UNLIKELY(OB_INVALID_INDEX == idx)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpect idx", K(ret));
|
||||
} else if (OB_FAIL(table_set.add_member(idx))) {
|
||||
LOG_WARN("failed to add members", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTransformUtils::get_table_rel_ids(const ObDMLStmt& stmt, const uint64_t table_id, ObSqlBitSet<>& table_set)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int32_t idx = stmt.get_table_bit_index(table_id);
|
||||
if (OB_UNLIKELY(OB_INVALID_INDEX == idx)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpect idx", K(ret));
|
||||
} else if (OB_FAIL(table_set.add_member(idx))) {
|
||||
LOG_WARN("failed to add members", K(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTransformUtils::get_table_rel_ids(
|
||||
const ObDMLStmt& stmt, const ObIArray<TableItem*>& tables, ObSqlBitSet<>& table_set)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < tables.count(); ++i) {
|
||||
if (OB_ISNULL(tables.at(i))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpect null", K(ret));
|
||||
} else if (OB_FAIL(get_table_rel_ids(stmt, *tables.at(i), table_set))) {
|
||||
LOG_WARN("failed to get table rel ids", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTransformUtils::get_from_item(ObDMLStmt* stmt, TableItem* table, FromItem& from)
|
||||
int ObTransformUtils::get_from_item(ObDMLStmt *stmt, TableItem *table, FromItem &from)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool found = false;
|
||||
@ -4586,11 +4476,11 @@ int ObTransformUtils::generate_unique_key(
|
||||
ObTransformerCtx* ctx, ObDMLStmt* stmt, ObSqlBitSet<>& ignore_tables, ObIArray<ObRawExpr*>& unique_keys)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObRelIds from_rel_ids;
|
||||
ObSqlBitSet<> from_rel_ids;
|
||||
if (OB_ISNULL(stmt) || OB_ISNULL(ctx)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("param is null", K(stmt), K(ctx), K(ret));
|
||||
} else if (OB_FAIL(get_from_tables(*stmt, from_rel_ids))) {
|
||||
} else if (OB_FAIL(stmt->get_from_tables(from_rel_ids))) {
|
||||
LOG_WARN("failed to get output rel ids", K(ret));
|
||||
} else {
|
||||
ObIArray<TableItem*>& table_items = stmt->get_table_items();
|
||||
@ -5413,15 +5303,12 @@ int ObTransformUtils::create_simple_view(
|
||||
// 5. finish creating the child stmts
|
||||
if (OB_SUCC(ret)) {
|
||||
// create select list
|
||||
ObSEArray<ObRawExpr*, 4> columns;
|
||||
ObSEArray<ObQueryRefRawExpr*, 4> query_refs;
|
||||
ObRelIds rel_ids;
|
||||
ObSEArray<ObRawExpr *, 4> columns;
|
||||
ObSEArray<ObQueryRefRawExpr *, 4> query_refs;
|
||||
ObSqlBitSet<> from_tables;
|
||||
ObSEArray<ObRawExpr*, 16> shared_exprs;
|
||||
if (OB_FAIL(get_from_tables(*view_stmt, rel_ids))) {
|
||||
if (OB_FAIL(view_stmt->get_from_tables(from_tables))) {
|
||||
LOG_WARN("failed to get from tables", K(ret));
|
||||
} else if (OB_FAIL(from_tables.add_members2(rel_ids))) {
|
||||
LOG_WARN("failed to add members", K(ret));
|
||||
} else if (OB_FAIL(view_stmt->get_column_exprs(columns))) {
|
||||
LOG_WARN("failed to get column exprs", K(ret));
|
||||
} else if (OB_FAIL(extract_table_exprs(*view_stmt, columns, from_tables, select_list))) {
|
||||
@ -5849,6 +5736,10 @@ int ObTransformUtils::create_view_with_table(
|
||||
LOG_WARN("failed to adjust subquery list", K(ret));
|
||||
} else if (OB_FAIL(view_stmt->adjust_subquery_stmt_parent(stmt, view_stmt))) {
|
||||
LOG_WARN("failed to adjust subquery stmt parent", K(ret));
|
||||
} else if ((stmt->is_delete_stmt() || stmt->is_update_stmt() || stmt->is_merge_stmt()) &&
|
||||
OB_FAIL(adjust_updatable_view(*ctx->expr_factory_, static_cast<ObDelUpdStmt*>(stmt),
|
||||
*new_table))) {
|
||||
LOG_WARN("failed to adjust updatable view", K(ret));
|
||||
} else if (OB_FAIL(stmt->remove_table_item(new_table))) {
|
||||
LOG_WARN("failed to remove table item", K(ret));
|
||||
} else if (OB_FAIL(stmt->replace_inner_stmt_expr(old_column_exprs, new_column_exprs))) {
|
||||
@ -5913,18 +5804,22 @@ int ObTransformUtils::pushdown_semi_info_right_filter(ObDMLStmt* stmt, ObTransfo
|
||||
// pushdown right table filter in semi condition:
|
||||
// 1. if right table is a basic table, create a generate table.
|
||||
// 2. pushdown the right table filters into the generate table.
|
||||
int ObTransformUtils::pushdown_semi_info_right_filter(
|
||||
ObDMLStmt* stmt, ObTransformerCtx* ctx, SemiInfo* semi_info, ObIArray<ObRawExpr*>& right_filters)
|
||||
// subquery in right filter can not be a shared subquery
|
||||
int ObTransformUtils::pushdown_semi_info_right_filter(ObDMLStmt *stmt,
|
||||
ObTransformerCtx *ctx,
|
||||
SemiInfo *semi_info,
|
||||
ObIArray<ObRawExpr*> &right_filters)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
TableItem* right_table = NULL;
|
||||
ObSelectStmt* child_stmt = NULL;
|
||||
bool can_push = false;
|
||||
ObSEArray<ObRawExpr*, 16> new_right_filters;
|
||||
ObSEArray<ObRawExpr*, 16> old_column_exprs;
|
||||
ObSEArray<ObRawExpr*, 16> new_column_exprs;
|
||||
if (OB_ISNULL(stmt) || OB_ISNULL(ctx) || OB_ISNULL(semi_info)) {
|
||||
if (OB_ISNULL(stmt) || OB_ISNULL(ctx) || OB_ISNULL(semi_info) || OB_ISNULL(ctx->expr_factory_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret), K(stmt), K(ctx), K(semi_info));
|
||||
LOG_WARN("unexpected null", K(ret), K(stmt), K(ctx), K(semi_info), K(ctx->expr_factory_));
|
||||
} else if (right_filters.empty()) {
|
||||
/* do nothing */
|
||||
} else if (OB_ISNULL(right_table = stmt->get_table_item_by_id(semi_info->right_table_id_))) {
|
||||
@ -5940,9 +5835,12 @@ int ObTransformUtils::pushdown_semi_info_right_filter(
|
||||
LOG_WARN("unexpected right table", K(ret), K(right_table), K(child_stmt));
|
||||
} else if (OB_FAIL(ObOptimizerUtil::remove_item(semi_info->semi_conditions_, right_filters))) {
|
||||
LOG_WARN("failed to remove item", K(ret));
|
||||
} else if (OB_FAIL(child_stmt->add_condition_exprs(right_filters))) {
|
||||
} else if (OB_FAIL(ObRawExprUtils::copy_exprs(*ctx->expr_factory_, right_filters,
|
||||
new_right_filters, COPY_REF_DEFAULT))) {
|
||||
LOG_WARN("failed to copy exprs", K(ret));
|
||||
} else if (OB_FAIL(child_stmt->add_condition_exprs(new_right_filters))) {
|
||||
LOG_WARN("failed to add condotion exprs", K(ret));
|
||||
} else if (OB_FAIL(extract_query_ref_expr(right_filters, child_stmt->get_subquery_exprs()))) {
|
||||
} else if (OB_FAIL(extract_query_ref_expr(new_right_filters, child_stmt->get_subquery_exprs()))) {
|
||||
LOG_WARN("failed to adjust subquery list", K(ret));
|
||||
} else if (OB_FAIL(stmt->adjust_subquery_list())) {
|
||||
LOG_WARN("failed to adjust subquery list", K(ret));
|
||||
@ -6119,43 +6017,9 @@ int ObTransformUtils::replace_table_in_joined_tables(TableItem* table, TableItem
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get_output_rel_ids
|
||||
* get ObRelIds for all tables in from items
|
||||
*/
|
||||
int ObTransformUtils::get_from_tables(const ObDMLStmt& stmt, ObRelIds& output_rel_ids)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int32_t bit_id = OB_INVALID_INDEX;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < stmt.get_from_item_size(); ++i) {
|
||||
const FromItem& from = stmt.get_from_item(i);
|
||||
if (from.is_joined_) {
|
||||
const JoinedTable* table = stmt.get_joined_table(from.table_id_);
|
||||
if (OB_ISNULL(table)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("failed to get joined table", K(ret));
|
||||
}
|
||||
for (int64_t j = 0; OB_SUCC(ret) && j < table->single_table_ids_.count(); ++j) {
|
||||
uint64_t table_id = table->single_table_ids_.at(j);
|
||||
if (OB_UNLIKELY(OB_INVALID_INDEX == (bit_id = stmt.get_table_bit_index(table_id)))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid table bit index", K(ret), K(table_id), K(bit_id));
|
||||
} else if (OB_FAIL(output_rel_ids.add_member(bit_id))) {
|
||||
LOG_WARN("failed to add member", K(ret));
|
||||
}
|
||||
}
|
||||
} else if (OB_UNLIKELY(OB_INVALID_INDEX == (bit_id = stmt.get_table_bit_index(from.table_id_)))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid table bit index", K(ret), K(from.table_id_), K(bit_id));
|
||||
} else if (OB_FAIL(output_rel_ids.add_member(bit_id))) {
|
||||
LOG_WARN("failed to add member", K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTransformUtils::classify_rownum_conds(
|
||||
ObDMLStmt& stmt, ObIArray<ObRawExpr*>& spj_conds, ObIArray<ObRawExpr*>& other_conds)
|
||||
int ObTransformUtils::classify_rownum_conds(ObDMLStmt &stmt,
|
||||
ObIArray<ObRawExpr *> &spj_conds,
|
||||
ObIArray<ObRawExpr *> &other_conds)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (stmt.is_select_stmt()) {
|
||||
@ -6777,7 +6641,7 @@ int ObTransformUtils::recursive_set_stmt_unique(ObSelectStmt* select_stmt, ObTra
|
||||
int ret = OB_SUCCESS;
|
||||
bool is_unique = false;
|
||||
bool is_stack_overflow = false;
|
||||
ObRelIds origin_output_rel_ids;
|
||||
ObSqlBitSet<> origin_output_rel_ids;
|
||||
ObSEArray<ObRawExpr*, 4> pkeys;
|
||||
ObSEArray<ObRawExpr*, 4> select_exprs;
|
||||
if (OB_ISNULL(select_stmt) || OB_ISNULL(ctx) || OB_ISNULL(ctx->session_info_) || OB_ISNULL(ctx->schema_checker_) ||
|
||||
@ -6801,7 +6665,7 @@ int ObTransformUtils::recursive_set_stmt_unique(ObSelectStmt* select_stmt, ObTra
|
||||
}
|
||||
} else if (OB_FAIL(select_stmt->get_select_exprs(select_exprs))) {
|
||||
LOG_WARN("failed to get select exprs", K(ret));
|
||||
} else if (OB_FAIL(get_from_tables(*select_stmt, origin_output_rel_ids))) {
|
||||
} else if (OB_FAIL(select_stmt->get_from_tables(origin_output_rel_ids))) {
|
||||
LOG_WARN("failed to get output rel ids", K(ret));
|
||||
} else {
|
||||
ObIArray<TableItem*>& table_items = select_stmt->get_table_items();
|
||||
@ -6870,11 +6734,11 @@ int ObTransformUtils::check_can_set_stmt_unique(ObDMLStmt* stmt, bool& can_set_u
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
can_set_unique = false;
|
||||
ObRelIds output_rel_ids;
|
||||
ObSqlBitSet<> output_rel_ids;
|
||||
if (OB_ISNULL(stmt)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("get unexpected null ptr", K(stmt), K(ret));
|
||||
} else if (OB_FAIL(get_from_tables(*stmt, output_rel_ids))) {
|
||||
} else if (OB_FAIL(stmt->get_from_tables(output_rel_ids))) {
|
||||
LOG_WARN("failed to get output rel ids", K(ret));
|
||||
} else {
|
||||
ObSelectStmt* view_stmt = NULL;
|
||||
|
@ -371,15 +371,12 @@ int ObTransformViewMerge::check_can_be_unnested(
|
||||
}
|
||||
if (OB_FAIL(ret) || !can_be) {
|
||||
/*do nothing*/
|
||||
} else if (helper.need_check_null_propagate) {
|
||||
ObSEArray<ObRawExpr*, 4> columns;
|
||||
ObRelIds rel_ids;
|
||||
} else if (helper.need_check_null_propagate){
|
||||
ObSEArray<ObRawExpr *, 4> columns;
|
||||
ObSqlBitSet<> from_tables;
|
||||
ObSEArray<ObRawExpr*, 4> column_exprs;
|
||||
if (OB_FAIL(ObTransformUtils::get_from_tables(*child_stmt, rel_ids))) {
|
||||
if (OB_FAIL(child_stmt->get_from_tables(from_tables))) {
|
||||
LOG_WARN("failed to get from tables", K(ret));
|
||||
} else if (OB_FAIL(from_tables.add_members2(rel_ids))) {
|
||||
LOG_WARN("failed to add members", K(ret));
|
||||
} else if (OB_FAIL(child_stmt->get_column_exprs(columns))) {
|
||||
LOG_WARN("failed to get column exprs", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_table_exprs(*child_stmt, columns, from_tables, column_exprs))) {
|
||||
@ -781,14 +778,11 @@ int ObTransformViewMerge::wrap_case_when_if_necessary(
|
||||
ObSelectStmt& child_stmt, ViewMergeHelper& helper, ObIArray<ObRawExpr*>& exprs)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObSEArray<ObRawExpr*, 4> columns;
|
||||
ObRelIds rel_ids;
|
||||
ObSEArray<ObRawExpr *, 4> columns;
|
||||
ObSqlBitSet<> from_tables;
|
||||
ObSEArray<ObRawExpr*, 4> column_exprs;
|
||||
if (OB_FAIL(ObTransformUtils::get_from_tables(child_stmt, rel_ids))) {
|
||||
if (OB_FAIL(child_stmt.get_from_tables(from_tables))) {
|
||||
LOG_WARN("failed to get from tables", K(ret));
|
||||
} else if (OB_FAIL(from_tables.add_members2(rel_ids))) {
|
||||
LOG_WARN("failed to add members", K(ret));
|
||||
} else if (OB_FAIL(child_stmt.get_column_exprs(columns))) {
|
||||
LOG_WARN("failed to get column exprs", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_table_exprs(child_stmt, columns, from_tables, column_exprs))) {
|
||||
|
@ -675,10 +675,10 @@ int ObWhereSubQueryPullup::check_correlated_where_expr_can_pullup(
|
||||
if (OB_FAIL(ObOptimizerUtil::get_groupby_win_func_common_exprs(subquery, common_part_exprs, is_valid))) {
|
||||
LOG_WARN("failed to get common exprs", K(ret));
|
||||
}
|
||||
ObIArray<ObRawExpr*>& where_exprs = subquery.get_condition_exprs();
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < where_exprs.count(); ++i) {
|
||||
ObSEArray<ObRawExpr*, 4> column_exprs;
|
||||
ObRawExpr* expr = where_exprs.at(i);
|
||||
ObIArray<ObRawExpr*> &where_exprs = subquery.get_condition_exprs();
|
||||
for (int64_t i = 0; OB_SUCC(ret) && can_pullup && i < where_exprs.count(); ++i) {
|
||||
ObSEArray<ObRawExpr *, 4> column_exprs;
|
||||
ObRawExpr *expr = where_exprs.at(i);
|
||||
bool is_correlated = false;
|
||||
if (OB_FAIL(ObTransformUtils::is_correlated_expr(expr, subquery.get_current_level() - 1, is_correlated))) {
|
||||
LOG_WARN("failed to check is correlated expr", K(ret));
|
||||
@ -1075,8 +1075,9 @@ int ObWhereSubQueryPullup::pullup_correlated_subquery_as_view(
|
||||
ObSEArray<ObRawExpr*, 4> right_hand_exprs;
|
||||
ObSEArray<ObRawExpr*, 4> new_conditions;
|
||||
ObSEArray<ObRawExpr*, 4> correlated_conds;
|
||||
SemiInfo* info = NULL;
|
||||
if (OB_ISNULL(stmt) || OB_ISNULL(subquery) || OB_ISNULL(expr) || OB_ISNULL(ctx_) || OB_ISNULL(ctx_->allocator_)) {
|
||||
SemiInfo *info = NULL;
|
||||
if (OB_ISNULL(stmt) || OB_ISNULL(subquery) || OB_ISNULL(expr) || OB_ISNULL(ctx_)
|
||||
|| OB_ISNULL(ctx_->allocator_) || OB_ISNULL(ctx_->expr_factory_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret), K(stmt), K(subquery), K(expr));
|
||||
} else if (OB_FAIL(ObTransformUtils::add_new_table_item(ctx_, stmt, subquery, right_table))) {
|
||||
@ -1106,22 +1107,30 @@ int ObWhereSubQueryPullup::pullup_correlated_subquery_as_view(
|
||||
LOG_WARN("failed to append exprs", K(ret));
|
||||
} else {
|
||||
ObSqlBitSet<> table_set;
|
||||
ObSEArray<ObDMLStmt*, 4> ignore_stmts;
|
||||
ObSEArray<ObRawExpr*, 4> origin_correlated_conds;
|
||||
ObSEArray<ObDMLStmt *, 4> ignore_stmts;
|
||||
ObSEArray<ObRawExpr*, 4> column_exprs;
|
||||
ObSEArray<ObRawExpr*, 4> upper_column_exprs;
|
||||
if (OB_FAIL(ObTransformUtils::get_table_rel_ids(*subquery, subquery->get_table_items(), table_set))) {
|
||||
if (OB_FAIL(subquery->get_table_rel_ids(subquery->get_table_items(), table_set))) {
|
||||
LOG_WARN("failed to get rel ids", K(ret));
|
||||
} else if (OB_FAIL(get_correlated_conditions(*subquery, correlated_conds))) {
|
||||
} else if (OB_FAIL(get_correlated_conditions(*subquery, origin_correlated_conds))) {
|
||||
LOG_WARN("failed to get semi conditions", K(ret));
|
||||
} else if (OB_FAIL(ObOptimizerUtil::remove_item(subquery->get_condition_exprs(), correlated_conds))) {
|
||||
} else if (OB_FAIL(ObOptimizerUtil::remove_item(subquery->get_condition_exprs(),
|
||||
origin_correlated_conds))) {
|
||||
LOG_WARN("failed to remove condition expr", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::extract_column_exprs(
|
||||
correlated_conds, subquery->get_current_level(), table_set, ignore_stmts, column_exprs))) {
|
||||
} else if (OB_FAIL(ObRawExprUtils::copy_exprs(*ctx_->expr_factory_, origin_correlated_conds,
|
||||
correlated_conds, COPY_REF_DEFAULT))) {
|
||||
LOG_WARN("failed to copy exprs", K(ret));
|
||||
} else if(OB_FAIL(ObTransformUtils::extract_column_exprs(correlated_conds,
|
||||
subquery->get_current_level(),
|
||||
table_set, ignore_stmts,
|
||||
column_exprs))) {
|
||||
LOG_WARN("extract column exprs failed", K(ret));
|
||||
} else if (column_exprs.empty()) {
|
||||
/* do nothing */
|
||||
} else if (OB_FALSE_IT(subquery->get_select_items().reset())) {
|
||||
} else if (OB_FAIL(ObTransformUtils::create_select_item(*ctx_->allocator_, column_exprs, subquery))) {
|
||||
} else if (column_exprs.empty()) {
|
||||
ret = ObTransformUtils::create_dummy_select_item(*subquery, ctx_);
|
||||
} else if (OB_FAIL(ObTransformUtils::create_select_item(*ctx_->allocator_, column_exprs,
|
||||
subquery))) {
|
||||
LOG_WARN("failed to create select item", K(ret));
|
||||
} else if (OB_FAIL(ObTransformUtils::create_columns_for_view(ctx_, *right_table, stmt, upper_column_exprs))) {
|
||||
LOG_WARN("failed to create columns for view", K(ret));
|
||||
@ -1246,7 +1255,7 @@ int ObWhereSubQueryPullup::fill_semi_left_table_ids(ObDMLStmt* stmt, SemiInfo* i
|
||||
} else if (OB_FAIL(left_rel_ids.del_member(right_idx))) {
|
||||
LOG_WARN("failed to delete members", K(ret));
|
||||
} else if (!left_rel_ids.is_empty()) {
|
||||
ret = ObTransformUtils::relids_to_table_ids(stmt, left_rel_ids, info->left_table_ids_);
|
||||
ret = stmt->relids_to_table_ids(left_rel_ids, info->left_table_ids_);
|
||||
} else if (OB_UNLIKELY(0 == stmt->get_from_item_size()) ||
|
||||
OB_ISNULL(table = stmt->get_table_item(stmt->get_from_item(0)))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
|
@ -409,9 +409,14 @@ int ObTransformWinMagic::transform_child_stmt(ObDMLStmt& stmt, ObSelectStmt& sub
|
||||
int ret = OB_SUCCESS;
|
||||
ObSEArray<ObRawExpr*, 4> new_condition_list;
|
||||
ObSEArray<FromItem, 4> new_from_list;
|
||||
if (OB_UNLIKELY(map_info.cond_map_.count() != subquery.get_condition_size()) ||
|
||||
OB_UNLIKELY(map_info.from_map_.count() != subquery.get_from_item_size()) ||
|
||||
OB_UNLIKELY(map_info.table_map_.count() != subquery.get_table_size())) {
|
||||
ObRawExprFactory *expr_factory = NULL;
|
||||
ObRawExpr *expr = NULL;
|
||||
if (OB_ISNULL(ctx_) || OB_ISNULL(expr_factory = ctx_->expr_factory_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret), K(ctx_), K(expr_factory));
|
||||
} else if (OB_UNLIKELY(map_info.cond_map_.count() != subquery.get_condition_size()) ||
|
||||
OB_UNLIKELY(map_info.from_map_.count() != subquery.get_from_item_size()) ||
|
||||
OB_UNLIKELY(map_info.table_map_.count() != subquery.get_table_size())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid map size",
|
||||
K(ret),
|
||||
@ -441,7 +446,14 @@ int ObTransformWinMagic::transform_child_stmt(ObDMLStmt& stmt, ObSelectStmt& sub
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < stmt.get_condition_size(); ++i) {
|
||||
if (!push_down_filter_ids.has_member(i)) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(new_condition_list.push_back(stmt.get_condition_expr(i)))) {
|
||||
} else if (OB_FAIL(ObRawExprUtils::copy_expr(*expr_factory, stmt.get_condition_expr(i),
|
||||
expr, COPY_REF_DEFAULT))) {
|
||||
// condition expr may be shared in stmt, copy it here.
|
||||
LOG_WARN("failed to copy expr", K(ret), K(expr));
|
||||
} else if (OB_ISNULL(expr)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected null", K(ret), K(expr));
|
||||
} else if (OB_FAIL(new_condition_list.push_back(expr))) {
|
||||
LOG_WARN("failed to push back new condition", K(ret));
|
||||
}
|
||||
}
|
||||
|
@ -11623,9 +11623,12 @@ int ObMigrateFinishTask::create_pg_partition_if_need()
|
||||
} else if (ctx_->is_copy_index()) {
|
||||
// no need to replace store map, just skip it.
|
||||
LOG_INFO("replica op tyoe is no need batch replace sstable, skip it");
|
||||
} else {
|
||||
const ObSavedStorageInfoV2& saved_storage_info = ctx_->pg_meta_.storage_info_;
|
||||
if (OB_FAIL(pg->get_pg_storage().batch_replace_store_map(ctx_->part_ctx_array_,
|
||||
} else if (!ctx_->is_copy_index()) {
|
||||
const ObSavedStorageInfoV2 &saved_storage_info = ctx_->pg_meta_.storage_info_;
|
||||
if (ctx_->replica_op_arg_.is_FtoL()) {
|
||||
// no need to replace store map, just skip.
|
||||
} else if (OB_FAIL(pg->get_pg_storage().batch_replace_store_map(
|
||||
ctx_->part_ctx_array_,
|
||||
saved_storage_info.get_data_info().get_schema_version(),
|
||||
ctx_->is_restore_,
|
||||
ctx_->old_trans_table_seq_))) {
|
||||
|
@ -11917,6 +11917,13 @@ bool ObReplicaOpArg::is_physical_restore_follower() const
|
||||
return RESTORE_FOLLOWER_REPLICA_OP == type_ && RESTORE_VERSION_1 == restore_version_;
|
||||
}
|
||||
|
||||
bool ObReplicaOpArg::is_FtoL() const
|
||||
{
|
||||
return CHANGE_REPLICA_OP == type_
|
||||
&& ObReplicaType::REPLICA_TYPE_FULL == src_.get_replica_type()
|
||||
&& ObReplicaType::REPLICA_TYPE_LOGONLY == dst_.get_replica_type();
|
||||
}
|
||||
|
||||
bool ObReplicaOpArg::is_standby_restore() const
|
||||
{
|
||||
return RESTORE_STANDBY_OP == type_;
|
||||
|
@ -233,6 +233,7 @@ struct ObReplicaOpArg {
|
||||
bool is_physical_restore() const;
|
||||
bool is_physical_restore_leader() const;
|
||||
bool is_physical_restore_follower() const;
|
||||
bool is_FtoL() const;
|
||||
bool is_standby_restore() const;
|
||||
const char* get_replica_op_type_str() const;
|
||||
TO_STRING_KV(K_(key), K_(dst), K_(src), K_(data_src), K_(quorum), "type", get_replica_op_type_str(), K_(base_version),
|
||||
|
@ -27107,7 +27107,7 @@ Outputs & filters:
|
||||
access([t3.c1], [t3.c3]), partitions(p[0-1]),
|
||||
is_index_back=false,
|
||||
range_key([t3.c1]), range(MIN ; MAX)always true
|
||||
15 - output([t2.c1], [t2.c2], [t2.c3], [t1.c1 + ?]), filter(nil),
|
||||
15 - output([t1.c1], [t2.c1], [t2.c2], [t2.c3], [t1.c1 + ?]), filter(nil),
|
||||
conds([lnnvl(t1.c1 + ? = t2.c2)]), nl_params_(nil), batch_join=false
|
||||
16 - output([t2.c1], [t2.c2], [t2.c3]), filter(nil)
|
||||
17 - output([t2.c1], [t2.c2], [t2.c3]), filter(nil), dop=1
|
||||
|
@ -3,14 +3,15 @@ SQL: select * from t1, t2 where t1.c1 > 10 and t1.c1 in (select c2 from t2);
|
||||
====================================================
|
||||
|ID|OPERATOR |NAME |EST. ROWS|COST|
|
||||
----------------------------------------------------
|
||||
|0 |NESTED-LOOP JOIN CARTESIAN| |5100 |4078|
|
||||
|0 |NESTED-LOOP JOIN CARTESIAN| |5100 |4152|
|
||||
|1 | TABLE SCAN |t2 |100 |92 |
|
||||
|2 | MATERIAL | |51 |324 |
|
||||
|3 | MERGE SEMI JOIN | |51 |306 |
|
||||
|2 | MATERIAL | |51 |345 |
|
||||
|3 | MERGE JOIN | |51 |317 |
|
||||
|4 | TABLE SCAN |t1 |100 |90 |
|
||||
|5 | SORT | |51 |165 |
|
||||
|6 | SUBPLAN SCAN |VIEW1|51 |114 |
|
||||
|7 | TABLE SCAN |t2 |51 |107 |
|
||||
|5 | SUBPLAN SCAN |VIEW2|51 |176 |
|
||||
|6 | MERGE DISTINCT | |51 |169 |
|
||||
|7 | SORT | |51 |158 |
|
||||
|8 | TABLE SCAN |t2 |51 |107 |
|
||||
====================================================
|
||||
|
||||
Outputs & filters:
|
||||
@ -21,26 +22,28 @@ Outputs & filters:
|
||||
access([t2.c1], [t2.c2], [t2.c3]), partitions(p0)
|
||||
2 - output([t1.c1], [t1.c2]), filter(nil)
|
||||
3 - output([t1.c1], [t1.c2]), filter(nil),
|
||||
equal_conds([t1.c1 = VIEW1.c2]), other_conds(nil)
|
||||
equal_conds([t1.c1 = VIEW2.VIEW1.c2]), other_conds(nil)
|
||||
4 - output([t1.c1], [t1.c2]), filter(nil),
|
||||
access([t1.c1], [t1.c2]), partitions(p0)
|
||||
5 - output([VIEW1.c2]), filter(nil), sort_keys([VIEW1.c2, ASC])
|
||||
6 - output([VIEW1.c2]), filter(nil),
|
||||
access([VIEW1.c2])
|
||||
7 - output([t2.c2]), filter([t2.c2 > ?]),
|
||||
5 - output([VIEW2.VIEW1.c2]), filter(nil),
|
||||
access([VIEW2.VIEW1.c2])
|
||||
6 - output([t2.c2]), filter(nil),
|
||||
distinct([t2.c2])
|
||||
7 - output([t2.c2]), filter(nil), sort_keys([t2.c2, ASC])
|
||||
8 - output([t2.c2]), filter([t2.c2 > ?]),
|
||||
access([t2.c2]), partitions(p0)
|
||||
|
||||
Outline Data:
|
||||
-------------------------------------
|
||||
/*+
|
||||
BEGIN_OUTLINE_DATA
|
||||
LEADING(@"SEL$1" ("opt.t2"@"SEL$1" ("opt.t1"@"SEL$1" "VIEW1"@"SEL$1" )))
|
||||
USE_NL(@"SEL$1" ("opt.t1"@"SEL$1" "VIEW1"@"SEL$1" ))
|
||||
USE_NL_MATERIALIZATION(@"SEL$1" ("opt.t1"@"SEL$1" "VIEW1"@"SEL$1" ))
|
||||
FULL(@"SEL$1" "opt.t2"@"SEL$1")
|
||||
USE_MERGE(@"SEL$1" ("VIEW1"@"SEL$1" ))
|
||||
FULL(@"SEL$1" "opt.t1"@"SEL$1")
|
||||
FULL(@"SEL$2" "opt.t2"@"SEL$2")
|
||||
LEADING(@"SEL$4" ("opt.t2"@"SEL$4" ("opt.t1"@"SEL$4" "VIEW2"@"SEL$4" )))
|
||||
USE_NL(@"SEL$4" ("opt.t1"@"SEL$4" "VIEW2"@"SEL$4" ))
|
||||
USE_NL_MATERIALIZATION(@"SEL$4" ("opt.t1"@"SEL$4" "VIEW2"@"SEL$4" ))
|
||||
FULL(@"SEL$4" "opt.t2"@"SEL$4")
|
||||
USE_MERGE(@"SEL$4" ("VIEW2"@"SEL$4" ))
|
||||
FULL(@"SEL$4" "opt.t1"@"SEL$4")
|
||||
FULL(@"SEL$3" "opt.t2"@"SEL$3")
|
||||
END_OUTLINE_DATA
|
||||
*/
|
||||
|
||||
|
@ -32866,7 +32866,7 @@ SQL: select SQL_CALC_FOUND_ROWS c1 from t1 union all select c1 from t2 union all
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -177059,7 +177059,7 @@ SQL: select t3.c2, v2.c3 from t3, (select t2.c2, v.c3 from t2, (select c3 from t
|
||||
"rel_id": [
|
||||
],
|
||||
"value": {
|
||||
"UNKNOWN":3
|
||||
"UNKNOWN":4
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -177171,7 +177171,7 @@ SQL: select t3.c2, v2.c3 from t3, (select t2.c2, v.c3 from t2, (select c3 from t
|
||||
"rel_id": [
|
||||
],
|
||||
"value": {
|
||||
"UNKNOWN":4
|
||||
"UNKNOWN":3
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -185390,7 +185390,7 @@ SQL: select t4.c2, v2.c3 from (select t2.c2, v.c3 from t2, (select c2, c3 from t
|
||||
"rel_id": [
|
||||
],
|
||||
"value": {
|
||||
"UNKNOWN":3
|
||||
"UNKNOWN":4
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -185502,7 +185502,7 @@ SQL: select t4.c2, v2.c3 from (select t2.c2, v.c3 from t2, (select c2, c3 from t
|
||||
"rel_id": [
|
||||
],
|
||||
"value": {
|
||||
"UNKNOWN":4
|
||||
"UNKNOWN":3
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -9972,7 +9972,7 @@ SQL: select * from v limit 10 union select * from v limit 10 union select * from
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -10577,7 +10577,7 @@ SQL: select * from v limit 10 union select * from v limit 10 union select * from
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -11182,7 +11182,7 @@ SQL: select * from v limit 10 union select * from v limit 10 union select * from
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -11803,7 +11803,7 @@ SQL: select * from v limit 10 union select * from v limit 10 union select * from
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -11870,7 +11870,7 @@ SQL: select * from v limit 10 union select * from v limit 10 union select * from
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -13766,7 +13766,7 @@ SQL: select * from v order by c1 union select * from v order by c1 union select
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -13833,7 +13833,7 @@ SQL: select * from v order by c1 union select * from v order by c1 union select
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -14454,7 +14454,7 @@ SQL: select * from v order by c1 union select * from v order by c1 union select
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -14521,7 +14521,7 @@ SQL: select * from v order by c1 union select * from v order by c1 union select
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -15142,7 +15142,7 @@ SQL: select * from v order by c1 union select * from v order by c1 union select
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -15209,7 +15209,7 @@ SQL: select * from v order by c1 union select * from v order by c1 union select
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -15830,7 +15830,7 @@ SQL: select * from v order by c1 union select * from v order by c1 union select
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -15897,7 +15897,7 @@ SQL: select * from v order by c1 union select * from v order by c1 union select
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -17793,7 +17793,7 @@ SQL: select * from v order by c1 union all select * from v order by c1 union all
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -17860,7 +17860,7 @@ SQL: select * from v order by c1 union all select * from v order by c1 union all
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -18481,7 +18481,7 @@ SQL: select * from v order by c1 union all select * from v order by c1 union all
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -18548,7 +18548,7 @@ SQL: select * from v order by c1 union all select * from v order by c1 union all
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -19169,7 +19169,7 @@ SQL: select * from v order by c1 union all select * from v order by c1 union all
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -19236,7 +19236,7 @@ SQL: select * from v order by c1 union all select * from v order by c1 union all
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -19857,7 +19857,7 @@ SQL: select * from v order by c1 union all select * from v order by c1 union all
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
@ -19924,7 +19924,7 @@ SQL: select * from v order by c1 union all select * from v order by c1 union all
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"flag":16386,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
|
@ -33,9 +33,9 @@ SQL: select * from t1, t2 where t1.c1 > 10 and t1.c1 in (select c2 from t2);
|
||||
"view_base_item":-1
|
||||
},
|
||||
{
|
||||
"table_id":-3,
|
||||
"table_name":"VIEW1",
|
||||
"alias_name":"VIEW1",
|
||||
"table_id":-5,
|
||||
"table_name":"VIEW2",
|
||||
"alias_name":"VIEW2",
|
||||
"synonym_name":"",
|
||||
"synonym_db_name":"",
|
||||
"table_type":2,
|
||||
@ -50,140 +50,6 @@ SQL: select * from t1, t2 where t1.c1 > 10 and t1.c1 in (select c2 from t2);
|
||||
"joined_table": [
|
||||
],
|
||||
"semi_info": [
|
||||
{
|
||||
"join_type":5,
|
||||
"semi_id":-4,
|
||||
"left_table_ids": [
|
||||
1099511677779
|
||||
],
|
||||
"right_table_id":-3,
|
||||
"semi_conditions": [
|
||||
{
|
||||
"item_type":"T_OP_EQ",
|
||||
"result_type": {
|
||||
"meta": {
|
||||
"type":"INT",
|
||||
"collation":"binary",
|
||||
"coercibility":"NUMERIC"
|
||||
},
|
||||
"accuracy": {
|
||||
"length":-1,
|
||||
"precision":1,
|
||||
"scale":0
|
||||
},
|
||||
"flag":0,
|
||||
"calc_type": {
|
||||
"type":"INT",
|
||||
"collation":"binary",
|
||||
"coercibility":"NUMERIC"
|
||||
}
|
||||
},
|
||||
"expr_info": [
|
||||
"CNT_COLUMN",
|
||||
"IS_JOIN_COND"
|
||||
],
|
||||
"rel_id": [
|
||||
1,
|
||||
3
|
||||
],
|
||||
"expr_levels": [
|
||||
0
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"item_type":"T_REF_COLUMN",
|
||||
"result_type": {
|
||||
"meta": {
|
||||
"type":"INT",
|
||||
"collation":"binary",
|
||||
"coercibility":"NUMERIC"
|
||||
},
|
||||
"accuracy": {
|
||||
"length":-1,
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
"coercibility":"INVALID"
|
||||
}
|
||||
},
|
||||
"expr_info": [
|
||||
"IS_COLUMN",
|
||||
"CNT_COLUMN"
|
||||
],
|
||||
"rel_id": [
|
||||
1
|
||||
],
|
||||
"table_id":1099511677779,
|
||||
"column_id":16,
|
||||
"database_name":"opt",
|
||||
"table_name":"t1",
|
||||
"synonym_name":"",
|
||||
"synonym_db_name":"",
|
||||
"column_name":"c1",
|
||||
"expr_level":0,
|
||||
"expr_levels": [
|
||||
0
|
||||
],
|
||||
"column_flags":0,
|
||||
"enum_set_values": [
|
||||
],
|
||||
"is_lob_column":false,
|
||||
"is_unpivot_mocked_column":false,
|
||||
"is_hidden":false
|
||||
},
|
||||
{
|
||||
"item_type":"T_REF_COLUMN",
|
||||
"result_type": {
|
||||
"meta": {
|
||||
"type":"INT",
|
||||
"collation":"binary",
|
||||
"coercibility":"NUMERIC"
|
||||
},
|
||||
"accuracy": {
|
||||
"length":-1,
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":0,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
"coercibility":"INVALID"
|
||||
}
|
||||
},
|
||||
"expr_info": [
|
||||
"IS_COLUMN",
|
||||
"CNT_COLUMN"
|
||||
],
|
||||
"rel_id": [
|
||||
3
|
||||
],
|
||||
"table_id":-3,
|
||||
"column_id":16,
|
||||
"database_name":"",
|
||||
"table_name":"VIEW1",
|
||||
"synonym_name":"",
|
||||
"synonym_db_name":"",
|
||||
"column_name":"c2",
|
||||
"expr_level":0,
|
||||
"expr_levels": [
|
||||
0
|
||||
],
|
||||
"column_flags":0,
|
||||
"enum_set_values": [
|
||||
],
|
||||
"is_lob_column":false,
|
||||
"is_unpivot_mocked_column":false,
|
||||
"is_hidden":false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"partition_express": [
|
||||
],
|
||||
@ -470,8 +336,8 @@ SQL: select * from t1, t2 where t1.c1 > 10 and t1.c1 in (select c2 from t2);
|
||||
},
|
||||
{
|
||||
"column_id":16,
|
||||
"table_id":-3,
|
||||
"column":"c2",
|
||||
"table_id":-5,
|
||||
"column":"VIEW1.c2",
|
||||
"auto_filled_timestamp":false,
|
||||
"default_value": {
|
||||
"NULL":"NULL"
|
||||
@ -505,13 +371,13 @@ SQL: select * from t1, t2 where t1.c1 > 10 and t1.c1 in (select c2 from t2);
|
||||
"rel_id": [
|
||||
3
|
||||
],
|
||||
"table_id":-3,
|
||||
"table_id":-5,
|
||||
"column_id":16,
|
||||
"database_name":"",
|
||||
"table_name":"VIEW1",
|
||||
"table_name":"VIEW2",
|
||||
"synonym_name":"",
|
||||
"synonym_db_name":"",
|
||||
"column_name":"c2",
|
||||
"column_name":"VIEW1.c2",
|
||||
"expr_level":0,
|
||||
"expr_levels": [
|
||||
0
|
||||
@ -853,6 +719,10 @@ SQL: select * from t1, t2 where t1.c1 > 10 and t1.c1 in (select c2 from t2);
|
||||
{
|
||||
"table_id":1099511677780,
|
||||
"is_join":false
|
||||
},
|
||||
{
|
||||
"table_id":-5,
|
||||
"is_join":false
|
||||
}
|
||||
],
|
||||
"start_with": [
|
||||
@ -971,6 +841,130 @@ SQL: select * from t1, t2 where t1.c1 > 10 and t1.c1 in (select c2 from t2);
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"item_type":"T_OP_EQ",
|
||||
"result_type": {
|
||||
"meta": {
|
||||
"type":"INT",
|
||||
"collation":"binary",
|
||||
"coercibility":"NUMERIC"
|
||||
},
|
||||
"accuracy": {
|
||||
"length":-1,
|
||||
"precision":1,
|
||||
"scale":0
|
||||
},
|
||||
"flag":0,
|
||||
"calc_type": {
|
||||
"type":"INT",
|
||||
"collation":"binary",
|
||||
"coercibility":"NUMERIC"
|
||||
}
|
||||
},
|
||||
"expr_info": [
|
||||
"CNT_COLUMN",
|
||||
"IS_JOIN_COND"
|
||||
],
|
||||
"rel_id": [
|
||||
1,
|
||||
3
|
||||
],
|
||||
"expr_levels": [
|
||||
0
|
||||
],
|
||||
"children": [
|
||||
{
|
||||
"item_type":"T_REF_COLUMN",
|
||||
"result_type": {
|
||||
"meta": {
|
||||
"type":"INT",
|
||||
"collation":"binary",
|
||||
"coercibility":"NUMERIC"
|
||||
},
|
||||
"accuracy": {
|
||||
"length":-1,
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":16387,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
"coercibility":"INVALID"
|
||||
}
|
||||
},
|
||||
"expr_info": [
|
||||
"IS_COLUMN",
|
||||
"CNT_COLUMN"
|
||||
],
|
||||
"rel_id": [
|
||||
1
|
||||
],
|
||||
"table_id":1099511677779,
|
||||
"column_id":16,
|
||||
"database_name":"opt",
|
||||
"table_name":"t1",
|
||||
"synonym_name":"",
|
||||
"synonym_db_name":"",
|
||||
"column_name":"c1",
|
||||
"expr_level":0,
|
||||
"expr_levels": [
|
||||
0
|
||||
],
|
||||
"column_flags":0,
|
||||
"enum_set_values": [
|
||||
],
|
||||
"is_lob_column":false,
|
||||
"is_unpivot_mocked_column":false,
|
||||
"is_hidden":false
|
||||
},
|
||||
{
|
||||
"item_type":"T_REF_COLUMN",
|
||||
"result_type": {
|
||||
"meta": {
|
||||
"type":"INT",
|
||||
"collation":"binary",
|
||||
"coercibility":"NUMERIC"
|
||||
},
|
||||
"accuracy": {
|
||||
"length":-1,
|
||||
"precision":11,
|
||||
"scale":0
|
||||
},
|
||||
"flag":0,
|
||||
"calc_type": {
|
||||
"type":"NULL",
|
||||
"collation":"invalid_type",
|
||||
"coercibility":"INVALID"
|
||||
}
|
||||
},
|
||||
"expr_info": [
|
||||
"IS_COLUMN",
|
||||
"CNT_COLUMN"
|
||||
],
|
||||
"rel_id": [
|
||||
3
|
||||
],
|
||||
"table_id":-5,
|
||||
"column_id":16,
|
||||
"database_name":"",
|
||||
"table_name":"VIEW2",
|
||||
"synonym_name":"",
|
||||
"synonym_db_name":"",
|
||||
"column_name":"VIEW1.c2",
|
||||
"expr_level":0,
|
||||
"expr_levels": [
|
||||
0
|
||||
],
|
||||
"column_flags":0,
|
||||
"enum_set_values": [
|
||||
],
|
||||
"is_lob_column":false,
|
||||
"is_unpivot_mocked_column":false,
|
||||
"is_hidden":false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"group_by": [
|
||||
@ -1182,8 +1176,8 @@ SQL: select * from t1, t2 where t1.c1 > 10 and t1.c1 in (select c2 from t2);
|
||||
"is_hidden":false
|
||||
},
|
||||
"is_alias":false,
|
||||
"alias_name":"c2",
|
||||
"expr_name":"c2",
|
||||
"alias_name":"VIEW1.c2",
|
||||
"expr_name":"",
|
||||
"default": {
|
||||
"NULL":"NULL"
|
||||
},
|
||||
@ -1199,7 +1193,7 @@ SQL: select * from t1, t2 where t1.c1 > 10 and t1.c1 in (select c2 from t2);
|
||||
"is_hidden_rowid":false
|
||||
}
|
||||
],
|
||||
"distinct":false,
|
||||
"distinct":true,
|
||||
"rollup":false,
|
||||
"nocycle":false,
|
||||
"from": [
|
||||
|
Loading…
x
Reference in New Issue
Block a user