postgresql/src/backend/access
Tom Lane ac9099fc1d Fix confusion in SP-GiST between attribute type and leaf storage type.
According to the documentation, the attType passed to the opclass
config function (and also relied on by the core code) is the type
of the heap column or expression being indexed.  But what was
actually being passed was the type stored for the index column.
This made no difference for user-defined SP-GiST opclasses,
because we weren't allowing the STORAGE clause of CREATE OPCLASS
to be used, so the two types would be the same.  But it's silly
not to allow that, seeing that the built-in poly_ops opclass
has a different value for opckeytype than opcintype, and that if you
want to do lossy storage then the types must really be different.
(Thus, user-defined opclasses doing lossy storage had to lie about
what type is in the index.)  Hence, remove the restriction, and make
sure that we use the input column type not opckeytype where relevant.

For reasons of backwards compatibility with existing user-defined
opclasses, we can't quite insist that the specified leafType match
the STORAGE clause; instead just add an amvalidate() warning if
they don't match.

Also fix some bugs that would only manifest when trying to return
index entries when attType is different from attLeafType.  It's not
too surprising that these have not been reported, because the only
usual reason for such a difference is to store the leaf value
lossily, rendering index-only scans impossible.

Add a src/test/modules module to exercise cases where attType is
different from attLeafType and yet index-only scan is supported.

Discussion: https://postgr.es/m/3728741.1617381471@sss.pgh.pa.us
2021-04-04 14:28:57 -04:00
..
brin Fix bug in brin_minmax_multi_union 2021-04-04 19:36:12 +02:00
common Fix interaction of TOAST compression with expression indexes. 2021-03-25 19:55:32 -04:00
gin VACUUM VERBOSE: Count "newly deleted" index pages. 2021-02-25 14:32:18 -08:00
gist Add macro RelationIsPermanent() to report relation permanence 2021-03-22 20:23:52 -04:00
hash Pass down "logically unchanged index" hint. 2021-01-13 08:11:00 -08:00
heap Accept slightly-filled pages for tuples larger than fillfactor. 2021-03-30 18:53:44 -07:00
index Fix GiST index deletion assert issue. 2021-01-26 23:24:37 -08:00
nbtree nbtree VACUUM: Cope with buggy opclasses. 2021-03-23 16:09:51 -07:00
rmgrdesc Don't consider newly inserted tuples in nbtree VACUUM. 2021-03-10 16:27:01 -08:00
spgist Fix confusion in SP-GiST between attribute type and leaf storage type. 2021-04-04 14:28:57 -04:00
table Allow configurable LZ4 TOAST compression. 2021-03-19 15:10:38 -04:00
tablesample Update copyright for 2021 2021-01-02 13:06:25 -05:00
transam Fix bug in WAL replay of COMMIT_TS_SETTS record. 2021-03-25 11:23:30 +09:00
Makefile Introduce access/{table.h, relation.h}, for generic functions from heapam.h. 2019-01-21 10:51:36 -08:00