mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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
This commit is contained in:
@ -180,9 +180,11 @@ DROP TABLE test1;
|
||||
create table test_partitioned (a int) partition by range (a);
|
||||
create index test_partitioned_index on test_partitioned (a);
|
||||
select get_raw_page('test_partitioned', 0); -- error about partitioned table
|
||||
ERROR: cannot get raw page from partitioned table "test_partitioned"
|
||||
ERROR: cannot get raw page from relation "test_partitioned"
|
||||
DETAIL: This operation is not supported for partitioned tables.
|
||||
select get_raw_page('test_partitioned_index', 0); -- error about partitioned index
|
||||
ERROR: cannot get raw page from partitioned index "test_partitioned_index"
|
||||
ERROR: cannot get raw page from relation "test_partitioned_index"
|
||||
DETAIL: This operation is not supported for partitioned indexes.
|
||||
-- a regular table which is a member of a partition set should work though
|
||||
create table test_part1 partition of test_partitioned for values from ( 1 ) to (100);
|
||||
select get_raw_page('test_part1', 0); -- get farther and error about empty table
|
||||
|
Reference in New Issue
Block a user