Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit55b5c67

Browse files
committed
Fix bugs in manipulation of large objects.
In v16 and up (since commitafbfc02), large object ownershipchecking has been broken because object_ownercheck() didn't take careof the discrepancy between our object-address representation of largeobjects (classId == LargeObjectRelationId) and the catalog where theirownership 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_internalwould pass the wrong classId to the PostAlterHook in the no-op codepath where the large object already has the desired owner. Also,recordExtObjInitPriv checked for the wrong classId; that bug is onlylatent because the stanza is dead code anyway, but as long as we'recarrying 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 bychanging AlterObjectOwner_internal's API to let the translation happeninside that function, rather than requiring callers to know about it.A more bulletproof fix, perhaps, would be to start usingLargeObjectMetadataRelationId as the dependency and object-addressclassId for blobs. However that has substantial risk of breakingthird-party code; even within our own code, it'd create hasslesfor pg_dump which would have to cope with a version-dependentrepresentation. For now, keep the status quo.Discussion:https://postgr.es/m/2650449.1702497209@sss.pgh.pa.us
1 parentd99294e commit55b5c67

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

‎src/backend/catalog/aclchk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5687,9 +5687,9 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
56875687

56885688
ReleaseSysCache(tuple);
56895689
}
5690-
/* pg_largeobject_metadata */
5691-
elseif (classoid==LargeObjectMetadataRelationId)
5690+
elseif (classoid==LargeObjectRelationId)
56925691
{
5692+
/* For large objects, we must consult pg_largeobject_metadata */
56935693
DatumaclDatum;
56945694
boolisNull;
56955695
HeapTupletuple;

‎src/backend/commands/alter.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,16 +1044,31 @@ AlterObjectOwner_internal(Relation rel, Oid objectId, Oid new_ownerId)
10441044
/* Perform actual update */
10451045
CatalogTupleUpdate(rel,&newtup->t_self,newtup);
10461046

1047-
/* Update owner dependency reference */
1047+
/*
1048+
* Update owner dependency reference. When working on a large object,
1049+
* we have to translate back to the OID conventionally used for LOs'
1050+
* classId.
1051+
*/
10481052
if (classId==LargeObjectMetadataRelationId)
10491053
classId=LargeObjectRelationId;
1054+
10501055
changeDependencyOnOwner(classId,objectId,new_ownerId);
10511056

10521057
/* Release memory */
10531058
pfree(values);
10541059
pfree(nulls);
10551060
pfree(replaces);
10561061
}
1062+
else
1063+
{
1064+
/*
1065+
* No need to change anything. But when working on a large object, we
1066+
* have to translate back to the OID conventionally used for LOs'
1067+
* classId, or the post-alter hook (if any) will get confused.
1068+
*/
1069+
if (classId==LargeObjectMetadataRelationId)
1070+
classId=LargeObjectRelationId;
1071+
}
10571072

10581073
InvokeObjectPostAlterHook(classId,objectId,0);
10591074
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp