=== Applying patches on top of PostgreSQL commit ID 9e7d152488f197e96f171f0714459c227c3f7693 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Sun Oct 11 12:18:26 UTC 2026 On branch cf/5129 nothing to commit, working tree clean === using 'git am' to apply patch ./v22-0001-mark_async_capable-subpath-should-match-subplan.patch === Applying: mark_async_capable(): subpath should match subplan === using 'git am' to apply patch ./v22-0002-Introduce-AppendBase-AppendBaseState-base-types-.patch === Applying: Introduce AppendBase/AppendBaseState base types for Append/MergeAppend Using index info to reconstruct a base tree... M contrib/pg_overexplain/pg_overexplain.c M contrib/pg_plan_advice/pgpa_scan.c M contrib/postgres_fdw/postgres_fdw.c M src/backend/nodes/nodeFuncs.c M src/backend/optimizer/plan/setrefs.c M src/backend/optimizer/plan/subselect.c M src/include/nodes/execnodes.h M src/include/nodes/plannodes.h M src/tools/pgindent/typedefs.list Falling back to patching base and 3-way merge... Auto-merging src/tools/pgindent/typedefs.list Auto-merging src/include/nodes/plannodes.h Auto-merging src/include/nodes/execnodes.h Auto-merging src/backend/optimizer/plan/subselect.c Auto-merging src/backend/optimizer/plan/setrefs.c CONFLICT (content): Merge conflict in src/backend/optimizer/plan/setrefs.c Auto-merging src/backend/nodes/nodeFuncs.c Auto-merging contrib/postgres_fdw/postgres_fdw.c Auto-merging contrib/pg_plan_advice/pgpa_scan.c Auto-merging contrib/pg_overexplain/pg_overexplain.c error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Introduce AppendBase/AppendBaseState base types for Append/MergeAppend When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". === using patch(1) to apply patch ./v22-0002-Introduce-AppendBase-AppendBaseState-base-types-.patch === patching file contrib/pg_overexplain/pg_overexplain.c patching file contrib/pg_plan_advice/pgpa_scan.c Hunk #1 succeeded at 167 (offset 3 lines). Hunk #2 succeeded at 179 (offset 3 lines). patching file contrib/pg_plan_advice/pgpa_walker.c patching file contrib/postgres_fdw/postgres_fdw.c patching file src/backend/commands/explain.c patching file src/backend/executor/execAmi.c patching file src/backend/executor/execCurrent.c patching file src/backend/executor/execProcnode.c patching file src/backend/executor/nodeAppend.c patching file src/backend/executor/nodeMergeAppend.c patching file src/backend/nodes/nodeFuncs.c Hunk #1 succeeded at 4775 (offset 10 lines). patching file src/backend/optimizer/plan/createplan.c patching file src/backend/optimizer/plan/setrefs.c Hunk #1 succeeded at 147 with fuzz 1. Hunk #2 succeeded at 1300 (offset 7 lines). Hunk #3 succeeded at 1782 (offset 8 lines). Hunk #4 FAILED at 1841. 1 out of 4 hunks FAILED -- saving rejects to file src/backend/optimizer/plan/setrefs.c.rej patching file src/backend/optimizer/plan/subselect.c Hunk #1 succeeded at 2924 (offset 12 lines). Hunk #2 succeeded at 2939 (offset 12 lines). patching file src/backend/utils/adt/ruleutils.c patching file src/include/nodes/execnodes.h patching file src/include/nodes/plannodes.h patching file src/tools/pgindent/typedefs.list Hunk #1 succeeded at 124 (offset -2 lines). Unstaged changes after reset: M contrib/pg_overexplain/pg_overexplain.c M contrib/pg_plan_advice/pgpa_scan.c M contrib/pg_plan_advice/pgpa_walker.c M contrib/postgres_fdw/postgres_fdw.c M src/backend/commands/explain.c M src/backend/executor/execAmi.c M src/backend/executor/execCurrent.c M src/backend/executor/execProcnode.c M src/backend/executor/nodeAppend.c M src/backend/executor/nodeMergeAppend.c M src/backend/nodes/nodeFuncs.c M src/backend/optimizer/plan/createplan.c M src/backend/optimizer/plan/setrefs.c M src/backend/optimizer/plan/subselect.c M src/backend/utils/adt/ruleutils.c M src/include/nodes/execnodes.h M src/include/nodes/plannodes.h M src/tools/pgindent/typedefs.list Removing src/backend/optimizer/plan/setrefs.c.rej === using 'git apply' to apply patch ./v22-0002-Introduce-AppendBase-AppendBaseState-base-types-.patch === Applied patch to 'contrib/pg_overexplain/pg_overexplain.c' cleanly. Applied patch to 'contrib/pg_plan_advice/pgpa_scan.c' cleanly. Applied patch to 'contrib/pg_plan_advice/pgpa_walker.c' cleanly. Applied patch to 'contrib/postgres_fdw/postgres_fdw.c' cleanly. Applied patch to 'src/backend/commands/explain.c' cleanly. Applied patch to 'src/backend/executor/execAmi.c' cleanly. Applied patch to 'src/backend/executor/execCurrent.c' cleanly. Applied patch to 'src/backend/executor/execProcnode.c' cleanly. Applied patch to 'src/backend/executor/nodeAppend.c' cleanly. Applied patch to 'src/backend/executor/nodeMergeAppend.c' cleanly. Applied patch to 'src/backend/nodes/nodeFuncs.c' cleanly. Applied patch to 'src/backend/optimizer/plan/createplan.c' cleanly. Applied patch to 'src/backend/optimizer/plan/setrefs.c' with conflicts. Applied patch to 'src/backend/optimizer/plan/subselect.c' cleanly. Applied patch to 'src/backend/utils/adt/ruleutils.c' cleanly. Applied patch to 'src/include/nodes/execnodes.h' cleanly. Applied patch to 'src/include/nodes/plannodes.h' cleanly. Applied patch to 'src/tools/pgindent/typedefs.list' cleanly. U src/backend/optimizer/plan/setrefs.c diff --cc src/backend/optimizer/plan/setrefs.c index af78892fafc,fba3db2da09..00000000000 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@@ -147,16 -147,11 +147,13 @@@ static void set_foreignscan_references( static void set_customscan_references(PlannerInfo *root, CustomScan *cscan, int rtoffset); - static Plan *set_append_references(PlannerInfo *root, - Append *aplan, - int rtoffset); - static Plan *set_mergeappend_references(PlannerInfo *root, - MergeAppend *mplan, - int rtoffset); + static Plan *set_appendbase_references(PlannerInfo *root, + AppendBase *plan, + int rtoffset); static void set_hash_references(PlannerInfo *root, Plan *plan, int rtoffset); static Relids offset_relid_set(Relids relids, int rtoffset); +static List *offset_relid_set_list(List *relid_sets, int rtoffset); +static Node *fix_dummy_setop_vars_mutator(Node *node, int *first_child_relid); static Node *fix_scan_expr(PlannerInfo *root, Node *node, int rtoffset, double num_exec); static Node *fix_scan_expr_mutator(Node *node, fix_scan_expr_context *context); @@@ -1898,13 -1887,11 +1895,19 @@@ set_appendbase_references(PlannerInfo * { Plan *result; - result = clean_up_removed_plan_level((Plan *) aplan, p); + result = clean_up_removed_plan_level((Plan *) plan, p); ++<<<<<<< ours + /* Remember that we removed an Append */ + record_elided_node(root->glob, p->plan_node_id, T_Append, + offset_relid_set(aplan->apprelids, rtoffset), + offset_relid_set_list(aplan->child_append_relid_sets, + rtoffset)); ++======= + /* Remember that we removed an Append/MergeAppend */ + record_elided_node(root->glob, p->plan_node_id, nodeTag(plan), + offset_relid_set(plan->apprelids, rtoffset)); ++>>>>>>> theirs return result; } @@@ -1915,93 -1902,9 +1918,99 @@@ * recursing to the children, because set_dummy_tlist_references doesn't * look at those. */ ++<<<<<<< ours + set_dummy_tlist_references((Plan *) aplan, rtoffset); + + aplan->apprelids = offset_relid_set(aplan->apprelids, rtoffset); + aplan->child_append_relid_sets = + offset_relid_set_list(aplan->child_append_relid_sets, rtoffset); + + /* + * Add PartitionPruneInfo, if any, to PlannerGlobal and update the index. + * Also update the RT indexes present in it to add the offset. + */ + if (aplan->part_prune_index >= 0) + aplan->part_prune_index = + register_partpruneinfo(root, aplan->part_prune_index, rtoffset); + + /* We don't need to recurse to lefttree or righttree ... */ + Assert(aplan->plan.lefttree == NULL); + Assert(aplan->plan.righttree == NULL); + + return (Plan *) aplan; +} + +/* + * set_mergeappend_references + * Do set_plan_references processing on a MergeAppend + * + * We try to strip out the MergeAppend entirely; if we can't, we have + * to do the normal processing on it. + */ +static Plan * +set_mergeappend_references(PlannerInfo *root, + MergeAppend *mplan, + int rtoffset) +{ + ListCell *l; + + /* + * MergeAppend, like Sort et al, doesn't actually evaluate its targetlist + * or check quals. If it's got exactly one child plan, then it's not + * doing anything useful at all, and we can strip it out. + */ + Assert(mplan->plan.qual == NIL); + + /* First, we gotta recurse on the children */ + foreach(l, mplan->mergeplans) + { + lfirst(l) = set_plan_refs(root, (Plan *) lfirst(l), rtoffset); + } + + /* + * See if it's safe to get rid of the MergeAppend entirely. For this to + * be safe, there must be only one child plan and that child plan's + * parallel awareness must match the MergeAppend's. The reason for the + * latter is that if the MergeAppend is parallel aware and the child is + * not, then the calling plan may execute the non-parallel aware child + * multiple times. (If you change these rules, update + * create_merge_append_path to match.) + */ + if (list_length(mplan->mergeplans) == 1) + { + Plan *p = (Plan *) linitial(mplan->mergeplans); + + if (p->parallel_aware == mplan->plan.parallel_aware) + { + Plan *result; + + result = clean_up_removed_plan_level((Plan *) mplan, p); + + /* Remember that we removed a MergeAppend */ + record_elided_node(root->glob, p->plan_node_id, T_MergeAppend, + offset_relid_set(mplan->apprelids, rtoffset), + offset_relid_set_list(mplan->child_append_relid_sets, + rtoffset)); + + return result; + } + } + + /* + * Otherwise, clean up the MergeAppend as needed. It's okay to do this + * after recursing to the children, because set_dummy_tlist_references + * doesn't look at those. + */ + set_dummy_tlist_references((Plan *) mplan, rtoffset); + + mplan->apprelids = offset_relid_set(mplan->apprelids, rtoffset); + mplan->child_append_relid_sets = + offset_relid_set_list(mplan->child_append_relid_sets, rtoffset); ++======= + set_dummy_tlist_references((Plan *) plan, rtoffset); + + plan->apprelids = offset_relid_set(plan->apprelids, rtoffset); ++>>>>>>> theirs /* * Add PartitionPruneInfo, if any, to PlannerGlobal and update the index.