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);
|
indcoloptions = (int2vector *) DatumGetPointer(colOptionDatum);
|
||||||
|
|
||||||
/* Fetch options of index if any */
|
/* Fetch options of index if any */
|
||||||
classTuple = SearchSysCache1(RELOID, oldIndexId);
|
classTuple = SearchSysCache1(RELOID, ObjectIdGetDatum(oldIndexId));
|
||||||
if (!HeapTupleIsValid(classTuple))
|
if (!HeapTupleIsValid(classTuple))
|
||||||
elog(ERROR, "cache lookup failed for relation %u", oldIndexId);
|
elog(ERROR, "cache lookup failed for relation %u", oldIndexId);
|
||||||
optionDatum = SysCacheGetAttr(RELOID, classTuple,
|
optionDatum = SysCacheGetAttr(RELOID, classTuple,
|
||||||
|
@ -295,7 +295,8 @@ AlterObjectRename_internal(Relation rel, Oid objectId, const char *new_name)
|
|||||||
}
|
}
|
||||||
else if (classId == SubscriptionRelationId)
|
else if (classId == SubscriptionRelationId)
|
||||||
{
|
{
|
||||||
if (SearchSysCacheExists2(SUBSCRIPTIONNAME, MyDatabaseId,
|
if (SearchSysCacheExists2(SUBSCRIPTIONNAME,
|
||||||
|
ObjectIdGetDatum(MyDatabaseId),
|
||||||
CStringGetDatum(new_name)))
|
CStringGetDatum(new_name)))
|
||||||
report_name_conflict(classId, new_name);
|
report_name_conflict(classId, new_name);
|
||||||
|
|
||||||
|
@ -1718,7 +1718,7 @@ sequence_options(Oid relid)
|
|||||||
Form_pg_sequence pgsform;
|
Form_pg_sequence pgsform;
|
||||||
List *options = NIL;
|
List *options = NIL;
|
||||||
|
|
||||||
pgstuple = SearchSysCache1(SEQRELID, relid);
|
pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(relid));
|
||||||
if (!HeapTupleIsValid(pgstuple))
|
if (!HeapTupleIsValid(pgstuple))
|
||||||
elog(ERROR, "cache lookup failed for sequence %u", relid);
|
elog(ERROR, "cache lookup failed for sequence %u", relid);
|
||||||
pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
|
pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
|
||||||
@ -1766,7 +1766,7 @@ pg_sequence_parameters(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
memset(isnull, 0, sizeof(isnull));
|
memset(isnull, 0, sizeof(isnull));
|
||||||
|
|
||||||
pgstuple = SearchSysCache1(SEQRELID, relid);
|
pgstuple = SearchSysCache1(SEQRELID, ObjectIdGetDatum(relid));
|
||||||
if (!HeapTupleIsValid(pgstuple))
|
if (!HeapTupleIsValid(pgstuple))
|
||||||
elog(ERROR, "cache lookup failed for sequence %u", relid);
|
elog(ERROR, "cache lookup failed for sequence %u", relid);
|
||||||
pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
|
pgsform = (Form_pg_sequence) GETSTRUCT(pgstuple);
|
||||||
|
@ -10147,7 +10147,7 @@ CloneFkReferenced(Relation parentRel, Relation partitionRel)
|
|||||||
Oid deleteTriggerOid,
|
Oid deleteTriggerOid,
|
||||||
updateTriggerOid;
|
updateTriggerOid;
|
||||||
|
|
||||||
tuple = SearchSysCache1(CONSTROID, constrOid);
|
tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constrOid));
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
elog(ERROR, "cache lookup failed for constraint %u", constrOid);
|
elog(ERROR, "cache lookup failed for constraint %u", constrOid);
|
||||||
constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
|
constrForm = (Form_pg_constraint) GETSTRUCT(tuple);
|
||||||
@ -10353,7 +10353,7 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel)
|
|||||||
Oid insertTriggerOid,
|
Oid insertTriggerOid,
|
||||||
updateTriggerOid;
|
updateTriggerOid;
|
||||||
|
|
||||||
tuple = SearchSysCache1(CONSTROID, parentConstrOid);
|
tuple = SearchSysCache1(CONSTROID, ObjectIdGetDatum(parentConstrOid));
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
elog(ERROR, "cache lookup failed for constraint %u",
|
elog(ERROR, "cache lookup failed for constraint %u",
|
||||||
parentConstrOid);
|
parentConstrOid);
|
||||||
@ -13723,7 +13723,7 @@ ATExecAlterColumnGenericOptions(Relation rel,
|
|||||||
|
|
||||||
/* First, determine FDW validator associated to the foreign table. */
|
/* First, determine FDW validator associated to the foreign table. */
|
||||||
ftrel = table_open(ForeignTableRelationId, AccessShareLock);
|
ftrel = table_open(ForeignTableRelationId, AccessShareLock);
|
||||||
tuple = SearchSysCache1(FOREIGNTABLEREL, rel->rd_id);
|
tuple = SearchSysCache1(FOREIGNTABLEREL, ObjectIdGetDatum(rel->rd_id));
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||||
@ -16186,7 +16186,8 @@ ATExecGenericOptions(Relation rel, List *options)
|
|||||||
|
|
||||||
ftrel = table_open(ForeignTableRelationId, RowExclusiveLock);
|
ftrel = table_open(ForeignTableRelationId, RowExclusiveLock);
|
||||||
|
|
||||||
tuple = SearchSysCacheCopy1(FOREIGNTABLEREL, rel->rd_id);
|
tuple = SearchSysCacheCopy1(FOREIGNTABLEREL,
|
||||||
|
ObjectIdGetDatum(rel->rd_id));
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||||
|
@ -1935,7 +1935,7 @@ AddRoleMems(Oid currentUserId, const char *rolename, Oid roleid,
|
|||||||
HeapTuple mrtup;
|
HeapTuple mrtup;
|
||||||
Form_pg_authid mrform;
|
Form_pg_authid mrform;
|
||||||
|
|
||||||
mrtup = SearchSysCache1(AUTHOID, memberid);
|
mrtup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(memberid));
|
||||||
if (!HeapTupleIsValid(mrtup))
|
if (!HeapTupleIsValid(mrtup))
|
||||||
elog(ERROR, "cache lookup failed for role %u", memberid);
|
elog(ERROR, "cache lookup failed for role %u", memberid);
|
||||||
mrform = (Form_pg_authid) GETSTRUCT(mrtup);
|
mrform = (Form_pg_authid) GETSTRUCT(mrtup);
|
||||||
|
@ -4313,7 +4313,7 @@ get_qual_for_range(Relation parent, PartitionBoundSpec *spec,
|
|||||||
Datum datum;
|
Datum datum;
|
||||||
PartitionBoundSpec *bspec;
|
PartitionBoundSpec *bspec;
|
||||||
|
|
||||||
tuple = SearchSysCache1(RELOID, inhrelid);
|
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(inhrelid));
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
elog(ERROR, "cache lookup failed for relation %u", inhrelid);
|
elog(ERROR, "cache lookup failed for relation %u", inhrelid);
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ RelationBuildPartitionDesc(Relation rel, bool omit_detached)
|
|||||||
PartitionBoundSpec *boundspec = NULL;
|
PartitionBoundSpec *boundspec = NULL;
|
||||||
|
|
||||||
/* Try fetching the tuple from the catcache, for speed. */
|
/* Try fetching the tuple from the catcache, for speed. */
|
||||||
tuple = SearchSysCache1(RELOID, inhrelid);
|
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(inhrelid));
|
||||||
if (HeapTupleIsValid(tuple))
|
if (HeapTupleIsValid(tuple))
|
||||||
{
|
{
|
||||||
Datum datum;
|
Datum datum;
|
||||||
|
@ -5334,13 +5334,13 @@ get_rolespec_tuple(const RoleSpec *role)
|
|||||||
|
|
||||||
case ROLESPEC_CURRENT_ROLE:
|
case ROLESPEC_CURRENT_ROLE:
|
||||||
case ROLESPEC_CURRENT_USER:
|
case ROLESPEC_CURRENT_USER:
|
||||||
tuple = SearchSysCache1(AUTHOID, GetUserId());
|
tuple = SearchSysCache1(AUTHOID, ObjectIdGetDatum(GetUserId()));
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
elog(ERROR, "cache lookup failed for role %u", GetUserId());
|
elog(ERROR, "cache lookup failed for role %u", GetUserId());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ROLESPEC_SESSION_USER:
|
case ROLESPEC_SESSION_USER:
|
||||||
tuple = SearchSysCache1(AUTHOID, GetSessionUserId());
|
tuple = SearchSysCache1(AUTHOID, ObjectIdGetDatum(GetSessionUserId()));
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
elog(ERROR, "cache lookup failed for role %u", GetSessionUserId());
|
elog(ERROR, "cache lookup failed for role %u", GetSessionUserId());
|
||||||
break;
|
break;
|
||||||
|
@ -3283,7 +3283,7 @@ print_function_arguments(StringInfo buf, HeapTuple proctup,
|
|||||||
HeapTuple aggtup;
|
HeapTuple aggtup;
|
||||||
Form_pg_aggregate agg;
|
Form_pg_aggregate agg;
|
||||||
|
|
||||||
aggtup = SearchSysCache1(AGGFNOID, proc->oid);
|
aggtup = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(proc->oid));
|
||||||
if (!HeapTupleIsValid(aggtup))
|
if (!HeapTupleIsValid(aggtup))
|
||||||
elog(ERROR, "cache lookup failed for aggregate %u",
|
elog(ERROR, "cache lookup failed for aggregate %u",
|
||||||
proc->oid);
|
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))
|
if (!list_member_oid(trftypes, typid))
|
||||||
return InvalidOid;
|
return InvalidOid;
|
||||||
|
|
||||||
tup = SearchSysCache2(TRFTYPELANG, typid, langid);
|
tup = SearchSysCache2(TRFTYPELANG, ObjectIdGetDatum(typid),
|
||||||
|
ObjectIdGetDatum(langid));
|
||||||
if (HeapTupleIsValid(tup))
|
if (HeapTupleIsValid(tup))
|
||||||
{
|
{
|
||||||
Oid funcid;
|
Oid funcid;
|
||||||
@ -2127,7 +2128,8 @@ get_transform_tosql(Oid typid, Oid langid, List *trftypes)
|
|||||||
if (!list_member_oid(trftypes, typid))
|
if (!list_member_oid(trftypes, typid))
|
||||||
return InvalidOid;
|
return InvalidOid;
|
||||||
|
|
||||||
tup = SearchSysCache2(TRFTYPELANG, typid, langid);
|
tup = SearchSysCache2(TRFTYPELANG, ObjectIdGetDatum(typid),
|
||||||
|
ObjectIdGetDatum(langid));
|
||||||
if (HeapTupleIsValid(tup))
|
if (HeapTupleIsValid(tup))
|
||||||
{
|
{
|
||||||
Oid funcid;
|
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);
|
parent = relation_open(parentrelid, AccessShareLock);
|
||||||
|
|
||||||
/* Get pg_class.relpartbound */
|
/* Get pg_class.relpartbound */
|
||||||
tuple = SearchSysCache1(RELOID, RelationGetRelid(rel));
|
tuple = SearchSysCache1(RELOID,
|
||||||
|
ObjectIdGetDatum(RelationGetRelid(rel)));
|
||||||
if (!HeapTupleIsValid(tuple))
|
if (!HeapTupleIsValid(tuple))
|
||||||
elog(ERROR, "cache lookup failed for relation %u",
|
elog(ERROR, "cache lookup failed for relation %u",
|
||||||
RelationGetRelid(rel));
|
RelationGetRelid(rel));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user