persevere NO INHERIT when Dump not-null constraints on inherited columns - Mailing list pgsql-hackers

From jian he
Subject persevere NO INHERIT when Dump not-null constraints on inherited columns
Date
Msg-id CACJufxEDEOO09G+OQFr=HmFr9ZDLZbRoV7+pj58h3_WeJ_K5UQ@mail.gmail.com
Whole thread
Responses Re: persevere NO INHERIT when Dump not-null constraints on inherited columns
List 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.



--
jian
https://www.enterprisedb.com/

Attachment

pgsql-hackers by date:

Previous
From: Nazir Bilal Yavuz
Date:
Subject: Re: Speed up COPY FROM text/CSV parsing using SIMD
Next
From: Tom Lane
Date:
Subject: Re: Passing mac-addresses by value?