From 9ab6b625e8f93ae2957144ec7f0ba32cf8a3bb5b Mon Sep 17 00:00:00 2001 From: Erik Wienhold Date: Fri, 8 Mar 2024 04:21:56 +0100 Subject: [PATCH v2] Document that typed tables rely on CREATE TYPE CREATE TABLE OF accepts only composite types that were created with CREATE TYPE. Clarify that also in the error message. --- doc/src/sgml/ref/create_table.sgml | 2 ++ src/backend/commands/tablecmds.c | 2 +- src/test/regress/expected/typed_table.out | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 4cbaaccaf7..889496cf0a 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -254,6 +254,8 @@ WITH ( MODULUS numeric_literal, REM schema-qualified). A typed table is tied to its type; for example the table will be dropped if the type is dropped (with DROP TYPE ... CASCADE). + Expects the composite type to have been created with + . diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 7014be8039..0f43f349dc 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -6979,7 +6979,7 @@ check_of_type(HeapTuple typetuple) if (!typeOk) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("type %s is not a composite type", + errmsg("type %s is not a composite type created with CREATE TYPE", format_type_be(typ->oid)))); } diff --git a/src/test/regress/expected/typed_table.out b/src/test/regress/expected/typed_table.out index 2e47ecbcf5..9edd744f6a 100644 --- a/src/test/regress/expected/typed_table.out +++ b/src/test/regress/expected/typed_table.out @@ -89,7 +89,7 @@ drop cascades to function get_all_persons() drop cascades to table persons2 drop cascades to table persons3 CREATE TABLE persons5 OF stuff; -- only CREATE TYPE AS types may be used -ERROR: type stuff is not a composite type +ERROR: type stuff is not a composite type created with CREATE TYPE DROP TABLE stuff; -- implicit casting CREATE TYPE person_type AS (id int, name text); -- 2.44.0