agora inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v3] Document that typed tables rely on CREATE TYPE
10+ messages / 2 participants
[nested] [flat]

* [PATCH v3] Document that typed tables rely on CREATE TYPE
@ 2024-03-08 03:21  Erik Wienhold <[email protected]>
  0 siblings, 0 replies; 10+ messages in thread

From: Erik Wienhold @ 2024-03-08 03:21 UTC (permalink / raw)

CREATE TABLE OF requires a stand-alone composite type.  Clarify that in
the error message.  Also reword the docs to better explain the
connection between created table and stand-alone composite type.

Reworded docs provided by David G. Johnston.
---
 doc/src/sgml/ref/create_table.sgml        | 18 +++++++++---------
 src/backend/commands/tablecmds.c          |  2 +-
 src/test/regress/expected/typed_table.out |  2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index dfb7822985..5c8c1edaed 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -249,19 +249,19 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>OF <replaceable class="parameter">type_name</replaceable></literal></term>
     <listitem>
      <para>
-      Creates a <firstterm>typed table</firstterm>, which takes its
-      structure from the specified composite type (name optionally
-      schema-qualified).  A typed table is tied to its type; for
-      example the table will be dropped if the type is dropped
-      (with <literal>DROP TYPE ... CASCADE</literal>).
+      Creates a <firstterm>typed table</firstterm>, which takes its structure
+      from an existing (name optionally schema-qualified) stand-alone composite
+      type (i.e. created using <xref linkend="sql-createtype"/>) though it
+      still produces a new composite type as well.  The table will have
+      a dependency on the referenced type such that cascaded alter and drop
+      actions on the type will propagate to the table.
      </para>
 
      <para>
-      When a typed table is created, then the data types of the
-      columns are determined by the underlying composite type and are
-      not specified by the <literal>CREATE TABLE</literal> command.
+      A typed table always has the same column names and data types as the
+      type it is derived from, and you cannot specify additional columns.
       But the <literal>CREATE TABLE</literal> command can add defaults
-      and constraints to the table and can specify storage parameters.
+      and constraints to the table, as well as specify storage parameters.
      </para>
     </listitem>
    </varlistentry>
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 6741e721ae..8e9dbe4bee 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -6990,7 +6990,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 stand-alone composite 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..745fbde811 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 stand-alone composite type
 DROP TABLE stuff;
 -- implicit casting
 CREATE TYPE person_type AS (id int, name text);
-- 
2.44.0


--66d7ms5uaqk6hs4e--





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [PATCH v1] Document that typed tables rely on CREATE TYPE
@ 2024-03-08 03:21  Erik Wienhold <[email protected]>
  0 siblings, 0 replies; 10+ messages in thread

From: Erik Wienhold @ 2024-03-08 03:21 UTC (permalink / raw)

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          | 8 +++++++-
 src/test/regress/expected/typed_table.out | 6 +++++-
 src/test/regress/sql/typed_table.sql      | 4 ++++
 4 files changed, 18 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 <replaceable class="parameter">numeric_literal</replaceable>, REM
       schema-qualified).  A typed table is tied to its type; for
       example the table will be dropped if the type is dropped
       (with <literal>DROP TYPE ... CASCADE</literal>).
+      Expects the composite type to have been created with
+      <xref linkend="sql-createtype"/>.
      </para>
 
      <para>
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 7014be8039..bef630139d 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -6975,8 +6975,14 @@ check_of_type(HeapTuple typetuple)
 		 * the type before the typed table creation/conversion commits.
 		 */
 		relation_close(typeRelation, NoLock);
+
+		if (!typeOk)
+			ereport(ERROR,
+					(errcode(ERRCODE_WRONG_OBJECT_TYPE),
+					 errmsg("type %s is not a composite type created with CREATE TYPE",
+							format_type_be(typ->oid))));
 	}
