create-composite-type.patch
text/x-patch
Filename: create-composite-type.patch
Type: text/x-patch
Part: 0
Message:
create composite type error message
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/commands/typecmds.c | 19 | 0 |
Index: src/backend/commands/typecmds.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/commands/typecmds.c,v
retrieving revision 1.145
diff -u -3 -p -r1.145 typecmds.c
--- src/backend/commands/typecmds.c 2 Jan 2010 16:57:39 -0000 1.145
+++ src/backend/commands/typecmds.c 18 Jan 2010 23:46:45 -0000
@@ -1509,6 +1509,8 @@ Oid
DefineCompositeType(const RangeVar *typevar, List *coldeflist)
{
CreateStmt *createStmt = makeNode(CreateStmt);
+ Oid old_type_oid;
+ Oid typeNamespace;
if (coldeflist == NIL)
ereport(ERROR,
@@ -1528,6 +1530,23 @@ DefineCompositeType(const RangeVar *type
createStmt->tablespacename = NULL;
/*
+ * Check for collision with an existing type name. If there is one and
+ * it's an autogenerated array, we can rename it out of the way.
+ */
+ typeNamespace = RangeVarGetCreationNamespace(createStmt->relation);
+ old_type_oid = GetSysCacheOid(TYPENAMENSP,
+ CStringGetDatum(createStmt->relation->relname),
+ ObjectIdGetDatum(typeNamespace),
+ 0, 0);
+ if (OidIsValid(old_type_oid))
+ {
+ if (!moveArrayTypeName(old_type_oid, createStmt->relation->relname, typeNamespace))
+ ereport(ERROR,
+ (errcode(ERRCODE_DUPLICATE_OBJECT),
+ errmsg("type \"%s\" already exists", createStmt->relation->relname)));
+ }
+
+ /*
* finally create the relation...
*/
return DefineRelation(createStmt, RELKIND_COMPOSITE_TYPE);