1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

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>
This commit is contained in:
Peter Eisentraut
2016-11-12 12:00:00 -05:00
parent 550214a4ef
commit 8b6d6cf853
18 changed files with 610 additions and 635 deletions

View File

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