Re: GIN pageinspect support for entry tree and posting tree

From: Japin Li <japinli(at)hotmail(dot)com>
To: Roman Khapov <rkhapov(at)yandex-team(dot)ru>
Cc: Kirill Reshke <reshkekirill(at)gmail(dot)com>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: GIN pageinspect support for entry tree and posting tree
Date: 2026-01-14 12:17:18
Message-ID: MEAPR01MB3031AA324D863C181318188BB68FA@MEAPR01MB3031.ausprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 14 Jan 2026 at 15:26, Roman Khapov <rkhapov(at)yandex-team(dot)ru> wrote:
>> Hi! Thank you 🙏 for your effort. 0003 looks good to me
>>
>> --
>> Best regards,
>> Kirill Reshke
>
> Hi! Thanks for the patch!
>
> I'v been reviewing your patch, and noticed there are some code logic
> that handles NULL values, but tests doesn't cover this scenarios.
>
> So, I added simple line at contrib/pageinspect/sql/gin.sql:
>
> INSERT INTO test1 VALUES (1, ARRAY[11, 111], ARRAY['a', 'b', 'c']);
> +INSERT INTO test1 VALUES (1, ARRAY[NULL, 222], ARRAY['d', NULL]);
> CREATE INDEX test1_y_idx ON test1 USING gin (y) WITH (fastupdate = off);
>
> And got unexpected result...
> As far as I understand, we shouldn't get error for the whole
> gin_entrypage_items executions when there are NULL-values columns at index key, but the
> output contains only the next error:
>
> SELECT * FROM gin_entrypage_items(get_raw_page('test1_y_idx', 1), 'test1_y_idx'::regclass);
> --[ RECORD 1 ]--------------
> -itemoffset | 1
> -downlink | (2147483664,1)
> -tids | {"(0,1)"}
> -keys | y=11
> --[ RECORD 2 ]--------------
> -itemoffset | 2
> -downlink | (2147483664,1)
> -tids | {"(0,1)"}
> -keys | y=111
> -
> +ERROR: invalid gin entry page tuple at offset 4
>
> Is the NULL values handle correct?
>

Nice catch!

I agree — the NULL handling seems wrong.
Here's a quick patch to fix it. What do you think?

--
Regards,
Japin Li
ChengDu WenWu Information Technology Co., Ltd.

Attachment Content-Type Size
nocfbot-fix-null-in-gin-index.diff text/x-patch 3.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Geier 2026-01-14 12:27:05 Re: Reduce build times of pg_trgm GIN indexes
Previous Message Dilip Kumar 2026-01-14 11:39:26 Re: Proposal: Conflict log history table for Logical Replication