-	if (!typeOk)
+	else
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("type %s is not a composite type",
diff --git a/src/test/regress/expected/typed_table.out b/src/test/regress/expected/typed_table.out
index 2e47ecbcf5..bb21b69a1a 100644
--- a/src/test/regress/expected/typed_table.out
+++ b/src/test/regress/expected/typed_table.out
@@ -89,8 +89,12 @@ 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;
+CREATE TYPE simple AS ENUM ('a');
+CREATE TABLE of_simple OF simple;  -- not a composite type
+ERROR:  type simple is not a composite type
+DROP TYPE simple;
 -- implicit casting
 CREATE TYPE person_type AS (id int, name text);
 CREATE TABLE persons OF person_type;
diff --git a/src/test/regress/sql/typed_table.sql b/src/test/regress/sql/typed_table.sql
index 9ef0cdfcc7..eaa11b0f94 100644
--- a/src/test/regress/sql/typed_table.sql
+++ b/src/test/regress/sql/typed_table.sql
@@ -50,6 +50,10 @@ CREATE TABLE persons5 OF stuff; -- only CREATE TYPE AS types may be used
 
 DROP TABLE stuff;
 
+CREATE TYPE simple AS ENUM ('a');
+CREATE TABLE of_simple OF simple;  -- not a composite type
+DROP TYPE simple;
+
 
 -- implicit casting
 
-- 
2.44.0


--3rqrwxze3hgjbv2c--





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [PATCH v2] Document that typed tables rely on CREATE TYPE
@ 2024-03-08 03:21  Erik Wienhold <[email protected]>
  0 siblings, 0 replies; 10+ messages in thread

From: Erik Wienhold @ 2024-03-08 03:21 UTC (permalink / raw)

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 <replaceable class="parameter">numeric_literal</replaceable>, REM
       schema-qualified).  A typed table is tied to its type; for
       example the table will be dropped if the type is dropped
       (with <literal>DROP TYPE ... CASCADE</literal>).
+      Expects the composite type to have been created with
+      <xref linkend="sql-createtype"/>.
      </para>
 
      <para>
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


--gseuo2ww4jrnzphn--





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [PATCH v3] Document that typed tables rely on CREATE TYPE
@ 2024-03-08 03:21  Erik Wienhold <[email protected]>
  0 siblings, 0 replies; 10+ messages in thread

From: Erik Wienhold @ 2024-03-08 03:21 UTC (permalink / raw)

CREATE TABLE OF requires a stand-alone composite type.  Clarify that in
the error message.  Also reword the docs to better explain the
connection between created table and stand-alone composite type.

Reworded docs provided by David G. Johnston.
---
 doc/src/sgml/ref/create_table.sgml        | 18 +++++++++---------
 src/backend/commands/tablecmds.c          |  2 +-
 src/test/regress/expected/typed_table.out |  2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index dfb7822985..5c8c1edaed 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -249,19 +249,19 @@ WITH ( MODULUS <replaceable class="parameter">numeric_literal</replaceable>, REM
     <term><literal>OF <replaceable class="parameter">type_name</replaceable></literal></term>
     <listitem>
      <para>
-      Creates a <firstterm>typed table</firstterm>, which takes its
-      structure from the specified composite type (name optionally
-      schema-qualified).  A typed table is tied to its type; for
-      example the table will be dropped if the type is dropped
-      (with <literal>DROP TYPE ... CASCADE</literal>).
+      Creates a <firstterm>typed table</firstterm>, which takes its structure
+      from an existing (name optionally schema-qualified) stand-alone composite
+      type (i.e. created using <xref linkend="sql-createtype"/>) though it
+      still produces a new composite type as well.  The table will have
+      a dependency on the referenced type such that cascaded alter and drop
+      actions on the type will propagate to the table.
      </para>
 
      <para>
-      When a typed table is created, then the data types of the
-      columns are determined by the underlying composite type and are
-      not specified by the <literal>CREATE TABLE</literal> command.
+      A typed table always has the same column names and data types as the
+      type it is derived from, and you cannot specify additional columns.
       But the <literal>CREATE TABLE</literal> command can add defaults
-      and constraints to the table and can specify storage parameters.
+      and constraints to the table, as well as specify storage parameters.
      </para>
     </listitem>
    </varlistentry>
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 6741e721ae..8e9dbe4bee 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -6990,7 +6990,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 stand-alone composite 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..745fbde811 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 stand-alone composite type
 DROP TABLE stuff;
 -- implicit casting
 CREATE TYPE person_type AS (id int, name text);
-- 
2.44.0


--66d7ms5uaqk6hs4e--





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [PATCH v1] Document that typed tables rely on CREATE TYPE
@ 2024-03-08 03:21  Erik Wienhold <[email protected]>
  0 siblings, 0 replies; 10+ messages in thread

From: Erik Wienhold @ 2024-03-08 03:21 UTC (permalink / raw)

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          | 8 +++++++-
 src/test/regress/expected/typed_table.out | 6 +++++-
 src/test/regress/sql/typed_table.sql      | 4 ++++
 4 files changed, 18 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 <replaceable class="parameter">numeric_literal</replaceable>, REM
       schema-qualified).  A typed table is tied to its type; for
       example the table will be dropped if the type is dropped
       (with <literal>DROP TYPE ... CASCADE</literal>).
+      Expects the composite type to have been created with
+      <xref linkend="sql-createtype"/>.
      </para>
 
      <para>
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 7014be8039..bef630139d 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -6975,8 +6975,14 @@ check_of_type(HeapTuple typetuple)
 		 * the type before the typed table creation/conversion commits.
 		 */
 		relation_close(typeRelation, NoLock);
