| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | persevere NO INHERIT when Dump not-null constraints on inherited columns |
| Date: | 2026-02-25 14:38:20 |
| Message-ID: | CACJufxEDEOO09G+OQFr=HmFr9ZDLZbRoV7+pj58h3_WeJ_K5UQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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.
| Attachment | Content-Type | Size |
|---|---|---|
| pg_dump_no_inherit_inherit_col.diff | text/x-patch | 489 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-02-25 14:40:51 | Re: Passing mac-addresses by value? |
| Previous Message | Nazir Bilal Yavuz | 2026-02-25 14:24:27 | Re: Speed up COPY FROM text/CSV parsing using SIMD |