mirror of
https://github.com/postgres/postgres.git
synced 2025-11-28 11:44:57 +03:00
Wrap calls to SearchSysCache and related functions using macros.
The purpose of this change is to eliminate the need for every caller of SearchSysCache, SearchSysCacheCopy, SearchSysCacheExists, GetSysCacheOid, and SearchSysCacheList to know the maximum number of allowable keys for a syscache entry (currently 4). This will make it far easier to increase the maximum number of keys in a future release should we choose to do so, and it makes the code shorter, too. Design and review by Tom Lane.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**********************************************************************
|
||||
* plperl.c - perl as a procedural language for PostgreSQL
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.165 2010/02/12 19:35:25 adunstan Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.166 2010/02/14 18:42:18 rhaas Exp $
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
@@ -1198,9 +1198,7 @@ plperl_validator(PG_FUNCTION_ARGS)
|
||||
int i;
|
||||
|
||||
/* Get the new function's pg_proc entry */
|
||||
tuple = SearchSysCache(PROCOID,
|
||||
ObjectIdGetDatum(funcoid),
|
||||
0, 0, 0);
|
||||
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcoid));
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
elog(ERROR, "cache lookup failed for function %u", funcoid);
|
||||
proc = (Form_pg_proc) GETSTRUCT(tuple);
|
||||
@@ -1773,9 +1771,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
|
||||
ErrorContextCallback plperl_error_context;
|
||||
|
||||
/* We'll need the pg_proc tuple in any case... */
|
||||
procTup = SearchSysCache(PROCOID,
|
||||
ObjectIdGetDatum(fn_oid),
|
||||
0, 0, 0);
|
||||
procTup = SearchSysCache1(PROCOID, ObjectIdGetDatum(fn_oid));
|
||||
if (!HeapTupleIsValid(procTup))
|
||||
elog(ERROR, "cache lookup failed for function %u", fn_oid);
|
||||
procStruct = (Form_pg_proc) GETSTRUCT(procTup);
|
||||
@@ -1867,9 +1863,8 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
|
||||
/************************************************************
|
||||
* Lookup the pg_language tuple by Oid
|
||||
************************************************************/
|
||||
langTup = SearchSysCache(LANGOID,
|
||||
ObjectIdGetDatum(procStruct->prolang),
|
||||
0, 0, 0);
|
||||
langTup = SearchSysCache1(LANGOID,
|
||||
ObjectIdGetDatum(procStruct->prolang));
|
||||
if (!HeapTupleIsValid(langTup))
|
||||
{
|
||||
free(prodesc->proname);
|
||||
@@ -1887,9 +1882,9 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
|
||||
************************************************************/
|
||||
if (!is_trigger)
|
||||
{
|
||||
typeTup = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(procStruct->prorettype),
|
||||
0, 0, 0);
|
||||
typeTup =
|
||||
SearchSysCache1(TYPEOID,
|
||||
ObjectIdGetDatum(procStruct->prorettype));
|
||||
if (!HeapTupleIsValid(typeTup))
|
||||
{
|
||||
free(prodesc->proname);
|
||||
@@ -1948,9 +1943,8 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
|
||||
prodesc->nargs = procStruct->pronargs;
|
||||
for (i = 0; i < prodesc->nargs; i++)
|
||||
{
|
||||
typeTup = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(procStruct->proargtypes.values[i]),
|
||||
0, 0, 0);
|
||||
typeTup = SearchSysCache1(TYPEOID,
|
||||
ObjectIdGetDatum(procStruct->proargtypes.values[i]));
|
||||
if (!HeapTupleIsValid(typeTup))
|
||||
{
|
||||
free(prodesc->proname);
|
||||
|
||||
Reference in New Issue
Block a user