pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
should all not-null constraints be inherited?
3+ messages / 3 participants
[nested] [flat]

* should all not-null constraints be inherited?
@ 2021-03-31 15:12  Alexey Bashtanov <bashtanov@imap.cc>
  0 siblings, 1 reply; 3+ messages in thread

From: Alexey Bashtanov @ 2021-03-31 15:12 UTC (permalink / raw)
  To: pgsql-bugs

Hello,

This is how one can create a parent with a non-nullable column and a 
child with the same column nullable:

create table t1(a int not null);
create table t2() inherits (t1);
alter table t2 alter column a drop not null;
insert into t2 select null;

pg_dump produces a dump that fails to restore, as the change by the 
alter command doesn't get addressed.
Reproduced in 10 and 14devel.

Should we fix ALTER TABLE or pg_dump?

Best, Alex





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: should all not-null constraints be inherited?
@ 2021-03-31 17:02  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Alexey Bashtanov <bashtanov@imap.cc>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2021-03-31 17:02 UTC (permalink / raw)
  To: Alexey Bashtanov <bashtanov@imap.cc>; +Cc: pgsql-bugs

Alexey Bashtanov <bashtanov@imap.cc> writes:
> This is how one can create a parent with a non-nullable column and a 
> child with the same column nullable:

Yeah, that's been on the to-do list for a long time.  The current
theory about it is that NOT NULL constraints ought to be represented
as entries in pg_constraint like CHECKs are, so that the inheritance
count and so forth could be managed the same way.  We could keep
attnotnull for convenience but it'd just mirror the existence of
the pg_constraint entry.

IIRC Alvaro had a WIP patch for this, but I've not heard anything
about it lately.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: should all not-null constraints be inherited?
@ 2021-03-31 17:40  Alvaro Herrera <alvherre@alvh.no-ip.org>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Alvaro Herrera @ 2021-03-31 17:40 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Alexey Bashtanov <bashtanov@imap.cc>; pgsql-bugs

On 2021-Mar-31, Tom Lane wrote:

> Yeah, that's been on the to-do list for a long time.  The current
> theory about it is that NOT NULL constraints ought to be represented
> as entries in pg_constraint like CHECKs are, so that the inheritance
> count and so forth could be managed the same way.  We could keep
> attnotnull for convenience but it'd just mirror the existence of
> the pg_constraint entry.
> 
> IIRC Alvaro had a WIP patch for this, but I've not heard anything
> about it lately.

That one is the first thing on my list for the next cycle.

-- 
Álvaro Herrera       Valdivia, Chile





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2021-03-31 17:40 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31 15:12 should all not-null constraints be inherited? Alexey Bashtanov <bashtanov@imap.cc>
2021-03-31 17:02 ` Tom Lane <tgl@sss.pgh.pa.us>
2021-03-31 17:40   ` Alvaro Herrera <alvherre@alvh.no-ip.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox