BUG #16285: bt_metap fails with value is out of range for type integer
The Post Office <noreply@postgresql.org>
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: vyegorov@gmail.com
Date: 2020-03-02T22:39:14Z
Lists: 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.
Commits
-
Paper over bt_metap() oldest_xact bug in backbranches.
- 393b449f1a64 12.3 landed
- c788115b5eb5 11.8 landed
-
pageinspect: Fix types used for bt_metap() columns.
- 691e8b2e1889 13.0 landed
-
Skip full index scan during cleanup of B-tree indexes when possible
- 857f9c36cda5 11.0 cited
-
pg_stat_statements: Widen query IDs from 32 bits to 64 bits.
- cff440d36869 11.0 cited