diff options
| author | Tom Lane | 2023-12-15 18:55:05 +0000 |
|---|---|---|
| committer | Tom Lane | 2023-12-15 18:55:05 +0000 |
| commit | 59bd34c2fa02b005dc33190245b2bffc6a08c0b9 (patch) | |
| tree | 238d2a4d73635780861b65fc945c5eaf237d031b /src/include/commands | |
| parent | 0e917508b89dd21c5bcd9183e77585f01055a20d (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/include/commands')
| -rw-r--r-- | src/include/commands/alter.h | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/include/commands/alter.h b/src/include/commands/alter.h index ae79968fadd..5ddeaba8f0d 100644 --- a/src/include/commands/alter.h +++ b/src/include/commands/alter.h @@ -17,7 +17,6 @@ #include "catalog/dependency.h" #include "catalog/objectaddress.h" #include "nodes/parsenodes.h" -#include "utils/relcache.h" extern ObjectAddress ExecRenameStmt(RenameStmt *stmt); @@ -29,7 +28,7 @@ extern Oid AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid, ObjectAddresses *objsMoved); extern ObjectAddress ExecAlterOwnerStmt(AlterOwnerStmt *stmt); -extern void AlterObjectOwner_internal(Relation rel, Oid objectId, +extern void AlterObjectOwner_internal(Oid classId, Oid objectId, Oid new_ownerId); #endif /* ALTER_H */ |
