aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/heap/heapam.c
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>2004-03-11 01:47:41 +0000
committerTatsuo Ishii <ishii@postgresql.org>2004-03-11 01:47:41 +0000
commit0b86ade1c2f3dcd2407e535baad1654e65252316 (patch)
treef643be1064f229e2245c30467e2d12923ba0f677 /src/backend/access/heap/heapam.c
parent60a068b3897a27cbb1a13a6b050d05a0ca479055 (diff)
downloadpostgresql-0b86ade1c2f3dcd2407e535baad1654e65252316.tar.gz
postgresql-0b86ade1c2f3dcd2407e535baad1654e65252316.zip
Add NOWAIT option to LOCK command
Diffstat (limited to 'src/backend/access/heap/heapam.c')
-rw-r--r--src/backend/access/heap/heapam.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index d98e3fd16c2..902f0621377 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -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
*