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 3935848.1617415502@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
List pgsql-hackers
I wrote:
> Also, both the code and docs thought that the "reconstructedValue"
> datums that are passed down the tree during a search should be of
> the leaf data type.  This seems to me to be arrant nonsense.
> As an example, if you made an opclass that indexes 1-D arrays
> by labeling each inner node with successive array elements,
> right down to the leaf which is the last array element, it will
> absolutely not work for the reconstructedValues to be of the
> leaf type --- they have to be of the array type.  (As I said
> in commit 1ebdec8c0, this'd be a fairly poorly-chosen opclass
> design, but it seems like it ought to physically work.)

So after trying to build an opclass that does that, I have a clearer
understanding of why opclasses that'd break the existing code are
so thin on the ground.  You can't do the above, because the opclass
cannot force the AM to add inner nodes that it doesn't want to.
For example, the first few index entries will simply be dumped into
the root page as undifferentiated leaf tuples.  This means that,
if you'd like to be able to return reconstructed index entries, the
leaf data type *must* be able to hold all the data that is in an
input value.  In principle you could represent it in some other
format, but the path of least resistance is definitely to make the
leaf type the same as the input.

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?

            regards, tom lane



pgsql-hackers by date:

Previous
From: vignesh C
Date:
Subject: Re: Data type correction in pgstat_report_replslot function parameters
Next
From: Zhihong Yu
Date:
Subject: Re: Have I found an interval arithmetic bug?