=== Applying patches on top of PostgreSQL commit ID 21c9756db6458f859e6579a6754c78154321cb39 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Sun Jul 6 11:50:22 UTC 2025 On branch cf/4764 nothing to commit, working tree clean === using 'git am' to apply patch ./v6-0001-Improve-SQL-comments-on-echo-hidden-output.patch === Patch format detection failed. === using patch(1) to apply patch ./v6-0001-Improve-SQL-comments-on-echo-hidden-output.patch === patching file src/bin/psql/command.c Hunk #2 succeeded at 320 (offset 7 lines). Hunk #3 succeeded at 462 (offset 21 lines). patching file src/bin/psql/common.c Hunk #2 succeeded at 656 (offset 35 lines). Hunk #3 succeeded at 665 (offset 35 lines). Hunk #4 succeeded at 2685 (offset 352 lines). patching file src/bin/psql/common.h patching file src/bin/psql/describe.c Hunk #1 succeeded at 1629 (offset 6 lines). Hunk #2 succeeded at 1650 (offset 6 lines). Hunk #3 succeeded at 1667 (offset 6 lines). Hunk #4 succeeded at 1684 (offset 6 lines). Hunk #5 succeeded at 1701 (offset 6 lines). Hunk #6 succeeded at 1762 (offset 6 lines). Hunk #7 succeeded at 1789 (offset 6 lines). Hunk #8 succeeded at 1816 (offset 6 lines). Hunk #9 succeeded at 1896 (offset 6 lines). Hunk #10 succeeded at 2199 (offset 12 lines). Hunk #11 succeeded at 2255 (offset 12 lines). Hunk #12 succeeded at 2278 (offset 12 lines). Hunk #13 succeeded at 2307 (offset 12 lines). Hunk #14 succeeded at 2429 (offset 12 lines). Hunk #15 FAILED at 2560. Hunk #16 FAILED at 2567. Hunk #17 FAILED at 2580. Hunk #18 FAILED at 2634. Hunk #19 FAILED at 2648. Hunk #26 succeeded at 3118 with fuzz 2. Hunk #27 succeeded at 3192 (offset 3 lines). Hunk #28 succeeded at 3230 (offset 3 lines). Hunk #29 succeeded at 3449 (offset 3 lines). Hunk #30 succeeded at 3487 (offset 3 lines). Hunk #31 succeeded at 3499 (offset 3 lines). Hunk #32 succeeded at 3509 (offset 3 lines). 5 out of 32 hunks FAILED -- saving rejects to file src/bin/psql/describe.c.rej Unstaged changes after reset: M src/bin/psql/command.c M src/bin/psql/common.c M src/bin/psql/common.h M src/bin/psql/describe.c Removing src/bin/psql/describe.c.rej === using 'git apply' to apply patch ./v6-0001-Improve-SQL-comments-on-echo-hidden-output.patch === Applied patch to 'src/bin/psql/command.c' cleanly. Applied patch to 'src/bin/psql/common.c' cleanly. Applied patch to 'src/bin/psql/common.h' cleanly. Applied patch to 'src/bin/psql/describe.c' with conflicts. U src/bin/psql/describe.c diff --cc src/bin/psql/describe.c index dd25d2fe7b8,af3cd405438..00000000000 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@@ -2555,124 -2552,139 +2564,187 @@@ describeOneTableDetails(const char *sch PQclear(result); } - /* - * Print foreign-key constraints (there are none if no triggers, - * except if the table is partitioned, in which case the triggers - * appear in the partitions) - */ - if (tableinfo.hastriggers || - tableinfo.relkind == RELKIND_PARTITIONED_TABLE) + /* Print foreign-key constraints */ + if (pset.sversion >= 120000 && + (tableinfo.ispartition || tableinfo.relkind == RELKIND_PARTITIONED_TABLE)) { ++<<<<<<< ours + /* + * Put the constraints defined in this table first, followed by + * the constraints defined in ancestor partitioned tables. + */ + printfPQExpBuffer(&buf, + "SELECT conrelid = '%s'::pg_catalog.regclass AS sametable,\n" + " conname,\n" + " pg_catalog.pg_get_constraintdef(oid, true) AS condef,\n" + " conrelid::pg_catalog.regclass AS ontable\n" + " FROM pg_catalog.pg_constraint,\n" + " pg_catalog.pg_partition_ancestors('%s')\n" + " WHERE conrelid = relid AND contype = " CppAsString2(CONSTRAINT_FOREIGN) " AND conparentid = 0\n" + "ORDER BY sametable DESC, conname;", + oid, oid); + } + else + { + printfPQExpBuffer(&buf, + "SELECT true as sametable, conname,\n" + " pg_catalog.pg_get_constraintdef(r.oid, true) as condef,\n" + " conrelid::pg_catalog.regclass AS ontable\n" + "FROM pg_catalog.pg_constraint r\n" + "WHERE r.conrelid = '%s' AND r.contype = " CppAsString2(CONSTRAINT_FOREIGN) "\n", + oid); ++======= + OutputComment(&buf, _("Get information about foreign key constraints")); + + if (pset.sversion >= 120000 && + (tableinfo.ispartition || tableinfo.relkind == RELKIND_PARTITIONED_TABLE)) + { + /* + * Put the constraints defined in this table first, followed + * by the constraints defined in ancestor partitioned tables. + */ + appendPQExpBuffer(&buf, + "SELECT conrelid = '%s'::pg_catalog.regclass AS sametable,\n" + " conname,\n" + " pg_catalog.pg_get_constraintdef(oid, true) AS condef,\n" + " conrelid::pg_catalog.regclass AS ontable\n" + " FROM pg_catalog.pg_constraint,\n" + " pg_catalog.pg_partition_ancestors('%s')\n" + " WHERE conrelid = relid AND contype = " CppAsString2(CONSTRAINT_FOREIGN) " AND conparentid = 0\n" + "ORDER BY sametable DESC, conname;", + oid, oid); + } + else + { + appendPQExpBuffer(&buf, + "SELECT true as sametable, conname,\n" + " pg_catalog.pg_get_constraintdef(r.oid, true) as condef,\n" + " conrelid::pg_catalog.regclass AS ontable\n" + "FROM pg_catalog.pg_constraint r\n" + "WHERE r.conrelid = '%s' AND r.contype = " CppAsString2(CONSTRAINT_FOREIGN) "\n", + oid); + + if (pset.sversion >= 120000) + appendPQExpBufferStr(&buf, " AND conparentid = 0\n"); + appendPQExpBufferStr(&buf, "ORDER BY conname"); + } ++>>>>>>> theirs - result = PSQLexec(buf.data); - if (!result) - goto error_return; - else - tuples = PQntuples(result); + if (pset.sversion >= 120000) + appendPQExpBufferStr(&buf, " AND conparentid = 0\n"); + appendPQExpBufferStr(&buf, "ORDER BY conname"); + } - if (tuples > 0) - { - int i_sametable = PQfnumber(result, "sametable"), - i_conname = PQfnumber(result, "conname"), - i_condef = PQfnumber(result, "condef"), - i_ontable = PQfnumber(result, "ontable"); + result = PSQLexec(buf.data); + if (!result) + goto error_return; + else + tuples = PQntuples(result); - printTableAddFooter(&cont, _("Foreign-key constraints:")); - for (i = 0; i < tuples; i++) - { - /* - * Print untranslated constraint name and definition. Use - * a "TABLE tab" prefix when the constraint is defined in - * a parent partitioned table. - */ - if (strcmp(PQgetvalue(result, i, i_sametable), "f") == 0) - printfPQExpBuffer(&buf, " TABLE \"%s\" CONSTRAINT \"%s\" %s", - PQgetvalue(result, i, i_ontable), - PQgetvalue(result, i, i_conname), - PQgetvalue(result, i, i_condef)); - else - printfPQExpBuffer(&buf, " \"%s\" %s", - PQgetvalue(result, i, i_conname), - PQgetvalue(result, i, i_condef)); + if (tuples > 0) + { + int i_sametable = PQfnumber(result, "sametable"), + i_conname = PQfnumber(result, "conname"), + i_condef = PQfnumber(result, "condef"), + i_ontable = PQfnumber(result, "ontable"); - printTableAddFooter(&cont, buf.data); - } + printTableAddFooter(&cont, _("Foreign-key constraints:")); + for (i = 0; i < tuples; i++) + { + /* + * Print untranslated constraint name and definition. Use a + * "TABLE tab" prefix when the constraint is defined in a + * parent partitioned table. + */ + if (strcmp(PQgetvalue(result, i, i_sametable), "f") == 0) + printfPQExpBuffer(&buf, " TABLE \"%s\" CONSTRAINT \"%s\" %s", + PQgetvalue(result, i, i_ontable), + PQgetvalue(result, i, i_conname), + PQgetvalue(result, i, i_condef)); + else + printfPQExpBuffer(&buf, " \"%s\" %s", + PQgetvalue(result, i, i_conname), + PQgetvalue(result, i, i_condef)); + + printTableAddFooter(&cont, buf.data); } - PQclear(result); } + PQclear(result); /* print incoming foreign-key references */ - if (tableinfo.hastriggers || - tableinfo.relkind == RELKIND_PARTITIONED_TABLE) + if (pset.sversion >= 120000) { ++<<<<<<< ours + printfPQExpBuffer(&buf, + "SELECT conname, conrelid::pg_catalog.regclass AS ontable,\n" + " pg_catalog.pg_get_constraintdef(oid, true) AS condef\n" + " FROM pg_catalog.pg_constraint c\n" + " WHERE confrelid IN (SELECT pg_catalog.pg_partition_ancestors('%s')\n" + " UNION ALL VALUES ('%s'::pg_catalog.regclass))\n" + " AND contype = " CppAsString2(CONSTRAINT_FOREIGN) " AND conparentid = 0\n" + "ORDER BY conname;", + oid, oid); + } + else + { + printfPQExpBuffer(&buf, + "SELECT conname, conrelid::pg_catalog.regclass AS ontable,\n" + " pg_catalog.pg_get_constraintdef(oid, true) AS condef\n" + " FROM pg_catalog.pg_constraint\n" + " WHERE confrelid = %s AND contype = " CppAsString2(CONSTRAINT_FOREIGN) "\n" + "ORDER BY conname;", + oid); + } ++======= + OutputComment(&buf, _("Get information about incoming foreign key references")); + if (pset.sversion >= 120000) + { + appendPQExpBuffer(&buf, + "SELECT conname, conrelid::pg_catalog.regclass AS ontable,\n" + " pg_catalog.pg_get_constraintdef(oid, true) AS condef\n" + " FROM pg_catalog.pg_constraint c\n" + " WHERE confrelid IN (SELECT pg_catalog.pg_partition_ancestors('%s')\n" + " UNION ALL VALUES ('%s'::pg_catalog.regclass))\n" + " AND contype = " CppAsString2(CONSTRAINT_FOREIGN) " AND conparentid = 0\n" + "ORDER BY conname;", + oid, oid); + } + else + { + appendPQExpBuffer(&buf, + "SELECT conname, conrelid::pg_catalog.regclass AS ontable,\n" + " pg_catalog.pg_get_constraintdef(oid, true) AS condef\n" + " FROM pg_catalog.pg_constraint\n" + " WHERE confrelid = %s AND contype = " CppAsString2(CONSTRAINT_FOREIGN) "\n" + "ORDER BY conname;", + oid); + } ++>>>>>>> theirs - result = PSQLexec(buf.data); - if (!result) - goto error_return; - else - tuples = PQntuples(result); + result = PSQLexec(buf.data); + if (!result) + goto error_return; + else + tuples = PQntuples(result); - if (tuples > 0) - { - int i_conname = PQfnumber(result, "conname"), - i_ontable = PQfnumber(result, "ontable"), - i_condef = PQfnumber(result, "condef"); + if (tuples > 0) + { + int i_conname = PQfnumber(result, "conname"), + i_ontable = PQfnumber(result, "ontable"), + i_condef = PQfnumber(result, "condef"); - printTableAddFooter(&cont, _("Referenced by:")); - for (i = 0; i < tuples; i++) - { - printfPQExpBuffer(&buf, " TABLE \"%s\" CONSTRAINT \"%s\" %s", - PQgetvalue(result, i, i_ontable), - PQgetvalue(result, i, i_conname), - PQgetvalue(result, i, i_condef)); + printTableAddFooter(&cont, _("Referenced by:")); + for (i = 0; i < tuples; i++) + { + printfPQExpBuffer(&buf, " TABLE \"%s\" CONSTRAINT \"%s\" %s", + PQgetvalue(result, i, i_ontable), + PQgetvalue(result, i, i_conname), + PQgetvalue(result, i, i_condef)); - printTableAddFooter(&cont, buf.data); - } + printTableAddFooter(&cont, buf.data); } - PQclear(result); } + PQclear(result); /* print any row-level policies */ if (pset.sversion >= 90500) @@@ -3105,10 -3121,10 +3181,11 @@@ */ if (verbose) { - printfPQExpBuffer(&buf, + OutputComment(&buf, _("Get information about NOT NULL constraints")); + appendPQExpBuffer(&buf, "SELECT c.conname, a.attname, c.connoinherit,\n" - " c.conislocal, c.coninhcount <> 0\n" + " c.conislocal, c.coninhcount <> 0,\n" + " c.convalidated\n" "FROM pg_catalog.pg_constraint c JOIN\n" " pg_catalog.pg_attribute a ON\n" " (a.attrelid = c.conrelid AND a.attnum = c.conkey[1])\n"