=== Applying patches on top of PostgreSQL commit ID 70c4a57b64d39c526eb4c44a925eb92a6e56f3c5 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Sat Nov 14 07:50:30 UTC 2026 On branch cf/5667 nothing to commit, working tree clean === using 'git am' to apply patch ./v9-0001-v9-enhance-index-support-for-virtual-generated-co.patch === Applying: v9 enhance-index-support-for-virtual-generated-columns .git/rebase-apply/patch:527: trailing whitespace. * Upon returning from this function, callers must apply .git/rebase-apply/patch:528: trailing whitespace. * ExpandVirtualGeneratedColumns() or RelationGetIndexExpressionsExpand warning: 2 lines add whitespace errors. Using index info to reconstruct a base tree... M src/backend/access/heap/heapam_handler.c M src/backend/bootstrap/bootstrap.c M src/backend/catalog/index.c M src/backend/catalog/toasting.c M src/backend/commands/analyze.c M src/backend/commands/indexcmds.c M src/backend/executor/execIndexing.c M src/backend/optimizer/path/costsize.c M src/backend/optimizer/plan/createplan.c M src/backend/optimizer/util/plancat.c M src/backend/utils/adt/selfuncs.c M src/backend/utils/cache/relcache.c M src/include/nodes/execnodes.h M src/include/nodes/pathnodes.h M src/include/utils/rel.h M src/include/utils/relcache.h M src/test/regress/expected/generated_virtual.out M src/test/regress/sql/generated_virtual.sql Falling back to patching base and 3-way merge... Auto-merging src/test/regress/sql/generated_virtual.sql Auto-merging src/test/regress/expected/generated_virtual.out Auto-merging src/include/utils/relcache.h Auto-merging src/include/utils/rel.h Auto-merging src/include/nodes/pathnodes.h Auto-merging src/include/nodes/execnodes.h Auto-merging src/backend/utils/cache/relcache.c Auto-merging src/backend/utils/adt/selfuncs.c Auto-merging src/backend/optimizer/util/plancat.c CONFLICT (content): Merge conflict in src/backend/optimizer/util/plancat.c Auto-merging src/backend/optimizer/plan/createplan.c Auto-merging src/backend/optimizer/path/costsize.c Auto-merging src/backend/executor/execIndexing.c Auto-merging src/backend/commands/indexcmds.c Auto-merging src/backend/commands/analyze.c Auto-merging src/backend/catalog/toasting.c Auto-merging src/backend/catalog/index.c Auto-merging src/backend/bootstrap/bootstrap.c Auto-merging src/backend/access/heap/heapam_handler.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 v9 enhance-index-support-for-virtual-generated-columns 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 ./v9-0001-v9-enhance-index-support-for-virtual-generated-co.patch === patching file src/backend/access/heap/heapam_handler.c Hunk #1 succeeded at 1146 (offset -7 lines). Hunk #2 succeeded at 1187 (offset -7 lines). Hunk #3 succeeded at 1594 (offset -7 lines). Hunk #4 succeeded at 1696 (offset -7 lines). Hunk #5 succeeded at 1715 (offset -7 lines). Hunk #6 succeeded at 1747 (offset -7 lines). Hunk #7 succeeded at 1884 (offset -7 lines). Hunk #8 succeeded at 1945 (offset -3 lines). patching file src/backend/bootstrap/bootstrap.c Hunk #1 succeeded at 1158 (offset 2 lines). patching file src/backend/catalog/index.c Hunk #1 succeeded at 1418 (offset 15 lines). Hunk #2 succeeded at 2490 (offset 15 lines). Hunk #3 succeeded at 2858 (offset 89 lines). Hunk #4 succeeded at 2867 (offset 89 lines). Hunk #5 succeeded at 2884 (offset 89 lines). Hunk #6 succeeded at 3360 (offset 90 lines). Hunk #7 succeeded at 3386 (offset 90 lines). Hunk #8 succeeded at 3406 (offset 90 lines). Hunk #9 succeeded at 3441 (offset 90 lines). patching file src/backend/catalog/indexing.c patching file src/backend/catalog/toasting.c Hunk #1 succeeded at 350 (offset 52 lines). patching file src/backend/commands/analyze.c Hunk #1 succeeded at 921 (offset 22 lines). Hunk #2 succeeded at 930 (offset 22 lines). Hunk #3 succeeded at 948 with fuzz 1 (offset 22 lines). Hunk #4 succeeded at 971 (offset 22 lines). patching file src/backend/commands/indexcmds.c Hunk #1 succeeded at 945 (offset 3 lines). Hunk #2 succeeded at 1140 (offset 19 lines). Hunk #3 succeeded at 1149 (offset 19 lines). Hunk #4 succeeded at 1169 (offset 19 lines). Hunk #5 succeeded at 2256 (offset 5 lines). patching file src/backend/executor/execIndexing.c Hunk #3 succeeded at 1136 (offset 26 lines). patching file src/backend/nodes/makefuncs.c patching file src/backend/optimizer/path/costsize.c patching file src/backend/optimizer/path/indxpath.c patching file src/backend/optimizer/plan/createplan.c Hunk #1 succeeded at 3376 (offset 30 lines). Hunk #2 succeeded at 5237 (offset 68 lines). Hunk #3 succeeded at 5262 (offset 68 lines). patching file src/backend/optimizer/util/plancat.c Hunk #1 succeeded at 432 (offset -1 lines). Hunk #2 FAILED at 955. Hunk #3 FAILED at 970. Hunk #4 FAILED at 1086. Hunk #5 succeeded at 1119 (offset 10 lines). Hunk #6 succeeded at 1141 (offset 10 lines). Hunk #7 FAILED at 1150. Hunk #8 FAILED at 1173. 5 out of 8 hunks FAILED -- saving rejects to file src/backend/optimizer/util/plancat.c.rej patching file src/backend/utils/adt/selfuncs.c Hunk #1 succeeded at 7480 (offset -51 lines). Hunk #2 succeeded at 7545 (offset -51 lines). Hunk #3 succeeded at 7700 (offset -51 lines). patching file src/backend/utils/cache/relcache.c Hunk #1 succeeded at 93 (offset 1 line). Hunk #2 succeeded at 1628 (offset 40 lines). Hunk #3 succeeded at 5230 (offset 70 lines). Hunk #4 succeeded at 5393 (offset 70 lines). Hunk #5 succeeded at 6668 (offset 78 lines). Hunk #6 succeeded at 7204 (offset 83 lines). patching file src/include/nodes/execnodes.h Hunk #1 succeeded at 189 (offset -1 lines). patching file src/include/nodes/pathnodes.h Hunk #1 succeeded at 1406 (offset 3 lines). patching file src/include/utils/rel.h patching file src/include/utils/relcache.h Hunk #1 succeeded at 58 with fuzz 2. patching file src/test/regress/expected/generated_virtual.out patching file src/test/regress/expected/indexing.out patching file src/test/regress/sql/generated_virtual.sql Hunk #1 succeeded at 431 (offset 4 lines). Hunk #2 succeeded at 507 (offset 4 lines). patching file src/test/regress/sql/indexing.sql Unstaged changes after reset: M src/backend/access/heap/heapam_handler.c M src/backend/bootstrap/bootstrap.c M src/backend/catalog/index.c M src/backend/catalog/indexing.c M src/backend/catalog/toasting.c M src/backend/commands/analyze.c M src/backend/commands/indexcmds.c M src/backend/executor/execIndexing.c M src/backend/nodes/makefuncs.c M src/backend/optimizer/path/costsize.c M src/backend/optimizer/path/indxpath.c M src/backend/optimizer/plan/createplan.c M src/backend/optimizer/util/plancat.c M src/backend/utils/adt/selfuncs.c M src/backend/utils/cache/relcache.c M src/include/nodes/execnodes.h M src/include/nodes/pathnodes.h M src/include/utils/rel.h M src/include/utils/relcache.h M src/test/regress/expected/generated_virtual.out M src/test/regress/expected/indexing.out M src/test/regress/sql/generated_virtual.sql M src/test/regress/sql/indexing.sql Removing src/backend/optimizer/util/plancat.c.rej === using 'git apply' to apply patch ./v9-0001-v9-enhance-index-support-for-virtual-generated-co.patch === /work/patches/./v9-0001-v9-enhance-index-support-for-virtual-generated-co.patch:532: trailing whitespace. * Upon returning from this function, callers must apply /work/patches/./v9-0001-v9-enhance-index-support-for-virtual-generated-co.patch:533: trailing whitespace. * ExpandVirtualGeneratedColumns() or RelationGetIndexExpressionsExpand Applied patch to 'src/backend/access/heap/heapam_handler.c' cleanly. Applied patch to 'src/backend/bootstrap/bootstrap.c' cleanly. Applied patch to 'src/backend/catalog/index.c' cleanly. Applied patch to 'src/backend/catalog/indexing.c' cleanly. Applied patch to 'src/backend/catalog/toasting.c' cleanly. Applied patch to 'src/backend/commands/analyze.c' cleanly. Applied patch to 'src/backend/commands/indexcmds.c' cleanly. Applied patch to 'src/backend/executor/execIndexing.c' cleanly. Applied patch to 'src/backend/nodes/makefuncs.c' cleanly. Applied patch to 'src/backend/optimizer/path/costsize.c' cleanly. Applied patch to 'src/backend/optimizer/path/indxpath.c' cleanly. Applied patch to 'src/backend/optimizer/plan/createplan.c' cleanly. Applied patch to 'src/backend/optimizer/util/plancat.c' with conflicts. Applied patch to 'src/backend/utils/adt/selfuncs.c' cleanly. Applied patch to 'src/backend/utils/cache/relcache.c' cleanly. Applied patch to 'src/include/nodes/execnodes.h' cleanly. Applied patch to 'src/include/nodes/pathnodes.h' cleanly. Applied patch to 'src/include/utils/rel.h' cleanly. Applied patch to 'src/include/utils/relcache.h' cleanly. Applied patch to 'src/test/regress/expected/generated_virtual.out' cleanly. Applied patch to 'src/test/regress/expected/indexing.out' cleanly. Applied patch to 'src/test/regress/sql/generated_virtual.sql' cleanly. Applied patch to 'src/test/regress/sql/indexing.sql' cleanly. U src/backend/optimizer/util/plancat.c warning: 2 lines add whitespace errors. diff --cc src/backend/optimizer/util/plancat.c index 22e0e8b11f8,07c7627e4e2..00000000000 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@@ -919,10 -932,31 +933,34 @@@ infer_arbiter_indexes(PlannerInfo *root */ foreach_ptr(RelationData, idxRel, indexRelList) { - Form_pg_index idxForm = idxRel->rd_index; - - if (indexOidFromConstraint == idxForm->indexrelid) + if (indexOidFromConstraint == RelationGetRelid(idxRel)) { ++<<<<<<< ours + Assert(idxRel->rd_index->indisready); + indexRelFromConstraint = idxRel; ++======= + /* Found it. */ + Assert(idxForm->indisready); + + /* + * Set up inferElems and inferIndexExprs to match the + * constraint index, so that we can match them in the loop + * below. + */ + for (int natt = 0; natt < idxForm->indnkeyatts; natt++) + { + int attno; + + attno = idxRel->rd_index->indkey.values[natt]; + if (attno != InvalidAttrNumber) + inferAttrs = + bms_add_member(inferAttrs, + attno - FirstLowInvalidHeapAttributeNumber); + } + + inferElems = RelationGetIndexExpressionsExpand(idxRel); + inferIndexExprs = RelationGetIndexPredicateExpand(idxRel); ++>>>>>>> theirs break; } } @@@ -939,10 -970,8 +977,15 @@@ { Form_pg_index idxForm; Bitmapset *indexedAttrs; ++<<<<<<< ours + List *idxExprs; + List *idxNonVarExprs; + ListCell *idxExprItem; + List *predExprs; ++======= + List *idxExpandExprs; + List *predExpandExprs; ++>>>>>>> theirs AttrNumber natt; bool match; @@@ -1046,14 -1070,29 +1089,35 @@@ if (idxForm->indisexclusion) continue; ++<<<<<<< ours + /* Simplify the index expressions the same way arbiterElems were */ + idxExprs = RelationGetIndexExpressions(idxRel); + if (idxExprs) ++======= + /* Build BMS representation of plain (non expression) index attrs */ + indexedAttrs = NULL; + for (natt = 0; natt < idxForm->indnkeyatts; natt++) + { + int attno = idxRel->rd_index->indkey.values[natt]; + + if (attno != 0) + indexedAttrs = bms_add_member(indexedAttrs, + attno - FirstLowInvalidHeapAttributeNumber); + } + + /* Non-expression attributes (if any) must match */ + if (!bms_equal(indexedAttrs, inferAttrs)) + continue; + + /* Expression attributes (if any) must match */ + idxExpandExprs = RelationGetIndexExpressionsExpand(idxRel); + if (idxExpandExprs) ++>>>>>>> theirs { if (varno != 1) - ChangeVarNodes((Node *) idxExprs, 1, varno, 0); + ChangeVarNodes((Node *) idxExpandExprs, 1, varno, 0); - idxExprs = (List *) eval_const_expressions(root, (Node *) idxExprs); + idxExpandExprs = (List *) eval_const_expressions(root, (Node *) idxExpandExprs); } /* @@@ -1142,29 -1146,41 +1206,46 @@@ * cataloged expressions. This does the right thing when unique * indexes redundantly repeat the same attribute, or if attributes * redundantly appear multiple times within an inference clause. - * - * In case a constraint was named, ensure the candidate has an equal - * set of expressions as the named constraint's index. */ ++<<<<<<< ours + if (list_difference(idxNonVarExprs, inferElems) != NIL) ++======= + if (list_difference(idxExpandExprs, inferElems) != NIL) ++>>>>>>> theirs continue; - predExprs = RelationGetIndexPredicate(idxRel); - if (predExprs) + predExpandExprs = RelationGetIndexPredicateExpand(idxRel); + if (predExpandExprs) { if (varno != 1) - ChangeVarNodes((Node *) predExprs, 1, varno, 0); + ChangeVarNodes((Node *) predExpandExprs, 1, varno, 0); - predExprs = (List *) + predExpandExprs = (List *) eval_const_expressions(root, - (Node *) make_ands_explicit(predExprs)); - predExprs = make_ands_implicit((Expr *) predExprs); + (Node *) make_ands_explicit(predExpandExprs)); + predExpandExprs = make_ands_implicit((Expr *) predExpandExprs); } /* - * Partial indexes affect each form of ON CONFLICT differently: if a - * constraint was named, then the predicates must be identical. In - * conventional inference, the index's predicate must be implied by - * the WHERE clause. + * If it's a partial index, its predicate must be implied by the ON + * CONFLICT's WHERE clause. */ ++<<<<<<< ours + if (!predicate_implied_by(predExprs, + (List *) onconflict->arbiterWhere, false)) + continue; ++======= + if (OidIsValid(indexOidFromConstraint)) + { + if (list_difference(predExpandExprs, inferIndexExprs) != NIL) + continue; + } + else + { + if (!predicate_implied_by(predExpandExprs, inferIndexExprs, false)) + continue; + } ++>>>>>>> theirs /* All good -- consider this index a match */ results = lappend_oid(results, idxForm->indexrelid);