More cleanups for the recent large object permissions patch.
authorRobert Haas <[email protected]>
Mon, 21 Dec 2009 01:34:11 +0000 (01:34 +0000)
committerRobert Haas <[email protected]>
Mon, 21 Dec 2009 01:34:11 +0000 (01:34 +0000)
Rewrite or adjust various comments for clarity.  Remove one bogus comment that
doesn't reflect what the code actually does.  Improve the description of the
lo_compat_privileges option.

src/backend/catalog/aclchk.c
src/backend/catalog/pg_largeobject.c
src/backend/commands/comment.c
src/backend/utils/adt/acl.c
src/backend/utils/misc/guc.c

index 809df7a573b9a240d38679f43032e2fdcf8bcbe5..b0aea415d2a830b65424ef07b6f802a28a0e63f2 100644 (file)
@@ -4261,9 +4261,8 @@ pg_language_ownercheck(Oid lan_oid, Oid roleid)
 /*
  * Ownership check for a largeobject (specified by OID)
  *
- * Note that we have no candidate to call this routine with a certain
- * snapshot except for SnapshotNow, so we don't provide an interface
- * with _snapshot() version now.
+ * This is only used for operations like ALTER LARGE OBJECT that are always
+ * relative to SnapshotNow.
  */
 bool
 pg_largeobject_ownercheck(Oid lobj_oid, Oid roleid)
index ada5b8829a5b902b448daafb88de1801d1e095ec..dfbf350d52ff8964405ebea79ca573d3ee577ef4 100644 (file)
@@ -79,10 +79,8 @@ LargeObjectCreate(Oid loid)
 }
 
 /*
- * Drop a large object having the given LO identifier.
- *
- * When we drop a large object, it is necessary to drop both of metadata
- * and data pages in same time.
+ * Drop a large object having the given LO identifier.  Both the data pages
+ * and metadata must be dropped.
  */
 void
 LargeObjectDrop(Oid loid)
@@ -191,13 +189,12 @@ LargeObjectAlterOwner(Oid loid, Oid newOwnerId)
        if (!superuser())
        {
            /*
-            * The 'lo_compat_privileges' is not checked here, because we
-            * don't have any access control features in the 8.4.x series
-            * or earlier release.
-            * So, it is not a place we can define a compatible behavior.
+            * lo_compat_privileges is not checked here, because ALTER
+            * LARGE OBJECT ... OWNER did not exist at all prior to
+            * PostgreSQL 8.5.
+            *
+            * We must be the owner of the existing object.
             */
-
-           /* Otherwise, must be owner of the existing object */
            if (!pg_largeobject_ownercheck(loid, GetUserId()))
                ereport(ERROR,
                        (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
@@ -251,9 +248,8 @@ LargeObjectAlterOwner(Oid loid, Oid newOwnerId)
 /*
  * LargeObjectExists
  *
- * Currently, we don't use system cache to contain metadata of
- * large objects, because massive number of large objects can
- * consume not a small amount of process local memory.
+ * 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
index 8f8ecc781d903de1cdd3e72e6f80d72178305d32..ece2a307bf00a79e04c302c367fe06dd060b0ab7 100644 (file)
@@ -1449,7 +1449,7 @@ CommentLargeObject(List *qualname, char *comment)
     *
     * See the comment in the inv_create() which describes
     * the reason why LargeObjectRelationId is used instead
-    * of the LargeObjectMetadataRelationId.
+    * of LargeObjectMetadataRelationId.
     */
    CreateComments(loid, LargeObjectRelationId, 0, comment);
 }
index d57707f04bd8a9e5f29f889cdd3268b0f3e2b485..7e61eae57758f635a345b52e4b4c1f42b0abdfba 100644 (file)
@@ -765,7 +765,6 @@ acldefault(GrantObjectType objtype, Oid ownerId)
            owner_default = ACL_ALL_RIGHTS_LANGUAGE;
            break;
        case ACL_OBJECT_LARGEOBJECT:
-           /* Grant SELECT,UPDATE by default, for now */
            world_default = ACL_NO_RIGHTS;
            owner_default = ACL_ALL_RIGHTS_LARGEOBJECT;
            break;
index 0376b164377f0f11d1771ff22b6b5a73a6e88dd9..b5307201ed8e37fad14b26402dbdc765dc4f4a8e 100644 (file)
@@ -1243,9 +1243,9 @@ static struct config_bool ConfigureNamesBool[] =
 
    {
        {"lo_compat_privileges", PGC_SUSET, COMPAT_OPTIONS_PREVIOUS,
-           gettext_noop("Enables backward compatibility in privilege checks on large objects"),
-           gettext_noop("When turned on, privilege checks on large objects perform "
-                        "with backward compatibility as 8.4.x or earlier releases.")
+           gettext_noop("Enables backward compatibility mode for privilege checks on large objects"),
+           gettext_noop("Skips privilege checks when reading or modifying large objects, "
+                        "for compatibility with PostgreSQL releases prior to 8.5.")
        },
        &lo_compat_privileges,
        false, NULL, NULL