postgresql/src/backend/access
Tom Lane dfc843d465 Fix more confusion in SP-GiST.
spg_box_quad_leaf_consistent unconditionally returned the leaf
datum as leafValue, even though in its usage for poly_ops that
value is of completely the wrong type.

In versions before 12, that was harmless because the core code did
nothing with leafValue in non-index-only scans ... but since commit
2a6368343, if we were doing a KNN-style scan, spgNewHeapItem would
unconditionally try to copy the value using the wrong datatype
parameters.  Said copying is a waste of time and space if we're not
going to return the data, but it accidentally failed to fail until
I fixed the datatype confusion in ac9099fc1.

Hence, change spgNewHeapItem to not copy the datum unless we're
actually going to return it later.  This saves cycles and dodges
the question of whether lossy opclasses are returning the right
type.  Also change spg_box_quad_leaf_consistent to not return
data that might be of the wrong type, as insurance against
somebody introducing a similar bug into the core code in future.

It seems like a good idea to back-patch these two changes into
v12 and v13, although I'm afraid to change spgNewHeapItem's
mistaken idea of which datatype to use in those branches.

Per buildfarm results from ac9099fc1.

Discussion: https://postgr.es/m/3728741.1617381471@sss.pgh.pa.us
2021-04-04 17:57:07 -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 more confusion in SP-GiST. 2021-04-04 17:57:07 -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