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.