pgsql: amcheck: Improve error message for partitioned index target.

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: amcheck: Improve error message for partitioned index target.
Date: 2025-07-14 11:06:13
Message-ID: E1ubH0f-006FDl-02@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

amcheck: Improve error message for partitioned index target.

Previously, amcheck could produce misleading error message when
a partitioned index was passed to functions like bt_index_check().
For example, bt_index_check() with a partitioned btree index produced:

ERROR: expected "btree" index as targets for verification
DETAIL: Relation ... is a btree index.

Reporting "expected btree index as targets" even when the specified
index was a btree was confusing. In this case, the function should fail
since the partitioned index specified is not valid target. This commit
improves the error reporting to better reflect this actual issue. Now,
bt_index_check() with a partitioned index, the error message is:

ERROR: expected index as targets for verification
DETAIL: This operation is not supported for partitioned indexes.

This commit also applies the following minor changes:

- Simplifies index_checkable() by using get_am_name() to retrieve
the access method name.

- Changes index_checkable() from extern to static, as it is only used
in verify_common.c.

- Updates the error code for invalid indexes to
ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE,
aligning with usage in similar modules like pgstattuple.

Author: Masahiro Ikeda <ikedamsh(at)oss(dot)nttdata(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Discussion: https://postgr.es/m/8829854bbfc8635ddecd0846bb72dfda@oss.nttdata.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/88a658a42e1b3e6b1a6d4e8322d731ddc3fe9b97

Modified Files
--------------
contrib/amcheck/expected/check_btree.out | 8 ++++++++
contrib/amcheck/sql/check_btree.sql | 7 +++++++
contrib/amcheck/verify_common.c | 24 ++++++++++++------------
contrib/amcheck/verify_common.h | 2 --
4 files changed, 27 insertions(+), 14 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2025-07-14 13:53:38 Re: pgsql: Add function to log the memory contexts of specified backend pro
Previous Message Peter Eisentraut 2025-07-14 11:03:57 pgsql: Translation updates