postgresql/src/backend
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
..
access Fix confusion in SP-GiST between attribute type and leaf storage type. 2021-04-04 14:28:57 -04:00
bootstrap Split backend status and progress related functionality out of pgstat.c. 2021-04-03 11:42:52 -07:00
catalog Fix has_column_privilege function corner case 2021-03-31 13:55:25 -04:00
commands Add Result Cache executor node (take 2) 2021-04-02 14:10:56 +13:00
executor Remove useless Asserts in Result Cache code 2021-04-03 10:41:43 +13:00
foreign Update copyright for 2021 2021-01-02 13:06:25 -05:00
jit Use errmsg_internal for debug messages 2021-02-17 11:33:25 +01:00
lib Update copyright for 2021 2021-01-02 13:06:25 -05:00
libpq Refactor HMAC implementations 2021-04-03 17:30:49 +09:00
main Update copyright for 2021 2021-01-02 13:06:25 -05:00
nodes Add Result Cache executor node (take 2) 2021-04-02 14:10:56 +13:00
optimizer Add support for NullIfExpr in eval_const_expressions 2021-04-02 11:01:49 +02:00
parser Allow an alias to be attached to a JOIN ... USING 2021-03-31 17:10:50 +02:00
partitioning ALTER TABLE ... DETACH PARTITION ... CONCURRENTLY 2021-03-25 18:00:28 -03:00
po Translation updates 2020-05-18 12:49:30 +02:00
port Use errmsg_internal for debug messages 2021-02-17 11:33:25 +01:00
postmaster Split backend status and progress related functionality out of pgstat.c. 2021-04-03 11:42:52 -07:00
regex Further tweak memory management for regex DFAs. 2021-03-08 16:32:29 -05:00
replication Do not rely on pgstat.h to indirectly include storage/ headers. 2021-04-02 20:02:47 -07:00
rewrite Rework planning and execution of UPDATE and DELETE. 2021-03-31 11:52:37 -04:00
snowball Update snowball 2021-02-19 08:10:15 +01:00
statistics Don't prematurely cram a value into a short int. 2021-03-31 16:45:24 -04:00
storage Improve efficiency of wait event reporting, remove proc.h dependency. 2021-04-03 12:03:45 -07:00
tcop Detect POLLHUP/POLLRDHUP while running queries. 2021-04-03 09:02:41 +13:00
tsearch Don't leak compiled regex(es) when an ispell cache entry is dropped. 2021-03-18 22:22:47 -04:00
utils Improve efficiency of wait event reporting, remove proc.h dependency. 2021-04-03 12:03:45 -07:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Add missing gettext triggers 2020-04-28 13:35:40 +02:00