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

Commit7a99fb6

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 parent8dd7082 commit7a99fb6

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
@@ -6135,9 +6135,9 @@ recordExtObjInitPriv(Oid objoid, Oid classoid)
61356135

61366136
ReleaseSysCache(tuple);
61376137
}
6138-
/* pg_largeobject_metadata */
6139-
elseif (classoid==LargeObjectMetadataRelationId)
6138+
elseif (classoid==LargeObjectRelationId)
61406139
{
6140+
/* For large objects, we must consult pg_largeobject_metadata */
61416141
DatumaclDatum;
61426142
boolisNull;
61436143
HeapTupletuple;

‎src/backend/commands/alter.c

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

1049-
/* Update owner dependency reference */
1049+
/*
1050+
* Update owner dependency reference. When working on a large object,
1051+
* we have to translate back to the OID conventionally used for LOs'
1052+
* classId.
1053+
*/
10501054
if (classId==LargeObjectMetadataRelationId)
10511055
classId=LargeObjectRelationId;
1056+
10521057
changeDependencyOnOwner(classId,objectId,new_ownerId);
10531058

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

10601075
InvokeObjectPostAlterHook(classId,objectId,0);
10611076
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp