Re: Pgstattuple on Sequences: Seeking Community Feedback on Potential Patch - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: Pgstattuple on Sequences: Seeking Community Feedback on Potential Patch
Date
Msg-id Ztd0VcV2PQJf5jUJ@nathan
Whole thread Raw
In response to Re: Pgstattuple on Sequences: Seeking Community Feedback on Potential Patch  (Matthias van de Meent <boekewurm+postgres@gmail.com>)
Responses Re: Pgstattuple on Sequences: Seeking Community Feedback on Potential Patch
List 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



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Optimize mul_var() for var1ndigits >= 8
Next
From: Tom Lane
Date:
Subject: Re: [PATCH] Add min/max aggregate functions to BYTEA