On Mon, 19 Jan 2026 at 16:52, Aleksander Alekseev
<[email protected]> wrote:
>
> Hi Kirill,
>
> > Please find two patches that would be very helpful to my own use
> > cases, and I believe they are universally useful. v1-0001 provides
> > pretty-print functionality for bt_page_items().
> > This makes much easier to get which exactly data page contains
>
> I did a quick look at 0001. Here are my two cents.
>
> If you are changing bt_page_items() you should also update the
> documentation [1] and cover the new functionality with tests.
>
> Adding a new required argument to the existing function doesn't strike
> me as a great idea. That's an API change which is arguably not that
> necessary. On top of that, pretty-printing potentially corrupted data
> may cause the backend to crash. IMO if we are going to do this the API
> should be very clear about the danger. I would prefer having a
> separate function, e.g. bt_page_items_unsafe. Or maybe this is
> something better done with an external tool like pg_filedump.
>
> Just thinking out loud. I wonder what other people think.
>
> [1]: https://www.postgresql.org/docs/current/pageinspect.html
>
> --
> Best regards,
> Aleksander Alekseev


Hi!
Thank you for looking into this!
Looks like I have posted an old version of my patch, which has no
default for pretty_print argument. This also makes tests to fail...

Anyway, I have borrowed this idea from
gist_page_items/gist_page_items_bytea, where the first function does
pretty print.
For btree, we have bt_page_items which returns bytea... So my
implementation choice was to just add a new parameter.
Also, gist_page_items documentation doest seem to care about corrupted
pages. Maybe there is some rule that you always use page inspection at
your own risk?

I will post an updated patch soon. If creating separate functions to
do pretty-print, bt_page_items_unsafe does not immediately strike me
as a good choice...

-- 
Best regards,
Kirill Reshke


Reply via email to