Re: Index-only scan for btree_gist turns bpchar to char

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Index-only scan for btree_gist turns bpchar to char
Date: 2022-01-04 19:19:21
Message-ID: 4053318.1641323961@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alexander Lakhin <exclusion(at)gmail(dot)com> writes:
> While testing the index-only scan fix, I've discovered that replacing
> the index-only scan with the index scan changes contrib/btree_gist
> output because index-only scan for btree_gist returns a string without
> padding.

Ugh, yeah. This seems to be because gbt_bpchar_compress() strips
trailing spaces (using rtrim1) before storing the value. The
idea evidently is to simplify gbt_bpchar_consistent, but it's not
acceptable if the opclass is supposed to support index-only scan.

I see two ways to fix this:

* Disallow index-only scan, by removing the fetch function for this
opclass. This'd require a module version bump, so people wouldn't
get that fix automatically.

* Change gbt_bpchar_compress to not trim spaces (it becomes just
like gbt_text_compress), and adapt gbt_bpchar_consistent to cope.
This does nothing for the problem immediately, unless you REINDEX
affected indexes --- but over time an index's entries would get
replaced with untrimmed versions.

I also wondered if we could make the fetch function reconstruct the
padding, but it doesn't seem to have access to the necessary info.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2022-01-04 19:32:20 Re: Add 64-bit XIDs into PostgreSQL 15
Previous Message Alexander Lakhin 2022-01-04 19:00:00 Re: Proposal: remove obsolete hot-standby testing infrastructure