summaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2010-08-05 14:45:09 +0000
committerRobert Haas <rhaas@postgresql.org>2010-08-05 14:45:09 +0000
commit2a6ef3445c73473edb222abf108b323fb7f002dc (patch)
treeca6a6f51dcf5193303f466c4072b243e3f979227 /src/backend/commands/tablecmds.c
parent641459f26954b04f74d098a758b716297b6554ea (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/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 2ab1cbedc7b..221e6417eb3 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.338 2010/08/03 15:47:02 rhaas Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.339 2010/08/05 14:45:01 rhaas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -414,12 +414,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
*/
if (stmt->tablespacename)
{
- tablespaceId = get_tablespace_oid(stmt->tablespacename);
- if (!OidIsValid(tablespaceId))
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("tablespace \"%s\" does not exist",
- stmt->tablespacename)));
+ tablespaceId = get_tablespace_oid(stmt->tablespacename, false);
}
else
{
@@ -2941,7 +2936,7 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
break;
case AT_ChangeOwner: /* ALTER OWNER */
ATExecChangeOwner(RelationGetRelid(rel),
- get_roleid_checked(cmd->name),
+ get_role_oid(cmd->name, false),
false, lockmode);
break;
case AT_ClusterOn: /* CLUSTER ON */
@@ -6945,11 +6940,7 @@ ATPrepSetTableSpace(AlteredTableInfo *tab, Relation rel, char *tablespacename, L
AclResult aclresult;
/* Check that the tablespace exists */
- tablespaceId = get_tablespace_oid(tablespacename);
- if (!OidIsValid(tablespaceId))
- ereport(ERROR,
- (errcode(ERRCODE_UNDEFINED_OBJECT),
- errmsg("tablespace \"%s\" does not exist", tablespacename)));
+ tablespaceId = get_tablespace_oid(tablespacename, false);
/* Check its permissions */
aclresult = pg_tablespace_aclcheck(tablespaceId, GetUserId(), ACL_CREATE);