pgsql: Fix unexpected error messages for various flavors of ALTER TABLE

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix unexpected error messages for various flavors of ALTER TABLE
Date: 2021-07-14 08:16:24
Message-ID: E1m3a48-0002gZ-0z@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix unexpected error messages for various flavors of ALTER TABLE

Some commands of ALTER TABLE could fail with the following error:
ERROR: "tab" is of the wrong type

This error is unexpected, as all the code paths leading to
ATWrongRelkindError() should use a supported set of relkinds to generate
correct error messages. This commit closes the gap with such mistakes,
by adding all the missing relkind combinations. Tests are added to
check all the problems found. Note that some combinations are not used,
but these are left around as it could have an impact on applications
relying on this code.

2ed532e has done a much larger refactoring on HEAD to make such error
messages easier to manage in the long-term, so nothing is needed there.

Author: Kyotaro Horiguchi
Reviewed-by: Peter Eisentraut, Ahsan Hadi, Michael Paquier
Discussion: https://postgr.es/m/20210216.181415.368926598204753659.horikyota.ntt@gmail.com
Backpatch-through: 11

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b242e1d239df238d612ad7037a1218cc47c641a4

Modified Files
--------------
src/backend/commands/tablecmds.c | 6 ++++++
src/test/regress/expected/alter_table.out | 5 +++++
src/test/regress/expected/foreign_data.out | 2 ++
src/test/regress/sql/alter_table.sql | 5 +++++
src/test/regress/sql/foreign_data.sql | 1 +
5 files changed, 19 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Magnus Hagander 2021-07-14 09:11:34 pgsql: Clarify description of pg_stat_statements columns
Previous Message Peter Eisentraut 2021-07-14 07:18:51 pgsql: Fix lack of message pluralization