=== Applying patches on top of PostgreSQL commit ID 3aad76a0a970faf22ea38dd61b5668d480b5a92f === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Fri Apr 18 12:42:20 UTC 2025 On branch cf/5685 nothing to commit, working tree clean === using 'git am' to apply patch ./v3-0001-Reduce-Var-IS-NOT-NULL-quals-during-constant-folding.patch === Applying: Reduce "Var IS [NOT] NULL" quals during constant folding Using index info to reconstruct a base tree... M src/backend/optimizer/plan/initsplan.c M src/backend/optimizer/plan/subselect.c M src/backend/optimizer/prep/prepjointree.c M src/backend/optimizer/util/clauses.c M src/backend/optimizer/util/plancat.c M src/include/nodes/parsenodes.h M src/include/nodes/pathnodes.h M src/include/optimizer/optimizer.h M src/test/regress/expected/generated_virtual.out M src/test/regress/expected/join.out Falling back to patching base and 3-way merge... Auto-merging src/test/regress/expected/join.out Auto-merging src/test/regress/expected/generated_virtual.out Auto-merging src/include/optimizer/optimizer.h Auto-merging src/include/nodes/pathnodes.h Auto-merging src/include/nodes/parsenodes.h Auto-merging src/backend/optimizer/util/plancat.c CONFLICT (content): Merge conflict in src/backend/optimizer/util/plancat.c Auto-merging src/backend/optimizer/util/clauses.c CONFLICT (content): Merge conflict in src/backend/optimizer/util/clauses.c Auto-merging src/backend/optimizer/prep/prepjointree.c Auto-merging src/backend/optimizer/plan/subselect.c Auto-merging src/backend/optimizer/plan/initsplan.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 Reduce "Var IS [NOT] NULL" quals during constant folding 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". Unstaged changes after reset: M contrib/postgres_fdw/expected/postgres_fdw.out M contrib/postgres_fdw/sql/postgres_fdw.sql M src/backend/optimizer/plan/initsplan.c M src/backend/optimizer/plan/planner.c M src/backend/optimizer/plan/subselect.c M src/backend/optimizer/prep/prepjointree.c M src/backend/optimizer/util/clauses.c M src/backend/optimizer/util/inherit.c M src/backend/optimizer/util/plancat.c M src/backend/optimizer/util/relnode.c M src/include/nodes/parsenodes.h M src/include/nodes/pathnodes.h M src/include/optimizer/optimizer.h M src/include/optimizer/plancat.h M src/include/optimizer/prep.h M src/test/regress/expected/generated_virtual.out M src/test/regress/expected/join.out M src/test/regress/expected/predicate.out === using patch(1) to apply patch ./v3-0001-Reduce-Var-IS-NOT-NULL-quals-during-constant-folding.patch === patching file contrib/postgres_fdw/expected/postgres_fdw.out patching file contrib/postgres_fdw/sql/postgres_fdw.sql patching file src/backend/optimizer/plan/initsplan.c patching file src/backend/optimizer/plan/planner.c patching file src/backend/optimizer/plan/subselect.c Hunk #1 succeeded at 1520 (offset 80 lines). Hunk #2 succeeded at 1738 (offset 80 lines). Hunk #3 succeeded at 1798 (offset 80 lines). patching file src/backend/optimizer/prep/prepjointree.c Hunk #4 succeeded at 1374 (offset 12 lines). patching file src/backend/optimizer/util/clauses.c Hunk #2 FAILED at 42. Hunk #3 succeeded at 2243 (offset 2 lines). Hunk #4 succeeded at 3539 (offset 2 lines). Hunk #5 succeeded at 4182 (offset 2 lines). 1 out of 5 hunks FAILED -- saving rejects to file src/backend/optimizer/util/clauses.c.rej patching file src/backend/optimizer/util/inherit.c patching file src/backend/optimizer/util/plancat.c Hunk #1 FAILED at 162. Hunk #2 succeeded at 683 (offset 2 lines). 1 out of 2 hunks FAILED -- saving rejects to file src/backend/optimizer/util/plancat.c.rej patching file src/backend/optimizer/util/relnode.c patching file src/include/nodes/parsenodes.h Hunk #1 succeeded at 1085 (offset 5 lines). Hunk #2 succeeded at 1113 (offset 5 lines). patching file src/include/nodes/pathnodes.h patching file src/include/optimizer/optimizer.h patching file src/include/optimizer/plancat.h patching file src/include/optimizer/prep.h patching file src/test/regress/expected/generated_virtual.out Hunk #1 succeeded at 1531 (offset 59 lines). patching file src/test/regress/expected/join.out patching file src/test/regress/expected/predicate.out Unstaged changes after reset: M contrib/postgres_fdw/expected/postgres_fdw.out M contrib/postgres_fdw/sql/postgres_fdw.sql M src/backend/optimizer/plan/initsplan.c M src/backend/optimizer/plan/planner.c M src/backend/optimizer/plan/subselect.c M src/backend/optimizer/prep/prepjointree.c M src/backend/optimizer/util/clauses.c M src/backend/optimizer/util/inherit.c M src/backend/optimizer/util/plancat.c M src/backend/optimizer/util/relnode.c M src/include/nodes/parsenodes.h M src/include/nodes/pathnodes.h M src/include/optimizer/optimizer.h M src/include/optimizer/plancat.h M src/include/optimizer/prep.h M src/test/regress/expected/generated_virtual.out M src/test/regress/expected/join.out M src/test/regress/expected/predicate.out Removing src/backend/optimizer/util/clauses.c.rej Removing src/backend/optimizer/util/plancat.c.rej === using 'git apply' to apply patch ./v3-0001-Reduce-Var-IS-NOT-NULL-quals-during-constant-folding.patch === Applied patch to 'contrib/postgres_fdw/expected/postgres_fdw.out' cleanly. Applied patch to 'contrib/postgres_fdw/sql/postgres_fdw.sql' cleanly. Applied patch to 'src/backend/optimizer/plan/initsplan.c' cleanly. Applied patch to 'src/backend/optimizer/plan/planner.c' cleanly. Applied patch to 'src/backend/optimizer/plan/subselect.c' cleanly. Applied patch to 'src/backend/optimizer/prep/prepjointree.c' cleanly. Applied patch to 'src/backend/optimizer/util/clauses.c' with conflicts. Applied patch to 'src/backend/optimizer/util/inherit.c' cleanly. Applied patch to 'src/backend/optimizer/util/plancat.c' with conflicts. Applied patch to 'src/backend/optimizer/util/relnode.c' cleanly. Applied patch to 'src/include/nodes/parsenodes.h' cleanly. Applied patch to 'src/include/nodes/pathnodes.h' cleanly. Applied patch to 'src/include/optimizer/optimizer.h' cleanly. Applied patch to 'src/include/optimizer/plancat.h' cleanly. Applied patch to 'src/include/optimizer/prep.h' cleanly. Applied patch to 'src/test/regress/expected/generated_virtual.out' cleanly. Applied patch to 'src/test/regress/expected/join.out' cleanly. Applied patch to 'src/test/regress/expected/predicate.out' cleanly. U src/backend/optimizer/util/clauses.c U src/backend/optimizer/util/plancat.c diff --cc src/backend/optimizer/util/clauses.c index 26a3e050086,e067273ca01..00000000000 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@@ -40,9 -41,8 +41,13 @@@ #include "optimizer/planmain.h" #include "parser/analyze.h" #include "parser/parse_coerce.h" +#include "parser/parse_collate.h" #include "parser/parse_func.h" ++<<<<<<< ours +#include "parser/parse_oper.h" ++======= + #include "parser/parsetree.h" ++>>>>>>> theirs #include "rewrite/rewriteHandler.h" #include "rewrite/rewriteManip.h" #include "tcop/tcopprot.h" diff --cc src/backend/optimizer/util/plancat.c index 59233b64730,956341c14d1..00000000000 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@@ -163,38 -163,6 +163,41 @@@ get_relation_info(PlannerInfo *root, Oi palloc0((rel->max_attr - rel->min_attr + 1) * sizeof(int32)); /* ++<<<<<<< ours + * Record which columns are defined as NOT NULL. We leave this + * unpopulated for non-partitioned inheritance parent relations as it's + * ambiguous as to what it means. Some child tables may have a NOT NULL + * constraint for a column while others may not. We could work harder and + * build a unioned set of all child relations notnullattnums, but there's + * currently no need. The RelOptInfo corresponding to the !inh + * RangeTblEntry does get populated. + */ + if (!inhparent || relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE) + { + for (int i = 0; i < relation->rd_att->natts; i++) + { + CompactAttribute *attr = TupleDescCompactAttr(relation->rd_att, i); + + Assert(attr->attnullability != ATTNULLABLE_UNKNOWN); + + if (attr->attnullability == ATTNULLABLE_VALID) + { + rel->notnullattnums = bms_add_member(rel->notnullattnums, + i + 1); + + /* + * Per RemoveAttributeById(), dropped columns will have their + * attnotnull unset, so we needn't check for dropped columns + * in the above condition. + */ + Assert(!attr->attisdropped); + } + } + } + + /* ++======= ++>>>>>>> theirs * Estimate relation size --- unless it's an inheritance parent, in which * case the size we want is not the rel's own size but the size of its * inheritance tree. That will be computed in set_append_rel_size().