1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-22 12:22:45 +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:
Michael Paquier
2023-07-20 15:18:25 +09:00
parent 47556a0013
commit 2a990abd79
11 changed files with 22 additions and 17 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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));