From eb15f26d577a11319b9429fb84f752a0135918db Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 23 Jul 2011 16:59:49 -0400 Subject: Rethink behavior of CREATE OR REPLACE during CREATE EXTENSION. The original implementation simply did nothing when replacing an existing object during CREATE EXTENSION. The folly of this was exposed by a report from Marc Munro: if the existing object belongs to another extension, we are left in an inconsistent state. We should insist that the object does not belong to another extension, and then add it to the current extension if not already a member. --- src/backend/commands/functioncmds.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/backend/commands/functioncmds.c') diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index 03da168ff2c..92abd44a600 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -1489,6 +1489,7 @@ CreateCast(CreateCastStmt *stmt) char sourcetyptype; char targettyptype; Oid funcid; + Oid castid; int nargs; char castcontext; char castmethod; @@ -1734,13 +1735,13 @@ CreateCast(CreateCastStmt *stmt) tuple = heap_form_tuple(RelationGetDescr(relation), values, nulls); - simple_heap_insert(relation, tuple); + castid = simple_heap_insert(relation, tuple); CatalogUpdateIndexes(relation, tuple); /* make dependency entries */ myself.classId = CastRelationId; - myself.objectId = HeapTupleGetOid(tuple); + myself.objectId = castid; myself.objectSubId = 0; /* dependency on source type */ @@ -1765,11 +1766,10 @@ CreateCast(CreateCastStmt *stmt) } /* dependency on extension */ - recordDependencyOnCurrentExtension(&myself); + recordDependencyOnCurrentExtension(&myself, false); /* Post creation hook for new cast */ - InvokeObjectAccessHook(OAT_POST_CREATE, - CastRelationId, myself.objectId, 0); + InvokeObjectAccessHook(OAT_POST_CREATE, CastRelationId, castid, 0); heap_freetuple(tuple); -- cgit v1.2.3