On Thu, Dec 23, 2021 at 3:52 AM 曾文旌(义从) <wenjing....@alibaba-inc.com> wrote:
> > Fixed a bug found during testing. > > > Wenjing > > >>> Hi, + if (condition_is_safe_pushdown_to_sublink(rinfo, expr_info->outer)) + { + /* replace qual expr from outer var = const to var = const and push down to sublink query */ + sublink_query_push_qual(subquery, (Node *)copyObject(rinfo->clause), expr_info->outer, expr_info->inner); Since sublink_query_push_qual() is always guarded by condition_is_safe_pushdown_to_sublink(), it seems sublink_query_push_qual() can be folded into condition_is_safe_pushdown_to_sublink(). For generate_base_implied_equalities(): + if (ec->ec_processed) + { + ec_index++; + continue; + } + else if (list_length(ec->ec_members) > 1) Minor comment: the keyword `else` can be omitted (due to `continue` above). + * Since there may be an unexpanded sublink in the targetList, + * we'll skip it for now. Since there may be an -> If there is an + {"lazy_process_sublink", PGC_USERSET, QUERY_TUNING_METHOD, + gettext_noop("enable lazy process sublink."), Looking at existing examples from src/backend/utils/misc/guc.c, enable_lazy_sublink_processing seems to be consistent with existing guc variable naming. +lazy_process_sublinks(PlannerInfo *root, bool single_result_rte) lazy_process_sublinks -> lazily_process_sublinks + else + { /* There shouldn't be any OJ info to translate, as yet */ Assert(subroot->join_info_list == NIL); Indentation for the else block is off. + if (istop) + f->quals = preprocess_expression_ext(root, f->quals, EXPRKIND_QUAL, false); + else + f->quals = preprocess_expression_ext(root, f->quals, EXPRKIND_QUAL, true); The above can be written as: + f->quals = preprocess_expression_ext(root, f->quals, EXPRKIND_QUAL, !istop); For find_equal_conditions_contain_uplevelvar_in_sublink_query(): + context.has_unexpected_expr == false && `!context.has_unexpected_expr` should suffice equal_expr_safety_check -> is_equal_expr_safe Cheers