tt0v1-only-composite.patch
text/plain
Filename: tt0v1-only-composite.patch
Type: text/plain
Part: 0
Message:
Re: Typed table DDL loose ends
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/parser/parse_utilcmd.c | 0 | 0 |
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index eba890b..31b1fb0 100644
*** a/src/backend/parser/parse_utilcmd.c
--- b/src/backend/parser/parse_utilcmd.c
***************
*** 825,830 **** transformOfType(CreateStmtContext *cxt, TypeName *ofTypename)
--- 825,831 ----
TupleDesc tupdesc;
int i;
Oid ofTypeId;
+ bool typeOk = false;
AssertArg(ofTypename);
***************
*** 833,842 **** transformOfType(CreateStmtContext *cxt, TypeName *ofTypename)
ofTypeId = HeapTupleGetOid(tuple);
ofTypename->typeOid = ofTypeId; /* cached for later */
! if (typ->typtype != TYPTYPE_COMPOSITE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
! errmsg("type %s is not a composite type",
format_type_be(ofTypeId))));
tupdesc = lookup_rowtype_tupdesc(ofTypeId, -1);
--- 834,852 ----
ofTypeId = HeapTupleGetOid(tuple);
ofTypename->typeOid = ofTypeId; /* cached for later */
! if (typ->typtype == TYPTYPE_COMPOSITE)
! {
! Relation typeRelation;
!
! Assert(OidIsValid(typ->typrelid));
! typeRelation = relation_open(typ->typrelid, AccessShareLock);
! typeOk = (typeRelation->rd_rel->relkind == RELKIND_COMPOSITE_TYPE);
! relation_close(typeRelation, NoLock);
! }
! if (!typeOk)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
! errmsg("type %s is not a stand-alone composite type",
format_type_be(ofTypeId))));
tupdesc = lookup_rowtype_tupdesc(ofTypeId, -1);
diff --git a/src/test/regress/expected/tyindex 0874a64..69ad58e 100644
*** a/src/test/regress/expected/typed_table.out
--- b/src/test/regress/expected/typed_table.out
***************
*** 91,96 **** DETAIL: drop cascades to table persons
--- 91,98 ----
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 stand-alone composite type
DROP TABLE stuff;
-- implicit casting
CREATE TYPE person_type AS (id int, name text);
diff --git a/src/test/regress/sql/typed_table.sqindex b0d452c..25aaccb 100644
*** a/src/test/regress/sql/typed_table.sql
--- b/src/test/regress/sql/typed_table.sql
***************
*** 46,51 **** CREATE TABLE persons4 OF person_type (
--- 46,53 ----
DROP TYPE person_type RESTRICT;
DROP TYPE person_type CASCADE;
+ CREATE TABLE persons5 OF stuff; -- only CREATE TYPE AS types may be used
+
DROP TABLE stuff;