mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +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:
@@ -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);
|
||||
|
@@ -48,12 +48,11 @@ CommentObject(CommentStmt *stmt)
|
||||
* (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
|
||||
* 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
|
||||
* will throw an error below; that's OK.)
|
||||
* case.
|
||||
*/
|
||||
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)))
|
||||
{
|
||||
@@ -70,12 +69,12 @@ CommentObject(CommentStmt *stmt)
|
||||
* does not exist, and will also acquire a lock on the target to guard
|
||||
* 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);
|
||||
|
||||
/* Require ownership of the target object. */
|
||||
check_object_ownership(GetUserId(), stmt->objtype, address,
|
||||
stmt->objname, stmt->objargs, relation);
|
||||
stmt->object, relation);
|
||||
|
||||
/* Perform other integrity checks as needed. */
|
||||
switch (stmt->objtype)
|
||||
|
@@ -30,10 +30,10 @@
|
||||
|
||||
|
||||
static void does_not_exist_skipping(ObjectType objtype,
|
||||
List *objname, List *objargs);
|
||||
static bool owningrel_does_not_exist_skipping(List *objname,
|
||||
Node *object);
|
||||
static bool owningrel_does_not_exist_skipping(List *object,
|
||||
const char **msg, char **name);
|
||||
static bool schema_does_not_exist_skipping(List *objname,
|
||||
static bool schema_does_not_exist_skipping(List *object,
|
||||
const char **msg, char **name);
|
||||
static bool type_in_list_does_not_exist_skipping(List *typenames,
|
||||
const char **msg, char **name);
|
||||
@@ -55,27 +55,19 @@ RemoveObjects(DropStmt *stmt)
|
||||
{
|
||||
ObjectAddresses *objects;
|
||||
ListCell *cell1;
|
||||
ListCell *cell2 = NULL;
|
||||
|
||||
objects = new_object_addresses();
|
||||
|
||||
foreach(cell1, stmt->objects)
|
||||
{
|
||||
ObjectAddress address;
|
||||
List *objname = lfirst(cell1);
|
||||
List *objargs = NIL;
|
||||
Node *object = lfirst(cell1);
|
||||
Relation relation = NULL;
|
||||
Oid namespaceId;
|
||||
|
||||
if (stmt->arguments)
|
||||
{
|
||||
cell2 = (!cell2 ? list_head(stmt->arguments) : lnext(cell2));
|
||||
objargs = lfirst(cell2);
|
||||
}
|
||||
|
||||
/* Get an ObjectAddress for the object. */
|
||||
address = get_object_address(stmt->removeType,
|
||||
objname, objargs,
|
||||
object,
|
||||
&relation,
|
||||
AccessExclusiveLock,
|
||||
stmt->missing_ok);
|
||||
@@ -88,7 +80,7 @@ RemoveObjects(DropStmt *stmt)
|
||||
if (!OidIsValid(address.objectId))
|
||||
{
|
||||
Assert(stmt->missing_ok);
|
||||
does_not_exist_skipping(stmt->removeType, objname, objargs);
|
||||
does_not_exist_skipping(stmt->removeType, object);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -110,7 +102,7 @@ RemoveObjects(DropStmt *stmt)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
|
||||
errmsg("\"%s\" is an aggregate function",
|
||||
NameListToString(objname)),
|
||||
NameListToString(castNode(ObjectWithArgs, object)->objname)),
|
||||
errhint("Use DROP AGGREGATE to drop aggregate functions.")));
|
||||
|
||||
ReleaseSysCache(tup);
|
||||
@@ -121,7 +113,7 @@ RemoveObjects(DropStmt *stmt)
|
||||
if (!OidIsValid(namespaceId) ||
|
||||
!pg_namespace_ownercheck(namespaceId, GetUserId()))
|
||||
check_object_ownership(GetUserId(), stmt->removeType, address,
|
||||
objname, objargs, relation);
|
||||
object, relation);
|
||||
|
||||
/* Release any relcache reference count, but keep lock until commit. */
|
||||
if (relation)
|
||||
@@ -147,23 +139,23 @@ RemoveObjects(DropStmt *stmt)
|
||||
* exist, fill the error message format string and name, and return true.
|
||||
*/
|
||||
static bool
|
||||
owningrel_does_not_exist_skipping(List *objname, const char **msg, char **name)
|
||||
owningrel_does_not_exist_skipping(List *object, const char **msg, char **name)
|
||||
{
|
||||
List *parent_objname;
|
||||
List *parent_object;
|
||||
RangeVar *parent_rel;
|
||||
|
||||
parent_objname = list_truncate(list_copy(objname),
|
||||
list_length(objname) - 1);
|
||||
parent_object = list_truncate(list_copy(object),
|
||||
list_length(object) - 1);
|
||||
|
||||
if (schema_does_not_exist_skipping(parent_objname, msg, name))
|
||||
if (schema_does_not_exist_skipping(parent_object, msg, name))
|
||||
return true;
|
||||
|
||||
parent_rel = makeRangeVarFromNameList(parent_objname);
|
||||
parent_rel = makeRangeVarFromNameList(parent_object);
|
||||
|
||||
if (!OidIsValid(RangeVarGetRelid(parent_rel, NoLock, true)))
|
||||
{
|
||||
*msg = gettext_noop("relation \"%s\" does not exist, skipping");
|
||||
*name = NameListToString(parent_objname);
|
||||
*name = NameListToString(parent_object);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -183,11 +175,11 @@ owningrel_does_not_exist_skipping(List *objname, const char **msg, char **name)
|
||||
* specified schema name, and return true.
|
||||
*/
|
||||
static bool
|
||||
schema_does_not_exist_skipping(List *objname, const char **msg, char **name)
|
||||
schema_does_not_exist_skipping(List *object, const char **msg, char **name)
|
||||
{
|
||||
RangeVar *rel;
|
||||
|
||||
rel = makeRangeVarFromNameList(objname);
|
||||
rel = makeRangeVarFromNameList(object);
|
||||
|
||||
if (rel->schemaname != NULL &&
|
||||
!OidIsValid(LookupNamespaceNoError(rel->schemaname)))
|
||||
@@ -252,7 +244,7 @@ type_in_list_does_not_exist_skipping(List *typenames, const char **msg,
|
||||
* get_object_address() in RemoveObjects would have thrown an ERROR.
|
||||
*/
|
||||
static void
|
||||
does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs)
|
||||
does_not_exist_skipping(ObjectType objtype, Node *object)
|
||||
{
|
||||
const char *msg = NULL;
|
||||
char *name = NULL;
|
||||
@@ -262,12 +254,12 @@ does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs)
|
||||
{
|
||||
case OBJECT_ACCESS_METHOD:
|
||||
msg = gettext_noop("access method \"%s\" does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
name = strVal((Value *) object);
|
||||
break;
|
||||
case OBJECT_TYPE:
|
||||
case OBJECT_DOMAIN:
|
||||
{
|
||||
TypeName *typ = linitial(objname);
|
||||
TypeName *typ = castNode(TypeName, object);
|
||||
|
||||
if (!schema_does_not_exist_skipping(typ->names, &msg, &name))
|
||||
{
|
||||
@@ -277,171 +269,180 @@ does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs)
|
||||
}
|
||||
break;
|
||||
case OBJECT_COLLATION:
|
||||
if (!schema_does_not_exist_skipping(objname, &msg, &name))
|
||||
if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("collation \"%s\" does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
name = NameListToString(castNode(List, object));
|
||||
}
|
||||
break;
|
||||
case OBJECT_CONVERSION:
|
||||
if (!schema_does_not_exist_skipping(objname, &msg, &name))
|
||||
if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("conversion \"%s\" does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
name = NameListToString(castNode(List, object));
|
||||
}
|
||||
break;
|
||||
case OBJECT_SCHEMA:
|
||||
msg = gettext_noop("schema \"%s\" does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
name = strVal((Value *) object);
|
||||
break;
|
||||
case OBJECT_TSPARSER:
|
||||
if (!schema_does_not_exist_skipping(objname, &msg, &name))
|
||||
if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("text search parser \"%s\" does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
name = NameListToString(castNode(List, object));
|
||||
}
|
||||
break;
|
||||
case OBJECT_TSDICTIONARY:
|
||||
if (!schema_does_not_exist_skipping(objname, &msg, &name))
|
||||
if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("text search dictionary \"%s\" does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
name = NameListToString(castNode(List, object));
|
||||
}
|
||||
break;
|
||||
case OBJECT_TSTEMPLATE:
|
||||
if (!schema_does_not_exist_skipping(objname, &msg, &name))
|
||||
if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("text search template \"%s\" does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
name = NameListToString(castNode(List, object));
|
||||
}
|
||||
break;
|
||||
case OBJECT_TSCONFIGURATION:
|
||||
if (!schema_does_not_exist_skipping(objname, &msg, &name))
|
||||
if (!schema_does_not_exist_skipping(castNode(List, object), &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("text search configuration \"%s\" does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
name = NameListToString(castNode(List, object));
|
||||
}
|
||||
break;
|
||||
case OBJECT_EXTENSION:
|
||||
msg = gettext_noop("extension \"%s\" does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
name = strVal((Value *) object);
|
||||
break;
|
||||
case OBJECT_FUNCTION:
|
||||
if (!schema_does_not_exist_skipping(objname, &msg, &name) &&
|
||||
!type_in_list_does_not_exist_skipping(objargs, &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("function %s(%s) does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
args = TypeNameListToString(objargs);
|
||||
ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
|
||||
if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
|
||||
!type_in_list_does_not_exist_skipping(owa->objargs, &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("function %s(%s) does not exist, skipping");
|
||||
name = NameListToString(owa->objname);
|
||||
args = TypeNameListToString(owa->objargs);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OBJECT_AGGREGATE:
|
||||
if (!schema_does_not_exist_skipping(objname, &msg, &name) &&
|
||||
!type_in_list_does_not_exist_skipping(objargs, &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("aggregate %s(%s) does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
args = TypeNameListToString(objargs);
|
||||
ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
|
||||
if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
|
||||
!type_in_list_does_not_exist_skipping(owa->objargs, &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("aggregate %s(%s) does not exist, skipping");
|
||||
name = NameListToString(owa->objname);
|
||||
args = TypeNameListToString(owa->objargs);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OBJECT_OPERATOR:
|
||||
if (!schema_does_not_exist_skipping(objname, &msg, &name) &&
|
||||
!type_in_list_does_not_exist_skipping(objargs, &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("operator %s does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
|
||||
if (!schema_does_not_exist_skipping(owa->objname, &msg, &name) &&
|
||||
!type_in_list_does_not_exist_skipping(owa->objargs, &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("operator %s does not exist, skipping");
|
||||
name = NameListToString(owa->objname);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OBJECT_LANGUAGE:
|
||||
msg = gettext_noop("language \"%s\" does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
name = strVal((Value *) object);
|
||||
break;
|
||||
case OBJECT_CAST:
|
||||
{
|
||||
if (!type_in_list_does_not_exist_skipping(objname, &msg, &name) &&
|
||||
!type_in_list_does_not_exist_skipping(objargs, &msg, &name))
|
||||
if (!type_in_list_does_not_exist_skipping(list_make1(linitial(castNode(List, object))), &msg, &name) &&
|
||||
!type_in_list_does_not_exist_skipping(list_make1(lsecond(castNode(List, object))), &msg, &name))
|
||||
{
|
||||
/* XXX quote or no quote? */
|
||||
msg = gettext_noop("cast from type %s to type %s does not exist, skipping");
|
||||
name = TypeNameToString((TypeName *) linitial(objname));
|
||||
args = TypeNameToString((TypeName *) linitial(objargs));
|
||||
name = TypeNameToString(castNode(TypeName, linitial(castNode(List, object))));
|
||||
args = TypeNameToString(castNode(TypeName, lsecond(castNode(List, object))));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OBJECT_TRANSFORM:
|
||||
if (!type_in_list_does_not_exist_skipping(objname, &msg, &name))
|
||||
if (!type_in_list_does_not_exist_skipping(list_make1(linitial(castNode(List, object))), &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("transform for type %s language \"%s\" does not exist, skipping");
|
||||
name = TypeNameToString((TypeName *) linitial(objname));
|
||||
args = strVal(linitial(objargs));
|
||||
name = TypeNameToString(castNode(TypeName, linitial(castNode(List, object))));
|
||||
args = strVal(lsecond(castNode(List, object)));
|
||||
}
|
||||
break;
|
||||
case OBJECT_TRIGGER:
|
||||
if (!owningrel_does_not_exist_skipping(objname, &msg, &name))
|
||||
if (!owningrel_does_not_exist_skipping(castNode(List, object), &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("trigger \"%s\" for relation \"%s\" does not exist, skipping");
|
||||
name = strVal(llast(objname));
|
||||
args = NameListToString(list_truncate(list_copy(objname),
|
||||
list_length(objname) - 1));
|
||||
name = strVal(llast(castNode(List, object)));
|
||||
args = NameListToString(list_truncate(list_copy(castNode(List, object)),
|
||||
list_length(castNode(List, object)) - 1));
|
||||
}
|
||||
break;
|
||||
case OBJECT_POLICY:
|
||||
if (!owningrel_does_not_exist_skipping(objname, &msg, &name))
|
||||
if (!owningrel_does_not_exist_skipping(castNode(List, object), &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("policy \"%s\" for relation \"%s\" does not exist, skipping");
|
||||
name = strVal(llast(objname));
|
||||
args = NameListToString(list_truncate(list_copy(objname),
|
||||
list_length(objname) - 1));
|
||||
name = strVal(llast(castNode(List, object)));
|
||||
args = NameListToString(list_truncate(list_copy(castNode(List, object)),
|
||||
list_length(castNode(List, object)) - 1));
|
||||
}
|
||||
break;
|
||||
case OBJECT_EVENT_TRIGGER:
|
||||
msg = gettext_noop("event trigger \"%s\" does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
name = strVal((Value *) object);
|
||||
break;
|
||||
case OBJECT_RULE:
|
||||
if (!owningrel_does_not_exist_skipping(objname, &msg, &name))
|
||||
if (!owningrel_does_not_exist_skipping(castNode(List, object), &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("rule \"%s\" for relation \"%s\" does not exist, skipping");
|
||||
name = strVal(llast(objname));
|
||||
args = NameListToString(list_truncate(list_copy(objname),
|
||||
list_length(objname) - 1));
|
||||
name = strVal(llast(castNode(List, object)));
|
||||
args = NameListToString(list_truncate(list_copy(castNode(List, object)),
|
||||
list_length(castNode(List, object)) - 1));
|
||||
}
|
||||
break;
|
||||
case OBJECT_FDW:
|
||||
msg = gettext_noop("foreign-data wrapper \"%s\" does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
name = strVal((Value *) object);
|
||||
break;
|
||||
case OBJECT_FOREIGN_SERVER:
|
||||
msg = gettext_noop("server \"%s\" does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
name = strVal((Value *) object);
|
||||
break;
|
||||
case OBJECT_OPCLASS:
|
||||
{
|
||||
List *opcname = list_copy_tail(objname, 1);
|
||||
List *opcname = list_copy_tail(castNode(List, object), 1);
|
||||
|
||||
if (!schema_does_not_exist_skipping(opcname, &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("operator class \"%s\" does not exist for access method \"%s\", skipping");
|
||||
name = NameListToString(opcname);
|
||||
args = strVal(linitial(objname));
|
||||
args = strVal(linitial(castNode(List, object)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OBJECT_OPFAMILY:
|
||||
{
|
||||
List *opfname = list_copy_tail(objname, 1);
|
||||
List *opfname = list_copy_tail(castNode(List, object), 1);
|
||||
|
||||
if (!schema_does_not_exist_skipping(opfname, &msg, &name))
|
||||
{
|
||||
msg = gettext_noop("operator family \"%s\" does not exist for access method \"%s\", skipping");
|
||||
name = NameListToString(opfname);
|
||||
args = strVal(linitial(objname));
|
||||
args = strVal(linitial(castNode(List, object)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OBJECT_PUBLICATION:
|
||||
msg = gettext_noop("publication \"%s\" does not exist, skipping");
|
||||
name = NameListToString(objname);
|
||||
name = strVal((Value *) object);
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "unrecognized object type: %d", (int) objtype);
|
||||
|
@@ -2672,9 +2672,8 @@ extension_config_remove(Oid extensionoid, Oid tableoid)
|
||||
* Execute ALTER EXTENSION SET SCHEMA
|
||||
*/
|
||||
ObjectAddress
|
||||
AlterExtensionNamespace(List *names, const char *newschema, Oid *oldschema)
|
||||
AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *oldschema)
|
||||
{
|
||||
char *extensionName;
|
||||
Oid extensionOid;
|
||||
Oid nspOid;
|
||||
Oid oldNspOid = InvalidOid;
|
||||
@@ -2690,12 +2689,6 @@ AlterExtensionNamespace(List *names, const char *newschema, Oid *oldschema)
|
||||
ObjectAddresses *objsMoved;
|
||||
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);
|
||||
|
||||
nspOid = LookupCreationNamespace(newschema);
|
||||
@@ -3191,7 +3184,7 @@ ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt,
|
||||
* does not exist, and will also acquire a lock on the object to guard
|
||||
* 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);
|
||||
|
||||
Assert(object.objectSubId == 0);
|
||||
@@ -3200,7 +3193,7 @@ ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt,
|
||||
|
||||
/* Permission check: must own target object, too */
|
||||
check_object_ownership(GetUserId(), stmt->objtype, object,
|
||||
stmt->objname, stmt->objargs, relation);
|
||||
stmt->object, relation);
|
||||
|
||||
/*
|
||||
* Check existing extension membership.
|
||||
|
@@ -89,12 +89,12 @@ ExecSecLabelStmt(SecLabelStmt *stmt)
|
||||
* object does not exist, and will also acquire a lock on the target to
|
||||
* 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);
|
||||
|
||||
/* Require ownership of the target object. */
|
||||
check_object_ownership(GetUserId(), stmt->objtype, address,
|
||||
stmt->objname, stmt->objargs, relation);
|
||||
stmt->object, relation);
|
||||
|
||||
/* Perform other integrity checks as needed. */
|
||||
switch (stmt->objtype)
|
||||
|
@@ -2786,7 +2786,7 @@ RenameConstraint(RenameStmt *stmt)
|
||||
Relation rel;
|
||||
HeapTuple tup;
|
||||
|
||||
typid = typenameTypeId(NULL, makeTypeNameFromNameList(stmt->object));
|
||||
typid = typenameTypeId(NULL, makeTypeNameFromNameList(castNode(List, stmt->object)));
|
||||
rel = heap_open(TypeRelationId, RowExclusiveLock);
|
||||
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
|
||||
if (!HeapTupleIsValid(tup))
|
||||
@@ -9392,11 +9392,9 @@ RebuildConstraintComment(AlteredTableInfo *tab, int pass, Oid objid,
|
||||
/* Build node CommentStmt */
|
||||
cmd = makeNode(CommentStmt);
|
||||
cmd->objtype = OBJECT_TABCONSTRAINT;
|
||||
cmd->objname = list_make3(
|
||||
makeString(get_namespace_name(RelationGetNamespace(rel))),
|
||||
makeString(RelationGetRelationName(rel)),
|
||||
makeString(conname));
|
||||
cmd->objargs = NIL;
|
||||
cmd->object = (Node *) list_make3(makeString(get_namespace_name(RelationGetNamespace(rel))),
|
||||
makeString(RelationGetRelationName(rel)),
|
||||
makeString(conname));
|
||||
cmd->comment = comment_str;
|
||||
|
||||
/* Append it to list of commands */
|
||||
|
@@ -3133,7 +3133,7 @@ replace_domain_constraint_value(ParseState *pstate, ColumnRef *cref)
|
||||
ObjectAddress
|
||||
RenameType(RenameStmt *stmt)
|
||||
{
|
||||
List *names = stmt->object;
|
||||
List *names = castNode(List, stmt->object);
|
||||
const char *newTypeName = stmt->newname;
|
||||
TypeName *typename;
|
||||
Oid typeOid;
|
||||
|
Reference in New Issue
Block a user