summaryrefslogtreecommitdiff
path: root/src/backend/commands/alter.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2016-11-12 12:00:00 -0500
committerPeter Eisentraut <peter_e@gmx.net>2017-03-06 13:31:47 -0500
commit8b6d6cf853aab12f0dc2adba7c99c3e458662734 (patch)
tree783806b4919b26f56dafde70e34bd6cd38bb261e /src/backend/commands/alter.c
parent550214a4efb214dfc9c2a475607deeeea69da858 (diff)
Remove objname/objargs split for referring to objects
In simpler times, it might have worked to refer to all kinds of objects by a list of name components and an optional argument list. But this doesn't work for all objects, which has resulted in a collection of hacks to place various other nodes types into these fields, which have to be unpacked at the other end. This makes it also weird to represent lists of such things in the grammar, because they would have to be lists of singleton lists, to make the unpacking work consistently. The other problem is that keeping separate name and args fields makes it awkward to deal with lists of functions. Change that by dropping the objargs field and have objname, renamed to object, be a generic Node, which can then be flexibly assigned and managed using the normal Node mechanisms. In many cases it will still be a List of names, in some cases it will be a string Value, for types it will be the existing Typename, for functions it will now use the existing ObjectWithArgs node type. Some of the more obscure object types still use somewhat arbitrary nested lists. Reviewed-by: Jim Nasby <Jim.Nasby@BlueTreble.com> Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
Diffstat (limited to 'src/backend/commands/alter.c')
-rw-r--r--src/backend/commands/alter.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 8ff5dd5aaf2..cf1391c2e6b 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -385,7 +385,7 @@ ExecRenameStmt(RenameStmt *stmt)
Relation relation;
address = get_object_address(stmt->renameType,
- stmt->object, stmt->objarg,
+ stmt->object,
&relation,
AccessExclusiveLock, false);
Assert(relation == NULL);
@@ -421,8 +421,8 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre
Relation rel;
address =
- get_object_address_rv(stmt->objectType, stmt->relation, stmt->objname,
- stmt->objargs, &rel, AccessExclusiveLock, false);
+ get_object_address_rv(stmt->objectType, stmt->relation, (List *) stmt->object,
+ &rel, AccessExclusiveLock, false);
/*
* If a relation was involved, it would have been opened and locked. We
@@ -431,8 +431,8 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre
if (rel)
heap_close(rel, NoLock);
- refAddr = get_object_address(OBJECT_EXTENSION, list_make1(stmt->extname),
- NULL, &rel, AccessExclusiveLock, false);
+ refAddr = get_object_address(OBJECT_EXTENSION, (Node *) stmt->extname,
+ &rel, AccessExclusiveLock, false);
Assert(rel == NULL);
if (refAddress)
*refAddress = refAddr;
@@ -461,7 +461,7 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
switch (stmt->objectType)
{
case OBJECT_EXTENSION:
- address = AlterExtensionNamespace(stmt->object, stmt->newschema,
+ address = AlterExtensionNamespace(strVal((Value *) stmt->object), stmt->newschema,
oldSchemaAddr ? &oldNspOid : NULL);
break;
@@ -476,7 +476,7 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
case OBJECT_DOMAIN:
case OBJECT_TYPE:
- address = AlterTypeNamespace(stmt->object, stmt->newschema,
+ address = AlterTypeNamespace(castNode(List, stmt->object), stmt->newschema,
stmt->objectType,
oldSchemaAddr ? &oldNspOid : NULL);
break;
@@ -501,7 +501,6 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
address = get_object_address(stmt->objectType,
stmt->object,
- stmt->objarg,
&relation,
AccessExclusiveLock,
false);
@@ -764,33 +763,34 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
switch (stmt->objectType)
{
case OBJECT_DATABASE:
- return AlterDatabaseOwner(strVal(linitial(stmt->object)), newowner);
+ return AlterDatabaseOwner(strVal((Value *) stmt->object), newowner);
case OBJECT_SCHEMA:
- return AlterSchemaOwner(strVal(linitial(stmt->object)), newowner);
+ return AlterSchemaOwner(strVal((Value *) stmt->object), newowner);
case OBJECT_TYPE:
case OBJECT_DOMAIN: /* same as TYPE */
- return AlterTypeOwner(stmt->object, newowner, stmt->objectType);
+ return AlterTypeOwner(castNode(List, stmt->object), newowner, stmt->objectType);
+ break;
case OBJECT_FDW:
- return AlterForeignDataWrapperOwner(strVal(linitial(stmt->object)),
+ return AlterForeignDataWrapperOwner(strVal((Value *) stmt->object),
newowner);
case OBJECT_FOREIGN_SERVER:
- return AlterForeignServerOwner(strVal(linitial(stmt->object)),
+ return AlterForeignServerOwner(strVal((Value *) stmt->object),
newowner);
case OBJECT_EVENT_TRIGGER:
- return AlterEventTriggerOwner(strVal(linitial(stmt->object)),
+ return AlterEventTriggerOwner(strVal((Value *) stmt->object),
newowner);
case OBJECT_PUBLICATION:
- return AlterPublicationOwner(strVal(linitial(stmt->object)),
+ return AlterPublicationOwner(strVal((Value *) stmt->object),
newowner);
case OBJECT_SUBSCRIPTION:
- return AlterSubscriptionOwner(strVal(linitial(stmt->object)),
+ return AlterSubscriptionOwner(strVal((Value *) stmt->object),
newowner);
/* Generic cases */
@@ -814,7 +814,6 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
address = get_object_address(stmt->objectType,
stmt->object,
- stmt->objarg,
&relation,
AccessExclusiveLock,
false);