diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2023-12-15 13:55:05 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2023-12-15 13:55:05 -0500 |
commit | 152bfc0af89de25400abe49205f1d9861a199b61 (patch) | |
tree | 72c78e3c44930e38f1a371da321584a2ee437f90 /src/backend/storage | |
parent | db69101a1d000d857a552e16e45f601adbb4dbc6 (diff) |
Fix bugs in manipulation of large objects.
In v16 and up (since commit afbfc0298), large object ownership
checking has been broken because object_ownercheck() didn't take care
of the discrepancy between our object-address representation of large
objects (classId == LargeObjectRelationId) and the catalog where their
ownership info is actually stored (LargeObjectMetadataRelationId).
This resulted in failures such as "unrecognized class ID: 2613"
when trying to update blob properties as a non-superuser.
Poking around for related bugs, I found that AlterObjectOwner_internal
would pass the wrong classId to the PostAlterHook in the no-op code
path where the large object already has the desired owner. Also,
recordExtObjInitPriv checked for the wrong classId; that bug is only
latent because the stanza is dead code anyway, but as long as we're
carrying it around it should be less wrong. These bugs are quite old.
In HEAD, we can reduce the scope for future bugs of this ilk by
changing AlterObjectOwner_internal's API to let the translation happen
inside that function, rather than requiring callers to know about it.
A more bulletproof fix, perhaps, would be to start using
LargeObjectMetadataRelationId as the dependency and object-address
classId for blobs. However that has substantial risk of breaking
third-party code; even within our own code, it'd create hassles
for pg_dump which would have to cope with a version-dependent
representation. For now, keep the status quo.
Discussion: https://postgr.es/m/2650449.1702497209@sss.pgh.pa.us
Diffstat (limited to 'src/backend/storage')
-rw-r--r-- | src/backend/storage/large_object/inv_api.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c index 84e543e7310..cab47f82fb6 100644 --- a/src/backend/storage/large_object/inv_api.c +++ b/src/backend/storage/large_object/inv_api.c @@ -221,11 +221,10 @@ inv_create(Oid lobjId) /* * dependency on the owner of largeobject * - * The reason why we use LargeObjectRelationId instead of - * LargeObjectMetadataRelationId here is to provide backward compatibility - * to the applications which utilize a knowledge about internal layout of - * system catalogs. OID of pg_largeobject_metadata and loid of - * pg_largeobject are same value, so there are no actual differences here. + * Note that LO dependencies are recorded using classId + * LargeObjectRelationId for backwards-compatibility reasons. Using + * LargeObjectMetadataRelationId instead would simplify matters for the + * backend, but it'd complicate pg_dump and possibly break other clients. */ recordDependencyOnOwner(LargeObjectRelationId, lobjId_new, GetUserId()); |