Re: Pgstattuple on Sequences: Seeking Community Feedback on Potential Patch
Nathan Bossart <nathandbossart@gmail.com>
From: Nathan Bossart <nathandbossart@gmail.com>
To: Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>, Ayush Vatsa <ayushvatsa1810@gmail.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>, Michael Paquier <michael@paquier.xyz>
Date: 2024-09-03T20:40:53Z
Lists: pgsql-hackers
On Tue, Sep 03, 2024 at 10:19:33PM +0200, Matthias van de Meent wrote:
> On Fri, 30 Aug 2024, 23:06 Nathan Bossart, <nathandbossart@gmail.com> wrote:
>> Another related inconsistency I just noticed in pageinspect:
>>
>> postgres=# select t_data from heap_page_items(get_raw_page('s', 0));
>> t_data
>> --------------------------------------
>> \x0100000000000000000000000000000000
>> (1 row)
>>
>> postgres=# select tuple_data_split('s'::regclass, t_data, t_infomask, t_infomask2, t_bits) from heap_page_items(get_raw_page('s', 0));
>> ERROR: only heap AM is supported
>
> I don't think this is an inconsistency:
>
> heap_page_items works on a raw page-as-bytea (produced by
> get_raw_page) without knowing about or accessing the actual relation
> type of that page, so it doesn't have the context why it should error
> out if the page looks similar enough to a heap page. I could feed it
> an arbitrary bytea, and it should still work as long as that bytea
> looks similar enough to a heap page.
> tuple_data_split, however, uses the regclass to decode the contents of
> the tuple, and can thus determine with certainty based on that
> regclass that it was supplied incorrect (non-heapAM table's regclass)
> arguments. It therefore has enough context to bail out and stop trying
> to decode the page's tuple data.
My point is really that tuple_data_split() needlessly ERRORs for sequences.
Other heap functions work fine for sequences, and we know it uses the heap
table AM, so why should tuple_data_split() fail? I agree that the others
needn't enforce relkind checks and that they might succeed in some cases
where tuple_data_split() might not be appropriate.
--
nathan
Commits
-
Fix contrib/pageinspect's test for sequences.
- ef46a73f6941 13.17 landed
- e0277d90acf6 12.21 landed
- a63aef5e496c 15.9 landed
- 9b3c3c0fc206 17.0 landed
- 70d1c664f437 18.0 landed
- 0970889e352c 14.14 landed
- 0938a4ecda33 16.5 landed
-
Reintroduce support for sequences in pgstattuple and pageinspect.
- e03042a7003d 15.9 landed
- dd5670fa549e 12.21 landed
- ca902529cc0f 13.17 landed
- 8a94af8a2d0f 14.14 landed
- 6ea7f04b7366 17.0 landed
- 2bd4c06bba8c 16.5 landed
- 05036a3155c1 18.0 landed
-
Only allow heap in a number of contrib modules.
- 4b82664156c2 12.0 cited