From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Daniel Gustafsson <daniel@yesql.se>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: zedaardv@drizzle.com <zedaardv@drizzle.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17720: pg_dump creates a dump with primary key that cannot be restored, when specifying 'using index ...'
Date: Fri, 16 Dec 2022 09:07:36 +0100
Message-ID: <173834de-18a1-4a9c-5e15-9b22e56c4293@enterprisedb.com> (raw)
In-Reply-To: <3039077.1671060472@sss.pgh.pa.us>
References: <17720-dab8ee0fa85d316d@postgresql.org>
<CAKFQuwam=1NoSNH=EJRUnuuD8JE_jM8tq22-SYqO1nxzoXFwzg@mail.gmail.com>
<9C039DE3-EFBD-4D65-B4CF-90D8148B7B4C@yesql.se>
<2684951.1671032222@sss.pgh.pa.us>
<20CD10FD-A9C2-47D0-9A75-B86532BC058E@yesql.se>
<3039077.1671060472@sss.pgh.pa.us>
On 15.12.22 00:27, Tom Lane wrote:
> Daniel Gustafsson <daniel@yesql.se> writes:
>> The attached prohibits the use of NULLS NOT DISTINCT for backing primary key
>> constraints but allow them for unique constraints. Is this along the lines of
>> what you had in mind?
>
> Needs more than zero comments in the code, and why bother testing
> is_alter_table in index_check_primary_key? We're disallowing
> this case across-the-board, no matter how you get to it.
>
> I'll defer to Peter on whether this is in fact the right way to go,
> or we should relax the syntax restriction as David suggests.
My first instinct was to just fix pg_dump to not dump syntax that can't
be loaded in.
It shouldn't matter what null treatment the underlying unique index has,
since the primary key can't have nulls anyway, so either type of index
should be acceptable. But then we'd need to think through a bunch of
possible ALTER behaviors. For example, if we just change pg_dump and
leave the index as is, a subsequent dump and restore would lose the
original null treatment flag. What if someone then wants to re-detach
the constraint from the index? (Does that exist now? Maybe not, but it
could.) What should happen then? This could all be worked out, I
think, but it would need more thought.
In short, I think preventing the ALTER command, as proposed in this
patch, seems like a good solution for the moment. Additional work to
enable some of this could follow later independently.
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: peter.eisentraut@enterprisedb.com, tgl@sss.pgh.pa.us, daniel@yesql.se, david.g.johnston@gmail.com, zedaardv@drizzle.com
Subject: Re: BUG #17720: pg_dump creates a dump with primary key that cannot be restored, when specifying 'using index ...'
In-Reply-To: <173834de-18a1-4a9c-5e15-9b22e56c4293@enterprisedb.com>
References: <17720-dab8ee0fa85d316d@postgresql.org> <CAKFQuwam=1NoSNH=EJRUnuuD8JE_jM8tq22-SYqO1nxzoXFwzg@mail.gmail.com> <9C039DE3-EFBD-4D65-B4CF-90D8148B7B4C@yesql.se> <2684951.1671032222@sss.pgh.pa.us> <20CD10FD-A9C2-47D0-9A75-B86532BC058E@yesql.se> <3039077.1671060472@sss.pgh.pa.us> <173834de-18a1-4a9c-5e15-9b22e56c4293@enterprisedb.com>
* 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