aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/dbcommands.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2010-02-14 18:42:19 +0000
committerRobert Haas <rhaas@postgresql.org>2010-02-14 18:42:19 +0000
commite26c539e9f326ea843c0ed005af093b56b55cd4d (patch)
tree4f3830d394229b747cbceeab3cdbbfccccec74d1 /src/backend/commands/dbcommands.c
parent1012492bc0bfb322d59db17e17735d17d634e264 (diff)
downloadpostgresql-e26c539e9f326ea843c0ed005af093b56b55cd4d.tar.gz
postgresql-e26c539e9f326ea843c0ed005af093b56b55cd4d.zip
Wrap calls to SearchSysCache and related functions using macros.
The purpose of this change is to eliminate the need for every caller of SearchSysCache, SearchSysCacheCopy, SearchSysCacheExists, GetSysCacheOid, and SearchSysCacheList to know the maximum number of allowable keys for a syscache entry (currently 4). This will make it far easier to increase the maximum number of keys in a future release should we choose to do so, and it makes the code shorter, too. Design and review by Tom Lane.
Diffstat (limited to 'src/backend/commands/dbcommands.c')
-rw-r--r--src/backend/commands/dbcommands.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 320c1773b85..9c6f1b6936a 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -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));