Hi,
I can understand why we have relation_openrv and try_relation_open,
but relation_open_nowait can be merged with relation_open.
Or there is something i'm missing? attached is a patch that do the merge.
--
regards,
Jaime Casanova
Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning.
Richard Cook
Index: contrib/dblink/dblink.c
===
RCS file: /home/postgres/cvsrepo/pgsql/contrib/dblink/dblink.c,v
retrieving revision 1.65
diff -c -r1.65 dblink.c
*** contrib/dblink/dblink.c 27 Aug 2007 01:24:50 - 1.65
--- contrib/dblink/dblink.c 28 Sep 2007 02:26:18 -
***
*** 1690,1696
AclResult aclresult;
/* open relation using relid, check permissions, get tupdesc */
! rel = relation_open(relid, AccessShareLock);
aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
ACL_SELECT);
--- 1690,1696
AclResult aclresult;
/* open relation using relid, check permissions, get tupdesc */
! rel = relation_open(relid, AccessShareLock, true);
aclresult = pg_class_aclcheck(RelationGetRelid(rel), GetUserId(),
ACL_SELECT);
***
*** 1819,1825
/*
* Open relation using relid
*/
! rel = relation_open(relid, AccessShareLock);
tupdesc = rel-rd_att;
natts = tupdesc-natts;
--- 1819,1825
/*
* Open relation using relid
*/
! rel = relation_open(relid, AccessShareLock, true);
tupdesc = rel-rd_att;
natts = tupdesc-natts;
***
*** 1902,1908
/*
* Open relation using relid
*/
! rel = relation_open(relid, AccessShareLock);
tupdesc = rel-rd_att;
natts = tupdesc-natts;
--- 1902,1908
/*
* Open relation using relid
*/
! rel = relation_open(relid, AccessShareLock, true);
tupdesc = rel-rd_att;
natts = tupdesc-natts;
***
*** 1954,1960
/*
* Open relation using relid
*/
! rel = relation_open(relid, AccessShareLock);
tupdesc = rel-rd_att;
natts = tupdesc-natts;
--- 1954,1960
/*
* Open relation using relid
*/
! rel = relation_open(relid, AccessShareLock, true);
tupdesc = rel-rd_att;
natts = tupdesc-natts;
***
*** 2098,2104
/*
* Open relation using relid
*/
! rel = relation_open(relid, AccessShareLock);
tupdesc = CreateTupleDescCopy(rel-rd_att);
relation_close(rel, AccessShareLock);
--- 2098,2104
/*
* Open relation using relid
*/
! rel = relation_open(relid, AccessShareLock, true);
tupdesc = CreateTupleDescCopy(rel-rd_att);
relation_close(rel, AccessShareLock);
Index: contrib/pgstattuple/pgstattuple.c
===
RCS file: /home/postgres/cvsrepo/pgsql/contrib/pgstattuple/pgstattuple.c,v
retrieving revision 1.30
diff -c -r1.30 pgstattuple.c
*** contrib/pgstattuple/pgstattuple.c 20 Sep 2007 17:56:30 - 1.30
--- contrib/pgstattuple/pgstattuple.c 28 Sep 2007 02:22:00 -
***
*** 183,189
(errmsg(must be superuser to use pgstattuple functions;
/* open relation */
! rel = relation_open(relid, AccessShareLock);
PG_RETURN_DATUM(pgstat_relation(rel, fcinfo));
}
--- 183,189
(errmsg(must be superuser to use pgstattuple functions;
/* open relation */
! rel = relation_open(relid, AccessShareLock, true);
PG_RETURN_DATUM(pgstat_relation(rel, fcinfo));
}
Index: src/backend/access/heap/heapam.c
===
RCS file: /home/postgres/cvsrepo/pgsql/src/backend/access/heap/heapam.c,v
retrieving revision 1.242
diff -c -r1.242 heapam.c
*** src/backend/access/heap/heapam.c 21 Sep 2007 21:25:42 - 1.242
--- src/backend/access/heap/heapam.c 28 Sep 2007 02:51:24 -
***
*** 819,824
--- 819,827
* obtained on the relation. (Generally, NoLock should only be
* used if the caller knows it has some appropriate lock on the
* relation already.)
+ *
+ * if wait is false open but don't wait for lock, instead throw an error
+ * when the requested lock is not immediately obtainable.
*
* An error is raised if the relation does not exist.
*
***
*** 827,833
*
*/
Relation
! relation_open(Oid relationId, LOCKMODE lockmode)
{
Relation r;
--- 830,836
*
*/
Relation
! relation_open(Oid relationId, LOCKMODE lockmode, bool wait)
{
Relation r;
***
*** 835,842
/* Get the lock before trying to open the relcache entry */
if (lockmode != NoLock)
! LockRelationOid(relationId, lockmode);
!
/* The relcache does all the real work... */
r =