1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

Standardize get_whatever_oid functions for object types with

unqualified names.

- Add a missing_ok parameter to get_tablespace_oid.
- Avoid duplicating get_tablespace_od guts in objectNamesToOids.
- Add a missing_ok parameter to get_database_oid.
- Replace get_roleid and get_role_checked with get_role_oid.
- Add get_namespace_oid, get_language_oid, get_am_oid.
- Refactor existing code to use new interfaces.

Thanks to KaiGai Kohei for the review.
This commit is contained in:
Robert Haas
2010-08-05 14:45:09 +00:00
parent 641459f269
commit 2a6ef3445c
25 changed files with 259 additions and 437 deletions

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.171 2010/07/09 22:57:39 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.172 2010/08/05 14:45:05 rhaas Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
@ -2638,34 +2638,3 @@ get_namespace_name(Oid nspid)
else
return NULL;
}
/* ---------- PG_AUTHID CACHE ---------- */
/*
* get_roleid
* Given a role name, look up the role's OID.
* Returns InvalidOid if no such role.
*/
Oid
get_roleid(const char *rolname)
{
return GetSysCacheOid1(AUTHNAME, PointerGetDatum(rolname));
}
/*
* get_roleid_checked
* Given a role name, look up the role's OID.
* ereports if no such role.
*/
Oid
get_roleid_checked(const char *rolname)
{
Oid roleid;
roleid = get_roleid(rolname);
if (!OidIsValid(roleid))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("role \"%s\" does not exist", rolname)));
return roleid;
}