From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: exclusion@gmail.com
Subject: BUG #18246: pgstathashindex() attempts to read invalid file for hash index attached to partitioned table
Date: Wed, 13 Dec 2023 09:00:01 +0000
Message-ID: <18246-f4d9ff7cb3af77e6@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 18246
Logged by: Alexander Lakhin
Email address: exclusion@gmail.com
PostgreSQL version: 16.1
Operating system: Ubuntu 22.04
Description:
The following script:
CREATE EXTENSION pgstattuple;
CREATE TABLE t (a int, b int[], c int) PARTITION BY RANGE (a);
CREATE INDEX a_idx ON t USING btree(a);
CREATE INDEX b_idx ON t USING gin(b);
CREATE INDEX c_idx ON t USING hash(c);
SELECT pgstatindex('a_idx');
SELECT pgstatginindex('b_idx');
SELECT pgstathashindex('c_idx');
gives an unexpected error for the hash index:
ERROR: could not open file "pg_tblspc/0/PG_16_202307071/0/0": No such file
or directory
while for btree and hash indexes errors are more adequate:
ERROR: relation "a_idx" is not a btree index
ERROR: relation "b_idx" is not a GIN index
Reproduced on REL_12_STABLE .. master.
(On master, thanks to commit 049ef3398, which added an Assert in smgr.c,
that assertion fails.)
This anomaly can be observed since 8b08f7d48 from 2018-01-19, but IMO the
culprit is e759854a0 from 2017-02-03, which introduced the following
asymmetry in pgstatindex.c:
if (!IS_INDEX(rel) || !IS_BTREE(rel))
if (!IS_INDEX(rel) || !IS_GIN(rel))
But:
if (!IS_HASH(rel))
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, exclusion@gmail.com
Subject: Re: BUG #18246: pgstathashindex() attempts to read invalid file for hash index attached to partitioned table
In-Reply-To: <18246-f4d9ff7cb3af77e6@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox