From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Andres Freund <andres@anarazel.de>
Cc: Justin Pryzby <pryzby@telsasoft.com>
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: cataloguing NOT NULL constraints
Date: Sun, 09 Apr 2023 16:11:42 -0400
Message-ID: <3863449.1681071102@sss.pgh.pa.us> (raw)
In-Reply-To: <20230409191101.po3bjtxdvm562f4o@alvherre.pgsql>
References: <20230409191101.po3bjtxdvm562f4o@alvherre.pgsql>
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
>> I'm inclined to think that this idea of suppressing the implied
>> NOT NULL from PRIMARY KEY is a nonstarter and we should just
>> go ahead and make such a constraint. Another idea could be for
>> pg_dump to emit the NOT NULL, load data, do the ALTER ADD PRIMARY
>> KEY, and then ALTER DROP NOT NULL.
> I like that second idea, yeah. It might be tough to make it work, but
> I'll try.
Yeah, I've been thinking more about it, and this might also yield a
workable solution for the TestUpgrade breakage. The idea would be,
roughly, for pg_dump to emit NOT NULL column decoration in all the
same places it does now, and then to drop it again immediately after
doing ADD PRIMARY KEY if it judges that there was no other reason
to have it. This gets rid of the inconsistency for --binary-upgrade
which I think is what is causing the breakage.
I also ran into something else I didn't much care for:
regression=# create table foo(f1 int primary key, f2 int);
CREATE TABLE
regression=# create table foochild() inherits(foo);
CREATE TABLE
regression=# alter table only foo alter column f2 set not null;
ERROR: cannot add constraint only to table with inheritance children
HINT: Do not specify the ONLY keyword.
Previous versions accepted this case, and I don't really see why
we can't do so with this new implementation -- isn't this exactly
what pg_constraint.connoinherit was invented to represent? Moreover,
existing pg_dump files can contain precisely this construct, so
blowing it off isn't going to be zero-cost.
regards, tom lane
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: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, alvherre@alvh.no-ip.org, andres@anarazel.de, pryzby@telsasoft.com, peter.eisentraut@enterprisedb.com, pgsql-hackers@lists.postgresql.org
Subject: Re: cataloguing NOT NULL constraints
In-Reply-To: <3863449.1681071102@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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