agora inbox for [email protected]
help / color / mirror / Atom feedFrom: Álvaro Herrera <[email protected]>
Subject: [PATCH v2] Fix pg_dump for NO INHERIT constraints on inheritance children
Date: Wed, 25 Feb 2026 19:17:54 +0100
Discussion: https://postgr.es/m/CACJufxEDEOO09G+OQFr=HmFr9ZDLZbRoV7+pj58h3_WeJ_K5UQ@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
--ole5fkw5oubhenmr--
view thread (6+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH v2] Fix pg_dump for NO INHERIT constraints on inheritance children
In-Reply-To: <no-message-id-4384@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox