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)
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)
......
This diff is collapsed.
......@@ -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))),
cmd->object = (Node *) list_make3(makeString(get_namespace_name(RelationGetNamespace(rel))),
makeString(RelationGetRelationName(rel)),
makeString(conname));
cmd->objargs = NIL;
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;
......
......@@ -3116,7 +3116,6 @@ _copyDropStmt(const DropStmt *from)
DropStmt *newnode = makeNode(DropStmt);
COPY_NODE_FIELD(objects);
COPY_NODE_FIELD(arguments);
COPY_SCALAR_FIELD(removeType);
COPY_SCALAR_FIELD(behavior);
COPY_SCALAR_FIELD(missing_ok);
......@@ -3143,8 +3142,7 @@ _copyCommentStmt(const CommentStmt *from)
CommentStmt *newnode = makeNode(CommentStmt);
COPY_SCALAR_FIELD(objtype);
COPY_NODE_FIELD(objname);
COPY_NODE_FIELD(objargs);
COPY_NODE_FIELD(object);
COPY_STRING_FIELD(comment);
return newnode;
......@@ -3156,8 +3154,7 @@ _copySecLabelStmt(const SecLabelStmt *from)
SecLabelStmt *newnode = makeNode(SecLabelStmt);
COPY_SCALAR_FIELD(objtype);
COPY_NODE_FIELD(objname);
COPY_NODE_FIELD(objargs);
COPY_NODE_FIELD(object);
COPY_STRING_FIELD(provider);
COPY_STRING_FIELD(label);
......@@ -3263,7 +3260,6 @@ _copyRenameStmt(const RenameStmt *from)
COPY_SCALAR_FIELD(relationType);
COPY_NODE_FIELD(relation);
COPY_NODE_FIELD(object);
COPY_NODE_FIELD(objarg);
COPY_STRING_FIELD(subname);
COPY_STRING_FIELD(newname);
COPY_SCALAR_FIELD(behavior);
......@@ -3279,8 +3275,7 @@ _copyAlterObjectDependsStmt(const AlterObjectDependsStmt *from)
COPY_SCALAR_FIELD(objectType);
COPY_NODE_FIELD(relation);
COPY_NODE_FIELD(objname);
COPY_NODE_FIELD(objargs);
COPY_NODE_FIELD(object);
COPY_NODE_FIELD(extname);
return newnode;
......@@ -3294,7 +3289,6 @@ _copyAlterObjectSchemaStmt(const AlterObjectSchemaStmt *from)
COPY_SCALAR_FIELD(objectType);
COPY_NODE_FIELD(relation);
COPY_NODE_FIELD(object);
COPY_NODE_FIELD(objarg);
COPY_STRING_FIELD(newschema);
COPY_SCALAR_FIELD(missing_ok);
......@@ -3309,7 +3303,6 @@ _copyAlterOwnerStmt(const AlterOwnerStmt *from)
COPY_SCALAR_FIELD(objectType);
COPY_NODE_FIELD(relation);
COPY_NODE_FIELD(object);
COPY_NODE_FIELD(objarg);
COPY_NODE_FIELD(newowner);
return newnode;
......@@ -3780,8 +3773,7 @@ _copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from)
COPY_STRING_FIELD(extname);
COPY_SCALAR_FIELD(action);
COPY_SCALAR_FIELD(objtype);
COPY_NODE_FIELD(objname);
COPY_NODE_FIELD(objargs);
COPY_NODE_FIELD(object);
return newnode;
}
......
......@@ -1220,7 +1220,6 @@ static bool
_equalDropStmt(const DropStmt *a, const DropStmt *b)
{
COMPARE_NODE_FIELD(objects);
COMPARE_NODE_FIELD(arguments);
COMPARE_SCALAR_FIELD(removeType);
COMPARE_SCALAR_FIELD(behavior);
COMPARE_SCALAR_FIELD(missing_ok);
......@@ -1243,8 +1242,7 @@ static bool
_equalCommentStmt(const CommentStmt *a, const CommentStmt *b)
{
COMPARE_SCALAR_FIELD(objtype);
COMPARE_NODE_FIELD(objname);
COMPARE_NODE_FIELD(objargs);
COMPARE_NODE_FIELD(object);
COMPARE_STRING_FIELD(comment);
return true;
......@@ -1254,8 +1252,7 @@ static bool
_equalSecLabelStmt(const SecLabelStmt *a, const SecLabelStmt *b)
{
COMPARE_SCALAR_FIELD(objtype);
COMPARE_NODE_FIELD(objname);
COMPARE_NODE_FIELD(objargs);
COMPARE_NODE_FIELD(object);
COMPARE_STRING_FIELD(provider);
COMPARE_STRING_FIELD(label);
......@@ -1347,7 +1344,6 @@ _equalRenameStmt(const RenameStmt *a, const RenameStmt *b)
COMPARE_SCALAR_FIELD(relationType);
COMPARE_NODE_FIELD(relation);
COMPARE_NODE_FIELD(object);
COMPARE_NODE_FIELD(objarg);
COMPARE_STRING_FIELD(subname);
COMPARE_STRING_FIELD(newname);
COMPARE_SCALAR_FIELD(behavior);
......@@ -1361,8 +1357,7 @@ _equalAlterObjectDependsStmt(const AlterObjectDependsStmt *a, const AlterObjectD
{
COMPARE_SCALAR_FIELD(objectType);
COMPARE_NODE_FIELD(relation);
COMPARE_NODE_FIELD(objname);
COMPARE_NODE_FIELD(objargs);
COMPARE_NODE_FIELD(object);
COMPARE_NODE_FIELD(extname);
return true;
......@@ -1374,7 +1369,6 @@ _equalAlterObjectSchemaStmt(const AlterObjectSchemaStmt *a, const AlterObjectSch
COMPARE_SCALAR_FIELD(objectType);
COMPARE_NODE_FIELD(relation);
COMPARE_NODE_FIELD(object);
COMPARE_NODE_FIELD(objarg);
COMPARE_STRING_FIELD(newschema);
COMPARE_SCALAR_FIELD(missing_ok);
......@@ -1387,7 +1381,6 @@ _equalAlterOwnerStmt(const AlterOwnerStmt *a, const AlterOwnerStmt *b)
COMPARE_SCALAR_FIELD(objectType);
COMPARE_NODE_FIELD(relation);
COMPARE_NODE_FIELD(object);
COMPARE_NODE_FIELD(objarg);
COMPARE_NODE_FIELD(newowner);
return true;
......@@ -1783,8 +1776,7 @@ _equalAlterExtensionContentsStmt(const AlterExtensionContentsStmt *a, const Alte
COMPARE_STRING_FIELD(extname);
COMPARE_SCALAR_FIELD(action);
COMPARE_SCALAR_FIELD(objtype);
COMPARE_NODE_FIELD(objname);
COMPARE_NODE_FIELD(objargs);
COMPARE_NODE_FIELD(object);
return true;
}
......
This diff is collapsed.
......@@ -947,10 +947,9 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
CommentStmt *stmt = makeNode(CommentStmt);
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(def->colname));
stmt->objargs = NIL;
stmt->comment = comment;
cxt->alist = lappend(cxt->alist, stmt);
......@@ -1013,10 +1012,9 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
CommentStmt *stmt = makeNode(CommentStmt);
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(n->conname));
stmt->objargs = NIL;
stmt->comment = comment;
cxt->alist = lappend(cxt->alist, stmt);
......
......@@ -40,17 +40,17 @@ extern const ObjectAddress InvalidObjectAddress;
#define ObjectAddressSet(addr, class_id, object_id) \
ObjectAddressSubSet(addr, class_id, object_id, 0)
extern ObjectAddress get_object_address(ObjectType objtype, List *objname,
List *objargs, Relation *relp,
extern ObjectAddress get_object_address(ObjectType objtype, Node *object,
Relation *relp,
LOCKMODE lockmode, bool missing_ok);
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);
extern void check_object_ownership(Oid roleid,
ObjectType objtype, ObjectAddress address,
List *objname, List *objargs, Relation relation);
Node *object, Relation relation);
extern Oid get_object_namespace(const ObjectAddress *address);
......
......@@ -48,7 +48,7 @@ extern ObjectAddress ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *
extern Oid get_extension_oid(const char *extname, bool missing_ok);
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);
extern void AlterExtensionOwner_oid(Oid extensionOid, Oid newOwnerId);
......
......@@ -2076,8 +2076,7 @@ typedef struct AlterExtensionContentsStmt
char *extname; /* Extension's name */
int action; /* +1 = add object, -1 = drop object */
ObjectType objtype; /* Object's type */
List *objname; /* Qualified name of the object */
List *objargs; /* Arguments if needed (eg, for functions) */
Node *object; /* Qualified name of the object */
} AlterExtensionContentsStmt;
/* ----------------------
......@@ -2462,8 +2461,7 @@ typedef struct AlterOpFamilyStmt
typedef struct DropStmt
{
NodeTag type;
List *objects; /* list of sublists of names (as Values) */
List *arguments; /* list of sublists of arguments (as Values) */
List *objects; /* list of names */
ObjectType removeType; /* object type */
DropBehavior behavior; /* RESTRICT or CASCADE behavior */
bool missing_ok; /* skip error if object is missing? */
......@@ -2490,8 +2488,7 @@ typedef struct CommentStmt
{
NodeTag type;
ObjectType objtype; /* Object's type */
List *objname; /* Qualified name of the object */
List *objargs; /* Arguments if needed (eg, for functions) */
Node *object; /* Qualified name of the object */
char *comment; /* Comment to insert, or NULL to remove */
} CommentStmt;
......@@ -2503,8 +2500,7 @@ typedef struct SecLabelStmt
{
NodeTag type;
ObjectType objtype; /* Object's type */
List *objname; /* Qualified name of the object */
List *objargs; /* Arguments if needed (eg, for functions) */
Node *object; /* Qualified name of the object */
char *provider; /* Label provider (or NULL) */
char *label; /* New security label to be assigned */
} SecLabelStmt;
......@@ -2678,8 +2674,7 @@ typedef struct RenameStmt
ObjectType renameType; /* OBJECT_TABLE, OBJECT_COLUMN, etc */
ObjectType relationType; /* if column name, associated relation type */
RangeVar *relation; /* in case it's a table */
List *object; /* in case it's some other object */
List *objarg; /* argument types, if applicable */
Node *object; /* in case it's some other object */
char *subname; /* name of contained object (column, rule,
* trigger, etc) */
char *newname; /* the new name */
......@@ -2696,8 +2691,7 @@ typedef struct AlterObjectDependsStmt
NodeTag type;
ObjectType objectType; /* OBJECT_FUNCTION, OBJECT_TRIGGER, etc */
RangeVar *relation; /* in case a table is involved */
List *objname; /* name of the object */
List *objargs; /* argument types, if applicable */
Node *object; /* name of the object */
Value *extname; /* extension name */
} AlterObjectDependsStmt;
......@@ -2710,8 +2704,7 @@ typedef struct AlterObjectSchemaStmt
NodeTag type;
ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
RangeVar *relation; /* in case it's a table */
List *object; /* in case it's some other object */
List *objarg; /* argument types, if applicable */
Node *object; /* in case it's some other object */
char *newschema; /* the new schema */
bool missing_ok; /* skip error if missing? */
} AlterObjectSchemaStmt;
......@@ -2725,8 +2718,7 @@ typedef struct AlterOwnerStmt
NodeTag type;
ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
RangeVar *relation; /* in case it's a table */
List *object; /* in case it's some other object */
List *objarg; /* argument types, if applicable */
Node *object; /* in case it's some other object */
RoleSpec *newowner; /* the new owner */
} AlterOwnerStmt;
......
......@@ -80,9 +80,6 @@ create event trigger regress_event_trigger2 on ddl_command_start
execute procedure test_event_trigger();
-- OK
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
create role regress_evt_user;
set role regress_evt_user;
......
......@@ -296,7 +296,7 @@ WARNING: error for publication relation,{eins,zwei,drei},{integer}: cross-datab
SELECT pg_get_object_address('language', '{one}', '{}');
ERROR: language "one" does not exist
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}', '{}');
ERROR: large object 123 does not exist
SELECT pg_get_object_address('large object', '{123,456}', '{}');
......@@ -306,47 +306,47 @@ ERROR: invalid input syntax for type oid: "blargh"
SELECT pg_get_object_address('schema', '{one}', '{}');
ERROR: schema "one" does not exist
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}', '{}');
ERROR: role "one" does not exist
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}', '{}');
ERROR: database "one" does not exist
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}', '{}');
ERROR: tablespace "one" does not exist
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}', '{}');
ERROR: foreign-data wrapper "one" does not exist
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}', '{}');
ERROR: server "one" does not exist
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}', '{}');
ERROR: extension "one" does not exist
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}', '{}');
ERROR: event trigger "one" does not exist
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}', '{}');
ERROR: access method "one" does not exist
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}', '{}');
ERROR: publication "one" does not exist
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}', '{}');
ERROR: subscription "one" does not exist
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
WITH objects (type, name, args) AS (VALUES
('table', '{addr_nsp, gentable}'::text[], '{}'::text[]),
......
......@@ -82,9 +82,6 @@ create event trigger regress_event_trigger2 on ddl_command_start
-- OK
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
create 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