aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/functioncmds.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-07-23 16:59:39 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-07-23 16:59:39 -0400
commit988cccc620dd8c16d77f88ede167b22056176324 (patch)
treedfbe1be00080bf91976341ce55a5624c2403b796 /src/backend/commands/functioncmds.c
parent6f1be5a67a758499beab0082b6e63b3040913268 (diff)
downloadpostgresql-988cccc620dd8c16d77f88ede167b22056176324.tar.gz
postgresql-988cccc620dd8c16d77f88ede167b22056176324.zip
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.
Diffstat (limited to 'src/backend/commands/functioncmds.c')
-rw-r--r--src/backend/commands/functioncmds.c10
1 files changed, 5 insertions, 5 deletions
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);