+
+		if (!typeOk)
+			ereport(ERROR,
+					(errcode(ERRCODE_WRONG_OBJECT_TYPE),
+					 errmsg("type %s is not a composite type created with CREATE TYPE",
+							format_type_be(typ->oid))));
 	}
-	if (!typeOk)
+	else
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("type %s is not a composite type",
diff --git a/src/test/regress/expected/typed_table.out b/src/test/regress/expected/typed_table.out
index 2e47ecbcf5..bb21b69a1a 100644
--- a/src/test/regress/expected/typed_table.out
+++ b/src/test/regress/expected/typed_table.out
@@ -89,8 +89,12 @@ 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;
+CREATE TYPE simple AS ENUM ('a');
+CREATE TABLE of_simple OF simple;  -- not a composite type
+ERROR:  type simple is not a composite type
+DROP TYPE simple;
 -- implicit casting
 CREATE TYPE person_type AS (id int, name text);
 CREATE TABLE persons OF person_type;
diff --git a/src/test/regress/sql/typed_table.sql b/src/test/regress/sql/typed_table.sql
index 9ef0cdfcc7..eaa11b0f94 100644
--- a/src/test/regress/sql/typed_table.sql
+++ b/src/test/regress/sql/typed_table.sql
@@ -50,6 +50,10 @@ CREATE TABLE persons5 OF stuff; -- only CREATE TYPE AS types may be used
 
 DROP TABLE stuff;
 
+CREATE TYPE simple AS ENUM ('a');
+CREATE TABLE of_simple OF simple;  -- not a composite type
+DROP TYPE simple;
+
 
 -- implicit casting
 
-- 
2.44.0


--3rqrwxze3hgjbv2c--





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [PATCH v2] Document that typed tables rely on CREATE TYPE
@ 2024-03-08 03:21  Erik Wienhold <[email protected]>
  0 siblings, 0 replies; 10+ messages in thread

From: Erik Wienhold @ 2024-03-08 03:21 UTC (permalink / raw)

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 <replaceable class="parameter">numeric_literal</replaceable>, REM
       schema-qualified).  A typed table is tied to its type; for
       example the table will be dropped if the type is dropped
       (with <literal>DROP TYPE ... CASCADE</literal>).
+      Expects the composite type to have been created with
+      <xref linkend="sql-createtype"/>.
      </para>
 
      <para>
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


--gseuo2ww4jrnzphn--





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [PATCH v1] Document that typed tables rely on CREATE TYPE
@ 2024-03-08 03:21  Erik Wienhold <[email protected]>
  0 siblings, 0 replies; 10+ messages in thread

From: Erik Wienhold @ 2024-03-08 03:21 UTC (permalink / raw)

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          | 8 +++++++-
 src/test/regress/expected/typed_table.out | 6 +++++-
 src/test/regress/sql/typed_table.sql      | 4 ++++
 4 files changed, 18 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 <replaceable class="parameter">numeric_literal</replaceable>, REM
       schema-qualified).  A typed table is tied to its type; for
       example the table will be dropped if the type is dropped
       (with <literal>DROP TYPE ... CASCADE</literal>).
+      Expects the composite type to have been created with
+      <xref linkend="sql-createtype"/>.
      </para>
 
      <para>
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 7014be8039..bef630139d 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -6975,8 +6975,14 @@ check_of_type(HeapTuple typetuple)
 		 * the type before the typed table creation/conversion commits.
 		 */
 		relation_close(typeRelation, NoLock);
+
+		if (!typeOk)
+			ereport(ERROR,
+					(errcode(ERRCODE_WRONG_OBJECT_TYPE),
+					 errmsg("type %s is not a composite type created with CREATE TYPE",
+							format_type_be(typ->oid))));
 	}
