Re: [BUG] false positive in bt_index_check in case of short 4B varlena datum
Andrey Borodin <x4mmm@yandex-team.ru>
From: Andrey Borodin <x4mmm@yandex-team.ru>
To: Andres Freund <andres@anarazel.de>
Cc: Alexander Korotkov <aekorotkov@gmail.com>,
Alexander Lakhin <exclusion@gmail.com>,
Michael Zhilin <m.zhilin@postgrespro.ru>,
pgsql-bugs@postgresql.org,
Yura Sokolov <y.sokolov@postgrespro.ru>
Date: 2026-05-01T18:06:49Z
Lists: pgsql-bugs
> On 1 May 2026, at 22:11, Andres Freund <andres@anarazel.de> wrote:
>
> While hacking on something, I added an assertion to VARSIZE() that the
> argument is actually a VARATT_4B (which it assumes). Worked everywhere, except
> for this caller: amcheck/regress fails, because sometimes the varlena is
> actually a short/1B varlena.
>
> Note that VARSIZE_4B on a short datum will give you completely bogus
> answers. E.g. in the case that failed the assertion, VARSIZE_1B() is 2, but
> VARSIZE_4B(PTR) is 7681.
I remember the original code was taken from somewhere else because there
was already some instances like this:
/*
* If value is above size target, and is of a compressible datatype,
* try to compress it in-line.
*/
if (!VARATT_IS_EXTENDED(DatumGetPointer(untoasted_values[i])) &&
VARSIZE(DatumGetPointer(untoasted_values[i])) > TOAST_INDEX_TARGET &&
(att->attstorage == TYPSTORAGE_EXTENDED ||
att->attstorage == TYPSTORAGE_MAIN))
{
I don't have VARATT_IS_EXTENDED vs VARATT_IS_COMPRESSED vs VARATT_IS_SHORT
business in my warm cache right away, but I'll try to remember what it means soon.
Best regards, Andrey Borodin.
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
amcheck: Use correct varlena size accessor in bt_normalize_tuple()
- 4284476c0f67 15 (unreleased) landed
- c89a1ca01344 16 (unreleased) landed
- 8abb8a1555f4 17 (unreleased) landed
- af09b18cbadb 14 (unreleased) landed
- 897e79486296 18 (unreleased) landed
- da1eff08a5be 19 (unreleased) landed