From e26c539e9f326ea843c0ed005af093b56b55cd4d Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Sun, 14 Feb 2010 18:42:19 +0000 Subject: 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. --- src/backend/commands/conversioncmds.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src/backend/commands/conversioncmds.c') diff --git a/src/backend/commands/conversioncmds.c b/src/backend/commands/conversioncmds.c index 149237e31b5..2e5a7dfe9ec 100644 --- a/src/backend/commands/conversioncmds.c +++ b/src/backend/commands/conversioncmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.40 2010/01/02 16:57:37 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/commands/conversioncmds.c,v 1.41 2010/02/14 18:42:14 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -162,9 +162,7 @@ DropConversionsCommand(DropStmt *drop) continue; } - tuple = SearchSysCache(CONVOID, - ObjectIdGetDatum(conversionOid), - 0, 0, 0); + tuple = SearchSysCache1(CONVOID, ObjectIdGetDatum(conversionOid)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for conversion %u", conversionOid); @@ -211,19 +209,16 @@ RenameConversion(List *name, const char *newname) errmsg("conversion \"%s\" does not exist", NameListToString(name)))); - tup = SearchSysCacheCopy(CONVOID, - ObjectIdGetDatum(conversionOid), - 0, 0, 0); + tup = SearchSysCacheCopy1(CONVOID, ObjectIdGetDatum(conversionOid)); if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "cache lookup failed for conversion %u", conversionOid); namespaceOid = ((Form_pg_conversion) GETSTRUCT(tup))->connamespace; /* make sure the new name doesn't exist */ - if (SearchSysCacheExists(CONNAMENSP, - CStringGetDatum(newname), - ObjectIdGetDatum(namespaceOid), - 0, 0)) + if (SearchSysCacheExists2(CONNAMENSP, + CStringGetDatum(newname), + ObjectIdGetDatum(namespaceOid))) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_OBJECT), errmsg("conversion \"%s\" already exists in schema \"%s\"", @@ -301,9 +296,7 @@ AlterConversionOwner_internal(Relation rel, Oid conversionOid, Oid newOwnerId) Assert(RelationGetRelid(rel) == ConversionRelationId); - tup = SearchSysCacheCopy(CONVOID, - ObjectIdGetDatum(conversionOid), - 0, 0, 0); + tup = SearchSysCacheCopy1(CONVOID, ObjectIdGetDatum(conversionOid)); if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "cache lookup failed for conversion %u", conversionOid); -- cgit v1.2.3