-	if (!typeOk)
+	else
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("type %s is not a composite type",
diff --git a/src/test/regress/expected/typed_table.out b/src/test/regress/expected/typed_table.out
index 2e47ecbcf5..bb21b69a1a 100644
--- a/src/test/regress/expected/typed_table.out
+++ b/src/test/regress/expected/typed_table.out
@@ -89,8 +89,12 @@ 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;
+CREATE TYPE simple AS ENUM ('a');
+CREATE TABLE of_simple OF simple;  -- not a composite type
+ERROR:  type simple is not a composite type
+DROP TYPE simple;
 -- implicit casting
 CREATE TYPE person_type AS (id int, name text);
 CREATE TABLE persons OF person_type;
diff --git a/src/test/regress/sql/typed_table.sql b/src/test/regress/sql/typed_table.sql
index 9ef0cdfcc7..eaa11b0f94 100644
--- a/src/test/regress/sql/typed_table.sql
+++ b/src/test/regress/sql/typed_table.sql
@@ -50,6 +50,10 @@ CREATE TABLE persons5 OF stuff; -- only CREATE TYPE AS types may be used
 
 DROP TABLE stuff;
 
+CREATE TYPE simple AS ENUM ('a');
+CREATE TABLE of_simple OF simple;  -- not a composite type
+DROP TYPE simple;
+
 
 -- implicit casting
 
-- 
2.44.0


--3rqrwxze3hgjbv2c--





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* [PATCH v2] Document that typed tables rely on CREATE TYPE
@ 2024-03-08 03:21  Erik Wienhold <[email protected]>
  0 siblings, 0 replies; 10+ messages in thread

From: Erik Wienhold @ 2024-03-08 03:21 UTC (permalink / raw)

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 <replaceable class="parameter">numeric_literal</replaceable>, REM
       schema-qualified).  A typed table is tied to its type; for
       example the table will be dropped if the type is dropped
       (with <literal>DROP TYPE ... CASCADE</literal>).
+      Expects the composite type to have been created with
+      <xref linkend="sql-createtype"/>.
      </para>
 
      <para>
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


--gseuo2ww4jrnzphn--





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* docs: Validation error with xmllint 2.15.0
@ 2025-09-22 01:50  Erik Wienhold <[email protected]>
  0 siblings, 1 reply; 10+ messages in thread

From: Erik Wienhold @ 2025-09-22 01:50 UTC (permalink / raw)
  To: [email protected]

I just upgraded to libxml2 2.15.0 and now the docs no longer validate
with the following error when running make html:

	/usr/bin/xmllint --nonet --path . --path . --output postgres-full.xml --noent --valid postgres.sgml
	ref/pg_combinebackup.sgml:317: validity error : standalone: normalization of attribute linkend on xref by external subset declaration
	   state of the cluster using <xref linkend="app-pgchecksums "/> is
	                                                              ^

Downgrading to libxml2 2.14.6 fixes the validation.  There's also an
unreleased fix [1] for this regression.  But I figure that it's best to
just remove the insignificant whitespace with the attached patch.

[1] https://gitlab.gnome.org/GNOME/libxml2/-/commit/da45a190f718e8e2f0e3d2a6325ffa23abc8b90c

-- 
Erik Wienhold


^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: docs: Validation error with xmllint 2.15.0
@ 2025-09-22 07:58  Daniel Gustafsson <[email protected]>
  parent: Erik Wienhold <[email protected]>
  0 siblings, 0 replies; 10+ messages in thread

From: Daniel Gustafsson @ 2025-09-22 07:58 UTC (permalink / raw)
  To: Erik Wienhold <[email protected]>; +Cc: [email protected]

> On 22 Sep 2025, at 03:50, Erik Wienhold <[email protected]> wrote:

> Downgrading to libxml2 2.14.6 fixes the validation.  There's also an
> unreleased fix [1] for this regression.  But I figure that it's best to
> just remove the insignificant whitespace with the attached patch.

Agreed, not least because that makes all xref tags consistent in style which
has a value of its own. Will fix.

--
Daniel Gustafsson






^ permalink  raw  reply  [nested|flat] 10+ messages in thread


end of thread, other threads:[~2025-09-22 07:58 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-03-08 03:21 [PATCH v2] Document that typed tables rely on CREATE TYPE Erik Wienhold <[email protected]>
2024-03-08 03:21 [PATCH v3] Document that typed tables rely on CREATE TYPE Erik Wienhold <[email protected]>
2024-03-08 03:21 [PATCH v2] Document that typed tables rely on CREATE TYPE Erik Wienhold <[email protected]>
2024-03-08 03:21 [PATCH v1] Document that typed tables rely on CREATE TYPE Erik Wienhold <[email protected]>
2024-03-08 03:21 [PATCH v2] Document that typed tables rely on CREATE TYPE Erik Wienhold <[email protected]>
2024-03-08 03:21 [PATCH v3] Document that typed tables rely on CREATE TYPE Erik Wienhold <[email protected]>
2024-03-08 03:21 [PATCH v1] Document that typed tables rely on CREATE TYPE Erik Wienhold <[email protected]>
2024-03-08 03:21 [PATCH v1] Document that typed tables rely on CREATE TYPE Erik Wienhold <[email protected]>
2025-09-22 01:50 docs: Validation error with xmllint 2.15.0 Erik Wienhold <[email protected]>
2025-09-22 07:58 ` Re: docs: Validation error with xmllint 2.15.0 Daniel Gustafsson <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox