diff options
author | Michael Paquier <michael@paquier.xyz> | 2021-07-14 17:15:26 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2021-07-14 17:15:26 +0900 |
commit | b242e1d239df238d612ad7037a1218cc47c641a4 (patch) | |
tree | 7462b60092be96f38ba9f0c64bf1c04b408a2cba /src/backend/commands/tablecmds.c | |
parent | 645c5d11939641ce4ad14f7e547e9c5ec2b98f71 (diff) | |
download | postgresql-b242e1d239df238d612ad7037a1218cc47c641a4.tar.gz postgresql-b242e1d239df238d612ad7037a1218cc47c641a4.zip |
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
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 816ce8521fe..8dc43195a5a 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -5372,6 +5372,9 @@ ATWrongRelkindError(Relation rel, int allowed_targets) case ATT_TABLE | ATT_MATVIEW | ATT_INDEX: msg = _("\"%s\" is not a table, materialized view, or index"); break; + case ATT_TABLE | ATT_MATVIEW | ATT_INDEX | ATT_PARTITIONED_INDEX: + msg = _("\"%s\" is not a table, materialized view, index, or partitioned index"); + break; case ATT_TABLE | ATT_MATVIEW | ATT_FOREIGN_TABLE: msg = _("\"%s\" is not a table, materialized view, or foreign table"); break; @@ -5384,6 +5387,9 @@ ATWrongRelkindError(Relation rel, int allowed_targets) case ATT_TABLE | ATT_MATVIEW | ATT_INDEX | ATT_FOREIGN_TABLE: msg = _("\"%s\" is not a table, materialized view, index, or foreign table"); break; + case ATT_TABLE | ATT_PARTITIONED_INDEX: + msg = _("\"%s\" is not a table or partitioned index"); + break; case ATT_VIEW: msg = _("\"%s\" is not a view"); break; |