From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Improve error messages about mismatching relkind
Date: Thu, 08 Jul 2021 07:52:15 +0000
Message-ID: <E1m1OpT-0004Ft-O9@gemulon.postgresql.org> (raw)
Improve error messages about mismatching relkind
Most error messages about a relkind that was not supported or
appropriate for the command was of the pattern
"relation \"%s\" is not a table, foreign table, or materialized view"
This style can become verbose and tedious to maintain. Moreover, it's
not very helpful: If I'm trying to create a comment on a TOAST table,
which is not supported, then the information that I could have created
a comment on a materialized view is pointless.
Instead, write the primary error message shorter and saying more
directly that what was attempted is not possible. Then, in the detail
message, explain that the operation is not supported for the relkind
the object was. To simplify that, add a new function
errdetail_relkind_not_supported() that does this.
In passing, make use of RELKIND_HAS_STORAGE() where appropriate,
instead of listing out the relkinds individually.
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://www.postgresql.org/message-id/flat/dc35a398-37d0-75ce-07ea-1dd71d98f8ec@2ndquadrant.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/2ed532ee8c474e9767e76e1f3251cc3a0224358c
Modified Files
--------------
contrib/amcheck/expected/check_heap.out | 15 +-
contrib/amcheck/verify_heapam.c | 38 ++-
contrib/pageinspect/expected/page.out | 6 +-
contrib/pageinspect/rawpage.c | 28 +-
contrib/pg_surgery/expected/heap_surgery.out | 6 +-
contrib/pg_surgery/heap_surgery.c | 54 ++--
contrib/pg_visibility/expected/pg_visibility.out | 75 +++--
contrib/pg_visibility/pg_visibility.c | 5 +-
contrib/pgstattuple/expected/pgstattuple.out | 30 +-
contrib/pgstattuple/pgstatapprox.c | 5 +-
contrib/pgstattuple/pgstatindex.c | 75 ++---
contrib/pgstattuple/pgstattuple.c | 31 +-
src/backend/catalog/Makefile | 1 +
src/backend/catalog/pg_class.c | 52 ++++
src/backend/catalog/toasting.c | 6 +-
src/backend/commands/comment.c | 5 +-
src/backend/commands/indexcmds.c | 16 +-
src/backend/commands/lockcmds.c | 5 +-
src/backend/commands/seclabel.c | 5 +-
src/backend/commands/sequence.c | 5 +-
src/backend/commands/statscmds.c | 5 +-
src/backend/commands/tablecmds.c | 357 +++++++++++++++--------
src/backend/commands/trigger.c | 15 +-
src/backend/parser/parse_utilcmd.c | 5 +-
src/backend/rewrite/rewriteDefine.c | 8 +-
src/include/catalog/pg_class.h | 1 +
src/test/regress/expected/alter_table.out | 9 +-
src/test/regress/expected/create_table_like.out | 3 +-
src/test/regress/expected/foreign_data.out | 6 +-
src/test/regress/expected/indexing.out | 3 +-
src/test/regress/expected/sequence.out | 3 +-
src/test/regress/expected/stats_ext.out | 12 +-
32 files changed, 512 insertions(+), 378 deletions(-)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: peter@eisentraut.org
Subject: Re: pgsql: Improve error messages about mismatching relkind
In-Reply-To: <E1m1OpT-0004Ft-O9@gemulon.postgresql.org>
References: <E1m1OpT-0004Ft-O9@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