1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-24 01:29:19 +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:
Robert Haas
2010-02-14 18:42:19 +00:00
parent 1012492bc0
commit e26c539e9f
97 changed files with 1125 additions and 2061 deletions

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.51 2010/01/02 16:57:36 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/aggregatecmds.c,v 1.52 2010/02/14 18:42:13 rhaas Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
@@ -236,9 +236,7 @@ RemoveAggregate(RemoveFuncStmt *stmt)
/*
* Find the function tuple, do permissions and validity checks
*/
tup = SearchSysCache(PROCOID,
ObjectIdGetDatum(procOid),
0, 0, 0);
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(procOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", procOid);
@@ -277,9 +275,7 @@ RenameAggregate(List *name, List *args, const char *newname)
/* Look up function and make sure it's an aggregate */
procOid = LookupAggNameTypeNames(name, args, false);
tup = SearchSysCacheCopy(PROCOID,
ObjectIdGetDatum(procOid),
0, 0, 0);
tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(procOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", procOid);
procForm = (Form_pg_proc) GETSTRUCT(tup);
@@ -287,11 +283,10 @@ RenameAggregate(List *name, List *args, const char *newname)
namespaceOid = procForm->pronamespace;
/* make sure the new name doesn't exist */
if (SearchSysCacheExists(PROCNAMEARGSNSP,
CStringGetDatum(newname),
PointerGetDatum(&procForm->proargtypes),
ObjectIdGetDatum(namespaceOid),
0))
if (SearchSysCacheExists3(PROCNAMEARGSNSP,
CStringGetDatum(newname),
PointerGetDatum(&procForm->proargtypes),
ObjectIdGetDatum(namespaceOid)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_FUNCTION),
errmsg("function %s already exists in schema \"%s\"",

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.150 2010/02/08 04:33:53 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/analyze.c,v 1.151 2010/02/14 18:42:13 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -827,9 +827,7 @@ examine_attribute(Relation onerel, int attnum)
stats = (VacAttrStats *) palloc0(sizeof(VacAttrStats));
stats->attr = (Form_pg_attribute) palloc(ATTRIBUTE_FIXED_PART_SIZE);
memcpy(stats->attr, attr, ATTRIBUTE_FIXED_PART_SIZE);
typtuple = SearchSysCache(TYPEOID,
ObjectIdGetDatum(attr->atttypid),
0, 0, 0);
typtuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(attr->atttypid));
if (!HeapTupleIsValid(typtuple))
elog(ERROR, "cache lookup failed for type %u", attr->atttypid);
stats->attrtype = (Form_pg_type) palloc(sizeof(FormData_pg_type));
@@ -1633,11 +1631,10 @@ update_attstats(Oid relid, bool inh, int natts, VacAttrStats **vacattrstats)
}
/* Is there already a pg_statistic tuple for this attribute? */
oldtup = SearchSysCache(STATRELATTINH,
ObjectIdGetDatum(relid),
Int16GetDatum(stats->attr->attnum),
BoolGetDatum(inh),
0);
oldtup = SearchSysCache3(STATRELATTINH,
ObjectIdGetDatum(relid),
Int16GetDatum(stats->attr->attnum),
BoolGetDatum(inh));
if (HeapTupleIsValid(oldtup))
{

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.200 2010/02/09 21:43:30 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/cluster.c,v 1.201 2010/02/14 18:42:14 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -136,9 +136,8 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
Form_pg_index indexForm;
indexOid = lfirst_oid(index);
idxtuple = SearchSysCache(INDEXRELID,
ObjectIdGetDatum(indexOid),
0, 0, 0);
idxtuple = SearchSysCache1(INDEXRELID,
ObjectIdGetDatum(indexOid));
if (!HeapTupleIsValid(idxtuple))
elog(ERROR, "cache lookup failed for index %u", indexOid);
indexForm = (Form_pg_index) GETSTRUCT(idxtuple);
@@ -316,9 +315,7 @@ cluster_rel(Oid tableOid, Oid indexOid, bool recheck, bool verbose,
/*
* Check that the index still exists
*/
if (!SearchSysCacheExists(RELOID,
ObjectIdGetDatum(indexOid),
0, 0, 0))
if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(indexOid)))
{
relation_close(OldHeap, AccessExclusiveLock);
return;
@@ -327,9 +324,7 @@ cluster_rel(Oid tableOid, Oid indexOid, bool recheck, bool verbose,
/*
* Check that the index is still the one with indisclustered set.
*/
tuple = SearchSysCache(INDEXRELID,
ObjectIdGetDatum(indexOid),
0, 0, 0);
tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexOid));
if (!HeapTupleIsValid(tuple)) /* probably can't happen */
{
relation_close(OldHeap, AccessExclusiveLock);
@@ -519,9 +514,7 @@ mark_index_clustered(Relation rel, Oid indexOid)
*/
if (OidIsValid(indexOid))
{
indexTuple = SearchSysCache(INDEXRELID,
ObjectIdGetDatum(indexOid),
0, 0, 0);
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexOid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexOid);
indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
@@ -544,9 +537,8 @@ mark_index_clustered(Relation rel, Oid indexOid)
{
Oid thisIndexOid = lfirst_oid(index);
indexTuple = SearchSysCacheCopy(INDEXRELID,
ObjectIdGetDatum(thisIndexOid),
0, 0, 0);
indexTuple = SearchSysCacheCopy1(INDEXRELID,
ObjectIdGetDatum(thisIndexOid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", thisIndexOid);
indexForm = (Form_pg_index) GETSTRUCT(indexTuple);
@@ -656,9 +648,7 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace)
/*
* But we do want to use reloptions of the old heap for new heap.
*/
tuple = SearchSysCache(RELOID,
ObjectIdGetDatum(OIDOldHeap),
0, 0, 0);
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(OIDOldHeap));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", OIDOldHeap);
reloptions = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_reloptions,
@@ -722,9 +712,7 @@ make_new_heap(Oid OIDOldHeap, Oid NewTableSpace)
if (OidIsValid(toastid))
{
/* keep the existing toast table's reloptions, if any */
tuple = SearchSysCache(RELOID,
ObjectIdGetDatum(toastid),
0, 0, 0);
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(toastid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", toastid);
reloptions = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_reloptions,
@@ -1077,16 +1065,12 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class,
/* We need writable copies of both pg_class tuples. */
relRelation = heap_open(RelationRelationId, RowExclusiveLock);
reltup1 = SearchSysCacheCopy(RELOID,
ObjectIdGetDatum(r1),
0, 0, 0);
reltup1 = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(r1));
if (!HeapTupleIsValid(reltup1))
elog(ERROR, "cache lookup failed for relation %u", r1);
relform1 = (Form_pg_class) GETSTRUCT(reltup1);
reltup2 = SearchSysCacheCopy(RELOID,
ObjectIdGetDatum(r2),
0, 0, 0);
reltup2 = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(r2));
if (!HeapTupleIsValid(reltup2))
elog(ERROR, "cache lookup failed for relation %u", r2);
relform2 = (Form_pg_class) GETSTRUCT(reltup2);

View File

@@ -7,7 +7,7 @@
* Copyright (c) 1996-2010, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.112 2010/01/02 16:57:37 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/comment.c,v 1.113 2010/02/14 18:42:14 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -800,9 +800,7 @@ CommentNamespace(List *qualname, char *comment)
errmsg("schema name cannot be qualified")));
namespace = strVal(linitial(qualname));
oid = GetSysCacheOid(NAMESPACENAME,
CStringGetDatum(namespace),
0, 0, 0);
oid = GetSysCacheOid1(NAMESPACENAME, CStringGetDatum(namespace));
if (!OidIsValid(oid))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
@@ -904,10 +902,9 @@ CommentRule(List *qualname, char *comment)
reloid = RelationGetRelid(relation);
/* Find the rule's pg_rewrite tuple, get its OID */
tuple = SearchSysCache(RULERELNAME,
ObjectIdGetDatum(reloid),
PointerGetDatum(rulename),
0, 0);
tuple = SearchSysCache2(RULERELNAME,
ObjectIdGetDatum(reloid),
PointerGetDatum(rulename));
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1217,9 +1214,7 @@ CommentLanguage(List *qualname, char *comment)
errmsg("language name cannot be qualified")));
language = strVal(linitial(qualname));
oid = GetSysCacheOid(LANGNAME,
CStringGetDatum(language),
0, 0, 0);
oid = GetSysCacheOid1(LANGNAME, CStringGetDatum(language));
if (!OidIsValid(oid))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
@@ -1260,9 +1255,7 @@ CommentOpClass(List *qualname, List *arguments, char *comment)
/*
* Get the access method's OID.
*/
amID = GetSysCacheOid(AMNAME,
CStringGetDatum(amname),
0, 0, 0);
amID = GetSysCacheOid1(AMNAME, CStringGetDatum(amname));
if (!OidIsValid(amID))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1282,11 +1275,10 @@ CommentOpClass(List *qualname, List *arguments, char *comment)
Oid namespaceId;
namespaceId = LookupExplicitNamespace(schemaname);
tuple = SearchSysCache(CLAAMNAMENSP,
ObjectIdGetDatum(amID),
PointerGetDatum(opcname),
ObjectIdGetDatum(namespaceId),
0);
tuple = SearchSysCache3(CLAAMNAMENSP,
ObjectIdGetDatum(amID),
PointerGetDatum(opcname),
ObjectIdGetDatum(namespaceId));
}
else
{
@@ -1297,9 +1289,7 @@ CommentOpClass(List *qualname, List *arguments, char *comment)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("operator class \"%s\" does not exist for access method \"%s\"",
opcname, amname)));
tuple = SearchSysCache(CLAOID,
ObjectIdGetDatum(opcID),
0, 0, 0);
tuple = SearchSysCache1(CLAOID, ObjectIdGetDatum(opcID));
}
if (!HeapTupleIsValid(tuple))
@@ -1346,9 +1336,7 @@ CommentOpFamily(List *qualname, List *arguments, char *comment)
/*
* Get the access method's OID.
*/
amID = GetSysCacheOid(AMNAME,
CStringGetDatum(amname),
0, 0, 0);
amID = GetSysCacheOid1(AMNAME, CStringGetDatum(amname));
if (!OidIsValid(amID))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1368,11 +1356,10 @@ CommentOpFamily(List *qualname, List *arguments, char *comment)
Oid namespaceId;
namespaceId = LookupExplicitNamespace(schemaname);
tuple = SearchSysCache(OPFAMILYAMNAMENSP,
ObjectIdGetDatum(amID),
PointerGetDatum(opfname),
ObjectIdGetDatum(namespaceId),
0);
tuple = SearchSysCache3(OPFAMILYAMNAMENSP,
ObjectIdGetDatum(amID),
PointerGetDatum(opfname),
ObjectIdGetDatum(namespaceId));
}
else
{
@@ -1383,9 +1370,7 @@ CommentOpFamily(List *qualname, List *arguments, char *comment)
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("operator family \"%s\" does not exist for access method \"%s\"",
opfname, amname)));
tuple = SearchSysCache(OPFAMILYOID,
ObjectIdGetDatum(opfID),
0, 0, 0);
tuple = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfID));
}
if (!HeapTupleIsValid(tuple))
@@ -1500,10 +1485,9 @@ CommentCast(List *qualname, List *arguments, char *comment)
sourcetypeid = typenameTypeId(NULL, sourcetype, NULL);
targettypeid = typenameTypeId(NULL, targettype, NULL);
tuple = SearchSysCache(CASTSOURCETARGET,
ObjectIdGetDatum(sourcetypeid),
ObjectIdGetDatum(targettypeid),
0, 0);
tuple = SearchSysCache2(CASTSOURCETARGET,
ObjectIdGetDatum(sourcetypeid),
ObjectIdGetDatum(targettypeid));
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),

