Re: Handling of opckeytype / CREATE OPERATOR CLASS (bug?)

From: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Handling of opckeytype / CREATE OPERATOR CLASS (bug?)
Date: 2021-03-23 15:33:17
Message-ID: 91b06edb-3942-47d8-0aee-e3c5767b2f1a@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 3/23/21 6:15 AM, Tom Lane wrote:
> Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com> writes:
>> On 3/23/21 3:13 AM, Tom Lane wrote:
>>> Hm. Both catalogs.sgml and pg_opclass.h say specifically that
>>> opckeytype should be zero if it's to be the same as the input
>>> column type. I don't think just dropping the enforcement of that
>>> is the right answer.
>
>> Yeah, that's possible. I was mostly just demonstrating the difference in
>> behavior. Maybe the right fix is to fix the catalog contents and then
>> tweak the AM code, or something.
>
> Digging in our git history, the rule about zero opckeytype dates to
> 2001 (f933766ba), which precedes our invention of polymorphic types
> in 2003 (somewhere around 730840c9b). So I'm pretty sure that that
> was a poor man's substitute for polymorphic opclasses, which we
> failed to clean up entirely after we got real polymorphic opclasses.
>
> Now, I'd be in favor of cleaning that up and just using standard
> polymorphism rules throughout. But (without having studied the code)
> it looks like the immediate issue is that something in the BRIN code is
> unfamiliar with the rule for zero opckeytype. It might be a noticeably
> smaller patch to fix that than to get rid of the convention about zero.
>

That's possible. I'm not familiar with how we deal with polymorphic
opclasses etc. but I tried to look for places dealing with opckeytype,
so that I can compare BRIN vs. the other AMs, but the only references
seem to be in amvalidate() functions.

So either the difference is not very obvious, or maybe the other AMs
don't trigger this for some reason. For example btree has a separate
opclass for cidr, so it does not have to use "inet_ops" as polymorphic.

regards

--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message 杨逸存 2021-03-23 15:38:05 Query about pg asynchronous processing support
Previous Message Tom Lane 2021-03-23 15:29:24 Re: [CLOBBER_CACHE]Server crashed with segfault 11 while executing clusterdb