summaryrefslogtreecommitdiff
path: root/src/backend/commands/comment.c
diff options
context:
space:
mode:
authorPeter Eisentraut2016-11-12 17:00:00 +0000
committerPeter Eisentraut2017-03-06 18:31:47 +0000
commit8b6d6cf853aab12f0dc2adba7c99c3e458662734 (patch)
tree783806b4919b26f56dafde70e34bd6cd38bb261e /src/backend/commands/comment.c
parent550214a4efb214dfc9c2a475607deeeea69da858 (diff)
Remove objname/objargs split for referring to objects
In simpler times, it might have worked to refer to all kinds of objects by a list of name components and an optional argument list. But this doesn't work for all objects, which has resulted in a collection of hacks to place various other nodes types into these fields, which have to be unpacked at the other end. This makes it also weird to represent lists of such things in the grammar, because they would have to be lists of singleton lists, to make the unpacking work consistently. The other problem is that keeping separate name and args fields makes it awkward to deal with lists of functions. Change that by dropping the objargs field and have objname, renamed to object, be a generic Node, which can then be flexibly assigned and managed using the normal Node mechanisms. In many cases it will still be a List of names, in some cases it will be a string Value, for types it will be the existing Typename, for functions it will now use the existing ObjectWithArgs node type. Some of the more obscure object types still use somewhat arbitrary nested lists. Reviewed-by: Jim Nasby <[email protected]> Reviewed-by: Michael Paquier <[email protected]>
Diffstat (limited to 'src/backend/commands/comment.c')
-rw-r--r--src/backend/commands/comment.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c
index 87ca62f2403..b5569bddaf2 100644
--- a/src/backend/commands/comment.c
+++ b/src/backend/commands/comment.c
@@ -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)