From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: nik@postgres.ai
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18244: Corruption in indexes involving whole-row expressions
Date: Wed, 13 Dec 2023 04:55:00 +0100
Message-ID: <c37d4184c476a15ad4c488d272bdc95ea7b0ff49.camel@cybertec.at> (raw)
In-Reply-To: <CA+hUKGJPxjaD3d_qYrHPxHLS_=ktVMFK7O-+9RgTBzQUTB9q6A@mail.gmail.com>
References: <18244-8a7897de2acd5a08@postgresql.org>
<f577abdc489e75a0b62f0648829d633d75ff8d95.camel@cybertec.at>
<CA+hUKGJPxjaD3d_qYrHPxHLS_=ktVMFK7O-+9RgTBzQUTB9q6A@mail.gmail.com>
On Wed, 2023-12-13 at 14:38 +1300, Thomas Munro wrote:
> On Wed, Dec 13, 2023 at 11:53 AM Laurenz Albe <laurenz.albe@cybertec.at> wrote:
> > On Tue, 2023-12-12 at 19:28 +0000, PG Bug reporting form wrote:
> > > nik=# create index on t1 (hash_record(t1));
> > >
> > > Such an index can easily be corrupted, e.g.:
> > >
> > > nik=# alter table t1 add column yo int default -1;
> > >
> > > Proposal: prohibit the use of whole-row expression – as it is already done
> > > for generated columns and produce a similar error ("cannot use whole-row
> > > variable in column generation expression")
> >
> > I reported that bug before:
> > https://www.postgresql.org/message-id/flat/e48a5d9a2d3d72985d61ee254314f5f5f5444a55.camel%40cybertec...
>
> FTR I also posted a repro for another variation of that problem. I
> think it's slightly more general that, it not just whole-row
> expressions (eg index on <table_name>), it's row types generally:
>
> https://www.postgresql.org/message-id/CA%2BhUKGKb4SB%2BqQ-vAVomxAvJY6um%2B5URyq2D0vv10g7mbYZ1Ww%40ma...
Yes, and that makes it difficult to decide on the correct path.
Should we check all places where the type is used before allowing
ALTER TYPE? Sounds complicated and error-prone.
Should we forbid composite types in index declarations? Sounds posssible,
but very restrictive. We might as well forbid composite types in table
definitions. That would be a good thing in my opinion, but it would cause
a compatibility headache.
Perhaps the best thing would be to add a warning to chapter 8.16.4 that
it is "best practice" (and conforming to the first normal form) not to
use composite types in column definitions, and that altering a composite
type used in a table definition can lead to consistency problems.
Yours,
Laurenz Albe
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: laurenz.albe@cybertec.at, thomas.munro@gmail.com, nik@postgres.ai
Subject: Re: BUG #18244: Corruption in indexes involving whole-row expressions
In-Reply-To: <c37d4184c476a15ad4c488d272bdc95ea7b0ff49.camel@cybertec.at>
References: <18244-8a7897de2acd5a08@postgresql.org> <f577abdc489e75a0b62f0648829d633d75ff8d95.camel@cybertec.at> <CA+hUKGJPxjaD3d_qYrHPxHLS_=ktVMFK7O-+9RgTBzQUTB9q6A@mail.gmail.com> <c37d4184c476a15ad4c488d272bdc95ea7b0ff49.camel@cybertec.at>
* 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