1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-24 14:22:24 +03:00

Add NOWAIT option to LOCK command

This commit is contained in:
Tatsuo Ishii
2004-03-11 01:47:41 +00:00
parent 60a068b389
commit 0b86ade1c2
9 changed files with 56 additions and 15 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.162 2004/01/16 20:51:30 tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.163 2004/03/11 01:47:35 ishii Exp $
*
*
* INTERFACE ROUTINES
@ -464,6 +464,33 @@ relation_open(Oid relationId, LOCKMODE lockmode)
return r;
}
Relation
conditional_relation_open(Oid relationId, LOCKMODE lockmode, bool nowait)
{
Relation r;
Assert(lockmode >= NoLock && lockmode < MAX_LOCKMODES);
/* The relcache does all the real work... */
r = RelationIdGetRelation(relationId);
if (!RelationIsValid(r))
elog(ERROR, "could not open relation with OID %u", relationId);
if (lockmode != NoLock)
{
if (nowait)
{
if (!ConditionalLockRelation(r, lockmode))
elog(ERROR, "could not aquire relation lock");
}
else
LockRelation(r, lockmode);
}
return r;
}
/* ----------------
* relation_openrv - open any relation specified by a RangeVar
*