pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: amcheck: Improve error message for partitioned index target.
Date: Mon, 14 Jul 2025 11:06:13 +0000
Message-ID: <E1ubH0f-006FDl-02@gemulon.postgresql.org> (raw)

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@oss.nttdata.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.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(-)



Message-ID: <E1ubH0f-006FDl-02@gemulon.postgresql.org>
Permalink:  ../E1ubH0f-006FDl-02@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1ubH0f-006FDl-02@gemulon.postgresql.org

 · 

reply

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-committers@postgresql.org
  Cc: fujii@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: amcheck: Improve error message for partitioned index target.
  In-Reply-To: <E1ubH0f-006FDl-02@gemulon.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