Commit 8b6d6cf8 authored by Peter Eisentraut's avatar Peter Eisentraut

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: default avatarJim Nasby <Jim.Nasby@BlueTreble.com>
Reviewed-by: default avatarMichael Paquier <michael.paquier@gmail.com>
parent 550214a4
This diff is collapsed.
...@@ -385,7 +385,7 @@ ExecRenameStmt(RenameStmt *stmt) ...@@ -385,7 +385,7 @@ ExecRenameStmt(RenameStmt *stmt)
Relation relation; Relation relation;
address = get_object_address(stmt->renameType, address = get_object_address(stmt->renameType,
stmt->object, stmt->objarg, stmt->object,
&relation, &relation,
AccessExclusiveLock, false); AccessExclusiveLock, false);
Assert(relation == NULL); Assert(relation == NULL);
...@@ -421,8 +421,8 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre ...@@ -421,8 +421,8 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre
Relation rel; Relation rel;
address = address =
get_object_address_rv(stmt->objectType, stmt->relation, stmt->objname, get_object_address_rv(stmt->objectType, stmt->relation, (List *) stmt->object,
stmt->objargs, &rel, AccessExclusiveLock, false); &rel, AccessExclusiveLock, false);
/* /*
* If a relation was involved, it would have been opened and locked. We * If a relation was involved, it would have been opened and locked. We
...@@ -431,8 +431,8 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre ...@@ -431,8 +431,8 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre
if (rel) if (rel)
heap_close(rel, NoLock); heap_close(rel, NoLock);
refAddr = get_object_address(OBJECT_EXTENSION, list_make1(stmt->extname), refAddr = get_object_address(OBJECT_EXTENSION, (Node *) stmt->extname,
NULL, &rel, AccessExclusiveLock, false); &rel, AccessExclusiveLock, false);
Assert(rel == NULL); Assert(rel == NULL);
if (refAddress) if (refAddress)
*refAddress = refAddr; *refAddress = refAddr;
...@@ -461,7 +461,7 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt, ...@@ -461,7 +461,7 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
switch (stmt->objectType) switch (stmt->objectType)
{ {
case OBJECT_EXTENSION: case OBJECT_EXTENSION:
address = AlterExtensionNamespace(stmt->object, stmt->newschema, address = AlterExtensionNamespace(strVal((Value *) stmt->object), stmt->newschema,
oldSchemaAddr ? &oldNspOid : NULL); oldSchemaAddr ? &oldNspOid : NULL);
break; break;
...@@ -476,7 +476,7 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt, ...@@ -476,7 +476,7 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
case OBJECT_DOMAIN: case OBJECT_DOMAIN:
case OBJECT_TYPE: case OBJECT_TYPE:
address = AlterTypeNamespace(stmt->object, stmt->newschema, address = AlterTypeNamespace(castNode(List, stmt->object), stmt->newschema,
stmt->objectType, stmt->objectType,
oldSchemaAddr ? &oldNspOid : NULL); oldSchemaAddr ? &oldNspOid : NULL);
break; break;
...@@ -501,7 +501,6 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt, ...@@ -501,7 +501,6 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
address = get_object_address(stmt->objectType, address = get_object_address(stmt->objectType,
stmt->object, stmt->object,
stmt->objarg,
&relation, &relation,
AccessExclusiveLock, AccessExclusiveLock,
false); false);
...@@ -764,33 +763,34 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt) ...@@ -764,33 +763,34 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
switch (stmt->objectType) switch (stmt->objectType)
{ {
case OBJECT_DATABASE: case OBJECT_DATABASE:
return AlterDatabaseOwner(strVal(linitial(stmt->object)), newowner); return AlterDatabaseOwner(strVal((Value *) stmt->object), newowner);
case OBJECT_SCHEMA: case OBJECT_SCHEMA:
return AlterSchemaOwner(strVal(linitial(stmt->object)), newowner); return AlterSchemaOwner(strVal((Value *) stmt->object), newowner);
case OBJECT_TYPE: case OBJECT_TYPE:
case OBJECT_DOMAIN: /* same as 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: case OBJECT_FDW:
return AlterForeignDataWrapperOwner(strVal(linitial(stmt->object)), return AlterForeignDataWrapperOwner(strVal((Value *) stmt->object),
newowner); newowner);
case OBJECT_FOREIGN_SERVER: case OBJECT_FOREIGN_SERVER:
return AlterForeignServerOwner(strVal(linitial(stmt->object)), return AlterForeignServerOwner(strVal((Value *) stmt->object),
newowner); newowner);
case OBJECT_EVENT_TRIGGER: case OBJECT_EVENT_TRIGGER:
return AlterEventTriggerOwner(strVal(linitial(stmt->object)), return AlterEventTriggerOwner(strVal((Value *) stmt->object),
newowner); newowner);
case OBJECT_PUBLICATION: case OBJECT_PUBLICATION:
return AlterPublicationOwner(strVal(linitial(stmt->object)), return AlterPublicationOwner(strVal((Value *) stmt->object),
newowner); newowner);
case OBJECT_SUBSCRIPTION: case OBJECT_SUBSCRIPTION:
return AlterSubscriptionOwner(strVal(linitial(stmt->object)), return AlterSubscriptionOwner(strVal((Value *) stmt->object),
newowner); newowner);
/* Generic cases */ /* Generic cases */
...@@ -814,7 +814,6 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt) ...@@ -814,7 +814,6 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
address = get_object_address(stmt->objectType, address = get_object_address(stmt->objectType,
stmt->object, stmt->object,
stmt->objarg,
&relation, &relation,
AccessExclusiveLock, AccessExclusiveLock,
false); false);
......
...@@ -48,12 +48,11 @@ CommentObject(CommentStmt *stmt) ...@@ -48,12 +48,11 @@ CommentObject(CommentStmt *stmt)
* (which is really pg_restore's fault, but for now we will work around * (which is really pg_restore's fault, but for now we will work around
* the problem here). Consensus is that the best fix is to treat wrong * the problem here). Consensus is that the best fix is to treat wrong
* database name as a WARNING not an ERROR; hence, the following special * database name as a WARNING not an ERROR; hence, the following special
* case. (If the length of stmt->objname is not 1, get_object_address * case.
* will throw an error below; that's OK.)
*/ */
if (stmt->objtype == OBJECT_DATABASE && list_length(stmt->objname) == 1) if (stmt->objtype == OBJECT_DATABASE)
{ {
char *database = strVal(linitial(stmt->objname)); char *database = strVal((Value *) stmt->object);
if (!OidIsValid(get_database_oid(database, true))) if (!OidIsValid(get_database_oid(database, true)))
{ {
...@@ -70,12 +69,12 @@ CommentObject(CommentStmt *stmt) ...@@ -70,12 +69,12 @@ CommentObject(CommentStmt *stmt)
* does not exist, and will also acquire a lock on the target to guard * does not exist, and will also acquire a lock on the target to guard
* against concurrent DROP operations. * against concurrent DROP operations.
*/ */
address = get_object_address(stmt->objtype, stmt->objname, stmt->objargs, address = get_object_address(stmt->objtype, stmt->object,
&relation, ShareUpdateExclusiveLock, false); &relation, ShareUpdateExclusiveLock, false);
/* Require ownership of the target object. */ /* Require ownership of the target object. */
check_object_ownership(GetUserId(), stmt->objtype, address, check_object_ownership(GetUserId(), stmt->objtype, address,
stmt->objname, stmt->objargs, relation); stmt->object, relation);
/* Perform other integrity checks as needed. */ /* Perform other integrity checks as needed. */
switch (stmt->objtype) switch (stmt->objtype)
......
This diff is collapsed.
...@@ -2672,9 +2672,8 @@ extension_config_remove(Oid extensionoid, Oid tableoid) ...@@ -2672,9 +2672,8 @@ extension_config_remove(Oid extensionoid, Oid tableoid)
* Execute ALTER EXTENSION SET SCHEMA * Execute ALTER EXTENSION SET SCHEMA
*/ */
ObjectAddress ObjectAddress
AlterExtensionNamespace(List *names, const char *newschema, Oid *oldschema) AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *oldschema)
{ {
char *extensionName;
Oid extensionOid; Oid extensionOid;
Oid nspOid; Oid nspOid;
Oid oldNspOid = InvalidOid; Oid oldNspOid = InvalidOid;
...@@ -2690,12 +2689,6 @@ AlterExtensionNamespace(List *names, const char *newschema, Oid *oldschema) ...@@ -2690,12 +2689,6 @@ AlterExtensionNamespace(List *names, const char *newschema, Oid *oldschema)
ObjectAddresses *objsMoved; ObjectAddresses *objsMoved;
ObjectAddress extAddr; ObjectAddress extAddr;
if (list_length(names) != 1)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("extension name cannot be qualified")));
extensionName = strVal(linitial(names));
extensionOid = get_extension_oid(extensionName, false); extensionOid = get_extension_oid(extensionName, false);
nspOid = LookupCreationNamespace(newschema); nspOid = LookupCreationNamespace(newschema);
...@@ -3191,7 +3184,7 @@ ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt, ...@@ -3191,7 +3184,7 @@ ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt,
* does not exist, and will also acquire a lock on the object to guard * does not exist, and will also acquire a lock on the object to guard
* against concurrent DROP and ALTER EXTENSION ADD/DROP operations. * against concurrent DROP and ALTER EXTENSION ADD/DROP operations.
*/ */
object = get_object_address(stmt->objtype, stmt->objname, stmt->objargs, object = get_object_address(stmt->objtype, stmt->object,
&relation, ShareUpdateExclusiveLock, false); &relation, ShareUpdateExclusiveLock, false);
Assert(object.objectSubId == 0); Assert(object.objectSubId == 0);
...@@ -3200,7 +3193,7 @@ ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt, ...@@ -3200,7 +3193,7 @@ ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt,
/* Permission check: must own target object, too */ /* Permission check: must own target object, too */
check_object_ownership(GetUserId(), stmt->objtype, object, check_object_ownership(GetUserId(), stmt->objtype, object,
stmt->objname, stmt->objargs, relation); stmt->object, relation);
/* /*
* Check existing extension membership. * Check existing extension membership.
......
...@@ -89,12 +89,12 @@ ExecSecLabelStmt(SecLabelStmt *stmt) ...@@ -89,12 +89,12 @@ ExecSecLabelStmt(SecLabelStmt *stmt)
* object does not exist, and will also acquire a lock on the target to * object does not exist, and will also acquire a lock on the target to
* guard against concurrent modifications. * guard against concurrent modifications.
*/ */
address = get_object_address(stmt->objtype, stmt->objname, stmt->objargs, address = get_object_address(stmt->objtype, stmt->object,
&relation, ShareUpdateExclusiveLock, false); &relation, ShareUpdateExclusiveLock, false);
/* Require ownership of the target object. */ /* Require ownership of the target object. */
check_object_ownership(GetUserId(), stmt->objtype, address, check_object_ownership(GetUserId(), stmt->objtype, address,
stmt->objname, stmt->objargs, relation); stmt->object, relation);
/* Perform other integrity checks as needed. */ /* Perform other integrity checks as needed. */
switch (stmt->objtype) switch (stmt->objtype)
......
...@@ -2786,7 +2786,7 @@ RenameConstraint(RenameStmt *stmt) ...@@ -2786,7 +2786,7 @@ RenameConstraint(RenameStmt *stmt)
Relation rel; Relation rel;
HeapTuple tup; HeapTuple tup;
typid = typenameTypeId(NULL, makeTypeNameFromNameList(stmt->object)); typid = typenameTypeId(NULL, makeTypeNameFromNameList(castNode(List, stmt->object)));
rel = heap_open(TypeRelationId, RowExclusiveLock); rel = heap_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tup)) if (!HeapTupleIsValid(tup))
...@@ -9392,11 +9392,9 @@ RebuildConstraintComment(AlteredTableInfo *tab, int pass, Oid objid, ...@@ -9392,11 +9392,9 @@ RebuildConstraintComment(AlteredTableInfo *tab, int pass, Oid objid,
/* Build node CommentStmt */ /* Build node CommentStmt */
cmd = makeNode(CommentStmt); cmd = makeNode(CommentStmt);
cmd->objtype = OBJECT_TABCONSTRAINT; cmd->objtype = OBJECT_TABCONSTRAINT;
cmd->objname = list_make3( cmd->object = (Node *) list_make3(makeString(get_namespace_name(RelationGetNamespace(rel))),
makeString(get_namespace_name(RelationGetNamespace(rel))),
makeString(RelationGetRelationName(rel)), makeString(RelationGetRelationName(rel)),
makeString(conname)); makeString(conname));
cmd->objargs = NIL;
cmd->comment = comment_str; cmd->comment = comment_str;
/* Append it to list of commands */ /* Append it to list of commands */
......
...@@ -3133,7 +3133,7 @@ replace_domain_constraint_value(ParseState *pstate, ColumnRef *cref) ...@@ -3133,7 +3133,7 @@ replace_domain_constraint_value(ParseState *pstate, ColumnRef *cref)
ObjectAddress ObjectAddress
RenameType(RenameStmt *stmt) RenameType(RenameStmt *stmt)
{ {
List *names = stmt->object; List *names = castNode(List, stmt->object);
const char *newTypeName = stmt->newname; const char *newTypeName = stmt->newname;
TypeName *typename; TypeName *typename;
Oid typeOid; Oid typeOid;
......
...@@ -3116,7 +3116,6 @@ _copyDropStmt(const DropStmt *from) ...@@ -3116,7 +3116,6 @@ _copyDropStmt(const DropStmt *from)
DropStmt *newnode = makeNode(DropStmt); DropStmt *newnode = makeNode(DropStmt);
COPY_NODE_FIELD(objects); COPY_NODE_FIELD(objects);
COPY_NODE_FIELD(arguments);
COPY_SCALAR_FIELD(removeType); COPY_SCALAR_FIELD(removeType);
COPY_SCALAR_FIELD(behavior); COPY_SCALAR_FIELD(behavior);
COPY_SCALAR_FIELD(missing_ok); COPY_SCALAR_FIELD(missing_ok);
...@@ -3143,8 +3142,7 @@ _copyCommentStmt(const CommentStmt *from) ...@@ -3143,8 +3142,7 @@ _copyCommentStmt(const CommentStmt *from)
CommentStmt *newnode = makeNode(CommentStmt); CommentStmt *newnode = makeNode(CommentStmt);
COPY_SCALAR_FIELD(objtype); COPY_SCALAR_FIELD(objtype);
COPY_NODE_FIELD(objname); COPY_NODE_FIELD(object);
COPY_NODE_FIELD(objargs);
COPY_STRING_FIELD(comment); COPY_STRING_FIELD(comment);
return newnode; return newnode;
...@@ -3156,8 +3154,7 @@ _copySecLabelStmt(const SecLabelStmt *from) ...@@ -3156,8 +3154,7 @@ _copySecLabelStmt(const SecLabelStmt *from)
SecLabelStmt *newnode = makeNode(SecLabelStmt); SecLabelStmt *newnode = makeNode(SecLabelStmt);
COPY_SCALAR_FIELD(objtype); COPY_SCALAR_FIELD(objtype);
COPY_NODE_FIELD(objname); COPY_NODE_FIELD(object);
COPY_NODE_FIELD(objargs);
COPY_STRING_FIELD(provider); COPY_STRING_FIELD(provider);
COPY_STRING_FIELD(label); COPY_STRING_FIELD(label);
...@@ -3263,7 +3260,6 @@ _copyRenameStmt(const RenameStmt *from) ...@@ -3263,7 +3260,6 @@ _copyRenameStmt(const RenameStmt *from)
COPY_SCALAR_FIELD(relationType); COPY_SCALAR_FIELD(relationType);
COPY_NODE_FIELD(relation); COPY_NODE_FIELD(relation);
COPY_NODE_FIELD(object); COPY_NODE_FIELD(object);
COPY_NODE_FIELD(objarg);
COPY_STRING_FIELD(subname); COPY_STRING_FIELD(subname);
COPY_STRING_FIELD(newname); COPY_STRING_FIELD(newname);
COPY_SCALAR_FIELD(behavior); COPY_SCALAR_FIELD(behavior);
...@@ -3279,8 +3275,7 @@ _copyAlterObjectDependsStmt(const AlterObjectDependsStmt *from) ...@@ -3279,8 +3275,7 @@ _copyAlterObjectDependsStmt(const AlterObjectDependsStmt *from)
COPY_SCALAR_FIELD(objectType); COPY_SCALAR_FIELD(objectType);
COPY_NODE_FIELD(relation); COPY_NODE_FIELD(relation);
COPY_NODE_FIELD(objname); COPY_NODE_FIELD(object);
COPY_NODE_FIELD(objargs);
COPY_NODE_FIELD(extname); COPY_NODE_FIELD(extname);
return newnode; return newnode;
...@@ -3294,7 +3289,6 @@ _copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *from) ...@@ -3294,7 +3289,6 @@ _copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *from)
COPY_SCALAR_FIELD(objectType); COPY_SCALAR_FIELD(objectType);
COPY_NODE_FIELD(relation); COPY_NODE_FIELD(relation);
COPY_NODE_FIELD(object); COPY_NODE_FIELD(object);
COPY_NODE_FIELD(objarg);
COPY_STRING_FIELD(newschema); COPY_STRING_FIELD(newschema);
COPY_SCALAR_FIELD(missing_ok); COPY_SCALAR_FIELD(missing_ok);
...@@ -3309,7 +3303,6 @@ _copyAlterOwnerStmt(const AlterOwnerStmt *from) ...@@ -3309,7 +3303,6 @@ _copyAlterOwnerStmt(const AlterOwnerStmt *from)
COPY_SCALAR_FIELD(objectType); COPY_SCALAR_FIELD(objectType);
COPY_NODE_FIELD(relation); COPY_NODE_FIELD(relation);
COPY_NODE_FIELD(object); COPY_NODE_FIELD(object);
COPY_NODE_FIELD(objarg);
COPY_NODE_FIELD(newowner); COPY_NODE_FIELD(newowner);
return newnode; return newnode;
...@@ -3780,8 +3773,7 @@ _copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from) ...@@ -3780,8 +3773,7 @@ _copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from)
COPY_STRING_FIELD(extname); COPY_STRING_FIELD(extname);
COPY_SCALAR_FIELD(action); COPY_SCALAR_FIELD(action);
COPY_SCALAR_FIELD(objtype); COPY_SCALAR_FIELD(objtype);
COPY_NODE_FIELD(objname); COPY_NODE_FIELD(object);
COPY_NODE_FIELD(objargs);
return newnode; return newnode;
} }
......
...@@ -1220,7 +1220,6 @@ static bool ...@@ -1220,7 +1220,6 @@ static bool
_equalDropStmt(const DropStmt *a, const DropStmt *b) _equalDropStmt(const DropStmt *a, const DropStmt *b)
{ {
COMPARE_NODE_FIELD(objects); COMPARE_NODE_FIELD(objects);
COMPARE_NODE_FIELD(arguments);
COMPARE_SCALAR_FIELD(removeType); COMPARE_SCALAR_FIELD(removeType);
COMPARE_SCALAR_FIELD(behavior); COMPARE_SCALAR_FIELD(behavior);
COMPARE_SCALAR_FIELD(missing_ok); COMPARE_SCALAR_FIELD(missing_ok);
...@@ -1243,8 +1242,7 @@ static bool ...@@ -1243,8 +1242,7 @@ static bool
_equalCommentStmt(const CommentStmt *a, const CommentStmt *b) _equalCommentStmt(const CommentStmt *a, const CommentStmt *b)
{ {
COMPARE_SCALAR_FIELD(objtype); COMPARE_SCALAR_FIELD(objtype);
COMPARE_NODE_FIELD(objname); COMPARE_NODE_FIELD(object);
COMPARE_NODE_FIELD(objargs);
COMPARE_STRING_FIELD(comment); COMPARE_STRING_FIELD(comment);
return true; return true;
...@@ -1254,8 +1252,7 @@ static bool ...@@ -1254,8 +1252,7 @@ static bool
_equalSecLabelStmt(const SecLabelStmt *a, const SecLabelStmt *b) _equalSecLabelStmt(const SecLabelStmt *a, const SecLabelStmt *b)
{ {
COMPARE_SCALAR_FIELD(objtype); COMPARE_SCALAR_FIELD(objtype);
COMPARE_NODE_FIELD(objname); COMPARE_NODE_FIELD(object);
COMPARE_NODE_FIELD(objargs);
COMPARE_STRING_FIELD(provider); COMPARE_STRING_FIELD(provider);
COMPARE_STRING_FIELD(label); COMPARE_STRING_FIELD(label);
...@@ -1347,7 +1344,6 @@ _equalRenameStmt(const RenameStmt *a, const RenameStmt *b) ...@@ -1347,7 +1344,6 @@ _equalRenameStmt(const RenameStmt *a, const RenameStmt *b)
COMPARE_SCALAR_FIELD(relationType); COMPARE_SCALAR_FIELD(relationType);
COMPARE_NODE_FIELD(relation); COMPARE_NODE_FIELD(relation);
COMPARE_NODE_FIELD(object); COMPARE_NODE_FIELD(object);
COMPARE_NODE_FIELD(objarg);
COMPARE_STRING_FIELD(subname); COMPARE_STRING_FIELD(subname);
COMPARE_STRING_FIELD(newname); COMPARE_STRING_FIELD(newname);
COMPARE_SCALAR_FIELD(behavior); COMPARE_SCALAR_FIELD(behavior);
...@@ -1361,8 +1357,7 @@ _equalAlterObjectDependsStmt(const AlterObjectDependsStmt *a, const AlterObjectD ...@@ -1361,8 +1357,7 @@ _equalAlterObjectDependsStmt(const AlterObjectDependsStmt *a, const AlterObjectD
{ {
COMPARE_SCALAR_FIELD(objectType); COMPARE_SCALAR_FIELD(objectType);
COMPARE_NODE_FIELD(relation); COMPARE_NODE_FIELD(relation);
COMPARE_NODE_FIELD(objname); COMPARE_NODE_FIELD(object);
COMPARE_NODE_FIELD(objargs);
COMPARE_NODE_FIELD(extname); COMPARE_NODE_FIELD(extname);
return true; return true;
...@@ -1374,7 +1369,6 @@ _equalAlterObjectSchemaStmt(const AlterObjectSchemaStmt *a, const AlterObjectSch ...@@ -1374,7 +1369,6 @@ _equalAlterObjectSchemaStmt(const AlterObjectSchemaStmt *a, const AlterObjectSch
COMPARE_SCALAR_FIELD(objectType); COMPARE_SCALAR_FIELD(objectType);
COMPARE_NODE_FIELD(relation); COMPARE_NODE_FIELD(relation);
COMPARE_NODE_FIELD(object); COMPARE_NODE_FIELD(object);
COMPARE_NODE_FIELD(objarg);
COMPARE_STRING_FIELD(newschema); COMPARE_STRING_FIELD(newschema);
COMPARE_SCALAR_FIELD(missing_ok); COMPARE_SCALAR_FIELD(missing_ok);
...@@ -1387,7 +1381,6 @@ _equalAlterOwnerStmt(const AlterOwnerStmt *a, const AlterOwnerStmt *b) ...@@ -1387,7 +1381,6 @@ _equalAlterOwnerStmt(const AlterOwnerStmt *a, const AlterOwnerStmt *b)
COMPARE_SCALAR_FIELD(objectType); COMPARE_SCALAR_FIELD(objectType);
COMPARE_NODE_FIELD(relation); COMPARE_NODE_FIELD(relation);
COMPARE_NODE_FIELD(object); COMPARE_NODE_FIELD(object);
COMPARE_NODE_FIELD(objarg);
COMPARE_NODE_FIELD(newowner); COMPARE_NODE_FIELD(newowner);
return true; return true;
...@@ -1783,8 +1776,7 @@ _equalAlterExtensionContentsStmt(const AlterExtensionContentsStmt *a, const Alte ...@@ -1783,8 +1776,7 @@ _equalAlterExtensionContentsStmt(const AlterExtensionContentsStmt *a, const Alte
COMPARE_STRING_FIELD(extname); COMPARE_STRING_FIELD(extname);
COMPARE_SCALAR_FIELD(action); COMPARE_SCALAR_FIELD(action);
COMPARE_SCALAR_FIELD(objtype); COMPARE_SCALAR_FIELD(objtype);
COMPARE_NODE_FIELD(objname); COMPARE_NODE_FIELD(object);
COMPARE_NODE_FIELD(objargs);
return true; return true;
} }
......
This diff is collapsed.
...@@ -947,10 +947,9 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla ...@@ -947,10 +947,9 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
CommentStmt *stmt = makeNode(CommentStmt); CommentStmt *stmt = makeNode(CommentStmt);
stmt->objtype = OBJECT_COLUMN; stmt->objtype = OBJECT_COLUMN;
stmt->objname = list_make3(makeString(cxt->relation->schemaname), stmt->object = (Node *) list_make3(makeString(cxt->relation->schemaname),
makeString(cxt->relation->relname), makeString(cxt->relation->relname),
makeString(def->colname)); makeString(def->colname));
stmt->objargs = NIL;
stmt->comment = comment; stmt->comment = comment;
cxt->alist = lappend(cxt->alist, stmt); cxt->alist = lappend(cxt->alist, stmt);
...@@ -1013,10 +1012,9 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla ...@@ -1013,10 +1012,9 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
CommentStmt *stmt = makeNode(CommentStmt); CommentStmt *stmt = makeNode(CommentStmt);
stmt->objtype = OBJECT_TABCONSTRAINT; stmt->objtype = OBJECT_TABCONSTRAINT;
stmt->objname = list_make3(makeString(cxt->relation->schemaname), stmt->object = (Node *) list_make3(makeString(cxt->relation->schemaname),
makeString(cxt->relation->relname), makeString(cxt->relation->relname),
makeString(n->conname)); makeString(n->conname));
stmt->objargs = NIL;
stmt->comment = comment; stmt->comment = comment;
cxt->alist = lappend(cxt->alist, stmt); cxt->alist = lappend(cxt->alist, stmt);
......
...@@ -40,17 +40,17 @@ extern const ObjectAddress InvalidObjectAddress; ...@@ -40,17 +40,17 @@ extern const ObjectAddress InvalidObjectAddress;
#define ObjectAddressSet(addr, class_id, object_id) \ #define ObjectAddressSet(addr, class_id, object_id) \
ObjectAddressSubSet(addr, class_id, object_id, 0) ObjectAddressSubSet(addr, class_id, object_id, 0)
extern ObjectAddress get_object_address(ObjectType objtype, List *objname, extern ObjectAddress get_object_address(ObjectType objtype, Node *object,
List *objargs, Relation *relp, Relation *relp,
LOCKMODE lockmode, bool missing_ok); LOCKMODE lockmode, bool missing_ok);
extern ObjectAddress get_object_address_rv(ObjectType objtype, RangeVar *rel, extern ObjectAddress get_object_address_rv(ObjectType objtype, RangeVar *rel,
List *objname, List *objargs, Relation *relp, List *object, Relation *relp,
LOCKMODE lockmode, bool missing_ok); LOCKMODE lockmode, bool missing_ok);
extern void check_object_ownership(Oid roleid, extern void check_object_ownership(Oid roleid,
ObjectType objtype, ObjectAddress address, ObjectType objtype, ObjectAddress address,
List *objname, List *objargs, Relation relation); Node *object, Relation relation);
extern Oid get_object_namespace(const ObjectAddress *address); extern Oid get_object_namespace(const ObjectAddress *address);
......
...@@ -48,7 +48,7 @@ extern ObjectAddress ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt * ...@@ -48,7 +48,7 @@ extern ObjectAddress ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *
extern Oid get_extension_oid(const char *extname, bool missing_ok); extern Oid get_extension_oid(const char *extname, bool missing_ok);
extern char *get_extension_name(Oid ext_oid); extern char *get_extension_name(Oid ext_oid);
extern ObjectAddress AlterExtensionNamespace(List *names, const char *newschema, extern ObjectAddress AlterExtensionNamespace(const char *extensionName, const char *newschema,
Oid *oldschema); Oid *oldschema);
extern void AlterExtensionOwner_oid(Oid extensionOid, Oid newOwnerId); extern void AlterExtensionOwner_oid(Oid extensionOid, Oid newOwnerId);
......
...@@ -2076,8 +2076,7 @@ typedef struct AlterExtensionContentsStmt ...@@ -2076,8 +2076,7 @@ typedef struct AlterExtensionContentsStmt
char *extname; /* Extension's name */ char *extname; /* Extension's name */
int action; /* +1 = add object, -1 = drop object */ int action; /* +1 = add object, -1 = drop object */
ObjectType objtype; /* Object's type */ ObjectType objtype; /* Object's type */
List *objname; /* Qualified name of the object */ Node *object; /* Qualified name of the object */
List *objargs; /* Arguments if needed (eg, for functions) */
} AlterExtensionContentsStmt; } AlterExtensionContentsStmt;
/* ---------------------- /* ----------------------
...@@ -2462,8 +2461,7 @@ typedef struct AlterOpFamilyStmt ...@@ -2462,8 +2461,7 @@ typedef struct AlterOpFamilyStmt
typedef struct DropStmt typedef struct DropStmt
{ {
NodeTag type; NodeTag type;
List *objects; /* list of sublists of names (as Values) */ List *objects; /* list of names */
List *arguments; /* list of sublists of arguments (as Values) */
ObjectType removeType; /* object type */ ObjectType removeType; /* object type */
DropBehavior behavior; /* RESTRICT or CASCADE behavior */ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
bool missing_ok; /* skip error if object is missing? */ bool missing_ok; /* skip error if object is missing? */
...@@ -2490,8 +2488,7 @@ typedef struct CommentStmt ...@@ -2490,8 +2488,7 @@ typedef struct CommentStmt
{ {
NodeTag type; NodeTag type;
ObjectType objtype; /* Object's type */ ObjectType objtype; /* Object's type */
List *objname; /* Qualified name of the object */ Node *object; /* Qualified name of the object */
List *objargs; /* Arguments if needed (eg, for functions) */
char *comment; /* Comment to insert, or NULL to remove */ char *comment; /* Comment to insert, or NULL to remove */
} CommentStmt; } CommentStmt;
...@@ -2503,8 +2500,7 @@ typedef struct SecLabelStmt ...@@ -2503,8 +2500,7 @@ typedef struct SecLabelStmt
{ {
NodeTag type; NodeTag type;
ObjectType objtype; /* Object's type */ ObjectType objtype; /* Object's type */
List *objname; /* Qualified name of the object */ Node *object; /* Qualified name of the object */
List *objargs; /* Arguments if needed (eg, for functions) */
char *provider; /* Label provider (or NULL) */ char *provider; /* Label provider (or NULL) */
char *label; /* New security label to be assigned */ char *label; /* New security label to be assigned */
} SecLabelStmt; } SecLabelStmt;
...@@ -2678,8 +2674,7 @@ typedef struct RenameStmt ...@@ -2678,8 +2674,7 @@ typedef struct RenameStmt
ObjectType renameType; /* OBJECT_TABLE, OBJECT_COLUMN, etc */ ObjectType renameType; /* OBJECT_TABLE, OBJECT_COLUMN, etc */
ObjectType relationType; /* if column name, associated relation type */ ObjectType relationType; /* if column name, associated relation type */
RangeVar *relation; /* in case it's a table */ RangeVar *relation; /* in case it's a table */
List *object; /* in case it's some other object */ Node *object; /* in case it's some other object */
List *objarg; /* argument types, if applicable */
char *subname; /* name of contained object (column, rule, char *subname; /* name of contained object (column, rule,
* trigger, etc) */ * trigger, etc) */
char *newname; /* the new name */ char *newname; /* the new name */
...@@ -2696,8 +2691,7 @@ typedef struct AlterObjectDependsStmt ...@@ -2696,8 +2691,7 @@ typedef struct AlterObjectDependsStmt
NodeTag type; NodeTag type;
ObjectType objectType; /* OBJECT_FUNCTION, OBJECT_TRIGGER, etc */ ObjectType objectType; /* OBJECT_FUNCTION, OBJECT_TRIGGER, etc */
RangeVar *relation; /* in case a table is involved */ RangeVar *relation; /* in case a table is involved */
List *objname; /* name of the object */ Node *object; /* name of the object */
List *objargs; /* argument types, if applicable */
Value *extname; /* extension name */ Value *extname; /* extension name */
} AlterObjectDependsStmt; } AlterObjectDependsStmt;
...@@ -2710,8 +2704,7 @@ typedef struct AlterObjectSchemaStmt ...@@ -2710,8 +2704,7 @@ typedef struct AlterObjectSchemaStmt
NodeTag type; NodeTag type;
ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */ ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
RangeVar *relation; /* in case it's a table */ RangeVar *relation; /* in case it's a table */
List *object; /* in case it's some other object */ Node *object; /* in case it's some other object */
List *objarg; /* argument types, if applicable */
char *newschema; /* the new schema */ char *newschema; /* the new schema */
bool missing_ok; /* skip error if missing? */ bool missing_ok; /* skip error if missing? */
} AlterObjectSchemaStmt; } AlterObjectSchemaStmt;
...@@ -2725,8 +2718,7 @@ typedef struct AlterOwnerStmt ...@@ -2725,8 +2718,7 @@ typedef struct AlterOwnerStmt
NodeTag type; NodeTag type;
ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */ ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
RangeVar *relation; /* in case it's a table */ RangeVar *relation; /* in case it's a table */
List *object; /* in case it's some other object */ Node *object; /* in case it's some other object */
List *objarg; /* argument types, if applicable */
RoleSpec *newowner; /* the new owner */ RoleSpec *newowner; /* the new owner */
} AlterOwnerStmt; } AlterOwnerStmt;
......
...@@ -80,9 +80,6 @@ create event trigger regress_event_trigger2 on ddl_command_start ...@@ -80,9 +80,6 @@ create event trigger regress_event_trigger2 on ddl_command_start
execute procedure test_event_trigger(); execute procedure test_event_trigger();
-- OK -- OK
comment on event trigger regress_event_trigger is 'test comment'; comment on event trigger regress_event_trigger is 'test comment';
-- should fail, event triggers are not schema objects
comment on event trigger wrong.regress_event_trigger is 'test comment';
ERROR: event trigger name cannot be qualified
-- drop as non-superuser should fail -- drop as non-superuser should fail
create role regress_evt_user; create role regress_evt_user;
set role regress_evt_user; set role regress_evt_user;
......
...@@ -296,7 +296,7 @@ WARNING: error for publication relation,{eins,zwei,drei},{integer}: cross-datab ...@@ -296,7 +296,7 @@ WARNING: error for publication relation,{eins,zwei,drei},{integer}: cross-datab
SELECT pg_get_object_address('language', '{one}', '{}'); SELECT pg_get_object_address('language', '{one}', '{}');
ERROR: language "one" does not exist ERROR: language "one" does not exist
SELECT pg_get_object_address('language', '{one,two}', '{}'); SELECT pg_get_object_address('language', '{one,two}', '{}');
ERROR: language name cannot be qualified ERROR: name list length must be exactly 1
SELECT pg_get_object_address('large object', '{123}', '{}'); SELECT pg_get_object_address('large object', '{123}', '{}');
ERROR: large object 123 does not exist ERROR: large object 123 does not exist
SELECT pg_get_object_address('large object', '{123,456}', '{}'); SELECT pg_get_object_address('large object', '{123,456}', '{}');
...@@ -306,47 +306,47 @@ ERROR: invalid input syntax for type oid: "blargh" ...@@ -306,47 +306,47 @@ ERROR: invalid input syntax for type oid: "blargh"
SELECT pg_get_object_address('schema', '{one}', '{}'); SELECT pg_get_object_address('schema', '{one}', '{}');
ERROR: schema "one" does not exist ERROR: schema "one" does not exist
SELECT pg_get_object_address('schema', '{one,two}', '{}'); SELECT pg_get_object_address('schema', '{one,two}', '{}');
ERROR: schema name cannot be qualified ERROR: name list length must be exactly 1
SELECT pg_get_object_address('role', '{one}', '{}'); SELECT pg_get_object_address('role', '{one}', '{}');
ERROR: role "one" does not exist ERROR: role "one" does not exist
SELECT pg_get_object_address('role', '{one,two}', '{}'); SELECT pg_get_object_address('role', '{one,two}', '{}');
ERROR: role name cannot be qualified ERROR: name list length must be exactly 1
SELECT pg_get_object_address('database', '{one}', '{}'); SELECT pg_get_object_address('database', '{one}', '{}');
ERROR: database "one" does not exist ERROR: database "one" does not exist
SELECT pg_get_object_address('database', '{one,two}', '{}'); SELECT pg_get_object_address('database', '{one,two}', '{}');
ERROR: database name cannot be qualified ERROR: name list length must be exactly 1
SELECT pg_get_object_address('tablespace', '{one}', '{}'); SELECT pg_get_object_address('tablespace', '{one}', '{}');
ERROR: tablespace "one" does not exist ERROR: tablespace "one" does not exist
SELECT pg_get_object_address('tablespace', '{one,two}', '{}'); SELECT pg_get_object_address('tablespace', '{one,two}', '{}');
ERROR: tablespace name cannot be qualified ERROR: name list length must be exactly 1
SELECT pg_get_object_address('foreign-data wrapper', '{one}', '{}'); SELECT pg_get_object_address('foreign-data wrapper', '{one}', '{}');
ERROR: foreign-data wrapper "one" does not exist ERROR: foreign-data wrapper "one" does not exist
SELECT pg_get_object_address('foreign-data wrapper', '{one,two}', '{}'); SELECT pg_get_object_address('foreign-data wrapper', '{one,two}', '{}');
ERROR: foreign-data wrapper name cannot be qualified ERROR: name list length must be exactly 1
SELECT pg_get_object_address('server', '{one}', '{}'); SELECT pg_get_object_address('server', '{one}', '{}');
ERROR: server "one" does not exist ERROR: server "one" does not exist
SELECT pg_get_object_address('server', '{one,two}', '{}'); SELECT pg_get_object_address('server', '{one,two}', '{}');
ERROR: server name cannot be qualified ERROR: name list length must be exactly 1
SELECT pg_get_object_address('extension', '{one}', '{}'); SELECT pg_get_object_address('extension', '{one}', '{}');
ERROR: extension "one" does not exist ERROR: extension "one" does not exist
SELECT pg_get_object_address('extension', '{one,two}', '{}'); SELECT pg_get_object_address('extension', '{one,two}', '{}');
ERROR: extension name cannot be qualified ERROR: name list length must be exactly 1
SELECT pg_get_object_address('event trigger', '{one}', '{}'); SELECT pg_get_object_address('event trigger', '{one}', '{}');
ERROR: event trigger "one" does not exist ERROR: event trigger "one" does not exist
SELECT pg_get_object_address('event trigger', '{one,two}', '{}'); SELECT pg_get_object_address('event trigger', '{one,two}', '{}');
ERROR: event trigger name cannot be qualified ERROR: name list length must be exactly 1
SELECT pg_get_object_address('access method', '{one}', '{}'); SELECT pg_get_object_address('access method', '{one}', '{}');
ERROR: access method "one" does not exist ERROR: access method "one" does not exist
SELECT pg_get_object_address('access method', '{one,two}', '{}'); SELECT pg_get_object_address('access method', '{one,two}', '{}');
ERROR: access method name cannot be qualified ERROR: name list length must be exactly 1
SELECT pg_get_object_address('publication', '{one}', '{}'); SELECT pg_get_object_address('publication', '{one}', '{}');
ERROR: publication "one" does not exist ERROR: publication "one" does not exist
SELECT pg_get_object_address('publication', '{one,two}', '{}'); SELECT pg_get_object_address('publication', '{one,two}', '{}');
ERROR: publication name cannot be qualified ERROR: name list length must be exactly 1
SELECT pg_get_object_address('subscription', '{one}', '{}'); SELECT pg_get_object_address('subscription', '{one}', '{}');
ERROR: subscription "one" does not exist ERROR: subscription "one" does not exist
SELECT pg_get_object_address('subscription', '{one,two}', '{}'); SELECT pg_get_object_address('subscription', '{one,two}', '{}');
ERROR: subscription name cannot be qualified ERROR: name list length must be exactly 1
-- test successful cases -- test successful cases
WITH objects (type, name, args) AS (VALUES WITH objects (type, name, args) AS (VALUES
('table', '{addr_nsp, gentable}'::text[], '{}'::text[]), ('table', '{addr_nsp, gentable}'::text[], '{}'::text[]),
......
...@@ -82,9 +82,6 @@ create event trigger regress_event_trigger2 on ddl_command_start ...@@ -82,9 +82,6 @@ create event trigger regress_event_trigger2 on ddl_command_start
-- OK -- OK
comment on event trigger regress_event_trigger is 'test comment'; comment on event trigger regress_event_trigger is 'test comment';
-- should fail, event triggers are not schema objects
comment on event trigger wrong.regress_event_trigger is 'test comment';
-- drop as non-superuser should fail -- drop as non-superuser should fail
create role regress_evt_user; create role regress_evt_user;
set role regress_evt_user; set role regress_evt_user;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment