summaryrefslogtreecommitdiff
path: root/src/backend/commands/indexcmds.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2010-02-14 18:42:19 +0000
committerRobert Haas <rhaas@postgresql.org>2010-02-14 18:42:19 +0000
commite26c539e9f326ea843c0ed005af093b56b55cd4d (patch)
tree4f3830d394229b747cbceeab3cdbbfccccec74d1 /src/backend/commands/indexcmds.c
parent1012492bc0bfb322d59db17e17735d17d634e264 (diff)
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.
Diffstat (limited to 'src/backend/commands/indexcmds.c')
-rw-r--r--src/backend/commands/indexcmds.c50
1 files changed, 17 insertions, 33 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index b79723a777d..dee14d57f65 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.192 2010/02/07 22:40:33 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.193 2010/02/14 18:42:14 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -273,9 +273,7 @@ DefineIndex(RangeVar *heapRelation,
/*
* look up the access method, verify it can handle the requested features
*/
- tuple = SearchSysCache(AMNAME,
- PointerGetDatum(accessMethodName),
- 0, 0, 0);
+ tuple = SearchSysCache1(AMNAME, PointerGetDatum(accessMethodName));
if (!HeapTupleIsValid(tuple))
{
/*
@@ -287,9 +285,7 @@ DefineIndex(RangeVar *heapRelation,
ereport(NOTICE,
(errmsg("substituting access method \"gist\" for obsolete method \"rtree\"")));
accessMethodName = "gist";
- tuple = SearchSysCache(AMNAME,
- PointerGetDatum(accessMethodName),
- 0, 0, 0);
+ tuple = SearchSysCache1(AMNAME, PointerGetDatum(accessMethodName));
}
if (!HeapTupleIsValid(tuple))
@@ -600,9 +596,8 @@ DefineIndex(RangeVar *heapRelation,
*/
pg_index = heap_open(IndexRelationId, RowExclusiveLock);
- indexTuple = SearchSysCacheCopy(INDEXRELID,
- ObjectIdGetDatum(indexRelationId),
- 0, 0, 0);
+ indexTuple = SearchSysCacheCopy1(INDEXRELID,
+ ObjectIdGetDatum(indexRelationId));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexRelationId);
indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
@@ -741,9 +736,8 @@ DefineIndex(RangeVar *heapRelation,
*/
pg_index = heap_open(IndexRelationId, RowExclusiveLock);
- indexTuple = SearchSysCacheCopy(INDEXRELID,
- ObjectIdGetDatum(indexRelationId),
- 0, 0, 0);
+ indexTuple = SearchSysCacheCopy1(INDEXRELID,
+ ObjectIdGetDatum(indexRelationId));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexRelationId);
indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
@@ -985,9 +979,8 @@ ComputeIndexAttrs(IndexInfo *indexInfo,
* so fetch the name of the selected opfamily for use in the
* error message.
*/
- opftuple = SearchSysCache(OPFAMILYOID,
- ObjectIdGetDatum(opfamily),
- 0, 0, 0);
+ opftuple = SearchSysCache1(OPFAMILYOID,
+ ObjectIdGetDatum(opfamily));
if (!HeapTupleIsValid(opftuple))
elog(ERROR, "cache lookup failed for opfamily %u",
opfamily);
@@ -1113,11 +1106,10 @@ GetIndexOpClass(List *opclass, Oid attrType,
Oid namespaceId;
namespaceId = LookupExplicitNamespace(schemaname);
- tuple = SearchSysCache(CLAAMNAMENSP,
- ObjectIdGetDatum(accessMethodId),
- PointerGetDatum(opcname),
- ObjectIdGetDatum(namespaceId),
- 0);
+ tuple = SearchSysCache3(CLAAMNAMENSP,
+ ObjectIdGetDatum(accessMethodId),
+ PointerGetDatum(opcname),
+ ObjectIdGetDatum(namespaceId));
}
else
{
@@ -1128,9 +1120,7 @@ GetIndexOpClass(List *opclass, Oid attrType,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("operator class \"%s\" does not exist for access method \"%s\"",
opcname, accessMethodName)));
- tuple = SearchSysCache(CLAOID,
- ObjectIdGetDatum(opClassId),
- 0, 0, 0);
+ tuple = SearchSysCache1(CLAOID, ObjectIdGetDatum(opClassId));
}
if (!HeapTupleIsValid(tuple))
@@ -1542,9 +1532,7 @@ relationHasPrimaryKey(Relation rel)
Oid indexoid = lfirst_oid(indexoidscan);
HeapTuple indexTuple;
- indexTuple = SearchSysCache(INDEXRELID,
- ObjectIdGetDatum(indexoid),
- 0, 0, 0);
+ indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple)) /* should not happen */
elog(ERROR, "cache lookup failed for index %u", indexoid);
result = ((Form_pg_index) GETSTRUCT(indexTuple))->indisprimary;
@@ -1569,9 +1557,7 @@ ReindexIndex(RangeVar *indexRelation)
HeapTuple tuple;
indOid = RangeVarGetRelid(indexRelation, false);
- tuple = SearchSysCache(RELOID,
- ObjectIdGetDatum(indOid),
- 0, 0, 0);
+ tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(indOid));
if (!HeapTupleIsValid(tuple)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for relation %u", indOid);
@@ -1602,9 +1588,7 @@ ReindexTable(RangeVar *relation)
HeapTuple tuple;
heapOid = RangeVarGetRelid(relation, false);
- tuple = SearchSysCache(RELOID,
- ObjectIdGetDatum(heapOid),
- 0, 0, 0);
+ tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(heapOid));
if (!HeapTupleIsValid(tuple)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for relation %u", heapOid);