Re: SP-GiST confusion: indexed column's type vs. index column type - Mailing list pgsql-hackers

From Tom Lane
Subject Re: SP-GiST confusion: indexed column's type vs. index column type
Date
Msg-id 4021834.1617470187@sss.pgh.pa.us
Whole thread Raw
In response to Re: SP-GiST confusion: indexed column's type vs. index column type  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: SP-GiST confusion: indexed column's type vs. index column type  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I wrote:
> I still want to make an opclass in which those types are different,
> if only for testing purposes, but I'm having a hard time coming up
> with a plan that's not totally lame.  Best idea I can think of is
> to wrap the input in a bytea, which just begs the question "why
> would you do that?".  Anybody have a less lame thought?

I thought of a plan that's at least simple to code: make an opclass
that takes "name" but does all the internal storage as "text".  Then
all the code can be stolen from spgtextproc.c with very minor changes.
I'd been too fixated on finding an example in which attType and
leafType differ as to pass-by-ref vs pass-by-value, but actually a
test case with positive typlen vs. varlena typlen will do just as well
for finding wrong-type references.

And, having coded that up, my first test result is

regression=# create extension spgist_name_ops ;
ERROR:  storage type cannot be different from data type for access method "spgist"

evidently because SPGiST doesn't set amroutine->amstorage.

That's silly on its face because we have built-in opclasses in which
those types are different, but it probably helps explain why there are
no field reports of trouble with these bugs ...

            regards, tom lane



pgsql-hackers by date:

Previous
From: Zhihong Yu
Date:
Subject: Re: CLUSTER on partitioned index
Next
From: vignesh C
Date:
Subject: Re: Replication slot stats misgivings