postgresql/contrib/btree_gist/expected
Tom Lane 3a69d45afc Fix results of index-only scans on btree_gist char(N) indexes.
If contrib/btree_gist is used to make a GIST index on a char(N)
(bpchar) column, and that column is retrieved via an index-only
scan, what came out had all trailing spaces removed.  Since
that doesn't happen in any other kind of table scan, this is
clearly a bug.  The cause is that gbt_bpchar_compress() strips
trailing spaces (using rtrim1) before a new index entry is made.
That was probably a good idea when this code was first written,
but since we invented index-only scans, it's not so good.

One answer could be to mark this opclass as incapable of index-only
scans.  But to do so, we'd need an extension module version bump,
followed by manual action by DBAs to install the updated version
of btree_gist.  And it's not really a desirable place to end up,
anyway.

Instead, let's fix the code by removing the unwanted space-stripping
action and adjusting the opclass's comparison logic to ignore
trailing spaces as bpchar normally does.  This will not hinder
cases that work today, since index searches with this logic will
act the same whether trailing spaces are stored or not.  It will
not by itself fix the problem of getting space-stripped results
from index-only scans, of course.  Users who care about that can
REINDEX affected indexes after installing this update, to immediately
replace all improperly-truncated index entries.  Otherwise, it can
be expected that the index's behavior will change incrementally as
old entries are replaced by new ones.

Per report from Alexander Lakhin.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/696c995b-b37f-5526-f45d-04abe713179f@gmail.com
2022-01-08 14:54:39 -05:00
..
bit.out Remove ruleutils.c's special case for BIT [VARYING] literals. 2018-09-11 16:32:25 -04:00
bytea.out Add index-only scan support to btree_gist. 2015-03-27 23:35:16 +02:00
cash.out Remove WITH OIDS support, change oid catalog column visibility. 2018-11-20 16:00:17 -08:00
char.out Fix results of index-only scans on btree_gist char(N) indexes. 2022-01-08 14:54:39 -05:00
char_1.out Fix results of index-only scans on btree_gist char(N) indexes. 2022-01-08 14:54:39 -05:00
cidr.out
date.out Add index-only scan support to btree_gist. 2015-03-27 23:35:16 +02:00
enum.out Add btree_gist support for enum types. 2017-03-21 10:43:27 -04:00
float4.out Change floating-point output format for improved performance. 2019-02-13 15:20:33 +00:00
float8.out Change floating-point output format for improved performance. 2019-02-13 15:20:33 +00:00
inet.out Improve stability of recently-added regression test case. 2018-10-16 12:01:18 -04:00
init.out Test all contrib-created operator classes with amvalidate. 2016-11-29 15:05:22 -05:00
int2.out Be more careful about printing constants in ruleutils.c. 2015-03-30 14:59:49 -04:00
int4.out Add index-only scan support to btree_gist. 2015-03-27 23:35:16 +02:00
int8.out Be more careful about printing constants in ruleutils.c. 2015-03-30 14:59:49 -04:00
interval.out Properly initialize SortSupport for ORDER BY rechecks in nodeIndexscan.c. 2016-06-05 11:53:06 -04:00
macaddr.out Add index-only scan support to btree_gist. 2015-03-27 23:35:16 +02:00
macaddr8.out Add support for EUI-64 MAC addresses as macaddr8 2017-03-15 11:16:25 -04:00
not_equal.out Ensure plan stability in contrib/btree_gist regression test. 2016-05-12 20:04:38 -04:00
numeric.out Be more careful about printing constants in ruleutils.c. 2015-03-30 14:59:49 -04:00
oid.out Remove WITH OIDS support, change oid catalog column visibility. 2018-11-20 16:00:17 -08:00
text.out Add index-only scan support to btree_gist. 2015-03-27 23:35:16 +02:00
text_1.out Add index-only scan support to btree_gist. 2015-03-27 23:35:16 +02:00
time.out Add index-only scan support to btree_gist. 2015-03-27 23:35:16 +02:00
timestamp.out Add index-only scan support to btree_gist. 2015-03-27 23:35:16 +02:00
timestamptz.out Add index-only scan support to btree_gist. 2015-03-27 23:35:16 +02:00
timetz.out
uuid.out Add uuid to the set of types supported by contrib/btree_gist. 2016-11-29 14:08:34 -05:00
varbit.out Remove ruleutils.c's special case for BIT [VARYING] literals. 2018-09-11 16:32:25 -04:00
varchar.out
varchar_1.out