mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +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:
@ -15,7 +15,7 @@
|
||||
*
|
||||
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.117 2010/01/02 16:57:55 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ri_triggers.c,v 1.118 2010/02/14 18:42:16 rhaas Exp $
|
||||
*
|
||||
* ----------
|
||||
*/
|
||||
@ -2901,9 +2901,7 @@ ri_GenerateQual(StringInfo buf,
|
||||
char *oprname;
|
||||
char *nspname;
|
||||
|
||||
opertup = SearchSysCache(OPEROID,
|
||||
ObjectIdGetDatum(opoid),
|
||||
0, 0, 0);
|
||||
opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(opoid));
|
||||
if (!HeapTupleIsValid(opertup))
|
||||
elog(ERROR, "cache lookup failed for operator %u", opoid);
|
||||
operform = (Form_pg_operator) GETSTRUCT(opertup);
|
||||
@ -2940,9 +2938,7 @@ ri_add_cast_to(StringInfo buf, Oid typid)
|
||||
char *typname;
|
||||
char *nspname;
|
||||
|
||||
typetup = SearchSysCache(TYPEOID,
|
||||
ObjectIdGetDatum(typid),
|
||||
0, 0, 0);
|
||||
typetup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (!HeapTupleIsValid(typetup))
|
||||
elog(ERROR, "cache lookup failed for type %u", typid);
|
||||
typform = (Form_pg_type) GETSTRUCT(typetup);
|
||||
@ -3071,9 +3067,7 @@ ri_FetchConstraintInfo(RI_ConstraintInfo *riinfo,
|
||||
errhint("Remove this referential integrity trigger and its mates, then do ALTER TABLE ADD CONSTRAINT.")));
|
||||
|
||||
/* OK, fetch the tuple */
|
||||
tup = SearchSysCache(CONSTROID,
|
||||
ObjectIdGetDatum(constraintOid),
|
||||
0, 0, 0);
|
||||
tup = SearchSysCache1(CONSTROID, ObjectIdGetDatum(constraintOid));
|
||||
if (!HeapTupleIsValid(tup)) /* should not happen */
|
||||
elog(ERROR, "cache lookup failed for constraint %u", constraintOid);
|
||||
conForm = (Form_pg_constraint) GETSTRUCT(tup);
|
||||
|
Reference in New Issue
Block a user