View File

@@ -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);

View File

@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.233 2010/01/16 14:16:31 sriggs Exp $
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.234 2010/02/14 18:42:14 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -809,9 +809,7 @@ dropdb(const char *dbname, bool missing_ok)
/*
* Remove the database's tuple from pg_database.
*/
tup = SearchSysCache(DATABASEOID,
ObjectIdGetDatum(db_id),
0, 0, 0);
tup = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(db_id));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for database %u", db_id);
@@ -951,9 +949,7 @@ RenameDatabase(const char *oldname, const char *newname)
errdetail_busy_db(notherbackends, npreparedxacts)));
/* rename */
newtup = SearchSysCacheCopy(DATABASEOID,
ObjectIdGetDatum(db_id),
0, 0, 0);
newtup = SearchSysCacheCopy1(DATABASEOID, ObjectIdGetDatum(db_id));
if (!HeapTupleIsValid(newtup))
elog(ERROR, "cache lookup failed for database %u", db_id);
namestrcpy(&(((Form_pg_database) GETSTRUCT(newtup))->datname), newname);
@@ -1611,9 +1607,7 @@ get_db_info(const char *name, LOCKMODE lockmode,
* the same name, we win; else, drop the lock and loop back to try
* again.
*/
tuple = SearchSysCache(DATABASEOID,
ObjectIdGetDatum(dbOid),
0, 0, 0);
tuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(dbOid));
if (HeapTupleIsValid(tuple))
{
Form_pg_database dbform = (Form_pg_database) GETSTRUCT(tuple);
@@ -1677,9 +1671,7 @@ have_createdb_privilege(void)
if (superuser())
return true;
utup = SearchSysCache(AUTHOID,
ObjectIdGetDatum(GetUserId()),
0, 0, 0);
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(GetUserId()));
if (HeapTupleIsValid(utup))
{
result = ((Form_pg_authid) GETSTRUCT(utup))->rolcreatedb;
@@ -1875,9 +1867,7 @@ get_database_name(Oid dbid)
HeapTuple dbtuple;
char *result;
dbtuple = SearchSysCache(DATABASEOID,
ObjectIdGetDatum(dbid),
0, 0, 0);
dbtuple = SearchSysCache1(DATABASEOID, ObjectIdGetDatum(dbid));
if (HeapTupleIsValid(dbtuple))
{
result = pstrdup(NameStr(((Form_pg_database) GETSTRUCT(dbtuple))->datname));

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/foreigncmds.c,v 1.10 2010/01/02 16:57:37 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/foreigncmds.c,v 1.11 2010/02/14 18:42:14 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -220,9 +220,7 @@ AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId)
rel = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy(FOREIGNDATAWRAPPERNAME,
CStringGetDatum(name),
0, 0, 0);
tup = SearchSysCacheCopy1(FOREIGNDATAWRAPPERNAME, CStringGetDatum(name));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
@@ -264,9 +262,7 @@ AlterForeignServerOwner(const char *name, Oid newOwnerId)
rel = heap_open(ForeignServerRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy(FOREIGNSERVERNAME,
CStringGetDatum(name),
0, 0, 0);
tup = SearchSysCacheCopy1(FOREIGNSERVERNAME, CStringGetDatum(name));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
@@ -447,9 +443,8 @@ AlterForeignDataWrapper(AlterFdwStmt *stmt)
stmt->fdwname),
errhint("Must be superuser to alter a foreign-data wrapper.")));
tp = SearchSysCacheCopy(FOREIGNDATAWRAPPERNAME,
CStringGetDatum(stmt->fdwname),
0, 0, 0);
tp = SearchSysCacheCopy1(FOREIGNDATAWRAPPERNAME,
CStringGetDatum(stmt->fdwname));
if (!HeapTupleIsValid(tp))
ereport(ERROR,
@@ -587,9 +582,7 @@ RemoveForeignDataWrapperById(Oid fdwId)
rel = heap_open(ForeignDataWrapperRelationId, RowExclusiveLock);
tp = SearchSysCache(FOREIGNDATAWRAPPEROID,
ObjectIdGetDatum(fdwId),
0, 0, 0);
tp = SearchSysCache1(FOREIGNDATAWRAPPEROID, ObjectIdGetDatum(fdwId));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for foreign-data wrapper %u", fdwId);
@@ -721,9 +714,8 @@ AlterForeignServer(AlterForeignServerStmt *stmt)
Oid srvId;
Form_pg_foreign_server srvForm;
tp = SearchSysCacheCopy(FOREIGNSERVERNAME,
CStringGetDatum(stmt->servername),
0, 0, 0);
tp = SearchSysCacheCopy1(FOREIGNSERVERNAME,
CStringGetDatum(stmt->servername));
if (!HeapTupleIsValid(tp))
ereport(ERROR,
@@ -851,9 +843,7 @@ RemoveForeignServerById(Oid srvId)
rel = heap_open(ForeignServerRelationId, RowExclusiveLock);
tp = SearchSysCache(FOREIGNSERVEROID,
ObjectIdGetDatum(srvId),
0, 0, 0);
tp = SearchSysCache1(FOREIGNSERVEROID, ObjectIdGetDatum(srvId));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for foreign server %u", srvId);
@@ -921,10 +911,9 @@ CreateUserMapping(CreateUserMappingStmt *stmt)
/*
* Check that the user mapping is unique within server.
*/
umId = GetSysCacheOid(USERMAPPINGUSERSERVER,
ObjectIdGetDatum(useId),
ObjectIdGetDatum(srv->serverid),
0, 0);
umId = GetSysCacheOid2(USERMAPPINGUSERSERVER,
ObjectIdGetDatum(useId),
ObjectIdGetDatum(srv->serverid));
if (OidIsValid(umId))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
@@ -1000,10 +989,9 @@ AlterUserMapping(AlterUserMappingStmt *stmt)
useId = GetUserOidFromMapping(stmt->username, false);
srv = GetForeignServerByName(stmt->servername, false);
umId = GetSysCacheOid(USERMAPPINGUSERSERVER,
ObjectIdGetDatum(useId),
ObjectIdGetDatum(srv->serverid),
0, 0);
umId = GetSysCacheOid2(USERMAPPINGUSERSERVER,
ObjectIdGetDatum(useId),
ObjectIdGetDatum(srv->serverid));
if (!OidIsValid(umId))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1012,9 +1000,7 @@ AlterUserMapping(AlterUserMappingStmt *stmt)
user_mapping_ddl_aclcheck(useId, srv->serverid, stmt->servername);
tp = SearchSysCacheCopy(USERMAPPINGOID,
ObjectIdGetDatum(umId),
0, 0, 0);
tp = SearchSysCacheCopy1(USERMAPPINGOID, ObjectIdGetDatum(umId));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for user mapping %u", umId);
@@ -1107,10 +1093,9 @@ RemoveUserMapping(DropUserMappingStmt *stmt)
return;
}
umId = GetSysCacheOid(USERMAPPINGUSERSERVER,
ObjectIdGetDatum(useId),
ObjectIdGetDatum(srv->serverid),
0, 0);
umId = GetSysCacheOid2(USERMAPPINGUSERSERVER,
ObjectIdGetDatum(useId),
ObjectIdGetDatum(srv->serverid));
if (!OidIsValid(umId))
{
@@ -1151,9 +1136,7 @@ RemoveUserMappingById(Oid umId)
rel = heap_open(UserMappingRelationId, RowExclusiveLock);
tp = SearchSysCache(USERMAPPINGOID,
ObjectIdGetDatum(umId),
0, 0, 0);
tp = SearchSysCache1(USERMAPPINGOID, ObjectIdGetDatum(umId));
if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for user mapping %u", umId);

View File

@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.115 2010/01/26 16:33:40 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.116 2010/02/14 18:42:14 rhaas Exp $
*
* DESCRIPTION
* These routines take the parse tree and pick out the
@@ -829,9 +829,7 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
languageName = case_translate_language_name(language);
/* Look up the language and validate permissions */
languageTuple = SearchSysCache(LANGNAME,
PointerGetDatum(languageName),
0, 0, 0);
languageTuple = SearchSysCache1(LANGNAME, PointerGetDatum(languageName));
if (!HeapTupleIsValid(languageTuple))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -990,9 +988,7 @@ RemoveFunction(RemoveFuncStmt *stmt)
return;
}
tup = SearchSysCache(PROCOID,
ObjectIdGetDatum(funcOid),
0, 0, 0);
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", funcOid);
@@ -1049,9 +1045,7 @@ RemoveFunctionById(Oid funcOid)
*/
relation = heap_open(ProcedureRelationId, RowExclusiveLock);
tup = SearchSysCache(PROCOID,
ObjectIdGetDatum(funcOid),
0, 0, 0);
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", funcOid);
@@ -1070,9 +1064,7 @@ RemoveFunctionById(Oid funcOid)
{
relation = heap_open(AggregateRelationId, RowExclusiveLock);
tup = SearchSysCache(AGGFNOID,
ObjectIdGetDatum(funcOid),
0, 0, 0);
tup = SearchSysCache1(AGGFNOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for pg_aggregate tuple for function %u", funcOid);
@@ -1102,9 +1094,7 @@ RenameFunction(List *name, List *argtypes, const char *newname)
procOid = LookupFuncNameTypeNames(name, argtypes, false);
tup = SearchSysCacheCopy(PROCOID,
ObjectIdGetDatum(procOid),
0, 0, 0);
tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(procOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", procOid);
procForm = (Form_pg_proc) GETSTRUCT(tup);
@@ -1119,11 +1109,10 @@ RenameFunction(List *name, List *argtypes, const char *newname)
namespaceOid = procForm->pronamespace;
/* make sure the new name doesn't exist */
if (SearchSysCacheExists(PROCNAMEARGSNSP,
CStringGetDatum(newname),
PointerGetDatum(&procForm->proargtypes),
ObjectIdGetDatum(namespaceOid),
0))
if (SearchSysCacheExists3(PROCNAMEARGSNSP,
CStringGetDatum(newname),
PointerGetDatum(&procForm->proargtypes),
ObjectIdGetDatum(namespaceOid)))
{
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_FUNCTION),
@@ -1169,9 +1158,7 @@ AlterFunctionOwner(List *name, List *argtypes, Oid newOwnerId)
procOid = LookupFuncNameTypeNames(name, argtypes, false);
tup = SearchSysCache(PROCOID,
ObjectIdGetDatum(procOid),
0, 0, 0);
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(procOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", procOid);
@@ -1198,9 +1185,7 @@ AlterFunctionOwner_oid(Oid procOid, Oid newOwnerId)
rel = heap_open(ProcedureRelationId, RowExclusiveLock);
tup = SearchSysCache(PROCOID,
ObjectIdGetDatum(procOid),
0, 0, 0);
tup = SearchSysCache1(PROCOID, ObjectIdGetDatum(procOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", procOid);
AlterFunctionOwner_internal(rel, tup, newOwnerId);
@@ -1317,9 +1302,7 @@ AlterFunction(AlterFunctionStmt *stmt)
stmt->func->funcargs,
false);
tup = SearchSysCacheCopy(PROCOID,
ObjectIdGetDatum(funcOid),
0, 0, 0);
tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", funcOid);
@@ -1436,9 +1419,7 @@ SetFunctionReturnType(Oid funcOid, Oid newRetType)
pg_proc_rel = heap_open(ProcedureRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy(PROCOID,
ObjectIdGetDatum(funcOid),
0, 0, 0);
tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", funcOid);
procForm = (Form_pg_proc) GETSTRUCT(tup);
@@ -1472,9 +1453,7 @@ SetFunctionArgType(Oid funcOid, int argIndex, Oid newArgType)
pg_proc_rel = heap_open(ProcedureRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy(PROCOID,
ObjectIdGetDatum(funcOid),
0, 0, 0);
tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for function %u", funcOid);
procForm = (Form_pg_proc) GETSTRUCT(tup);
@@ -1560,9 +1539,7 @@ CreateCast(CreateCastStmt *stmt)
stmt->func->funcargs,
false);
tuple = SearchSysCache(PROCOID,
ObjectIdGetDatum(funcid),
0, 0, 0);
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcid);
@@ -1716,10 +1693,9 @@ CreateCast(CreateCastStmt *stmt)
* the unique index would catch it anyway (so no need to sweat about race
* conditions).
*/
tuple = SearchSysCache(CASTSOURCETARGET,
ObjectIdGetDatum(sourcetypeid),
ObjectIdGetDatum(targettypeid),
0, 0);
tuple = SearchSysCache2(CASTSOURCETARGET,
ObjectIdGetDatum(sourcetypeid),
ObjectIdGetDatum(targettypeid));
if (HeapTupleIsValid(tuple))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
@@ -1790,10 +1766,9 @@ DropCast(DropCastStmt *stmt)
sourcetypeid = typenameTypeId(NULL, stmt->sourcetype, NULL);
targettypeid = typenameTypeId(NULL, stmt->targettype, NULL);
tuple = SearchSysCache(CASTSOURCETARGET,
ObjectIdGetDatum(sourcetypeid),
ObjectIdGetDatum(targettypeid),
0, 0);
tuple = SearchSysCache2(CASTSOURCETARGET,
ObjectIdGetDatum(sourcetypeid),
ObjectIdGetDatum(targettypeid));
if (!HeapTupleIsValid(tuple))
{
if (!stmt->missing_ok)
@@ -1888,9 +1863,7 @@ AlterFunctionNamespace(List *name, List *argtypes, bool isagg,
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC,
NameListToString(name));
tup = SearchSysCacheCopy(PROCOID,
ObjectIdGetDatum(procOid),
0, 0, 0);
tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(procOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for function %u", procOid);
proc = (Form_pg_proc) GETSTRUCT(tup);
@@ -1920,11 +1893,10 @@ AlterFunctionNamespace(List *name, List *argtypes, bool isagg,
errmsg("cannot move objects into or out of TOAST schema")));
/* check for duplicate name (more friendly than unique-index failure) */
if (SearchSysCacheExists(PROCNAMEARGSNSP,
CStringGetDatum(NameStr(proc->proname)),
PointerGetDatum(&proc->proargtypes),
ObjectIdGetDatum(nspOid),
0))
if (SearchSysCacheExists3(PROCNAMEARGSNSP,
CStringGetDatum(NameStr(proc->proname)),
PointerGetDatum(&proc->proargtypes),
ObjectIdGetDatum(nspOid)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_FUNCTION),
errmsg("function \"%s\" already exists in schema \"%s\"",
@@ -2011,9 +1983,7 @@ ExecuteDoStmt(DoStmt *stmt)
languageName = case_translate_language_name(language);
/* Look up the language and validate permissions */
languageTuple = SearchSysCache(LANGNAME,
PointerGetDatum(languageName),
0, 0, 0);
languageTuple = SearchSysCache1(LANGNAME, PointerGetDatum(languageName));
if (!HeapTupleIsValid(languageTuple))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/operatorcmds.c,v 1.44 2010/01/02 16:57:37 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/operatorcmds.c,v 1.45 2010/02/14 18:42:14 rhaas Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
@@ -308,9 +308,7 @@ RemoveOperator(RemoveFuncStmt *stmt)
return;
}
tup = SearchSysCache(OPEROID,
ObjectIdGetDatum(operOid),
0, 0, 0);
tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for operator %u", operOid);
@@ -344,9 +342,7 @@ RemoveOperatorById(Oid operOid)
relation = heap_open(OperatorRelationId, RowExclusiveLock);
tup = SearchSysCache(OPEROID,
ObjectIdGetDatum(operOid),
0, 0, 0);
tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for operator %u", operOid);
@@ -399,9 +395,7 @@ AlterOperatorOwner_internal(Relation rel, Oid operOid, Oid newOwnerId)
Assert(RelationGetRelid(rel) == OperatorRelationId);
tup = SearchSysCacheCopy(OPEROID,
ObjectIdGetDatum(operOid),
0, 0, 0);
tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(operOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for operator %u", operOid);

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.88 2010/01/02 16:57:37 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.89 2010/02/14 18:42:14 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -78,9 +78,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
*/
languageName = case_translate_language_name(stmt->plname);
if (SearchSysCacheExists(LANGNAME,
PointerGetDatum(languageName),
0, 0, 0))
if (SearchSysCacheExists1(LANGNAME, PointerGetDatum(languageName)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("language \"%s\" already exists", languageName)));
@@ -489,9 +487,7 @@ DropProceduralLanguage(DropPLangStmt *stmt)
*/
languageName = case_translate_language_name(stmt->plname);
langTup = SearchSysCache(LANGNAME,
CStringGetDatum(languageName),
0, 0, 0);
langTup = SearchSysCache1(LANGNAME, CStringGetDatum(languageName));
if (!HeapTupleIsValid(langTup))
{
if (!stmt->missing_ok)
@@ -536,9 +532,7 @@ DropProceduralLanguageById(Oid langOid)
rel = heap_open(LanguageRelationId, RowExclusiveLock);
langTup = SearchSysCache(LANGOID,
ObjectIdGetDatum(langOid),
0, 0, 0);
langTup = SearchSysCache1(LANGOID, ObjectIdGetDatum(langOid));
if (!HeapTupleIsValid(langTup)) /* should not happen */
elog(ERROR, "cache lookup failed for language %u", langOid);
@@ -564,18 +558,14 @@ RenameLanguage(const char *oldname, const char *newname)
rel = heap_open(LanguageRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy(LANGNAME,
CStringGetDatum(oldname),
0, 0, 0);
tup = SearchSysCacheCopy1(LANGNAME, CStringGetDatum(oldname));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("language \"%s\" does not exist", oldname)));
/* make sure the new name doesn't exist */
if (SearchSysCacheExists(LANGNAME,
CStringGetDatum(newname),
0, 0, 0))
if (SearchSysCacheExists1(LANGNAME, CStringGetDatum(newname)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("language \"%s\" already exists", newname)));
@@ -608,9 +598,7 @@ AlterLanguageOwner(const char *name, Oid newOwnerId)
rel = heap_open(LanguageRelationId, RowExclusiveLock);
tup = SearchSysCache(LANGNAME,
CStringGetDatum(name),
0, 0, 0);
tup = SearchSysCache1(LANGNAME, CStringGetDatum(name));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -635,9 +623,7 @@ AlterLanguageOwner_oid(Oid oid, Oid newOwnerId)
rel = heap_open(LanguageRelationId, RowExclusiveLock);
tup = SearchSysCache(LANGOID,
ObjectIdGetDatum(oid),
0, 0, 0);
tup = SearchSysCache1(LANGOID, ObjectIdGetDatum(oid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for language %u", oid);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.55 2010/01/02 16:57:37 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.56 2010/02/14 18:42:14 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -178,9 +178,8 @@ RemoveSchemas(DropStmt *drop)
errmsg("schema name cannot be qualified")));
namespaceName = strVal(linitial(names));
namespaceId = GetSysCacheOid(NAMESPACENAME,
CStringGetDatum(namespaceName),
0, 0, 0);
namespaceId = GetSysCacheOid1(NAMESPACENAME,
CStringGetDatum(namespaceName));
if (!OidIsValid(namespaceId))
{
@@ -233,9 +232,8 @@ RemoveSchemaById(Oid schemaOid)
relation = heap_open(NamespaceRelationId, RowExclusiveLock);
tup = SearchSysCache(NAMESPACEOID,
ObjectIdGetDatum(schemaOid),
0, 0, 0);
tup = SearchSysCache1(NAMESPACEOID,
ObjectIdGetDatum(schemaOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for namespace %u", schemaOid);
@@ -259,9 +257,7 @@ RenameSchema(const char *oldname, const char *newname)
rel = heap_open(NamespaceRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy(NAMESPACENAME,
CStringGetDatum(oldname),
0, 0, 0);
tup = SearchSysCacheCopy1(NAMESPACENAME, CStringGetDatum(oldname));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_SCHEMA),
@@ -269,9 +265,8 @@ RenameSchema(const char *oldname, const char *newname)
/* make sure the new name doesn't exist */
if (HeapTupleIsValid(
SearchSysCache(NAMESPACENAME,
CStringGetDatum(newname),
0, 0, 0)))
SearchSysCache1(NAMESPACENAME,
CStringGetDatum(newname))))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_SCHEMA),
errmsg("schema \"%s\" already exists", newname)));
@@ -310,9 +305,7 @@ AlterSchemaOwner_oid(Oid oid, Oid newOwnerId)
rel = heap_open(NamespaceRelationId, RowExclusiveLock);
tup = SearchSysCache(NAMESPACEOID,
ObjectIdGetDatum(oid),
0, 0, 0);
tup = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(oid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for schema %u", oid);
@@ -335,9 +328,7 @@ AlterSchemaOwner(const char *name, Oid newOwnerId)
rel = heap_open(NamespaceRelationId, RowExclusiveLock);
tup = SearchSysCache(NAMESPACENAME,
CStringGetDatum(name),
0, 0, 0);
tup = SearchSysCache1(NAMESPACENAME, CStringGetDatum(name));
if (!HeapTupleIsValid(tup))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_SCHEMA),

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.165 2010/02/09 21:43:30 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.166 2010/02/14 18:42:14 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -692,9 +692,7 @@ lastval(PG_FUNCTION_ARGS)
errmsg("lastval is not yet defined in this session")));
/* Someone may have dropped the sequence since the last nextval() */
if (!SearchSysCacheExists(RELOID,
ObjectIdGetDatum(last_used_seq->relid),
0, 0, 0))
if (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(last_used_seq->relid)))
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("lastval is not yet defined in this session")));

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.325 2010/02/07 20:48:10 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.326 2010/02/14 18:42:14 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -728,9 +728,7 @@ RemoveRelations(DropStmt *drop)
*/
if (relkind == RELKIND_INDEX)
{
tuple = SearchSysCache(INDEXRELID,
ObjectIdGetDatum(relOid),
0, 0, 0);
tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(relOid));
if (HeapTupleIsValid(tuple))
{
Form_pg_index index = (Form_pg_index) GETSTRUCT(tuple);
@@ -743,9 +741,7 @@ RemoveRelations(DropStmt *drop)
/* Get the lock before trying to fetch the syscache entry */
LockRelationOid(relOid, AccessExclusiveLock);
tuple = SearchSysCache(RELOID,
ObjectIdGetDatum(relOid),
0, 0, 0);
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relOid);
classform = (Form_pg_class) GETSTRUCT(tuple);
@@ -1906,9 +1902,7 @@ setRelhassubclassInRelation(Oid relationId, bool relhassubclass)
* need to update it, but we still need to issue an SI inval message.
*/
relationRelation = heap_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy(RELOID,
ObjectIdGetDatum(relationId),
0, 0, 0);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relationId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationId);
classtuple = (Form_pg_class) GETSTRUCT(tuple);
@@ -2062,10 +2056,9 @@ renameatt(Oid myrelid,
/* new name should not already exist */
/* this test is deliberately not attisdropped-aware */
if (SearchSysCacheExists(ATTNAME,
ObjectIdGetDatum(myrelid),
PointerGetDatum(newattname),
0, 0))
if (SearchSysCacheExists2(ATTNAME,
ObjectIdGetDatum(myrelid),
PointerGetDatum(newattname)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_COLUMN),
errmsg("column \"%s\" of relation \"%s\" already exists",
@@ -2172,9 +2165,7 @@ RenameRelationInternal(Oid myrelid, const char *newrelname, Oid namespaceId)
*/
relrelation = heap_open(RelationRelationId, RowExclusiveLock);
reltup = SearchSysCacheCopy(RELOID,
ObjectIdGetDatum(myrelid),
0, 0, 0);
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup)) /* shouldn't happen */
elog(ERROR, "cache lookup failed for relation %u", myrelid);
relform = (Form_pg_class) GETSTRUCT(reltup);
@@ -3671,9 +3662,7 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
pgclass = heap_open(RelationRelationId, RowExclusiveLock);
reltup = SearchSysCacheCopy(RELOID,
ObjectIdGetDatum(myrelid),
0, 0, 0);
reltup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(myrelid));
if (!HeapTupleIsValid(reltup))
elog(ERROR, "cache lookup failed for relation %u", myrelid);
relkind = ((Form_pg_class) GETSTRUCT(reltup))->relkind;
@@ -3682,10 +3671,9 @@ ATExecAddColumn(AlteredTableInfo *tab, Relation rel,
* this test is deliberately not attisdropped-aware, since if one tries to
* add a column matching a dropped column name, it's gonna fail anyway.
*/
if (SearchSysCacheExists(ATTNAME,
ObjectIdGetDatum(myrelid),
PointerGetDatum(colDef->colname),
0, 0))
if (SearchSysCacheExists2(ATTNAME,
ObjectIdGetDatum(myrelid),
PointerGetDatum(colDef->colname)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_COLUMN),
errmsg("column \"%s\" of relation \"%s\" already exists",
@@ -3953,9 +3941,7 @@ ATExecDropNotNull(Relation rel, const char *colName)
Form_pg_index indexStruct;
int i;
indexTuple = SearchSysCache(INDEXRELID,
ObjectIdGetDatum(indexoid),
0, 0, 0);
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexoid);
indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
@@ -4496,9 +4482,8 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName,
class_rel = heap_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy(RELOID,
ObjectIdGetDatum(RelationGetRelid(rel)),
0, 0, 0);
tuple = SearchSysCacheCopy1(RELOID,
ObjectIdGetDatum(RelationGetRelid(rel)));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(rel));
@@ -4876,9 +4861,7 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel,
int16 eqstrategy;
/* We need several fields out of the pg_opclass entry */
cla_ht = SearchSysCache(CLAOID,
ObjectIdGetDatum(opclasses[i]),
0, 0, 0);
cla_ht = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclasses[i]));
if (!HeapTupleIsValid(cla_ht))
elog(ERROR, "cache lookup failed for opclass %u", opclasses[i]);
cla_tup = (Form_pg_opclass) GETSTRUCT(cla_ht);
@@ -5103,9 +5086,7 @@ transformFkeyGetPrimaryKey(Relation pkrel, Oid *indexOid,
{
Oid indexoid = lfirst_oid(indexoidscan);
indexTuple = SearchSysCache(INDEXRELID,
ObjectIdGetDatum(indexoid),
0, 0, 0);
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexoid);
indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
@@ -5200,9 +5181,7 @@ transformFkeyCheckAttrs(Relation pkrel,
j;
indexoid = lfirst_oid(indexoidscan);
indexTuple = SearchSysCache(INDEXRELID,
ObjectIdGetDatum(indexoid),
0, 0, 0);
indexTuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexoid));
if (!HeapTupleIsValid(indexTuple))
elog(ERROR, "cache lookup failed for index %u", indexoid);
indexStruct = (Form_pg_index) GETSTRUCT(indexTuple);
@@ -6432,9 +6411,7 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing)
/* Get its pg_class tuple, too */
class_rel = heap_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCache(RELOID,
ObjectIdGetDatum(relationOid),
0, 0, 0);
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relationOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relationOid);
tuple_class = (Form_pg_class) GETSTRUCT(tuple);
@@ -6788,9 +6765,7 @@ ATExecSetRelOptions(Relation rel, List *defList, bool isReset)
/* Get the old reloptions */
relid = RelationGetRelid(rel);
tuple = SearchSysCache(RELOID,
ObjectIdGetDatum(relid),
0, 0, 0);
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
@@ -6853,9 +6828,7 @@ ATExecSetRelOptions(Relation rel, List *defList, bool isReset)
toastrel = heap_open(toastid, AccessExclusiveLock);
/* Get the old reloptions */
tuple = SearchSysCache(RELOID,
ObjectIdGetDatum(toastid),
0, 0, 0);
tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(toastid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", toastid);
@@ -6960,9 +6933,7 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace)
/* Get a modifiable copy of the relation's pg_class row */
pg_class = heap_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy(RELOID,
ObjectIdGetDatum(tableOid),
0, 0, 0);
tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(tableOid));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", tableOid);
rd_rel = (Form_pg_class) GETSTRUCT(tuple);
@@ -7866,9 +7837,7 @@ AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
HeapTuple classTup;
Form_pg_class classForm;
classTup = SearchSysCacheCopy(RELOID,
ObjectIdGetDatum(relOid),
0, 0, 0);
classTup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relOid));
if (!HeapTupleIsValid(classTup))
elog(ERROR, "cache lookup failed for relation %u", relOid);
classForm = (Form_pg_class) GETSTRUCT(classTup);

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.260 2010/01/24 21:49:17 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.261 2010/02/14 18:42:14 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -574,9 +574,8 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
* entries.
*/
pgrel = heap_open(RelationRelationId, RowExclusiveLock);
tuple = SearchSysCacheCopy(RELOID,
ObjectIdGetDatum(RelationGetRelid(rel)),
0, 0, 0);
tuple = SearchSysCacheCopy1(RELOID,
ObjectIdGetDatum(RelationGetRelid(rel)));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u",
RelationGetRelid(rel));

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/tsearchcmds.c,v 1.19 2010/01/02 16:57:39 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/tsearchcmds.c,v 1.20 2010/02/14 18:42:14 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -338,9 +338,7 @@ RemoveTSParserById(Oid prsId)
relation = heap_open(TSParserRelationId, RowExclusiveLock);
tup = SearchSysCache(TSPARSEROID,
ObjectIdGetDatum(prsId),
0, 0, 0);
tup = SearchSysCache1(TSPARSEROID, ObjectIdGetDatum(prsId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search parser %u", prsId);
@@ -372,19 +370,16 @@ RenameTSParser(List *oldname, const char *newname)
prsId = TSParserGetPrsid(oldname, false);
tup = SearchSysCacheCopy(TSPARSEROID,
ObjectIdGetDatum(prsId),
0, 0, 0);
tup = SearchSysCacheCopy1(TSPARSEROID, ObjectIdGetDatum(prsId));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for text search parser %u", prsId);
namespaceOid = ((Form_pg_ts_parser) GETSTRUCT(tup))->prsnamespace;
if (SearchSysCacheExists(TSPARSERNAMENSP,
PointerGetDatum(newname),
ObjectIdGetDatum(namespaceOid),
0, 0))
if (SearchSysCacheExists2(TSPARSERNAMENSP,
PointerGetDatum(newname),
ObjectIdGetDatum(namespaceOid)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("text search parser \"%s\" already exists",
@@ -450,9 +445,7 @@ verify_dictoptions(Oid tmplId, List *dictoptions)
if (!IsUnderPostmaster)
return;
tup = SearchSysCache(TSTEMPLATEOID,
ObjectIdGetDatum(tmplId),
0, 0, 0);
tup = SearchSysCache1(TSTEMPLATEOID, ObjectIdGetDatum(tmplId));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for text search template %u",
tmplId);
@@ -591,9 +584,7 @@ RenameTSDictionary(List *oldname, const char *newname)
dictId = TSDictionaryGetDictid(oldname, false);
tup = SearchSysCacheCopy(TSDICTOID,
ObjectIdGetDatum(dictId),
0, 0, 0);
tup = SearchSysCacheCopy1(TSDICTOID, ObjectIdGetDatum(dictId));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for text search dictionary %u",
@@ -601,10 +592,9 @@ RenameTSDictionary(List *oldname, const char *newname)
namespaceOid = ((Form_pg_ts_dict) GETSTRUCT(tup))->dictnamespace;
if (SearchSysCacheExists(TSDICTNAMENSP,
PointerGetDatum(newname),
ObjectIdGetDatum(namespaceOid),
0, 0))
if (SearchSysCacheExists2(TSDICTNAMENSP,
PointerGetDatum(newname),
ObjectIdGetDatum(namespaceOid)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("text search dictionary \"%s\" already exists",
@@ -673,9 +663,7 @@ RemoveTSDictionaries(DropStmt *drop)
continue;
}
tup = SearchSysCache(TSDICTOID,
ObjectIdGetDatum(dictOid),
0, 0, 0);
tup = SearchSysCache1(TSDICTOID, ObjectIdGetDatum(dictOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for text search dictionary %u",
dictOid);
@@ -712,9 +700,7 @@ RemoveTSDictionaryById(Oid dictId)
relation = heap_open(TSDictionaryRelationId, RowExclusiveLock);
tup = SearchSysCache(TSDICTOID,
ObjectIdGetDatum(dictId),
0, 0, 0);
tup = SearchSysCache1(TSDICTOID, ObjectIdGetDatum(dictId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search dictionary %u",
@@ -749,9 +735,7 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
rel = heap_open(TSDictionaryRelationId, RowExclusiveLock);
tup = SearchSysCache(TSDICTOID,
ObjectIdGetDatum(dictId),
0, 0, 0);
tup = SearchSysCache1(TSDICTOID, ObjectIdGetDatum(dictId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search dictionary %u",
@@ -859,9 +843,7 @@ AlterTSDictionaryOwner(List *name, Oid newOwnerId)
dictId = TSDictionaryGetDictid(name, false);
tup = SearchSysCacheCopy(TSDICTOID,
ObjectIdGetDatum(dictId),
0, 0, 0);
tup = SearchSysCacheCopy1(TSDICTOID, ObjectIdGetDatum(dictId));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for text search dictionary %u",
@@ -1093,9 +1075,7 @@ RenameTSTemplate(List *oldname, const char *newname)
tmplId = TSTemplateGetTmplid(oldname, false);
tup = SearchSysCacheCopy(TSTEMPLATEOID,
ObjectIdGetDatum(tmplId),
0, 0, 0);
tup = SearchSysCacheCopy1(TSTEMPLATEOID, ObjectIdGetDatum(tmplId));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for text search template %u",
@@ -1103,10 +1083,9 @@ RenameTSTemplate(List *oldname, const char *newname)
namespaceOid = ((Form_pg_ts_template) GETSTRUCT(tup))->tmplnamespace;
if (SearchSysCacheExists(TSTEMPLATENAMENSP,
PointerGetDatum(newname),
ObjectIdGetDatum(namespaceOid),
0, 0))
if (SearchSysCacheExists2(TSTEMPLATENAMENSP,
PointerGetDatum(newname),
ObjectIdGetDatum(namespaceOid)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("text search template \"%s\" already exists",
@@ -1190,9 +1169,7 @@ RemoveTSTemplateById(Oid tmplId)
relation = heap_open(TSTemplateRelationId, RowExclusiveLock);
tup = SearchSysCache(TSTEMPLATEOID,
ObjectIdGetDatum(tmplId),
0, 0, 0);
tup = SearchSysCache1(TSTEMPLATEOID, ObjectIdGetDatum(tmplId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search template %u",
@@ -1221,9 +1198,7 @@ GetTSConfigTuple(List *names)
if (!OidIsValid(cfgId))
return NULL;
tup = SearchSysCache(TSCONFIGOID,
ObjectIdGetDatum(cfgId),
0, 0, 0);
tup = SearchSysCache1(TSCONFIGOID, ObjectIdGetDatum(cfgId));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for text search configuration %u",
@@ -1376,9 +1351,7 @@ DefineTSConfiguration(List *names, List *parameters)
{
Form_pg_ts_config cfg;
tup = SearchSysCache(TSCONFIGOID,
ObjectIdGetDatum(sourceOid),
0, 0, 0);
tup = SearchSysCache1(TSCONFIGOID, ObjectIdGetDatum(sourceOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search configuration %u",
sourceOid);
@@ -1490,9 +1463,7 @@ RenameTSConfiguration(List *oldname, const char *newname)
cfgId = TSConfigGetCfgid(oldname, false);
tup = SearchSysCacheCopy(TSCONFIGOID,
ObjectIdGetDatum(cfgId),
0, 0, 0);
tup = SearchSysCacheCopy1(TSCONFIGOID, ObjectIdGetDatum(cfgId));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for text search configuration %u",
@@ -1500,10 +1471,9 @@ RenameTSConfiguration(List *oldname, const char *newname)
namespaceOid = ((Form_pg_ts_config) GETSTRUCT(tup))->cfgnamespace;
if (SearchSysCacheExists(TSCONFIGNAMENSP,
PointerGetDatum(newname),
ObjectIdGetDatum(namespaceOid),
0, 0))
if (SearchSysCacheExists2(TSCONFIGNAMENSP,
PointerGetDatum(newname),
ObjectIdGetDatum(namespaceOid)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("text search configuration \"%s\" already exists",
@@ -1608,9 +1578,7 @@ RemoveTSConfigurationById(Oid cfgId)
/* Remove the pg_ts_config entry */
relCfg = heap_open(TSConfigRelationId, RowExclusiveLock);
tup = SearchSysCache(TSCONFIGOID,
ObjectIdGetDatum(cfgId),
0, 0, 0);
tup = SearchSysCache1(TSCONFIGOID, ObjectIdGetDatum(cfgId));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for text search dictionary %u",
@@ -1660,9 +1628,7 @@ AlterTSConfigurationOwner(List *name, Oid newOwnerId)
cfgId = TSConfigGetCfgid(name, false);
tup = SearchSysCacheCopy(TSCONFIGOID,
ObjectIdGetDatum(cfgId),
0, 0, 0);
tup = SearchSysCacheCopy1(TSCONFIGOID, ObjectIdGetDatum(cfgId));
if (!HeapTupleIsValid(tup)) /* should not happen */
elog(ERROR, "cache lookup failed for text search configuration %u",

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.146 2010/01/20 05:47:09 petere Exp $
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.147 2010/02/14 18:42:14 rhaas Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
@@ -178,10 +178,9 @@ DefineType(List *names, List *parameters)
* Look to see if type already exists (presumably as a shell; if not,
* TypeCreate will complain).
*/
typoid = GetSysCacheOid(TYPENAMENSP,
CStringGetDatum(typeName),
ObjectIdGetDatum(typeNamespace),
0, 0);
typoid = GetSysCacheOid2(TYPENAMENSP,
CStringGetDatum(typeName),
ObjectIdGetDatum(typeNamespace));
/*
* If it's not a shell, see if it's an autogenerated array type, and if so
@@ -710,9 +709,7 @@ RemoveTypeById(Oid typeOid)
relation = heap_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCache(TYPEOID,
ObjectIdGetDatum(typeOid),
0, 0, 0);
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
@@ -787,10 +784,9 @@ DefineDomain(CreateDomainStmt *stmt)
* Check for collision with an existing type name. If there is one and
* it's an autogenerated array, we can rename it out of the way.
*/
old_type_oid = GetSysCacheOid(TYPENAMENSP,
CStringGetDatum(domainName),
ObjectIdGetDatum(domainNamespace),
0, 0);
old_type_oid = GetSysCacheOid2(TYPENAMENSP,
CStringGetDatum(domainName),
ObjectIdGetDatum(domainNamespace));
if (OidIsValid(old_type_oid))
{
if (!moveArrayTypeName(old_type_oid, domainName, domainNamespace))
@@ -1113,10 +1109,9 @@ DefineEnum(CreateEnumStmt *stmt)
* Check for collision with an existing type name. If there is one and
* it's an autogenerated array, we can rename it out of the way.
*/
old_type_oid = GetSysCacheOid(TYPENAMENSP,
CStringGetDatum(enumName),
ObjectIdGetDatum(enumNamespace),
0, 0);
old_type_oid = GetSysCacheOid2(TYPENAMENSP,
CStringGetDatum(enumName),
ObjectIdGetDatum(enumNamespace));
if (OidIsValid(old_type_oid))
{
if (!moveArrayTypeName(old_type_oid, enumName, enumNamespace))
@@ -1536,10 +1531,10 @@ DefineCompositeType(const RangeVar *typevar, List *coldeflist)
* about a "type" instead of below about a "relation".
*/
typeNamespace = RangeVarGetCreationNamespace(createStmt->relation);
old_type_oid = GetSysCacheOid(TYPENAMENSP,
CStringGetDatum(createStmt->relation->relname),
ObjectIdGetDatum(typeNamespace),
0, 0);
old_type_oid =
GetSysCacheOid2(TYPENAMENSP,
CStringGetDatum(createStmt->relation->relname),
ObjectIdGetDatum(typeNamespace));
if (OidIsValid(old_type_oid))
{
if (!moveArrayTypeName(old_type_oid, createStmt->relation->relname, typeNamespace))
@@ -1582,9 +1577,7 @@ AlterDomainDefault(List *names, Node *defaultRaw)
/* Look up the domain in the type table */
rel = heap_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy(TYPEOID,
ObjectIdGetDatum(domainoid),
0, 0, 0);
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
typTup = (Form_pg_type) GETSTRUCT(tup);
@@ -1710,9 +1703,7 @@ AlterDomainNotNull(List *names, bool notNull)
/* Look up the domain in the type table */
typrel = heap_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy(TYPEOID,
ObjectIdGetDatum(domainoid),
0, 0, 0);
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
typTup = (Form_pg_type) GETSTRUCT(tup);
@@ -1812,9 +1803,7 @@ AlterDomainDropConstraint(List *names, const char *constrName,
/* Look up the domain in the type table */
rel = heap_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy(TYPEOID,
ObjectIdGetDatum(domainoid),
0, 0, 0);
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
@@ -1887,9 +1876,7 @@ AlterDomainAddConstraint(List *names, Node *newConstraint)
/* Look up the domain in the type table */
typrel = heap_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy(TYPEOID,
ObjectIdGetDatum(domainoid),
0, 0, 0);
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", domainoid);
typTup = (Form_pg_type) GETSTRUCT(tup);
@@ -2399,9 +2386,7 @@ GetDomainConstraints(Oid typeOid)
ScanKeyData key[1];
SysScanDesc scan;
tup = SearchSysCache(TYPEOID,
ObjectIdGetDatum(typeOid),
0, 0, 0);
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
typTup = (Form_pg_type) GETSTRUCT(tup);
@@ -2512,9 +2497,7 @@ RenameType(List *names, const char *newTypeName)
/* Look up the type in the type table */
rel = heap_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy(TYPEOID,
ObjectIdGetDatum(typeOid),
0, 0, 0);
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
typTup = (Form_pg_type) GETSTRUCT(tup);
@@ -2699,9 +2682,7 @@ AlterTypeOwnerInternal(Oid typeOid, Oid newOwnerId,
rel = heap_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy(TYPEOID,
ObjectIdGetDatum(typeOid),
0, 0, 0);
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
typTup = (Form_pg_type) GETSTRUCT(tup);
@@ -2791,9 +2772,7 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
rel = heap_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy(TYPEOID,
ObjectIdGetDatum(typeOid),
0, 0, 0);
tup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(typeOid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", typeOid);
typform = (Form_pg_type) GETSTRUCT(tup);
@@ -2821,10 +2800,9 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
errmsg("cannot move objects into or out of TOAST schema")));
/* check for duplicate name (more friendly than unique-index failure) */
if (SearchSysCacheExists(TYPENAMENSP,
CStringGetDatum(NameStr(typform->typname)),
ObjectIdGetDatum(nspOid),
0, 0))
if (SearchSysCacheExists2(TYPENAMENSP,
CStringGetDatum(NameStr(typform->typname)),
ObjectIdGetDatum(nspOid)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("type \"%s\" already exists in schema \"%s\"",

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.191 2010/01/02 16:57:39 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.192 2010/02/14 18:42:14 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -61,9 +61,7 @@ have_createrole_privilege(void)
if (superuser())
return true;
utup = SearchSysCache(AUTHOID,
ObjectIdGetDatum(GetUserId()),
0, 0, 0);
utup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(GetUserId()));
if (HeapTupleIsValid(utup))
{
result = ((Form_pg_authid) GETSTRUCT(utup))->rolcreaterole;
@@ -295,9 +293,7 @@ CreateRole(CreateRoleStmt *stmt)
pg_authid_rel = heap_open(AuthIdRelationId, RowExclusiveLock);
pg_authid_dsc = RelationGetDescr(pg_authid_rel);
tuple = SearchSysCache(AUTHNAME,
PointerGetDatum(stmt->role),
0, 0, 0);
tuple = SearchSysCache1(AUTHNAME, PointerGetDatum(stmt->role));
if (HeapTupleIsValid(tuple))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
@@ -576,9 +572,7 @@ AlterRole(AlterRoleStmt *stmt)
pg_authid_rel = heap_open(AuthIdRelationId, RowExclusiveLock);
pg_authid_dsc = RelationGetDescr(pg_authid_rel);
tuple = SearchSysCache(AUTHNAME,
PointerGetDatum(stmt->role),
0, 0, 0);
tuple = SearchSysCache1(AUTHNAME, PointerGetDatum(stmt->role));
if (!HeapTupleIsValid(tuple))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -765,9 +759,7 @@ AlterRoleSet(AlterRoleSetStmt *stmt)
HeapTuple roletuple;
Oid databaseid = InvalidOid;
roletuple = SearchSysCache(AUTHNAME,
PointerGetDatum(stmt->role),
0, 0, 0);
roletuple = SearchSysCache1(AUTHNAME, PointerGetDatum(stmt->role));
if (!HeapTupleIsValid(roletuple))
ereport(ERROR,
@@ -849,9 +841,7 @@ DropRole(DropRoleStmt *stmt)
SysScanDesc sscan;
Oid roleid;
tuple = SearchSysCache(AUTHNAME,
PointerGetDatum(role),
0, 0, 0);
tuple = SearchSysCache1(AUTHNAME, PointerGetDatum(role));
if (!HeapTupleIsValid(tuple))
{
if (!stmt->missing_ok)
@@ -1005,9 +995,7 @@ RenameRole(const char *oldname, const char *newname)
rel = heap_open(AuthIdRelationId, RowExclusiveLock);
dsc = RelationGetDescr(rel);
oldtuple = SearchSysCache(AUTHNAME,
CStringGetDatum(oldname),
0, 0, 0);
oldtuple = SearchSysCache1(AUTHNAME, CStringGetDatum(oldname));
if (!HeapTupleIsValid(oldtuple))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
@@ -1033,9 +1021,7 @@ RenameRole(const char *oldname, const char *newname)
errmsg("current user cannot be renamed")));
/* make sure the new name doesn't exist */
if (SearchSysCacheExists(AUTHNAME,
CStringGetDatum(newname),
0, 0, 0))
if (SearchSysCacheExists1(AUTHNAME, CStringGetDatum(newname)))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("role \"%s\" already exists", newname)));
@@ -1326,10 +1312,9 @@ AddRoleMems(const char *rolename, Oid roleid,
* Check if entry for this role/member already exists; if so, give
* warning unless we are adding admin option.
*/
authmem_tuple = SearchSysCache(AUTHMEMROLEMEM,
ObjectIdGetDatum(roleid),
ObjectIdGetDatum(memberid),
0, 0);
authmem_tuple = SearchSysCache2(AUTHMEMROLEMEM,
ObjectIdGetDatum(roleid),
ObjectIdGetDatum(memberid));
if (HeapTupleIsValid(authmem_tuple) &&
(!admin_opt ||
((Form_pg_auth_members) GETSTRUCT(authmem_tuple))->admin_option))
@@ -1440,10 +1425,9 @@ DelRoleMems(const char *rolename, Oid roleid,
/*
* Find entry for this role/member
*/
authmem_tuple = SearchSysCache(AUTHMEMROLEMEM,
ObjectIdGetDatum(roleid),
ObjectIdGetDatum(memberid),
0, 0);
authmem_tuple = SearchSysCache2(AUTHMEMROLEMEM,
ObjectIdGetDatum(roleid),
ObjectIdGetDatum(memberid));
if (!HeapTupleIsValid(authmem_tuple))
{
ereport(WARNING,

View File

@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.407 2010/02/09 21:43:30 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.408 2010/02/14 18:42:14 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -498,9 +498,7 @@ vac_update_relstats(Relation relation,
rd = heap_open(RelationRelationId, RowExclusiveLock);
/* Fetch a copy of the tuple to scribble on */
ctup = SearchSysCacheCopy(RELOID,
ObjectIdGetDatum(relid),
0, 0, 0);
ctup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
if (!HeapTupleIsValid(ctup))
elog(ERROR, "pg_class entry for relid %u vanished during vacuuming",
relid);
@@ -644,9 +642,7 @@ vac_update_datfrozenxid(void)
relation = heap_open(DatabaseRelationId, RowExclusiveLock);
/* Fetch a copy of the tuple to scribble on */
tuple = SearchSysCacheCopy(DATABASEOID,
ObjectIdGetDatum(MyDatabaseId),
0, 0, 0);
tuple = SearchSysCacheCopy1(DATABASEOID, ObjectIdGetDatum(MyDatabaseId));
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for database %u", MyDatabaseId);
dbform = (Form_pg_database) GETSTRUCT(tuple);

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.132 2010/01/02 16:57:40 momjian Exp $
* $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.133 2010/02/14 18:42:14 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -727,9 +727,7 @@ assign_session_authorization(const char *value, bool doit, GucSource source)
return NULL;
}
roleTup = SearchSysCache(AUTHNAME,
PointerGetDatum(value),
0, 0, 0);
roleTup = SearchSysCache1(AUTHNAME, PointerGetDatum(value));
if (!HeapTupleIsValid(roleTup))
{
ereport(GUC_complaint_elevel(source),
@@ -839,9 +837,7 @@ assign_role(const char *value, bool doit, GucSource source)
return NULL;
}
roleTup = SearchSysCache(AUTHNAME,
PointerGetDatum(value),
0, 0, 0);
roleTup = SearchSysCache1(AUTHNAME, PointerGetDatum(value));
if (!HeapTupleIsValid(roleTup))
{
ereport(GUC_complaint_elevel(source),