From 1e647cb0e329b88c3fa5bc77aacf9f140f06b231 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Thu, 7 Jan 2010 02:41:16 +0000 Subject: [PATCH] Improve a couple of comments relating to large object snapshot management. --- src/backend/catalog/aclchk.c | 15 +++++---------- src/backend/catalog/pg_largeobject.c | 8 +++++--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c index 00244d9043..0bcdffb789 100644 --- a/src/backend/catalog/aclchk.c +++ b/src/backend/catalog/aclchk.c @@ -3515,16 +3515,11 @@ pg_language_aclmask(Oid lang_oid, Oid roleid, /* * Exported routine for examining a user's privileges for a largeobject * - * The reason why this interface has an argument of snapshot is that - * we apply a snapshot available on lo_open(), not SnapshotNow, when - * it is opened as read-only mode. - * If we could see the metadata and data from inconsistent viewpoint, - * it will give us much confusion. So, we need to provide an interface - * which takes an argument of snapshot. - * - * If the caller refers a large object with a certain snapshot except - * for SnapshotNow, its permission checks should be also applied in - * the same snapshot. + * When a large object is opened for reading, it is opened relative to the + * caller's snapshot, but when it is opened for writing, it is always relative + * to SnapshotNow, as documented in doc/src/sgml/lobj.sgml. This function + * takes a snapshot argument so that the permissions check can be made relative + * to the same snapshot that will be used to read the underlying data. */ AclMode pg_largeobject_aclmask_snapshot(Oid lobj_oid, Oid roleid, diff --git a/src/backend/catalog/pg_largeobject.c b/src/backend/catalog/pg_largeobject.c index 76178f1f27..0751af7dc4 100644 --- a/src/backend/catalog/pg_largeobject.c +++ b/src/backend/catalog/pg_largeobject.c @@ -251,9 +251,11 @@ LargeObjectAlterOwner(Oid loid, Oid newOwnerId) * We don't use the system cache to for large object metadata, for fear of * using too much local memory. * - * Note that LargeObjectExists always scans the system catalog - * with SnapshotNow, so it is unavailable to use to check - * existence in read-only accesses. + * This function always scans the system catalog using SnapshotNow, so it + * should not be used when a large object is opened in read-only mode (because + * large objects opened in read only mode are supposed to be viewed relative + * to the caller's snapshot, whereas in read-write mode they are relative to + * SnapshotNow). */ bool LargeObjectExists(Oid loid) -- 2.39.5