=== Applying patches on top of PostgreSQL commit ID e6dfd068ed453b8690551dac700d57fbf32ba187 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Thu Jul 24 01:21:18 UTC 2025 On branch cf/5768 nothing to commit, working tree clean === using 'git am' to apply patch ./v2-0001-ALTER-DOMAIN-ADD-NOT-NULL-NOT-VALID.patch === Applying: ALTER DOMAIN ADD NOT NULL NOT VALID Using index info to reconstruct a base tree... M doc/src/sgml/catalogs.sgml M src/backend/commands/typecmds.c M src/backend/parser/gram.y M src/bin/pg_dump/pg_dump.c M src/bin/pg_dump/t/002_pg_dump.pl M src/bin/psql/describe.c M src/test/regress/expected/domain.out M src/test/regress/sql/domain.sql Falling back to patching base and 3-way merge... Auto-merging src/test/regress/sql/domain.sql Auto-merging src/test/regress/expected/domain.out Auto-merging src/bin/psql/describe.c Auto-merging src/bin/pg_dump/t/002_pg_dump.pl CONFLICT (content): Merge conflict in src/bin/pg_dump/t/002_pg_dump.pl Auto-merging src/bin/pg_dump/pg_dump.c CONFLICT (content): Merge conflict in src/bin/pg_dump/pg_dump.c Auto-merging src/backend/parser/gram.y Auto-merging src/backend/commands/typecmds.c Auto-merging doc/src/sgml/catalogs.sgml error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 ALTER DOMAIN ADD NOT NULL NOT VALID 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 doc/src/sgml/catalogs.sgml M doc/src/sgml/ref/alter_domain.sgml M src/backend/catalog/pg_constraint.c M src/backend/commands/typecmds.c M src/backend/parser/gram.y M src/bin/pg_dump/pg_dump.c M src/bin/pg_dump/t/002_pg_dump.pl M src/bin/psql/describe.c M src/test/regress/expected/domain.out M src/test/regress/sql/domain.sql === using patch(1) to apply patch ./v2-0001-ALTER-DOMAIN-ADD-NOT-NULL-NOT-VALID.patch === patching file doc/src/sgml/catalogs.sgml Hunk #1 succeeded at 9520 (offset 5 lines). patching file doc/src/sgml/ref/alter_domain.sgml patching file src/backend/catalog/pg_constraint.c patching file src/backend/commands/typecmds.c Hunk #1 succeeded at 2765 (offset 8 lines). Hunk #2 succeeded at 3056 (offset 8 lines). Hunk #3 succeeded at 3185 (offset 8 lines). patching file src/backend/parser/gram.y Hunk #1 succeeded at 4402 (offset 11 lines). patching file src/bin/pg_dump/pg_dump.c Hunk #1 FAILED at 8250. Hunk #2 FAILED at 8260. Hunk #3 FAILED at 8282. Hunk #4 FAILED at 8300. Hunk #5 FAILED at 12497. Hunk #6 FAILED at 12518. Hunk #7 FAILED at 18388. 7 out of 7 hunks FAILED -- saving rejects to file src/bin/pg_dump/pg_dump.c.rej patching file src/bin/pg_dump/t/002_pg_dump.pl Hunk #1 succeeded at 1235 (offset 30 lines). patching file src/bin/psql/describe.c Hunk #1 succeeded at 4559 (offset 1 line). patching file src/test/regress/expected/domain.out patching file src/test/regress/sql/domain.sql Unstaged changes after reset: M doc/src/sgml/catalogs.sgml M doc/src/sgml/ref/alter_domain.sgml M src/backend/catalog/pg_constraint.c M src/backend/commands/typecmds.c M src/backend/parser/gram.y M src/bin/pg_dump/t/002_pg_dump.pl M src/bin/psql/describe.c M src/test/regress/expected/domain.out M src/test/regress/sql/domain.sql Removing src/bin/pg_dump/pg_dump.c.rej === using 'git apply' to apply patch ./v2-0001-ALTER-DOMAIN-ADD-NOT-NULL-NOT-VALID.patch === Applied patch to 'doc/src/sgml/catalogs.sgml' cleanly. Applied patch to 'doc/src/sgml/ref/alter_domain.sgml' cleanly. Applied patch to 'src/backend/catalog/pg_constraint.c' cleanly. Applied patch to 'src/backend/commands/typecmds.c' cleanly. Applied patch to 'src/backend/parser/gram.y' cleanly. Applied patch to 'src/bin/pg_dump/pg_dump.c' with conflicts. Applied patch to 'src/bin/pg_dump/t/002_pg_dump.pl' with conflicts. Applied patch to 'src/bin/psql/describe.c' cleanly. Applied patch to 'src/test/regress/expected/domain.out' cleanly. Applied patch to 'src/test/regress/sql/domain.sql' cleanly. U src/bin/pg_dump/pg_dump.c U src/bin/pg_dump/t/002_pg_dump.pl diff --cc src/bin/pg_dump/pg_dump.c index 6298edb26b5,88e825f24fe..00000000000 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@@ -8335,26 -8251,21 +8335,42 @@@ getDomainConstraints(Archive *fout, Typ i_oid, i_conname, i_consrc, ++<<<<<<< ours + i_convalidated, ++======= ++>>>>>>> theirs i_contype; int ntups; if (!fout->is_prepared[PREPQUERY_GETDOMAINCONSTRAINTS]) { ++<<<<<<< ours + /* + * Set up query for constraint-specific details. For servers 17 and + * up, domains have constraints of type 'n' as well as 'c', otherwise + * just the latter. + */ + appendPQExpBuffer(query, + "PREPARE getDomainConstraints(pg_catalog.oid) AS\n" + "SELECT tableoid, oid, conname, " + "pg_catalog.pg_get_constraintdef(oid) AS consrc, " + "convalidated, contype " + "FROM pg_catalog.pg_constraint " + "WHERE contypid = $1 AND contype IN (%s) " + "ORDER BY conname", + fout->remoteVersion < 170000 ? "'c'" : "'c', 'n'"); ++======= + /* Set up query for constraint-specific details */ + appendPQExpBufferStr(query, + "PREPARE getDomainConstraints(pg_catalog.oid) AS\n" + "SELECT tableoid, oid, conname, " + "pg_catalog.pg_get_constraintdef(oid) AS consrc, " + "convalidated, " + "contype " + "FROM pg_catalog.pg_constraint " + "WHERE contypid = $1 " + "ORDER BY conname"); ++>>>>>>> theirs ExecuteSqlStatement(fout, query->data); @@@ -8373,50 -8284,34 +8389,75 @@@ i_oid = PQfnumber(res, "oid"); i_conname = PQfnumber(res, "conname"); i_consrc = PQfnumber(res, "consrc"); ++<<<<<<< ours + i_convalidated = PQfnumber(res, "convalidated"); ++======= ++>>>>>>> theirs i_contype = PQfnumber(res, "contype"); constrinfo = (ConstraintInfo *) pg_malloc(ntups * sizeof(ConstraintInfo)); - - tyinfo->nDomChecks = ntups; tyinfo->domChecks = constrinfo; - for (i = 0; i < ntups; i++) + /* 'i' tracks result rows; 'j' counts CHECK constraints */ + for (int i = 0, j = 0; i < ntups; i++) { ++<<<<<<< ours + bool validated = PQgetvalue(res, i, i_convalidated)[0] == 't'; + char contype = (PQgetvalue(res, i, i_contype))[0]; + ConstraintInfo *constraint; + + if (contype == CONSTRAINT_CHECK) + { + constraint = &constrinfo[j++]; + tyinfo->nDomChecks++; + } + else + { + Assert(contype == CONSTRAINT_NOTNULL); + Assert(tyinfo->notnull == NULL); + /* use last item in array for the not-null constraint */ + tyinfo->notnull = &(constrinfo[ntups - 1]); + constraint = tyinfo->notnull; + } + + constraint->dobj.objType = DO_CONSTRAINT; + constraint->dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); + constraint->dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); + AssignDumpId(&(constraint->dobj)); + constraint->dobj.name = pg_strdup(PQgetvalue(res, i, i_conname)); + constraint->dobj.namespace = tyinfo->dobj.namespace; + constraint->contable = NULL; + constraint->condomain = tyinfo; + constraint->contype = contype; + constraint->condef = pg_strdup(PQgetvalue(res, i, i_consrc)); + constraint->confrelid = InvalidOid; + constraint->conindex = 0; + constraint->condeferrable = false; + constraint->condeferred = false; + constraint->conislocal = true; + + constraint->separate = !validated; ++======= + bool validated = PQgetvalue(res, i, 4)[0] == 't'; + + constrinfo[i].dobj.objType = DO_CONSTRAINT; + constrinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid)); + constrinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid)); + AssignDumpId(&constrinfo[i].dobj); + constrinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_conname)); + constrinfo[i].dobj.namespace = tyinfo->dobj.namespace; + constrinfo[i].contable = NULL; + constrinfo[i].condomain = tyinfo; + constrinfo[i].contype = *(PQgetvalue(res, i, i_contype)); + constrinfo[i].condef = pg_strdup(PQgetvalue(res, i, i_consrc)); + constrinfo[i].confrelid = InvalidOid; + constrinfo[i].conindex = 0; + constrinfo[i].condeferrable = false; + constrinfo[i].condeferred = false; + constrinfo[i].conislocal = true; + + constrinfo[i].separate = !validated; ++>>>>>>> theirs /* * Make the domain depend on the constraint, ensuring it won't be @@@ -12635,34 -12500,16 +12676,47 @@@ dumpDomain(Archive *fout, const TypeInf appendPQExpBuffer(q, " COLLATE %s", fmtQualifiedDumpable(coll)); } ++<<<<<<< ours + /* + * Print a not-null constraint if there's one. In servers older than 17 + * these don't have names, so just print it unadorned; in newer ones they + * do, but most of the time it's going to be the standard generated one, + * so omit the name in that case also. + */ + if (typnotnull[0] == 't') + { + if (fout->remoteVersion < 170000 || tyinfo->notnull == NULL) + appendPQExpBufferStr(q, " NOT NULL"); + else + { + ConstraintInfo *notnull = tyinfo->notnull; + + if (!notnull->separate) + { + char *default_name; + + /* XXX should match ChooseConstraintName better */ + default_name = psprintf("%s_not_null", tyinfo->dobj.name); + + if (strcmp(default_name, notnull->dobj.name) == 0) + appendPQExpBufferStr(q, " NOT NULL"); + else + appendPQExpBuffer(q, " CONSTRAINT %s %s", + fmtId(notnull->dobj.name), notnull->condef); + free(default_name); + } ++======= + if (typnotnull[0] == 't' && fout->remoteVersion < 190000) + appendPQExpBufferStr(q, " NOT NULL"); + else + { + for (i = 0; i < tyinfo->nDomChecks; i++) + { + ConstraintInfo *domcheck = &(tyinfo->domChecks[i]); + + if (!domcheck->separate && domcheck->contype == 'n') + appendPQExpBufferStr(q, " NOT NULL"); ++>>>>>>> theirs } } diff --cc src/bin/pg_dump/t/002_pg_dump.pl index 6c7ec80e271,71ad355b97c..00000000000 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@@ -1207,11 -1205,13 +1207,21 @@@ my %tests = }, }, ++<<<<<<< ours + # This constraint is invalid therefore it goes in SECTION_POST_DATA + 'COMMENT ON CONSTRAINT ON test_table_nn' => { + regexp => qr/^ + \QCOMMENT ON CONSTRAINT nn ON dump_test.test_table_nn IS\E + /xm, ++======= + 'DOMAIN CONSTRAINT NOT NULL / NOT VALID' => { + create_sql => 'CREATE DOMAIN dump_test.test_domain_nn AS INT; + ALTER DOMAIN dump_test.test_domain_nn ADD CONSTRAINT nn NOT NULL NOT VALID;', + regexp => qr/^ + \QALTER DOMAIN dump_test.test_domain_nn\E \n^\s+ + \QADD CONSTRAINT nn NOT NULL NOT VALID;\E + /xm, ++>>>>>>> theirs like => { %full_runs, %dump_test_schema_runs, section_post_data => 1, }, @@@ -1221,20 -1221,6 +1231,23 @@@ }, }, ++<<<<<<< ours + # This constraint is valid therefore it goes in SECTION_PRE_DATA + 'COMMENT ON CONSTRAINT ON test_table_chld2' => { + regexp => qr/^ + \QCOMMENT ON CONSTRAINT nn ON dump_test.test_table_nn_chld2 IS\E + /xm, + like => { + %full_runs, %dump_test_schema_runs, section_pre_data => 1, + }, + unlike => { + exclude_dump_test_schema => 1, + only_dump_measurement => 1, + }, + }, + ++======= ++>>>>>>> theirs 'CONSTRAINT NOT NULL / NOT VALID (child1)' => { regexp => qr/^ \QCREATE TABLE dump_test.test_table_nn_chld1 (\E\n