diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-09-30 23:21:26 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-09-30 23:21:26 +0000 |
commit | d2af5f8a3e89f02dd54949fa42e2dcd31ddcd5c7 (patch) | |
tree | 122463e70e53c0fd7ae418dc8eb9057ffedae130 /src/backend/access/index/indexam.c | |
parent | d6748843069f7dd4205cd85b60977b5414647635 (diff) | |
download | postgresql-d2af5f8a3e89f02dd54949fa42e2dcd31ddcd5c7.tar.gz postgresql-d2af5f8a3e89f02dd54949fa42e2dcd31ddcd5c7.zip |
Adjust index locking rules as per my proposal of earlier today. You
now are supposed to take some kind of lock on an index whenever you
are going to access the index contents, rather than relying only on a
lock on the parent table.
Diffstat (limited to 'src/backend/access/index/indexam.c')
-rw-r--r-- | src/backend/access/index/indexam.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index 949deb27a28..7c698fb48a2 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.74 2004/08/29 04:12:20 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.75 2004/09/30 23:21:14 tgl Exp $ * * INTERFACE ROUTINES * index_open - open an index relation by relation OID @@ -112,10 +112,15 @@ /* ---------------- * index_open - open an index relation by relation OID * - * Note: we acquire no lock on the index. An AccessShareLock is - * acquired by index_beginscan (and released by index_endscan). - * Generally, the caller should already hold some type of lock on - * the parent relation to ensure that the index doesn't disappear. + * Note: we acquire no lock on the index. A lock is not needed when + * simply examining the index reldesc; the index's schema information + * is considered to be protected by the lock that the caller had better + * be holding on the parent relation. Some type of lock should be + * obtained on the index before physically accessing it, however. + * This is handled automatically for most uses by index_beginscan + * and index_endscan for scan cases, or by ExecOpenIndices and + * ExecCloseIndices for update cases. Other callers will need to + * obtain their own locks. * * This is a convenience routine adapted for indexscan use. * Some callers may prefer to use relation_open directly. |