From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Nondeterministic collations vs. text_pattern_ops
Date: Wed, 18 Sep 2019 11:04:13 -0400
Message-ID: <25976.1568819053@sss.pgh.pa.us> (raw)
In-Reply-To: <c7e57eaf-5d7f-22b6-6f48-85580889de8d@2ndquadrant.com>
References: <22566.1568675619@sss.pgh.pa.us>
<57e4d38e-eb2c-9a77-5a7c-b94396187cf9@2ndquadrant.com>
<3615.1568733452@sss.pgh.pa.us>
<c7e57eaf-5d7f-22b6-6f48-85580889de8d@2ndquadrant.com>
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
> Here is a draft patch.
> It will require a catversion change because those operator classes don't
> have assigned OIDs so far.
That's slightly annoying given where we are with v12. We could
avoid it by looking up the opclass's opfamily and seeing if it's
TEXT_BTREE_FAM_OID etc, which do already have hand-assigned OIDs.
But maybe avoiding a catversion bump now is not worth the cost of
an extra syscache lookup. (It'd give me an excuse to shove the
leakproofness-marking changes from the other thread into v12, so
there's that.)
Speaking of extra syscache lookups, I don't like that you rearranged
the if-test to check nondeterminism before the opclass identity checks.
That's usually going to be a wasted lookup.
> The comment block I just moved over for the time being. It should
> probably be rephrased a bit.
Indeed. Maybe like
* text_pattern_ops uses text_eq as the equality operator, which is
* fine as long as the collation is deterministic; text_eq then
* reduces to bitwise equality and so it is semantically compatible
* with the other operators and functions in the opclass. But with a
* nondeterministic collation, text_eq could yield results that are
* incompatible with the actual behavior of the index (which is
* determined by the opclass's comparison function). We prevent
* such problems by refusing creation of an index with this opclass
* and a nondeterministic collation.
*
* The same applies to varchar_pattern_ops and bpchar_pattern_ops.
* If we find more cases, we might decide to create a real mechanism
* for marking opclasses as incompatible with nondeterminism; but
* for now, this small hack suffices.
*
* Another solution is to use a special operator, not text_eq, as the
* equality opclass member, but that is undesirable because it would
* prevent index usage in many queries that work fine today.
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, peter.eisentraut@2ndquadrant.com
Subject: Re: Nondeterministic collations vs. text_pattern_ops
In-Reply-To: <25976.1568819053@sss.pgh.pa.us>
References: <22566.1568675619@sss.pgh.pa.us> <57e4d38e-eb2c-9a77-5a7c-b94396187cf9@2ndquadrant.com> <3615.1568733452@sss.pgh.pa.us> <c7e57eaf-5d7f-22b6-6f48-85580889de8d@2ndquadrant.com> <25976.1568819053@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