diff options
author | Bruce Momjian <bruce@momjian.us> | 2003-02-19 23:41:15 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2003-02-19 23:41:15 +0000 |
commit | 69c049cef4ad2bce1b6ac9e96544cbaaa907378e (patch) | |
tree | 410877efaea77947caf292a33b386b517018ccd5 /src/backend/commands/typecmds.c | |
parent | e2a618fe25f9e02f17dacff4c3d2f117b56c7715 (diff) | |
download | postgresql-69c049cef4ad2bce1b6ac9e96544cbaaa907378e.tar.gz postgresql-69c049cef4ad2bce1b6ac9e96544cbaaa907378e.zip |
Back out LOCKTAG changes by Rod Taylor, pending code review. Sorry.
Diffstat (limited to 'src/backend/commands/typecmds.c')
-rw-r--r-- | src/backend/commands/typecmds.c | 72 |
1 files changed, 8 insertions, 64 deletions
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c index 7ae852672c5..f3f99c6b33b 100644 --- a/src/backend/commands/typecmds.c +++ b/src/backend/commands/typecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.31 2003/02/19 04:02:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.32 2003/02/19 23:41:15 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -353,12 +353,6 @@ RemoveType(List *names, DropBehavior behavior) elog(ERROR, "Type \"%s\" does not exist", TypeNameToString(typename)); - /* - * Grab an exclusive lock on the type id, the SearchSysCache confirms - * the type still exists after locking - */ - LockObject(typeoid, RelOid_pg_type, AccessExclusiveLock); - tup = SearchSysCache(TYPEOID, ObjectIdGetDatum(typeoid), 0, 0, 0); @@ -382,9 +376,6 @@ RemoveType(List *names, DropBehavior behavior) object.objectSubId = 0; performDeletion(&object, behavior); - - /* Hold the lock until the end of the transaction */ - UnlockObject(typeoid, RelOid_pg_type, NoLock); } @@ -689,7 +680,7 @@ void RemoveDomain(List *names, DropBehavior behavior) { TypeName *typename; - Oid domainoid; + Oid typeoid; HeapTuple tup; char typtype; ObjectAddress object; @@ -701,26 +692,20 @@ RemoveDomain(List *names, DropBehavior behavior) typename->arrayBounds = NIL; /* Use LookupTypeName here so that shell types can be removed. */ - domainoid = LookupTypeName(typename); - if (!OidIsValid(domainoid)) + typeoid = LookupTypeName(typename); + if (!OidIsValid(typeoid)) elog(ERROR, "Type \"%s\" does not exist", TypeNameToString(typename)); - /* - * Lock the domain. The SearchSysCache confirms the domain still exists - * after locking - */ - LockObject(domainoid, RelOid_pg_type, AccessExclusiveLock); - tup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(domainoid), + ObjectIdGetDatum(typeoid), 0, 0, 0); if (!HeapTupleIsValid(tup)) elog(ERROR, "RemoveDomain: type \"%s\" does not exist", TypeNameToString(typename)); /* Permission check: must own type or its namespace */ - if (!pg_type_ownercheck(domainoid, GetUserId()) && + if (!pg_type_ownercheck(typeoid, GetUserId()) && !pg_namespace_ownercheck(((Form_pg_type) GETSTRUCT(tup))->typnamespace, GetUserId())) aclcheck_error(ACLCHECK_NOT_OWNER, TypeNameToString(typename)); @@ -738,13 +723,10 @@ RemoveDomain(List *names, DropBehavior behavior) * Do the deletion */ object.classId = RelOid_pg_type; - object.objectId = domainoid; + object.objectId = typeoid; object.objectSubId = 0; performDeletion(&object, behavior); - - /* Hold the lock until the end of the transaction */ - UnlockObject(domainoid, RelOid_pg_type, NoLock); } @@ -959,12 +941,6 @@ AlterDomainDefault(List *names, Node *defaultRaw) elog(ERROR, "Type \"%s\" does not exist", TypeNameToString(typename)); - /* - * Lock the domain. The SearchSysCacheCopy confirms the type - * still exists after locking - */ - LockObject(domainoid, RelOid_pg_type, AccessExclusiveLock); - tup = SearchSysCacheCopy(TYPEOID, ObjectIdGetDatum(domainoid), 0, 0, 0); @@ -1049,7 +1025,6 @@ AlterDomainDefault(List *names, Node *defaultRaw) /* Clean up */ heap_close(rel, NoLock); heap_freetuple(newtuple); - UnlockObject(domainoid, RelOid_pg_type, NoLock); }; /* @@ -1081,12 +1056,6 @@ AlterDomainNotNull(List *names, bool notNull) elog(ERROR, "Type \"%s\" does not exist", TypeNameToString(typename)); - /* - * Lock the domain. The SearchSysCacheCopy confirms the domain - * still exists after locking - */ - LockObject(domainoid, RelOid_pg_type, AccessExclusiveLock); - tup = SearchSysCacheCopy(TYPEOID, ObjectIdGetDatum(domainoid), 0, 0, 0); @@ -1168,7 +1137,6 @@ AlterDomainNotNull(List *names, bool notNull) /* Clean up */ heap_freetuple(tup); heap_close(typrel, RowExclusiveLock); - UnlockObject(domainoid, RelOid_pg_type, NoLock); } /* @@ -1204,12 +1172,6 @@ AlterDomainDropConstraint(List *names, const char *constrName, DropBehavior beha elog(ERROR, "Type \"%s\" does not exist", TypeNameToString(typename)); - /* - * Lock the domain. The SearchSysCacheCopy confirms the type still - * exists after locking. - */ - LockObject(domainoid, RelOid_pg_type, AccessExclusiveLock); - tup = SearchSysCacheCopy(TYPEOID, ObjectIdGetDatum(domainoid), 0, 0, 0); @@ -1257,7 +1219,6 @@ AlterDomainDropConstraint(List *names, const char *constrName, DropBehavior beha heap_close(conrel, RowExclusiveLock); heap_close(rel, NoLock); - UnlockObject(domainoid, RelOid_pg_type, NoLock); }; /* @@ -1298,12 +1259,6 @@ AlterDomainAddConstraint(List *names, Node *newConstraint) elog(ERROR, "Type \"%s\" does not exist", TypeNameToString(typename)); - /* - * Lock the domain. The SearchSysCacheCopy confirms the domain - * still exists after locking. - */ - LockObject(domainoid, RelOid_pg_type, AccessExclusiveLock); - tup = SearchSysCacheCopy(TYPEOID, ObjectIdGetDatum(domainoid), 0, 0, 0); @@ -1438,7 +1393,6 @@ AlterDomainAddConstraint(List *names, Node *newConstraint) /* Clean up */ heap_close(typrel, RowExclusiveLock); - UnlockObject(domainoid, RelOid_pg_type, NoLock); } /* @@ -1742,10 +1696,7 @@ GetDomainConstraints(Oid typeOid) Form_pg_type typTup; ScanKeyData key[1]; SysScanDesc scan; - - /* Lock the domain */ - LockObject(typeOid, RelOid_pg_type, AccessShareLock); - + tup = SearchSysCache(TYPEOID, ObjectIdGetDatum(typeOid), 0, 0, 0); @@ -1873,12 +1824,6 @@ AlterTypeOwner(List *names, AclId newOwnerSysId) elog(ERROR, "Type \"%s\" does not exist", TypeNameToString(typename)); - /* - * Lock the type. The SearchSysCacheCopy serves to confirm the - * domain still exists after locking - */ - LockObject(typeOid, RelOid_pg_type, AccessExclusiveLock); - tup = SearchSysCacheCopy(TYPEOID, ObjectIdGetDatum(typeOid), 0, 0, 0); @@ -1901,5 +1846,4 @@ AlterTypeOwner(List *names, AclId newOwnerSysId) /* Clean up */ heap_close(rel, RowExclusiveLock); - UnlockObject(typeOid, RelOid_pg_type, NoLock); } |