From: Tom Lane <tgl@sss.pgh.pa.us>
To: Guancheng Luo <prajnamort@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: [PATCH] Check operator when creating unique index on partition table
Date: Wed, 25 Mar 2020 13:00:36 -0400
Message-ID: <4731.1585155636@sss.pgh.pa.us> (raw)
In-Reply-To: <D9C3CEF7-04E8-47A1-8300-CA1DCD5ED40D@gmail.com>
References: <D9C3CEF7-04E8-47A1-8300-CA1DCD5ED40D@gmail.com>
Guancheng Luo <prajnamort@gmail.com> writes:
> I found that things could go wrong in some cases, when the unique index and the partition key use different opclass.
I agree that this is an oversight, but it seems like your solution is
overcomplicated and probably still too forgiving. Should we not just
insist that the index opfamily match the partition key opfamily?
It looks to me like that would reduce the code change to about like
this:
- if (key->partattrs[i] == indexInfo->ii_IndexAttrNumbers[j])
+ if (key->partattrs[i] == indexInfo->ii_IndexAttrNumbers[j] &&
+ key->partopfamily[i] == get_opclass_family(classObjectId[j]))
which is a lot more straightforward and provides a lot more certainty
that the index will act as the partition constraint demands.
This would reject, for example, a hash index associated with a btree-based
partition constraint, but I'm not sure we're losing anything much thereby.
(I do not think your patch is correct for the case where the opfamilies
belong to different AMs, anyway.)
I'm not really on board with adding a whole new test script for this,
either.
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 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-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, prajnamort@gmail.com
Subject: Re: [PATCH] Check operator when creating unique index on partition table
In-Reply-To: <4731.1585155636@sss.pgh.pa.us>
References: <D9C3CEF7-04E8-47A1-8300-CA1DCD5ED40D@gmail.com> <4731.1585155636@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