aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/alter.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-06-25 21:55:59 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-06-25 21:55:59 +0000
commit0adfa2c39d567394f423c69bfaf467d0d00ee3df (patch)
tree215559f976b4e28454fcf7abaa8c96c748ec7fef /src/backend/commands/alter.c
parent1621192b11369a7f0c47aaff1c8ec16bad29ab69 (diff)
downloadpostgresql-0adfa2c39d567394f423c69bfaf467d0d00ee3df.tar.gz
postgresql-0adfa2c39d567394f423c69bfaf467d0d00ee3df.zip
Support renaming of tablespaces, and changing the owners of
aggregates, conversions, functions, operators, operator classes, schemas, types, and tablespaces. Fold the existing implementations of alter domain owner and alter database owner in with these. Christopher Kings-Lynne
Diffstat (limited to 'src/backend/commands/alter.c')
-rw-r--r--src/backend/commands/alter.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 40a28103c77..50516e1f046 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.7 2004/05/26 04:41:09 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/alter.c,v 1.8 2004/06/25 21:55:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -25,7 +25,9 @@
#include "commands/proclang.h"
#include "commands/schemacmds.h"
#include "commands/tablecmds.h"
+#include "commands/tablespace.h"
#include "commands/trigger.h"
+#include "commands/typecmds.h"
#include "commands/user.h"
#include "miscadmin.h"
#include "parser/parse_clause.h"
@@ -35,6 +37,10 @@
#include "utils/syscache.h"
+/*
+ * Executes an ALTER OBJECT / RENAME TO statement. Based on the object
+ * type, the function appropriate to that type is executed.
+ */
void
ExecRenameStmt(RenameStmt *stmt)
{
@@ -74,6 +80,10 @@ ExecRenameStmt(RenameStmt *stmt)
RenameSchema(stmt->subname, stmt->newname);
break;
+ case OBJECT_TABLESPACE:
+ RenameTableSpace(stmt->subname, stmt->newname);
+ break;
+
case OBJECT_USER:
RenameUser(stmt->subname, stmt->newname);
break;
@@ -133,3 +143,62 @@ ExecRenameStmt(RenameStmt *stmt)
(int) stmt->renameType);
}
}
+
+/*
+ * Executes an ALTER OBJECT / OWNER TO statement. Based on the object
+ * type, the function appropriate to that type is executed.
+ */
+void
+ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
+{
+ AclId newowner = get_usesysid(stmt->newowner);
+
+ switch (stmt->objectType)
+ {
+ case OBJECT_AGGREGATE:
+ AlterAggregateOwner(stmt->object,
+ (TypeName *) linitial(stmt->objarg),
+ newowner);
+ break;
+
+ case OBJECT_CONVERSION:
+ AlterConversionOwner(stmt->object, newowner);
+ break;
+
+ case OBJECT_DATABASE:
+ AlterDatabaseOwner((char *) linitial(stmt->object), newowner);
+ break;
+
+ case OBJECT_FUNCTION:
+ AlterFunctionOwner(stmt->object, stmt->objarg, newowner);
+ break;
+
+ case OBJECT_OPERATOR:
+ AlterOperatorOwner(stmt->object,
+ (TypeName *) linitial(stmt->objarg),
+ (TypeName *) lsecond(stmt->objarg),
+ newowner);
+ break;
+
+ case OBJECT_OPCLASS:
+ AlterOpClassOwner(stmt->object, stmt->addname, newowner);
+ break;
+
+ case OBJECT_SCHEMA:
+ AlterSchemaOwner((char *) linitial(stmt->object), newowner);
+ break;
+
+ case OBJECT_TABLESPACE:
+ AlterTableSpaceOwner((char *) linitial(stmt->object), newowner);
+ break;
+
+ case OBJECT_TYPE:
+ case OBJECT_DOMAIN: /* same as TYPE */
+ AlterTypeOwner(stmt->object, newowner);
+ break;
+
+ default:
+ elog(ERROR, "unrecognized AlterOwnerStmt type: %d",
+ (int) stmt->objectType);
+ }
+}