1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

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.
This commit is contained in:
Tom Lane
2011-07-23 16:59:39 -04:00
parent 6f1be5a67a
commit 988cccc620
14 changed files with 61 additions and 36 deletions

View File

@ -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);