diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-07-31 20:09:10 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-07-31 20:09:10 +0000 |
commit | 09d3670df3e4593be1d2299a62d982829016b847 (patch) | |
tree | 7a62e91c1cf595d0334dd2c196d1c79835cc267b /src/backend/storage/large_object/inv_api.c | |
parent | 4cd72b53b9975bab5f4ca0792cf4f54c84829404 (diff) | |
download | postgresql-09d3670df3e4593be1d2299a62d982829016b847.tar.gz postgresql-09d3670df3e4593be1d2299a62d982829016b847.zip |
Change the relation_open protocol so that we obtain lock on a relation
(table or index) before trying to open its relcache entry. This fixes
race conditions in which someone else commits a change to the relation's
catalog entries while we are in process of doing relcache load. Problems
of that ilk have been reported sporadically for years, but it was not
really practical to fix until recently --- for instance, the recent
addition of WAL-log support for in-place updates helped.
Along the way, remove pg_am.amconcurrent: all AMs are now expected to support
concurrent update.
Diffstat (limited to 'src/backend/storage/large_object/inv_api.c')
-rw-r--r-- | src/backend/storage/large_object/inv_api.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c index fd6ae5abc32..582eabdb2ad 100644 --- a/src/backend/storage/large_object/inv_api.c +++ b/src/backend/storage/large_object/inv_api.c @@ -17,7 +17,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/large_object/inv_api.c,v 1.118 2006/07/14 14:52:23 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/storage/large_object/inv_api.c,v 1.119 2006/07/31 20:09:05 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -69,7 +69,7 @@ open_lo_relation(void) if (lo_heap_r == NULL) lo_heap_r = heap_open(LargeObjectRelationId, RowExclusiveLock); if (lo_index_r == NULL) - lo_index_r = index_open(LargeObjectLOidPNIndexId); + lo_index_r = index_open(LargeObjectLOidPNIndexId, RowExclusiveLock); } PG_CATCH(); { @@ -103,7 +103,7 @@ close_lo_relation(bool isCommit) CurrentResourceOwner = TopTransactionResourceOwner; if (lo_index_r) - index_close(lo_index_r); + index_close(lo_index_r, NoLock); if (lo_heap_r) heap_close(lo_heap_r, NoLock); } @@ -314,7 +314,7 @@ inv_getsize(LargeObjectDesc *obj_desc) BTEqualStrategyNumber, F_OIDEQ, ObjectIdGetDatum(obj_desc->id)); - sd = index_beginscan(lo_heap_r, lo_index_r, true, + sd = index_beginscan(lo_heap_r, lo_index_r, obj_desc->snapshot, 1, skey); /* @@ -425,7 +425,7 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes) BTGreaterEqualStrategyNumber, F_INT4GE, Int32GetDatum(pageno)); - sd = index_beginscan(lo_heap_r, lo_index_r, true, + sd = index_beginscan(lo_heap_r, lo_index_r, obj_desc->snapshot, 2, skey); while ((tuple = index_getnext(sd, ForwardScanDirection)) != NULL) @@ -541,7 +541,7 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes) BTGreaterEqualStrategyNumber, F_INT4GE, Int32GetDatum(pageno)); - sd = index_beginscan(lo_heap_r, lo_index_r, false /* got lock */, + sd = index_beginscan(lo_heap_r, lo_index_r, obj_desc->snapshot, 2, skey); oldtuple = NULL; |