pgsql: Improve error messages about mismatching relkind

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема pgsql: Improve error messages about mismatching relkind
Дата
Msg-id E1m1OpT-0004Ft-O9@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix crash in postgres_fdw for provably-empty remote UPDATE/DELET
Следующее
От: Daniel Gustafsson
Дата:
Сообщение: pgsql: Fix typos in pgstat.c, reorderbuffer.c and pathnodes.h