diff options
author | Robert Haas <rhaas@postgresql.org> | 2010-08-05 14:45:09 +0000 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2010-08-05 14:45:09 +0000 |
commit | 2a6ef3445c73473edb222abf108b323fb7f002dc (patch) | |
tree | ca6a6f51dcf5193303f466c4072b243e3f979227 /src/backend/commands/schemacmds.c | |
parent | 641459f26954b04f74d098a758b716297b6554ea (diff) |
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.
Diffstat (limited to 'src/backend/commands/schemacmds.c')
-rw-r--r-- | src/backend/commands/schemacmds.c | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c index b30fdce73d0..f678cda9024 100644 --- a/src/backend/commands/schemacmds.c +++ b/src/backend/commands/schemacmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.57 2010/02/26 02:00:39 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/commands/schemacmds.c,v 1.58 2010/08/05 14:45:01 rhaas Exp $ * *------------------------------------------------------------------------- */ @@ -57,7 +57,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString) * Who is supposed to own the new schema? */ if (authId) - owner_uid = get_roleid_checked(authId); + owner_uid = get_role_oid(authId, false); else owner_uid = saved_uid; @@ -178,24 +178,13 @@ RemoveSchemas(DropStmt *drop) errmsg("schema name cannot be qualified"))); namespaceName = strVal(linitial(names)); - namespaceId = GetSysCacheOid1(NAMESPACENAME, - CStringGetDatum(namespaceName)); + namespaceId = get_namespace_oid(namespaceName, drop->missing_ok); if (!OidIsValid(namespaceId)) { - if (!drop->missing_ok) - { - ereport(ERROR, - (errcode(ERRCODE_UNDEFINED_SCHEMA), - errmsg("schema \"%s\" does not exist", - namespaceName))); - } - else - { - ereport(NOTICE, - (errmsg("schema \"%s\" does not exist, skipping", - namespaceName))); - } + ereport(NOTICE, + (errmsg("schema \"%s\" does not exist, skipping", + namespaceName))); continue; } @@ -264,9 +253,7 @@ RenameSchema(const char *oldname, const char *newname) errmsg("schema \"%s\" does not exist", oldname))); /* make sure the new name doesn't exist */ - if (HeapTupleIsValid( - SearchSysCache1(NAMESPACENAME, - CStringGetDatum(newname)))) + if (OidIsValid(get_namespace_oid(newname, true))) ereport(ERROR, (errcode(ERRCODE_DUPLICATE_SCHEMA), errmsg("schema \"%s\" already exists", newname))); |