mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Add missing ObjectIdGetDatum() in syscache lookup calls for Oids
Based on how postgres.h foes the Oid <-> Datum conversion, there is no existing bugs but let's be consistent. 17 spots have been noticed as incorrectly passing down Oids rather than Datums. Aleksander got one, Zhang two and I the rest. Author: Michael Paquier, Aleksander Alekseev, Zhang Mingli Discussion: https://postgr.es/m/ZLUhqsqQN1MOaxdw@paquier.xyz
This commit is contained in:
parent
47556a0013
commit
2a990abd79
@ -1330,7 +1330,7 @@ index_concurrently_create_copy(Relation heapRelation, Oid oldIndexId,
|
||||
indcoloptions = (int2vector *) DatumGetPointer(colOptionDatum);
|
||||
|
||||
/* Fetch options of index if any */
|
||||
classTuple = SearchSysCache1(RELOID, oldIndexId);
|
||||
classTuple = SearchSysCache1(RELOID, ObjectIdGetDatum(oldIndexId));
|
||||
if (!HeapTupleIsValid(classTuple))
|
||||
elog(ERROR, "cache lookup failed for relation %u", oldIndexId);
|
||||
optionDatum = SysCacheGetAttr(RELOID, classTuple,
|
||||
|
@ -295,7 +295,8 @@ AlterObjectRename_internal(Relation rel, Oid objectId, const char *new_name)
|
||||
}
|
||||
else if (classId == SubscriptionRelationId)
|
||||
{
|
||||
if (SearchSysCacheExists2(SUBSCRIPTIONNAME, MyDatabaseId,
|
||||
if (SearchSysCacheExists2(SUBSCRIPTIONNAME,
|
||||
ObjectIdGetDatum(MyDatabaseId),
|
||||
CStringGetDatum(new_name)))
|
||||
report_name_conflict(classId, new_name);
|
||||
|
||||
|
@ -1718,7 +1718,7 @@ sequence_options(Oid relid)
|
||||
Form_pg_sequence pgsform;
|
||||
List *options = NIL;
|
||||
|
||||
pgstuple = SearchSysCache1(SEQRELID, relid);
|
||||
pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(relid));
|
||||
if (!HeapTupleIsValid(pgstuple))
|
||||
elog(ERROR, "cache lookup failed for sequence %u", relid);
|
||||
pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
|
||||
@ -1766,7 +1766,7 @@ pg_sequence_parameters(PG_FUNCTION_ARGS)
|
||||
|
||||
memset(isnull, 0, sizeof(isnull));
|
||||
|
||||
pgstuple = SearchSysCache1(SEQRELID, relid);
|
||||
pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(relid));
|
||||
if (!HeapTupleIsValid(pgstuple))
|
||||
elog(ERROR, "cache lookup failed for sequence %u", relid);
|
||||
pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
|
||||
|
@ -10147,7 +10147,7 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel)
|
||||
Oid deleteTriggerOid,
|
||||
updateTriggerOid;
|
||||
|
||||
tuple = SearchSysCache1(CONSTROID, constrOid);
|
||||
tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constrOid));
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
elog(ERROR, "cache lookup failed for constraint %u", constrOid);
|
||||
constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
|
||||
@ -10353,7 +10353,7 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel)
|
||||
Oid insertTriggerOid,
|
||||
updateTriggerOid;
|
||||
|
||||
tuple = SearchSysCache1(CONSTROID, parentConstrOid);
|
||||
tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(parentConstrOid));
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
elog(ERROR, "cache lookup failed for constraint %u",
|
||||
parentConstrOid);
|
||||
@ -13723,7 +13723,7 @@ ATExecAlterColumnGenericOptions(Relation rel,
|
||||
|
||||
/* First, determine FDW validator associated to the foreign table. */
|
||||
ftrel = table_open(ForeignTableRelationId, AccessShareLock);
|
||||
tuple = SearchSysCache1(FOREIGNTABLEREL, rel->rd_id);
|
||||
tuple = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(rel->rd_id));
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
@ -16186,7 +16186,8 @@ ATExecGenericOptions(Relation rel, List *options)
|
||||
|
||||
ftrel = table_open(ForeignTableRelationId, RowExclusiveLock);
|
||||
|
||||
tuple = SearchSysCacheCopy1(FOREIGNTABLEREL, rel->rd_id);
|
||||
tuple = SearchSysCacheCopy1(FOREIGNTABLEREL,
|
||||
ObjectIdGetDatum(rel->rd_id));
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
|
@ -1935,7 +1935,7 @@ AddRoleMems(Oid currentUserId, const char *rolename, Oid roleid,
|
||||
HeapTuple mrtup;
|
||||
Form_pg_authid mrform;
|
||||
|
||||
mrtup = SearchSysCache1(AUTHOID, memberid);
|
||||
mrtup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(memberid));
|
||||
if (!HeapTupleIsValid(mrtup))
|
||||
elog(ERROR, "cache lookup failed for role %u", memberid);
|
||||
mrform = (Form_pg_authid) GETSTRUCT(mrtup);
|
||||
|
@ -4313,7 +4313,7 @@ get_qual_for_range(Relation parent, PartitionBoundSpec *spec,
|
||||
Datum datum;
|
||||
PartitionBoundSpec *bspec;
|
||||
|
||||
tuple = SearchSysCache1(RELOID, inhrelid);
|
||||
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(inhrelid));
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
elog(ERROR, "cache lookup failed for relation %u", inhrelid);
|
||||
|
||||
|
@ -183,7 +183,7 @@ RelationBuildPartitionDesc(Relation rel, bool omit_detached)
|
||||
PartitionBoundSpec *boundspec = NULL;
|
||||
|
||||
/* Try fetching the tuple from the catcache, for speed. */
|
||||
tuple = SearchSysCache1(RELOID, inhrelid);
|
||||
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(inhrelid));
|
||||
if (HeapTupleIsValid(tuple))
|
||||
{
|
||||
Datum datum;
|
||||
|
@ -5334,13 +5334,13 @@ get_rolespec_tuple(const RoleSpec *role)
|
||||
|
||||
case ROLESPEC_CURRENT_ROLE:
|
||||
case ROLESPEC_CURRENT_USER:
|
||||
tuple = SearchSysCache1(AUTHOID, GetUserId());
|
||||
tuple = SearchSysCache1(AUTHOID, ObjectIdGetDatum(GetUserId()));
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
elog(ERROR, "cache lookup failed for role %u", GetUserId());
|
||||
break;
|
||||
|
||||
case ROLESPEC_SESSION_USER:
|
||||
tuple = SearchSysCache1(AUTHOID, GetSessionUserId());
|
||||
tuple = SearchSysCache1(AUTHOID, ObjectIdGetDatum(GetSessionUserId()));
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
elog(ERROR, "cache lookup failed for role %u", GetSessionUserId());
|
||||
break;
|
||||
|
@ -3283,7 +3283,7 @@ print_function_arguments(StringInfo buf, HeapTuple proctup,
|
||||
HeapTuple aggtup;
|
||||
Form_pg_aggregate agg;
|
||||
|
||||
aggtup = SearchSysCache1(AGGFNOID, proc->oid);
|
||||
aggtup = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(proc->oid));
|
||||
if (!HeapTupleIsValid(aggtup))
|
||||
elog(ERROR, "cache lookup failed for aggregate %u",
|
||||
proc->oid);
|
||||
|
6
src/backend/utils/cache/lsyscache.c
vendored
6
src/backend/utils/cache/lsyscache.c
vendored
@ -2106,7 +2106,8 @@ get_transform_fromsql(Oid typid, Oid langid, List *trftypes)
|
||||
if (!list_member_oid(trftypes, typid))
|
||||
return InvalidOid;
|
||||
|
||||
tup = SearchSysCache2(TRFTYPELANG, typid, langid);
|
||||
tup = SearchSysCache2(TRFTYPELANG, ObjectIdGetDatum(typid),
|
||||
ObjectIdGetDatum(langid));
|
||||
if (HeapTupleIsValid(tup))
|
||||
{
|
||||
Oid funcid;
|
||||
@ -2127,7 +2128,8 @@ get_transform_tosql(Oid typid, Oid langid, List *trftypes)
|
||||
if (!list_member_oid(trftypes, typid))
|
||||
return InvalidOid;
|
||||
|
||||
tup = SearchSysCache2(TRFTYPELANG, typid, langid);
|
||||
tup = SearchSysCache2(TRFTYPELANG, ObjectIdGetDatum(typid),
|
||||
ObjectIdGetDatum(langid));
|
||||
if (HeapTupleIsValid(tup))
|
||||
{
|
||||
Oid funcid;
|
||||
|
3
src/backend/utils/cache/partcache.c
vendored
3
src/backend/utils/cache/partcache.c
vendored
@ -365,7 +365,8 @@ generate_partition_qual(Relation rel)
|
||||
parent = relation_open(parentrelid, AccessShareLock);
|
||||
|
||||
/* Get pg_class.relpartbound */
|
||||
tuple = SearchSysCache1(RELOID, RelationGetRelid(rel));
|
||||
tuple = SearchSysCache1(RELOID,
|
||||
ObjectIdGetDatum(RelationGetRelid(rel)));
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
elog(ERROR, "cache lookup failed for relation %u",
|
||||
RelationGetRelid(rel));
|
||||
|
Loading…
x
Reference in New Issue
Block a user