1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-12 21:01:52 +03:00

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
This commit is contained in:
Tom Lane
2004-06-25 21:55:59 +00:00
parent 1621192b11
commit 0adfa2c39d
40 changed files with 1380 additions and 234 deletions

View File

@ -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);
}
}