BUG #16285: bt_metap fails with value is out of range for type integer - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #16285: bt_metap fails with value is out of range for type integer
Date
Msg-id 16285-df8fc1000ab3d5fc@postgresql.org
Whole thread Raw
Responses Re: BUG #16285: bt_metap fails with value is out of range for type integer
Re: BUG #16285: bt_metap fails with value is out of range for typeinteger
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16285
Logged by:          Victor Yegorov
Email address:      vyegorov@gmail.com
PostgreSQL version: 12.2
Operating system:   Ubuntu 18.04.3 LTS
Description:

I have an index, that is giving issues pageinspect-ing it:

SELECT * FROM bt_metap('index')\gx
ERROR:  value "2180413846" is out of range for type integer

At the same time:

SELECT * FROM pgstatindex('index')\gx
-[ RECORD 1 ]------+----------
version            | 3
tree_level         | 2
index_size         | 131571712
root_block_no      | 290
internal_pages     | 56
leaf_pages         | 16003
empty_pages        | 0
deleted_pages      | 1
avg_leaf_density   | 50.06
leaf_fragmentation | 66.08

Looking at the sources of both extensions, I can see, that pgstatindex() is
using psprintf(INT64_FORMAT) for page counters and psprintf("%u") for root
page, while bt_metap() is using only psprintf("%d");

I assume psprintf("%u") should be used at least for metad->btm_root and
metad->btm_fastroot in the bt_metap(PG_FUNCTION_ARGS) function.


pgsql-bugs by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: BUG #16283: crash on create index segmentation fault
Next
From: Peter Geoghegan
Date:
Subject: Re: BUG #16285: bt_metap fails with value is out of range for type integer