aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/opclasscmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/opclasscmds.c')
-rw-r--r--src/backend/commands/opclasscmds.c226
1 files changed, 88 insertions, 138 deletions
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 0a7635da68e..a043680e340 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.65 2010/01/02 16:57:37 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/opclasscmds.c,v 1.66 2010/02/14 18:42:14 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -104,11 +104,10 @@ OpFamilyCacheLookup(Oid amID, List *opfamilyname)
Oid namespaceId;
namespaceId = LookupExplicitNamespace(schemaname);
- return SearchSysCache(OPFAMILYAMNAMENSP,
- ObjectIdGetDatum(amID),
- PointerGetDatum(opfname),
- ObjectIdGetDatum(namespaceId),
- 0);
+ return SearchSysCache3(OPFAMILYAMNAMENSP,
+ ObjectIdGetDatum(amID),
+ PointerGetDatum(opfname),
+ ObjectIdGetDatum(namespaceId));
}
else
{
@@ -117,9 +116,7 @@ OpFamilyCacheLookup(Oid amID, List *opfamilyname)
if (!OidIsValid(opfID))
return NULL;
- return SearchSysCache(OPFAMILYOID,
- ObjectIdGetDatum(opfID),
- 0, 0, 0);
+ return SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfID));
}
}
@@ -144,11 +141,10 @@ OpClassCacheLookup(Oid amID, List *opclassname)
Oid namespaceId;
namespaceId = LookupExplicitNamespace(schemaname);
- return SearchSysCache(CLAAMNAMENSP,
- ObjectIdGetDatum(amID),
- PointerGetDatum(opcname),
- ObjectIdGetDatum(namespaceId),
- 0);
+ return SearchSysCache3(CLAAMNAMENSP,
+ ObjectIdGetDatum(amID),
+ PointerGetDatum(opcname),
+ ObjectIdGetDatum(namespaceId));
}
else
{
@@ -157,9 +153,7 @@ OpClassCacheLookup(Oid amID, List *opclassname)
if (!OidIsValid(opcID))
return NULL;
- return SearchSysCache(CLAOID,
- ObjectIdGetDatum(opcID),
- 0, 0, 0);
+ return SearchSysCache1(CLAOID, ObjectIdGetDatum(opcID));
}
}
@@ -187,11 +181,10 @@ CreateOpFamily(char *amname, char *opfname, Oid namespaceoid, Oid amoid)
* Make sure there is no existing opfamily of this name (this is just to
* give a more friendly error message than "duplicate key").
*/
- if (SearchSysCacheExists(OPFAMILYAMNAMENSP,
- ObjectIdGetDatum(amoid),
- CStringGetDatum(opfname),
- ObjectIdGetDatum(namespaceoid),
- 0))
+ if (SearchSysCacheExists3(OPFAMILYAMNAMENSP,
+ ObjectIdGetDatum(amoid),
+ CStringGetDatum(opfname),
+ ObjectIdGetDatum(namespaceoid)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("operator family \"%s\" for access method \"%s\" already exists",
@@ -281,9 +274,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
get_namespace_name(namespaceoid));
/* Get necessary info about access method */
- tup = SearchSysCache(AMNAME,
- CStringGetDatum(stmt->amname),
- 0, 0, 0);
+ tup = SearchSysCache1(AMNAME, CStringGetDatum(stmt->amname));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -362,11 +353,10 @@ DefineOpClass(CreateOpClassStmt *stmt)
else
{
/* Lookup existing family of same name and namespace */
- tup = SearchSysCache(OPFAMILYAMNAMENSP,
- ObjectIdGetDatum(amoid),
- PointerGetDatum(opcname),
- ObjectIdGetDatum(namespaceoid),
- 0);
+ tup = SearchSysCache3(OPFAMILYAMNAMENSP,
+ ObjectIdGetDatum(amoid),
+ PointerGetDatum(opcname),
+ ObjectIdGetDatum(namespaceoid));
if (HeapTupleIsValid(tup))
{
opfamilyoid = HeapTupleGetOid(tup);
@@ -521,11 +511,10 @@ DefineOpClass(CreateOpClassStmt *stmt)
* Make sure there is no existing opclass of this name (this is just to
* give a more friendly error message than "duplicate key").
*/
- if (SearchSysCacheExists(CLAAMNAMENSP,
- ObjectIdGetDatum(amoid),
- CStringGetDatum(opcname),
- ObjectIdGetDatum(namespaceoid),
- 0))
+ if (SearchSysCacheExists3(CLAAMNAMENSP,
+ ObjectIdGetDatum(amoid),
+ CStringGetDatum(opcname),
+ ObjectIdGetDatum(namespaceoid)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("operator class \"%s\" for access method \"%s\" already exists",
@@ -673,9 +662,7 @@ DefineOpFamily(CreateOpFamilyStmt *stmt)
get_namespace_name(namespaceoid));
/* Get necessary info about access method */
- tup = SearchSysCache(AMNAME,
- CStringGetDatum(stmt->amname),
- 0, 0, 0);
+ tup = SearchSysCache1(AMNAME, CStringGetDatum(stmt->amname));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -705,11 +692,10 @@ DefineOpFamily(CreateOpFamilyStmt *stmt)
* Make sure there is no existing opfamily of this name (this is just to
* give a more friendly error message than "duplicate key").
*/
- if (SearchSysCacheExists(OPFAMILYAMNAMENSP,
- ObjectIdGetDatum(amoid),
- CStringGetDatum(opfname),
- ObjectIdGetDatum(namespaceoid),
- 0))
+ if (SearchSysCacheExists3(OPFAMILYAMNAMENSP,
+ ObjectIdGetDatum(amoid),
+ CStringGetDatum(opfname),
+ ObjectIdGetDatum(namespaceoid)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("operator family \"%s\" for access method \"%s\" already exists",
@@ -776,9 +762,7 @@ AlterOpFamily(AlterOpFamilyStmt *stmt)
Form_pg_am pg_am;
/* Get necessary info about access method */
- tup = SearchSysCache(AMNAME,
- CStringGetDatum(stmt->amname),
- 0, 0, 0);
+ tup = SearchSysCache1(AMNAME, CStringGetDatum(stmt->amname));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1065,9 +1049,7 @@ assignOperTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
Form_pg_operator opform;
/* Fetch the operator definition */
- optup = SearchSysCache(OPEROID,
- ObjectIdGetDatum(member->object),
- 0, 0, 0);
+ optup = SearchSysCache1(OPEROID, ObjectIdGetDatum(member->object));
if (optup == NULL)
elog(ERROR, "cache lookup failed for operator %u", member->object);
opform = (Form_pg_operator) GETSTRUCT(optup);
@@ -1106,9 +1088,7 @@ assignProcTypes(OpFamilyMember *member, Oid amoid, Oid typeoid)
Form_pg_proc procform;
/* Fetch the procedure definition */
- proctup = SearchSysCache(PROCOID,
- ObjectIdGetDatum(member->object),
- 0, 0, 0);
+ proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(member->object));
if (proctup == NULL)
elog(ERROR, "cache lookup failed for function %u", member->object);
procform = (Form_pg_proc) GETSTRUCT(proctup);
@@ -1244,11 +1224,11 @@ storeOperators(List *opfamilyname, Oid amoid,
* existing pg_amop entry (just to give a nicer error message)
*/
if (isAdd &&
- SearchSysCacheExists(AMOPSTRATEGY,
- ObjectIdGetDatum(opfamilyoid),
- ObjectIdGetDatum(op->lefttype),
- ObjectIdGetDatum(op->righttype),
- Int16GetDatum(op->number)))
+ SearchSysCacheExists4(AMOPSTRATEGY,
+ ObjectIdGetDatum(opfamilyoid),
+ ObjectIdGetDatum(op->lefttype),
+ ObjectIdGetDatum(op->righttype),
+ Int16GetDatum(op->number)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("operator %d(%s,%s) already exists in operator family \"%s\"",
@@ -1344,11 +1324,11 @@ storeProcedures(List *opfamilyname, Oid amoid,
* existing pg_amproc entry (just to give a nicer error message)
*/
if (isAdd &&
- SearchSysCacheExists(AMPROCNUM,
- ObjectIdGetDatum(opfamilyoid),
- ObjectIdGetDatum(proc->lefttype),
- ObjectIdGetDatum(proc->righttype),
- Int16GetDatum(proc->number)))
+ SearchSysCacheExists4(AMPROCNUM,
+ ObjectIdGetDatum(opfamilyoid),
+ ObjectIdGetDatum(proc->lefttype),
+ ObjectIdGetDatum(proc->righttype),
+ Int16GetDatum(proc->number)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("function %d(%s,%s) already exists in operator family \"%s\"",
@@ -1430,11 +1410,11 @@ dropOperators(List *opfamilyname, Oid amoid, Oid opfamilyoid,
Oid amopid;
ObjectAddress object;
- amopid = GetSysCacheOid(AMOPSTRATEGY,
- ObjectIdGetDatum(opfamilyoid),
- ObjectIdGetDatum(op->lefttype),
- ObjectIdGetDatum(op->righttype),
- Int16GetDatum(op->number));
+ amopid = GetSysCacheOid4(AMOPSTRATEGY,
+ ObjectIdGetDatum(opfamilyoid),
+ ObjectIdGetDatum(op->lefttype),
+ ObjectIdGetDatum(op->righttype),
+ Int16GetDatum(op->number));
if (!OidIsValid(amopid))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1470,11 +1450,11 @@ dropProcedures(List *opfamilyname, Oid amoid, Oid opfamilyoid,
Oid amprocid;
ObjectAddress object;
- amprocid = GetSysCacheOid(AMPROCNUM,
- ObjectIdGetDatum(opfamilyoid),
- ObjectIdGetDatum(op->lefttype),
- ObjectIdGetDatum(op->righttype),
- Int16GetDatum(op->number));
+ amprocid = GetSysCacheOid4(AMPROCNUM,
+ ObjectIdGetDatum(opfamilyoid),
+ ObjectIdGetDatum(op->lefttype),
+ ObjectIdGetDatum(op->righttype),
+ Int16GetDatum(op->number));
if (!OidIsValid(amprocid))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1508,9 +1488,7 @@ RemoveOpClass(RemoveOpClassStmt *stmt)
/*
* Get the access method's OID.
*/
- amID = GetSysCacheOid(AMNAME,
- CStringGetDatum(stmt->amname),
- 0, 0, 0);
+ amID = GetSysCacheOid1(AMNAME, CStringGetDatum(stmt->amname));
if (!OidIsValid(amID))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1571,9 +1549,7 @@ RemoveOpFamily(RemoveOpFamilyStmt *stmt)
/*
* Get the access method's OID.
*/
- amID = GetSysCacheOid(AMNAME,
- CStringGetDatum(stmt->amname),
- 0, 0, 0);
+ amID = GetSysCacheOid1(AMNAME, CStringGetDatum(stmt->amname));
if (!OidIsValid(amID))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1631,9 +1607,7 @@ RemoveOpFamilyById(Oid opfamilyOid)
rel = heap_open(OperatorFamilyRelationId, RowExclusiveLock);
- tup = SearchSysCache(OPFAMILYOID,
- ObjectIdGetDatum(opfamilyOid),
- 0, 0, 0);
+ tup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for opfamily %u", opfamilyOid);
@@ -1652,9 +1626,7 @@ RemoveOpClassById(Oid opclassOid)
rel = heap_open(OperatorClassRelationId, RowExclusiveLock);
- tup = SearchSysCache(CLAOID,
- ObjectIdGetDatum(opclassOid),
- 0, 0, 0);
+ tup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for opclass %u", opclassOid);
@@ -1739,9 +1711,7 @@ RenameOpClass(List *name, const char *access_method, const char *newname)
Relation rel;
AclResult aclresult;
- amOid = GetSysCacheOid(AMNAME,
- CStringGetDatum(access_method),
- 0, 0, 0);
+ amOid = GetSysCacheOid1(AMNAME, CStringGetDatum(access_method));
if (!OidIsValid(amOid))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1759,11 +1729,10 @@ RenameOpClass(List *name, const char *access_method, const char *newname)
{
namespaceOid = LookupExplicitNamespace(schemaname);
- tup = SearchSysCacheCopy(CLAAMNAMENSP,
- ObjectIdGetDatum(amOid),
- PointerGetDatum(opcname),
- ObjectIdGetDatum(namespaceOid),
- 0);
+ tup = SearchSysCacheCopy3(CLAAMNAMENSP,
+ ObjectIdGetDatum(amOid),
+ PointerGetDatum(opcname),
+ ObjectIdGetDatum(namespaceOid));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1781,9 +1750,7 @@ RenameOpClass(List *name, const char *access_method, const char *newname)
errmsg("operator class \"%s\" does not exist for access method \"%s\"",
opcname, access_method)));
- tup = SearchSysCacheCopy(CLAOID,
- ObjectIdGetDatum(opcOid),
- 0, 0, 0);
+ tup = SearchSysCacheCopy1(CLAOID, ObjectIdGetDatum(opcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for opclass %u", opcOid);
@@ -1791,11 +1758,10 @@ RenameOpClass(List *name, const char *access_method, const char *newname)
}
/* make sure the new name doesn't exist */
- if (SearchSysCacheExists(CLAAMNAMENSP,
- ObjectIdGetDatum(amOid),
- CStringGetDatum(newname),
- ObjectIdGetDatum(namespaceOid),
- 0))
+ if (SearchSysCacheExists3(CLAAMNAMENSP,
+ ObjectIdGetDatum(amOid),
+ CStringGetDatum(newname),
+ ObjectIdGetDatum(namespaceOid)))
{
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
@@ -1839,9 +1805,7 @@ RenameOpFamily(List *name, const char *access_method, const char *newname)
Relation rel;
AclResult aclresult;
- amOid = GetSysCacheOid(AMNAME,
- CStringGetDatum(access_method),
- 0, 0, 0);
+ amOid = GetSysCacheOid1(AMNAME, CStringGetDatum(access_method));
if (!OidIsValid(amOid))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1859,11 +1823,10 @@ RenameOpFamily(List *name, const char *access_method, const char *newname)
{
namespaceOid = LookupExplicitNamespace(schemaname);
- tup = SearchSysCacheCopy(OPFAMILYAMNAMENSP,
- ObjectIdGetDatum(amOid),
- PointerGetDatum(opfname),
- ObjectIdGetDatum(namespaceOid),
- 0);
+ tup = SearchSysCacheCopy3(OPFAMILYAMNAMENSP,
+ ObjectIdGetDatum(amOid),
+ PointerGetDatum(opfname),
+ ObjectIdGetDatum(namespaceOid));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1881,9 +1844,7 @@ RenameOpFamily(List *name, const char *access_method, const char *newname)
errmsg("operator family \"%s\" does not exist for access method \"%s\"",
opfname, access_method)));
- tup = SearchSysCacheCopy(OPFAMILYOID,
- ObjectIdGetDatum(opfOid),
- 0, 0, 0);
+ tup = SearchSysCacheCopy1(OPFAMILYOID, ObjectIdGetDatum(opfOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for opfamily %u", opfOid);
@@ -1891,11 +1852,10 @@ RenameOpFamily(List *name, const char *access_method, const char *newname)
}
/* make sure the new name doesn't exist */
- if (SearchSysCacheExists(OPFAMILYAMNAMENSP,
- ObjectIdGetDatum(amOid),
- CStringGetDatum(newname),
- ObjectIdGetDatum(namespaceOid),
- 0))
+ if (SearchSysCacheExists3(OPFAMILYAMNAMENSP,
+ ObjectIdGetDatum(amOid),
+ CStringGetDatum(newname),
+ ObjectIdGetDatum(namespaceOid)))
{
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
@@ -1936,9 +1896,7 @@ AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId)
char *opcname;
char *schemaname;
- amOid = GetSysCacheOid(AMNAME,
- CStringGetDatum(access_method),
- 0, 0, 0);
+ amOid = GetSysCacheOid1(AMNAME, CStringGetDatum(access_method));
if (!OidIsValid(amOid))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1958,11 +1916,10 @@ AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId)
namespaceOid = LookupExplicitNamespace(schemaname);
- tup = SearchSysCacheCopy(CLAAMNAMENSP,
- ObjectIdGetDatum(amOid),
- PointerGetDatum(opcname),
- ObjectIdGetDatum(namespaceOid),
- 0);
+ tup = SearchSysCacheCopy3(CLAAMNAMENSP,
+ ObjectIdGetDatum(amOid),
+ PointerGetDatum(opcname),
+ ObjectIdGetDatum(namespaceOid));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1980,9 +1937,7 @@ AlterOpClassOwner(List *name, const char *access_method, Oid newOwnerId)
errmsg("operator class \"%s\" does not exist for access method \"%s\"",
opcname, access_method)));
- tup = SearchSysCacheCopy(CLAOID,
- ObjectIdGetDatum(opcOid),
- 0, 0, 0);
+ tup = SearchSysCacheCopy1(CLAOID, ObjectIdGetDatum(opcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for opclass %u", opcOid);
}
@@ -2063,9 +2018,7 @@ AlterOpFamilyOwner(List *name, const char *access_method, Oid newOwnerId)
char *opfname;
char *schemaname;
- amOid = GetSysCacheOid(AMNAME,
- CStringGetDatum(access_method),
- 0, 0, 0);
+ amOid = GetSysCacheOid1(AMNAME, CStringGetDatum(access_method));
if (!OidIsValid(amOid))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -2085,11 +2038,10 @@ AlterOpFamilyOwner(List *name, const char *access_method, Oid newOwnerId)
namespaceOid = LookupExplicitNamespace(schemaname);
- tup = SearchSysCacheCopy(OPFAMILYAMNAMENSP,
- ObjectIdGetDatum(amOid),
- PointerGetDatum(opfname),
- ObjectIdGetDatum(namespaceOid),
- 0);
+ tup = SearchSysCacheCopy3(OPFAMILYAMNAMENSP,
+ ObjectIdGetDatum(amOid),
+ PointerGetDatum(opfname),
+ ObjectIdGetDatum(namespaceOid));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -2107,9 +2059,7 @@ AlterOpFamilyOwner(List *name, const char *access_method, Oid newOwnerId)
errmsg("operator family \"%s\" does not exist for access method \"%s\"",
opfname, access_method)));
- tup = SearchSysCacheCopy(OPFAMILYOID,
- ObjectIdGetDatum(opfOid),
- 0, 0, 0);
+ tup = SearchSysCacheCopy1(OPFAMILYOID, ObjectIdGetDatum(opfOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for opfamily %u", opfOid);
}