Hi.
Related:
https://git.postgresql.org/cgit/postgresql.git/commit/?id=fd41ba93e4630921a72ed5127cd0d552a8f3f8fc
create table p1(f1 int);
create table p1_c1() inherits(p1);
alter table p1_c1 add constraint p1c1_a_nn not null f1 no inherit;
pg_dump --table-and-children=p1* --clean --if-exists --no-data
output:
---------------<<<<<<
DROP TABLE IF EXISTS public.p1_c1;
DROP TABLE IF EXISTS public.p1;
CREATE TABLE public.p1 (
f1 integer
);
CREATE TABLE public.p1_c1 (
CONSTRAINT p1c1_a_nn NOT NULL f1
)
INHERITS (public.p1);
---------------<<<<<<
for p1_c1, it should be
CREATE TABLE public.p1_c1 (
CONSTRAINT p1c1_a_nn NOT NULL f1 NO INHERIT
)
INHERITS (public.p1);
add
```
if (tbinfo->notnull_noinh[j])
appendPQExpBufferStr(q, " NO INHERIT");
```
at the end of IF loop
```
if (!shouldPrintColumn(dopt, tbinfo, j) &&
!tbinfo->attisdropped[j] &&
tbinfo->notnull_constrs[j] != NULL &&
tbinfo->notnull_islocal[j])
{
}
```
will fix this problem.
--
jian
https://www.enterprisedb.com/
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");
}
}