On 2026-Feb-25, Álvaro Herrera wrote: > Ugh, you're right, this is broken and your patch fixes it. > > I'm gonna write a quick test case for this and push as soon as I'm able.
Here it is. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
>From 353414c011baca3bc1fd51856eed733e00c5fbd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Herrera?= <[email protected]> Date: Wed, 25 Feb 2026 19:17:54 +0100 Subject: [PATCH v2] Fix pg_dump for NO INHERIT constraints on inheritance children Discussion: https://postgr.es/m/CACJufxEDEOO09G+OQFr=hmfr9zdlzbrov7+pj58h3_wej_k...@mail.gmail.com --- src/bin/pg_dump/pg_dump.c | 3 +++ src/bin/pg_dump/t/002_pg_dump.pl | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 450cec285b3..46a6794a57f 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -17421,6 +17421,9 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo) appendPQExpBuffer(q, "CONSTRAINT %s NOT NULL %s", tbinfo->notnull_constrs[j], fmtId(tbinfo->attnames[j])); + + if (tbinfo->notnull_noinh[j]) + appendPQExpBufferStr(q, " NO INHERIT"); } } diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index bc7a082f57a..a265c98f807 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -1070,6 +1070,26 @@ my %tests = ( }, }, + 'CONSTRAINT NOT NULL / NO INHERIT' => { + create_sql => 'CREATE TABLE dump_test.test_table_nonn (col1 int); + CREATE TABLE dump_test.test_table_nonn_chld1 ( + CONSTRAINT nn NOT NULL col1 NO INHERIT) + INHERITS (dump_test.test_table_nonn); ', + regexp => qr/^ + \QCREATE TABLE dump_test.test_table_nonn_chld1 (\E \n^\s+ + \QCONSTRAINT nn NOT NULL col1 NO INHERIT\E + /xm, + like => { + %full_runs, %dump_test_schema_runs, + section_pre_data => 1, + }, + unlike => { + exclude_dump_test_schema => 1, + only_dump_measurement => 1, + binary_upgrade => 1, + }, + }, + 'CONSTRAINT PRIMARY KEY / WITHOUT OVERLAPS' => { create_sql => 'CREATE TABLE dump_test.test_table_tpk ( col1 int4range, -- 2.47.3
