DROP FUNCTION of multiple functions
Here is a patch series that implements several changes in the internal
grammar and node representation of function signatures. They are not
necessarily meant to be applied separately, but they explain the
progression of the changes nicely, so I left them like that for review.
The end goal is to make some user-visible changes in DROP FUNCTION and
possibly other commands that refer to functions.
With these patches, it is now possible to use DROP FUNCTION to drop
multiple functions at once: DROP FUNCTION func1(), func2(), func3().
Other DROP commands already supported that, but DROP FUNCTION didn't
because the internal representation was complicated and couldn't handle it.
The next step after this would be to allow referring to functions
without having to supply the arguments, if the name is unique. This is
an SQL-standard feature and would be very useful for dealing "business
logic" functions with 10+ arguments. The details of that are to be
worked out, but with the help of the present changes, this would be a
quite localized change, because the grammar representation is well
encapsulated.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
0001-Use-grammar-symbol-function_with_argtypes-consistent.patchtext/x-patch; name=0001-Use-grammar-symbol-function_with_argtypes-consistent.patchDownload
From 0a5d27cf9ab91bb03daa956d5167c5c993dfb857 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Thu, 15 Sep 2016 12:00:00 -0500
Subject: [PATCH 1/7] Use grammar symbol function_with_argtypes consistently
Instead of sometimes referring to a function signature like func_name
func_args, use the existing function_with_argtypes symbol, which
combines the two.
---
src/backend/parser/gram.y | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 5547fc8..755b387 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -5366,21 +5366,21 @@ opclass_item:
n->order_family = $5;
$$ = (Node *) n;
}
- | FUNCTION Iconst func_name func_args
+ | FUNCTION Iconst function_with_argtypes
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION;
- n->name = $3;
- n->args = extractArgTypes($4);
+ n->name = $3->funcname;
+ n->args = $3->funcargs;
n->number = $2;
$$ = (Node *) n;
}
- | FUNCTION Iconst '(' type_list ')' func_name func_args
+ | FUNCTION Iconst '(' type_list ')' function_with_argtypes
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION;
- n->name = $6;
- n->args = extractArgTypes($7);
+ n->name = $6->funcname;
+ n->args = $6->funcargs;
n->number = $2;
n->class_args = $4;
$$ = (Node *) n;
@@ -5780,13 +5780,13 @@ CommentStmt:
n->comment = $7;
$$ = (Node *) n;
}
- | COMMENT ON FUNCTION func_name func_args IS comment_text
+ | COMMENT ON FUNCTION function_with_argtypes IS comment_text
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_FUNCTION;
- n->objname = $4;
- n->objargs = extractArgTypes($5);
- n->comment = $7;
+ n->objname = $4->funcname;
+ n->objargs = $4->funcargs;
+ n->comment = $6;
$$ = (Node *) n;
}
| COMMENT ON OPERATOR any_operator oper_argtypes IS comment_text
@@ -5998,15 +5998,15 @@ SecLabelStmt:
n->label = $9;
$$ = (Node *) n;
}
- | SECURITY LABEL opt_provider ON FUNCTION func_name func_args
+ | SECURITY LABEL opt_provider ON FUNCTION function_with_argtypes
IS security_label
{
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_FUNCTION;
- n->objname = $6;
- n->objargs = extractArgTypes($7);
- n->label = $9;
+ n->objname = $6->funcname;
+ n->objargs = $6->funcargs;
+ n->label = $8;
$$ = (Node *) n;
}
| SECURITY LABEL opt_provider ON LARGE_P OBJECT_P NumericOnly
@@ -7236,24 +7236,24 @@ opt_restrict:
*****************************************************************************/
RemoveFuncStmt:
- DROP FUNCTION func_name func_args opt_drop_behavior
+ DROP FUNCTION function_with_argtypes opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($3);
- n->arguments = list_make1(extractArgTypes($4));
- n->behavior = $5;
+ n->objects = list_make1($3->funcname);
+ n->arguments = list_make1($3->funcargs);
+ n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
$$ = (Node *)n;
}
- | DROP FUNCTION IF_P EXISTS func_name func_args opt_drop_behavior
+ | DROP FUNCTION IF_P EXISTS function_with_argtypes opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($5);
- n->arguments = list_make1(extractArgTypes($6));
- n->behavior = $7;
+ n->objects = list_make1($5->funcname);
+ n->arguments = list_make1($5->funcargs);
+ n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
$$ = (Node *)n;
--
2.10.2
0002-Move-function_with_argtypes-to-a-better-location.patchtext/x-patch; name=0002-Move-function_with_argtypes-to-a-better-location.patchDownload
From 1026aa3068e2a77b85aeb5f5f36e1d427bd1d6d9 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Thu, 15 Sep 2016 12:00:00 -0500
Subject: [PATCH 2/7] Move function_with_argtypes to a better location
It was apparently added for use by GRANT/REVOKE, but move it closer to
where other function signature related things are kept.
---
src/backend/parser/gram.y | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 755b387..37b5151 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -6485,22 +6485,6 @@ opt_grant_grant_option:
| /*EMPTY*/ { $$ = FALSE; }
;
-function_with_argtypes_list:
- function_with_argtypes { $$ = list_make1($1); }
- | function_with_argtypes_list ',' function_with_argtypes
- { $$ = lappend($1, $3); }
- ;
-
-function_with_argtypes:
- func_name func_args
- {
- FuncWithArgs *n = makeNode(FuncWithArgs);
- n->funcname = $1;
- n->funcargs = extractArgTypes($2);
- $$ = n;
- }
- ;
-
/*****************************************************************************
*
* GRANT and REVOKE ROLE statements
@@ -6853,6 +6837,22 @@ func_args_list:
| func_args_list ',' func_arg { $$ = lappend($1, $3); }
;
+function_with_argtypes_list:
+ function_with_argtypes { $$ = list_make1($1); }
+ | function_with_argtypes_list ',' function_with_argtypes
+ { $$ = lappend($1, $3); }
+ ;
+
+function_with_argtypes:
+ func_name func_args
+ {
+ FuncWithArgs *n = makeNode(FuncWithArgs);
+ n->funcname = $1;
+ n->funcargs = extractArgTypes($2);
+ $$ = n;
+ }
+ ;
+
/*
* func_args_with_defaults is separate because we only want to accept
* defaults in CREATE FUNCTION, not in ALTER etc.
--
2.10.2
0003-Add-aggregate_with_argtypes-and-use-it-consistently.patchtext/x-patch; name=0003-Add-aggregate_with_argtypes-and-use-it-consistently.patchDownload
From 61c392466d132ce8f4ef9309cce31b403eed4fe6 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Thu, 15 Sep 2016 12:00:00 -0500
Subject: [PATCH 3/7] Add aggregate_with_argtypes and use it consistently
This works like function_with_argtypes, but aggregates allow slightly
different arguments.
---
src/backend/parser/gram.y | 74 +++++++++++++++++++++++++++--------------------
1 file changed, 42 insertions(+), 32 deletions(-)
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 37b5151..d4d5467 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -338,7 +338,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <accesspriv> privilege
%type <list> privileges privilege_list
%type <privtarget> privilege_target
-%type <funwithargs> function_with_argtypes
+%type <funwithargs> function_with_argtypes aggregate_with_argtypes
%type <list> function_with_argtypes_list
%type <ival> defacl_privilege_target
%type <defelt> DefACLOption
@@ -3940,14 +3940,14 @@ AlterExtensionContentsStmt:
n->objname = list_make1(makeString($7));
$$ = (Node *)n;
}
- | ALTER EXTENSION name add_drop AGGREGATE func_name aggr_args
+ | ALTER EXTENSION name add_drop AGGREGATE aggregate_with_argtypes
{
AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_AGGREGATE;
- n->objname = $6;
- n->objargs = extractAggrArgTypes($7);
+ n->objname = $6->funcname;
+ n->objargs = $6->funcargs;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')'
@@ -5771,13 +5771,13 @@ CommentStmt:
n->comment = $6;
$$ = (Node *) n;
}
- | COMMENT ON AGGREGATE func_name aggr_args IS comment_text
+ | COMMENT ON AGGREGATE aggregate_with_argtypes IS comment_text
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_AGGREGATE;
- n->objname = $4;
- n->objargs = extractAggrArgTypes($5);
- n->comment = $7;
+ n->objname = $4->funcname;
+ n->objargs = $4->funcargs;
+ n->comment = $6;
$$ = (Node *) n;
}
| COMMENT ON FUNCTION function_with_argtypes IS comment_text
@@ -5987,15 +5987,15 @@ SecLabelStmt:
n->label = $8;
$$ = (Node *) n;
}
- | SECURITY LABEL opt_provider ON AGGREGATE func_name aggr_args
+ | SECURITY LABEL opt_provider ON AGGREGATE aggregate_with_argtypes
IS security_label
{
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_AGGREGATE;
- n->objname = $6;
- n->objargs = extractAggrArgTypes($7);
- n->label = $9;
+ n->objname = $6->funcname;
+ n->objargs = $6->funcargs;
+ n->label = $8;
$$ = (Node *) n;
}
| SECURITY LABEL opt_provider ON FUNCTION function_with_argtypes
@@ -7055,6 +7055,16 @@ aggr_args_list:
| aggr_args_list ',' aggr_arg { $$ = lappend($1, $3); }
;
+aggregate_with_argtypes:
+ func_name aggr_args
+ {
+ FuncWithArgs *n = makeNode(FuncWithArgs);
+ n->funcname = $1;
+ n->funcargs = extractAggrArgTypes($2);
+ $$ = n;
+ }
+ ;
+
createfunc_opt_list:
/* Must be at least one to prevent conflict */
createfunc_opt_item { $$ = list_make1($1); }
@@ -7261,24 +7271,24 @@ RemoveFuncStmt:
;
RemoveAggrStmt:
- DROP AGGREGATE func_name aggr_args opt_drop_behavior
+ DROP AGGREGATE aggregate_with_argtypes opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($3);
- n->arguments = list_make1(extractAggrArgTypes($4));
- n->behavior = $5;
+ n->objects = list_make1($3->funcname);
+ n->arguments = list_make1($3->funcargs);
+ n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
$$ = (Node *)n;
}
- | DROP AGGREGATE IF_P EXISTS func_name aggr_args opt_drop_behavior
+ | DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($5);
- n->arguments = list_make1(extractAggrArgTypes($6));
- n->behavior = $7;
+ n->objects = list_make1($5->funcname);
+ n->arguments = list_make1($5->funcargs);
+ n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
$$ = (Node *)n;
@@ -7577,13 +7587,13 @@ AlterTblSpcStmt:
*
*****************************************************************************/
-RenameStmt: ALTER AGGREGATE func_name aggr_args RENAME TO name
+RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_AGGREGATE;
- n->object = $3;
- n->objarg = extractAggrArgTypes($4);
- n->newname = $7;
+ n->object = $3->funcname;
+ n->objarg = $3->funcargs;
+ n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
}
@@ -8109,13 +8119,13 @@ AlterObjectDependsStmt:
*****************************************************************************/
AlterObjectSchemaStmt:
- ALTER AGGREGATE func_name aggr_args SET SCHEMA name
+ ALTER AGGREGATE aggregate_with_argtypes SET SCHEMA name
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_AGGREGATE;
- n->object = $3;
- n->objarg = extractAggrArgTypes($4);
- n->newschema = $7;
+ n->object = $3->funcname;
+ n->objarg = $3->funcargs;
+ n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
}
@@ -8363,13 +8373,13 @@ operator_def_elem: ColLabel '=' NONE
*
*****************************************************************************/
-AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleSpec
+AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_AGGREGATE;
- n->object = $3;
- n->objarg = extractAggrArgTypes($4);
- n->newowner = $7;
+ n->object = $3->funcname;
+ n->objarg = $3->funcargs;
+ n->newowner = $6;
$$ = (Node *)n;
}
| ALTER COLLATION any_name OWNER TO RoleSpec
--
2.10.2
0004-Pass-around-function-signatures-as-FuncWithArgs.patchtext/x-patch; name=0004-Pass-around-function-signatures-as-FuncWithArgs.patchDownload
From 8f86ed1aceec8cff7e402e59f1dd49a140daf260 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Thu, 15 Sep 2016 12:00:00 -0400
Subject: [PATCH 4/7] Pass around function signatures as FuncWithArgs
Use the existing FuncWithArgs node type for passing around function
signatures, instead of always passing around name and argument list as
two separate variables. This makes some things simpler, because only
one value has to be carried around.
---
src/backend/catalog/objectaddress.c | 38 ++++++++++++++++-------
src/backend/commands/dropcmds.c | 30 +++++++++++--------
src/backend/parser/gram.y | 60 ++++++++++++++++---------------------
3 files changed, 71 insertions(+), 57 deletions(-)
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index d531d17..905a488 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -820,17 +820,23 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
address = get_object_address_type(objtype, list_head(objname), missing_ok);
break;
case OBJECT_AGGREGATE:
- address.classId = ProcedureRelationId;
- address.objectId =
- LookupAggNameTypeNames(objname, objargs, missing_ok);
- address.objectSubId = 0;
- break;
+ {
+ FuncWithArgs *fwa = (FuncWithArgs *) linitial(objname);
+ address.classId = ProcedureRelationId;
+ address.objectId =
+ LookupAggNameTypeNames(fwa->funcname, fwa->funcargs, missing_ok);
+ address.objectSubId = 0;
+ break;
+ }
case OBJECT_FUNCTION:
- address.classId = ProcedureRelationId;
- address.objectId =
- LookupFuncNameTypeNames(objname, objargs, missing_ok);
- address.objectSubId = 0;
- break;
+ {
+ FuncWithArgs *fwa = (FuncWithArgs *) linitial(objname);
+ address.classId = ProcedureRelationId;
+ address.objectId =
+ LookupFuncNameTypeNames(fwa->funcname, fwa->funcargs, missing_ok);
+ address.objectSubId = 0;
+ break;
+ }
case OBJECT_OPERATOR:
Assert(list_length(objargs) == 2);
address.classId = OperatorRelationId;
@@ -1992,6 +1998,16 @@ pg_get_object_address(PG_FUNCTION_ARGS)
args = textarray_to_strvaluelist(argsarr);
}
+ if (type == OBJECT_FUNCTION || type == OBJECT_AGGREGATE)
+ {
+ FuncWithArgs *fwa = makeNode(FuncWithArgs);
+
+ fwa->funcname = name;
+ fwa->funcargs = args;
+ name = list_make1(fwa);
+ args = NIL;
+ }
+
/*
* get_object_name is pretty sensitive to the length its input lists;
* check that they're what it wants.
@@ -2100,7 +2116,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
case OBJECT_FUNCTION:
if (!pg_proc_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC,
- NameListToString(objname));
+ NameListToString(((FuncWithArgs *) linitial(objname))->funcname));
break;
case OBJECT_OPERATOR:
if (!pg_oper_ownercheck(address.objectId, roleid))
diff --git a/src/backend/commands/dropcmds.c b/src/backend/commands/dropcmds.c
index 61ff8f2..ecf1428 100644
--- a/src/backend/commands/dropcmds.c
+++ b/src/backend/commands/dropcmds.c
@@ -110,7 +110,7 @@ RemoveObjects(DropStmt *stmt)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is an aggregate function",
- NameListToString(objname)),
+ NameListToString(((FuncWithArgs *) linitial(objname))->funcname)),
errhint("Use DROP AGGREGATE to drop aggregate functions.")));
ReleaseSysCache(tup);
@@ -329,21 +329,27 @@ does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs)
name = NameListToString(objname);
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);
+ FuncWithArgs *fwa = (FuncWithArgs *) linitial(objname);
+ if (!schema_does_not_exist_skipping(fwa->funcname, &msg, &name) &&
+ !type_in_list_does_not_exist_skipping(fwa->funcargs, &msg, &name))
+ {
+ msg = gettext_noop("function %s(%s) does not exist, skipping");
+ name = NameListToString(fwa->funcname);
+ args = TypeNameListToString(fwa->funcargs);
+ }
+ 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);
+ FuncWithArgs *fwa = (FuncWithArgs *) linitial(objname);
+ if (!schema_does_not_exist_skipping(fwa->funcname, &msg, &name) &&
+ !type_in_list_does_not_exist_skipping(fwa->funcargs, &msg, &name))
+ {
+ msg = gettext_noop("aggregate %s(%s) does not exist, skipping");
+ name = NameListToString(fwa->funcname);
+ args = TypeNameListToString(fwa->funcargs);
+ }
}
break;
case OBJECT_OPERATOR:
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index d4d5467..27110a5 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -3946,8 +3946,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_AGGREGATE;
- n->objname = $6->funcname;
- n->objargs = $6->funcargs;
+ n->objname = list_make1($6);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')'
@@ -3993,8 +3992,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_FUNCTION;
- n->objname = $6->funcname;
- n->objargs = $6->funcargs;
+ n->objname = list_make1($6);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop opt_procedural LANGUAGE name
@@ -5775,8 +5773,8 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_AGGREGATE;
- n->objname = $4->funcname;
- n->objargs = $4->funcargs;
+ n->objname = list_make1($4);
+ n->objargs = NIL;
n->comment = $6;
$$ = (Node *) n;
}
@@ -5784,8 +5782,8 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_FUNCTION;
- n->objname = $4->funcname;
- n->objargs = $4->funcargs;
+ n->objname = list_make1($4);
+ n->objargs = NIL;
n->comment = $6;
$$ = (Node *) n;
}
@@ -5993,8 +5991,8 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_AGGREGATE;
- n->objname = $6->funcname;
- n->objargs = $6->funcargs;
+ n->objname = list_make1($6);
+ n->objargs = NIL;
n->label = $8;
$$ = (Node *) n;
}
@@ -6004,8 +6002,8 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_FUNCTION;
- n->objname = $6->funcname;
- n->objargs = $6->funcargs;
+ n->objname = list_make1($6);
+ n->objargs = NIL;
n->label = $8;
$$ = (Node *) n;
}
@@ -7250,8 +7248,8 @@ RemoveFuncStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($3->funcname);
- n->arguments = list_make1($3->funcargs);
+ n->objects = list_make1(list_make1($3));
+ n->arguments = NIL;
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
@@ -7261,8 +7259,8 @@ RemoveFuncStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($5->funcname);
- n->arguments = list_make1($5->funcargs);
+ n->objects = list_make1(list_make1($5));
+ n->arguments = NIL;
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7275,8 +7273,8 @@ RemoveAggrStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($3->funcname);
- n->arguments = list_make1($3->funcargs);
+ n->objects = list_make1(list_make1($3));
+ n->arguments = NIL;
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
@@ -7286,8 +7284,8 @@ RemoveAggrStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($5->funcname);
- n->arguments = list_make1($5->funcargs);
+ n->objects = list_make1(list_make1($5));
+ n->arguments = NIL;
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7591,8 +7589,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_AGGREGATE;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = list_make1($3);
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -7655,8 +7652,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_FUNCTION;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = list_make1($3);
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8075,8 +8071,8 @@ AlterObjectDependsStmt:
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_FUNCTION;
n->relation = NULL;
- n->objname = $3->funcname;
- n->objargs = $3->funcargs;
+ n->objname = list_make1($3);
+ n->objargs = NIL;
n->extname = makeString($7);
$$ = (Node *)n;
}
@@ -8123,8 +8119,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_AGGREGATE;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = list_make1($3);
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8169,8 +8164,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_FUNCTION;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = list_make1($3);
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8377,8 +8371,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_AGGREGATE;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = list_make1($3);
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8418,8 +8411,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_FUNCTION;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = list_make1($3);
n->newowner = $6;
$$ = (Node *)n;
}
--
2.10.2
0005-Allow-dropping-multiple-functions-at-once.patchtext/x-patch; name=0005-Allow-dropping-multiple-functions-at-once.patchDownload
From 34e8ebae9a45ffa8f30fdee8d0b94c9589c5ca89 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Thu, 15 Sep 2016 12:00:00 -0400
Subject: [PATCH 5/7] Allow dropping multiple functions at once
The generic drop support already supported dropping multiple objects of
the same kind at once. But the previous representation
of function signatures across two grammar symbols and structure members
made this cumbersome to do for functions, so it was not supported. Now
that function signatures are represented by a single structure, it's
trivial to add this support.
---
doc/src/sgml/ref/drop_aggregate.sgml | 2 +-
doc/src/sgml/ref/drop_function.sgml | 2 +-
src/backend/commands/dropcmds.c | 3 +++
src/backend/parser/gram.y | 24 +++++++++++++++---------
src/test/regress/expected/create_function_3.out | 6 ++----
src/test/regress/sql/create_function_3.sql | 2 ++
6 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/doc/src/sgml/ref/drop_aggregate.sgml b/doc/src/sgml/ref/drop_aggregate.sgml
index c27c5ea..f239d39 100644
--- a/doc/src/sgml/ref/drop_aggregate.sgml
+++ b/doc/src/sgml/ref/drop_aggregate.sgml
@@ -21,7 +21,7 @@
<refsynopsisdiv>
<synopsis>
-DROP AGGREGATE [ IF EXISTS ] <replaceable>name</replaceable> ( <replaceable>aggregate_signature</replaceable> ) [ CASCADE | RESTRICT ]
+DROP AGGREGATE [ IF EXISTS ] <replaceable>name</replaceable> ( <replaceable>aggregate_signature</replaceable> ) [, ...] [ CASCADE | RESTRICT ]
<phrase>where <replaceable>aggregate_signature</replaceable> is:</phrase>
diff --git a/doc/src/sgml/ref/drop_function.sgml b/doc/src/sgml/ref/drop_function.sgml
index 5883d13..ad76c95 100644
--- a/doc/src/sgml/ref/drop_function.sgml
+++ b/doc/src/sgml/ref/drop_function.sgml
@@ -21,7 +21,7 @@
<refsynopsisdiv>
<synopsis>
-DROP FUNCTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] )
+DROP FUNCTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) [, ...]
[ CASCADE | RESTRICT ]
</synopsis>
</refsynopsisdiv>
diff --git a/src/backend/commands/dropcmds.c b/src/backend/commands/dropcmds.c
index ecf1428..32fe2e9 100644
--- a/src/backend/commands/dropcmds.c
+++ b/src/backend/commands/dropcmds.c
@@ -73,6 +73,9 @@ RemoveObjects(DropStmt *stmt)
objargs = lfirst(cell2);
}
+ if (stmt->removeType == OBJECT_AGGREGATE || stmt->removeType == OBJECT_FUNCTION)
+ objname = list_make1(objname);
+
/* Get an ObjectAddress for the object. */
address = get_object_address(stmt->removeType,
objname, objargs,
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 27110a5..215e686 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -339,7 +339,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <list> privileges privilege_list
%type <privtarget> privilege_target
%type <funwithargs> function_with_argtypes aggregate_with_argtypes
-%type <list> function_with_argtypes_list
+%type <list> function_with_argtypes_list aggregate_with_argtypes_list
%type <ival> defacl_privilege_target
%type <defelt> DefACLOption
%type <list> DefACLOptionList
@@ -7063,6 +7063,12 @@ aggregate_with_argtypes:
}
;
+aggregate_with_argtypes_list:
+ aggregate_with_argtypes { $$ = list_make1($1); }
+ | aggregate_with_argtypes_list ',' aggregate_with_argtypes
+ { $$ = lappend($1, $3); }
+ ;
+
createfunc_opt_list:
/* Must be at least one to prevent conflict */
createfunc_opt_item { $$ = list_make1($1); }
@@ -7244,22 +7250,22 @@ opt_restrict:
*****************************************************************************/
RemoveFuncStmt:
- DROP FUNCTION function_with_argtypes opt_drop_behavior
+ DROP FUNCTION function_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1(list_make1($3));
+ n->objects = $3;
n->arguments = NIL;
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
$$ = (Node *)n;
}
- | DROP FUNCTION IF_P EXISTS function_with_argtypes opt_drop_behavior
+ | DROP FUNCTION IF_P EXISTS function_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1(list_make1($5));
+ n->objects = $5;
n->arguments = NIL;
n->behavior = $6;
n->missing_ok = true;
@@ -7269,22 +7275,22 @@ RemoveFuncStmt:
;
RemoveAggrStmt:
- DROP AGGREGATE aggregate_with_argtypes opt_drop_behavior
+ DROP AGGREGATE aggregate_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1(list_make1($3));
+ n->objects = $3;
n->arguments = NIL;
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
$$ = (Node *)n;
}
- | DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes opt_drop_behavior
+ | DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1(list_make1($5));
+ n->objects = $5;
n->arguments = NIL;
n->behavior = $6;
n->missing_ok = true;
diff --git a/src/test/regress/expected/create_function_3.out b/src/test/regress/expected/create_function_3.out
index 7bb957b..cc4e98a 100644
--- a/src/test/regress/expected/create_function_3.out
+++ b/src/test/regress/expected/create_function_3.out
@@ -217,9 +217,10 @@ SELECT routine_name, ordinal_position, parameter_name, parameter_default
functest_is_3 | 2 | b |
(7 rows)
+DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int);
-- Cleanups
DROP SCHEMA temp_func_test CASCADE;
-NOTICE: drop cascades to 19 other objects
+NOTICE: drop cascades to 16 other objects
DETAIL: drop cascades to function functest_a_1(text,date)
drop cascades to function functest_a_2(text[])
drop cascades to function functest_a_3()
@@ -236,8 +237,5 @@ drop cascades to function functext_f_1(integer)
drop cascades to function functext_f_2(integer)
drop cascades to function functext_f_3(integer)
drop cascades to function functext_f_4(integer)
-drop cascades to function functest_is_1(integer,integer,text)
-drop cascades to function functest_is_2(integer)
-drop cascades to function functest_is_3(integer)
DROP USER regress_unpriv_user;
RESET search_path;
diff --git a/src/test/regress/sql/create_function_3.sql b/src/test/regress/sql/create_function_3.sql
index 43454ef..66a463b 100644
--- a/src/test/regress/sql/create_function_3.sql
+++ b/src/test/regress/sql/create_function_3.sql
@@ -156,6 +156,8 @@ CREATE FUNCTION functest_IS_3(a int default 1, out b int)
WHERE routine_schema = 'temp_func_test' AND routine_name ~ '^functest_is_'
ORDER BY 1, 2;
+DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int);
+
-- Cleanups
DROP SCHEMA temp_func_test CASCADE;
--
2.10.2
0006-Replace-LookupFuncNameTypeNames-with-LookupFuncWithA.patchtext/x-patch; name=0006-Replace-LookupFuncNameTypeNames-with-LookupFuncWithA.patchDownload
From e51b44b9d13e1a8173d2731e1b1ce1b40c8ff0af Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Mon, 19 Sep 2016 12:00:00 -0400
Subject: [PATCH 6/7] Replace LookupFuncNameTypeNames() with
LookupFuncWithArgs()
The old function took function name and function argument list as
separate arguments. Now that all function signatures are passed around
as a FuncWithArgs struct, this is no longer necessary and can be
replaced by a function that takes FuncWithArgs directly.
---
src/backend/catalog/aclchk.c | 3 +--
src/backend/catalog/objectaddress.c | 6 ++----
src/backend/commands/functioncmds.c | 12 ++++--------
src/backend/commands/opclasscmds.c | 28 +++++++++++++---------------
src/backend/nodes/copyfuncs.c | 1 -
src/backend/nodes/equalfuncs.c | 1 -
src/backend/parser/gram.y | 22 ++++++++++++----------
src/backend/parser/parse_func.c | 32 ++++++++++++++++----------------
src/include/nodes/parsenodes.h | 4 +---
src/include/parser/parse_func.h | 4 ++--
10 files changed, 51 insertions(+), 62 deletions(-)
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index c0df671..16449cf 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -661,8 +661,7 @@ objectNamesToOids(GrantObjectType objtype, List *objnames)
FuncWithArgs *func = (FuncWithArgs *) lfirst(cell);
Oid funcid;
- funcid = LookupFuncNameTypeNames(func->funcname,
- func->funcargs, false);
+ funcid = LookupFuncWithArgs(func, false);
objects = lappend_oid(objects, funcid);
}
break;
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 905a488..a682460 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -823,8 +823,7 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
{
FuncWithArgs *fwa = (FuncWithArgs *) linitial(objname);
address.classId = ProcedureRelationId;
- address.objectId =
- LookupAggNameTypeNames(fwa->funcname, fwa->funcargs, missing_ok);
+ address.objectId = LookupAggWithArgs(fwa, missing_ok);
address.objectSubId = 0;
break;
}
@@ -832,8 +831,7 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
{
FuncWithArgs *fwa = (FuncWithArgs *) linitial(objname);
address.classId = ProcedureRelationId;
- address.objectId =
- LookupFuncNameTypeNames(fwa->funcname, fwa->funcargs, missing_ok);
+ address.objectId = LookupFuncWithArgs(fwa, missing_ok);
address.objectSubId = 0;
break;
}
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index becafc3..94aa348 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -1184,9 +1184,7 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
rel = heap_open(ProcedureRelationId, RowExclusiveLock);
- funcOid = LookupFuncNameTypeNames(stmt->func->funcname,
- stmt->func->funcargs,
- false);
+ funcOid = LookupFuncWithArgs(stmt->func, false);
tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
@@ -1461,9 +1459,7 @@ CreateCast(CreateCastStmt *stmt)
{
Form_pg_proc procstruct;
- funcid = LookupFuncNameTypeNames(stmt->func->funcname,
- stmt->func->funcargs,
- false);
+ funcid = LookupFuncWithArgs(stmt->func, false);
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tuple))
@@ -1843,7 +1839,7 @@ CreateTransform(CreateTransformStmt *stmt)
*/
if (stmt->fromsql)
{
- fromsqlfuncid = LookupFuncNameTypeNames(stmt->fromsql->funcname, stmt->fromsql->funcargs, false);
+ fromsqlfuncid = LookupFuncWithArgs(stmt->fromsql, false);
if (!pg_proc_ownercheck(fromsqlfuncid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->fromsql->funcname));
@@ -1868,7 +1864,7 @@ CreateTransform(CreateTransformStmt *stmt)
if (stmt->tosql)
{
- tosqlfuncid = LookupFuncNameTypeNames(stmt->tosql->funcname, stmt->tosql->funcargs, false);
+ tosqlfuncid = LookupFuncWithArgs(stmt->tosql, false);
if (!pg_proc_ownercheck(tosqlfuncid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->tosql->funcname));
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index f4dfdb9..db45f79 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -478,19 +478,19 @@ DefineOpClass(CreateOpClassStmt *stmt)
errmsg("invalid operator number %d,"
" must be between 1 and %d",
item->number, maxOpNumber)));
- if (item->args != NIL)
+ if (item->name->funcargs != NIL)
{
- TypeName *typeName1 = (TypeName *) linitial(item->args);
- TypeName *typeName2 = (TypeName *) lsecond(item->args);
+ TypeName *typeName1 = (TypeName *) linitial(item->name->funcargs);
+ TypeName *typeName2 = (TypeName *) lsecond(item->name->funcargs);
- operOid = LookupOperNameTypeNames(NULL, item->name,
+ operOid = LookupOperNameTypeNames(NULL, item->name->funcname,
typeName1, typeName2,
false, -1);
}
else
{
/* Default to binary op on input datatype */
- operOid = LookupOperName(NULL, item->name,
+ operOid = LookupOperName(NULL, item->name->funcname,
typeoid, typeoid,
false, -1);
}
@@ -529,8 +529,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
errmsg("invalid procedure number %d,"
" must be between 1 and %d",
item->number, maxProcNumber)));
- funcOid = LookupFuncNameTypeNames(item->name, item->args,
- false);
+ funcOid = LookupFuncWithArgs(item->name, false);
#ifdef NOT_USED
/* XXX this is unnecessary given the superuser check above */
/* Caller must own function */
@@ -863,12 +862,12 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
errmsg("invalid operator number %d,"
" must be between 1 and %d",
item->number, maxOpNumber)));
- if (item->args != NIL)
+ if (item->name->funcargs != NIL)
{
- TypeName *typeName1 = (TypeName *) linitial(item->args);
- TypeName *typeName2 = (TypeName *) lsecond(item->args);
+ TypeName *typeName1 = (TypeName *) linitial(item->name->funcargs);
+ TypeName *typeName2 = (TypeName *) lsecond(item->name->funcargs);
- operOid = LookupOperNameTypeNames(NULL, item->name,
+ operOid = LookupOperNameTypeNames(NULL, item->name->funcname,
typeName1, typeName2,
false, -1);
}
@@ -914,8 +913,7 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
errmsg("invalid procedure number %d,"
" must be between 1 and %d",
item->number, maxProcNumber)));
- funcOid = LookupFuncNameTypeNames(item->name, item->args,
- false);
+ funcOid = LookupFuncWithArgs(item->name, false);
#ifdef NOT_USED
/* XXX this is unnecessary given the superuser check above */
/* Caller must own function */
@@ -996,7 +994,7 @@ AlterOpFamilyDrop(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
errmsg("invalid operator number %d,"
" must be between 1 and %d",
item->number, maxOpNumber)));
- processTypesSpec(item->args, &lefttype, &righttype);
+ processTypesSpec(item->class_args, &lefttype, &righttype);
/* Save the info */
member = (OpFamilyMember *) palloc0(sizeof(OpFamilyMember));
member->number = item->number;
@@ -1011,7 +1009,7 @@ AlterOpFamilyDrop(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
errmsg("invalid procedure number %d,"
" must be between 1 and %d",
item->number, maxProcNumber)));
- processTypesSpec(item->args, &lefttype, &righttype);
+ processTypesSpec(item->class_args, &lefttype, &righttype);
/* Save the info */
member = (OpFamilyMember *) palloc0(sizeof(OpFamilyMember));
member->number = item->number;
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 71714bc..0da30b1 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -3445,7 +3445,6 @@ _copyCreateOpClassItem(const CreateOpClassItem *from)
COPY_SCALAR_FIELD(itemtype);
COPY_NODE_FIELD(name);
- COPY_NODE_FIELD(args);
COPY_SCALAR_FIELD(number);
COPY_NODE_FIELD(order_family);
COPY_NODE_FIELD(class_args);
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index 29a090f..ecff265 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -1525,7 +1525,6 @@ _equalCreateOpClassItem(const CreateOpClassItem *a, const CreateOpClassItem *b)
{
COMPARE_SCALAR_FIELD(itemtype);
COMPARE_NODE_FIELD(name);
- COMPARE_NODE_FIELD(args);
COMPARE_SCALAR_FIELD(number);
COMPARE_NODE_FIELD(order_family);
COMPARE_NODE_FIELD(class_args);
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 215e686..3681208 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -5346,9 +5346,11 @@ opclass_item:
OPERATOR Iconst any_operator opclass_purpose opt_recheck
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
+ FuncWithArgs *fwa = makeNode(FuncWithArgs);
+ fwa->funcname = $3;
+ fwa->funcargs = NIL;
n->itemtype = OPCLASS_ITEM_OPERATOR;
- n->name = $3;
- n->args = NIL;
+ n->name = fwa;
n->number = $2;
n->order_family = $4;
$$ = (Node *) n;
@@ -5357,9 +5359,11 @@ opclass_item:
opt_recheck
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
+ FuncWithArgs *fwa = makeNode(FuncWithArgs);
+ fwa->funcname = $3;
+ fwa->funcargs = $4;
n->itemtype = OPCLASS_ITEM_OPERATOR;
- n->name = $3;
- n->args = $4;
+ n->name = fwa;
n->number = $2;
n->order_family = $5;
$$ = (Node *) n;
@@ -5368,8 +5372,7 @@ opclass_item:
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION;
- n->name = $3->funcname;
- n->args = $3->funcargs;
+ n->name = $3;
n->number = $2;
$$ = (Node *) n;
}
@@ -5377,8 +5380,7 @@ opclass_item:
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION;
- n->name = $6->funcname;
- n->args = $6->funcargs;
+ n->name = $6;
n->number = $2;
n->class_args = $4;
$$ = (Node *) n;
@@ -5465,7 +5467,7 @@ opclass_drop:
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_OPERATOR;
n->number = $2;
- n->args = $4;
+ n->class_args = $4;
$$ = (Node *) n;
}
| FUNCTION Iconst '(' type_list ')'
@@ -5473,7 +5475,7 @@ opclass_drop:
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION;
n->number = $2;
- n->args = $4;
+ n->class_args = $4;
$$ = (Node *) n;
}
;
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index 56c9a42..b3938e4 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -1933,19 +1933,19 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError)
}
/*
- * LookupFuncNameTypeNames
+ * LookupFuncWithArgs
* Like LookupFuncName, but the argument types are specified by a
- * list of TypeName nodes.
+ * FuncWithArgs node.
*/
Oid
-LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
+LookupFuncWithArgs(FuncWithArgs *func, bool noError)
{
Oid argoids[FUNC_MAX_ARGS];
int argcount;
int i;
ListCell *args_item;
- argcount = list_length(argtypes);
+ argcount = list_length(func->funcargs);
if (argcount > FUNC_MAX_ARGS)
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
@@ -1954,7 +1954,7 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
FUNC_MAX_ARGS,
FUNC_MAX_ARGS)));
- args_item = list_head(argtypes);
+ args_item = list_head(func->funcargs);
for (i = 0; i < argcount; i++)
{
TypeName *t = (TypeName *) lfirst(args_item);
@@ -1963,19 +1963,19 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
args_item = lnext(args_item);
}
- return LookupFuncName(funcname, argcount, argoids, noError);
+ return LookupFuncName(func->funcname, argcount, argoids, noError);
}
/*
- * LookupAggNameTypeNames
- * Find an aggregate function given a name and list of TypeName nodes.
+ * LookupAggWithArgs
+ * Find an aggregate function from a given FuncWithArgs node.
*
- * This is almost like LookupFuncNameTypeNames, but the error messages refer
+ * This is almost like LookupFuncWithArgs, but the error messages refer
* to aggregates rather than plain functions, and we verify that the found
* function really is an aggregate.
*/
Oid
-LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
+LookupAggWithArgs(FuncWithArgs *agg, bool noError)
{
Oid argoids[FUNC_MAX_ARGS];
int argcount;
@@ -1985,7 +1985,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
HeapTuple ftup;
Form_pg_proc pform;
- argcount = list_length(argtypes);
+ argcount = list_length(agg->funcargs);
if (argcount > FUNC_MAX_ARGS)
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
@@ -1995,7 +1995,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
FUNC_MAX_ARGS)));
i = 0;
- foreach(lc, argtypes)
+ foreach(lc, agg->funcargs)
{
TypeName *t = (TypeName *) lfirst(lc);
@@ -2003,7 +2003,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
i++;
}
- oid = LookupFuncName(aggname, argcount, argoids, true);
+ oid = LookupFuncName(agg->funcname, argcount, argoids, true);
if (!OidIsValid(oid))
{
@@ -2013,12 +2013,12 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("aggregate %s(*) does not exist",
- NameListToString(aggname))));
+ NameListToString(agg->funcname))));
else
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("aggregate %s does not exist",
- func_signature_string(aggname, argcount,
+ func_signature_string(agg->funcname, argcount,
NIL, argoids))));
}
@@ -2037,7 +2037,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("function %s is not an aggregate",
- func_signature_string(aggname, argcount,
+ func_signature_string(agg->funcname, argcount,
NIL, argoids))));
}
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 6de2cab..564ed50 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2271,9 +2271,7 @@ typedef struct CreateOpClassItem
{
NodeTag type;
int itemtype; /* see codes above */
- /* fields used for an operator or function item: */
- List *name; /* operator or function name */
- List *args; /* argument types */
+ FuncWithArgs *name; /* operator or function name and args */
int number; /* strategy num or support proc num */
List *order_family; /* only used for ordering operators */
List *class_args; /* only used for functions */
diff --git a/src/include/parser/parse_func.h b/src/include/parser/parse_func.h
index ed16d36..b1a5494 100644
--- a/src/include/parser/parse_func.h
+++ b/src/include/parser/parse_func.h
@@ -62,9 +62,9 @@ extern const char *func_signature_string(List *funcname, int nargs,
extern Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes,
bool noError);
-extern Oid LookupFuncNameTypeNames(List *funcname, List *argtypes,
+extern Oid LookupFuncWithArgs(FuncWithArgs *func,
bool noError);
-extern Oid LookupAggNameTypeNames(List *aggname, List *argtypes,
+extern Oid LookupAggWithArgs(FuncWithArgs *agg,
bool noError);
extern void check_srf_call_placement(ParseState *pstate, int location);
--
2.10.2
0007-Pass-operators-around-with-FuncWithArgs-as-well.patchtext/x-patch; name=0007-Pass-operators-around-with-FuncWithArgs-as-well.patchDownload
From ca25c97a62d8ae0722e17b4b5d975c7adc885601 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Mon, 19 Sep 2016 12:00:00 -0400
Subject: [PATCH 7/7] Pass operators around with FuncWithArgs as well
This unifies the operator handling with the previous changes for
functions and aggregates.
---
doc/src/sgml/ref/drop_operator.sgml | 2 +-
src/backend/catalog/objectaddress.c | 38 +++++++++---------
src/backend/commands/dropcmds.c | 13 ++++---
src/backend/commands/opclasscmds.c | 18 +--------
src/backend/commands/operatorcmds.c | 5 +--
src/backend/nodes/copyfuncs.c | 1 -
src/backend/nodes/equalfuncs.c | 1 -
src/backend/parser/gram.y | 77 +++++++++++++++++++++----------------
src/backend/parser/parse_oper.c | 25 ++++++------
src/include/nodes/parsenodes.h | 3 +-
src/include/parser/parse_oper.h | 5 +--
11 files changed, 90 insertions(+), 98 deletions(-)
diff --git a/doc/src/sgml/ref/drop_operator.sgml b/doc/src/sgml/ref/drop_operator.sgml
index 13dd974..e196547 100644
--- a/doc/src/sgml/ref/drop_operator.sgml
+++ b/doc/src/sgml/ref/drop_operator.sgml
@@ -21,7 +21,7 @@
<refsynopsisdiv>
<synopsis>
-DROP OPERATOR [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> ( { <replaceable class="PARAMETER">left_type</replaceable> | NONE } , { <replaceable class="PARAMETER">right_type</replaceable> | NONE } ) [ CASCADE | RESTRICT ]
+DROP OPERATOR [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> ( { <replaceable class="PARAMETER">left_type</replaceable> | NONE } , { <replaceable class="PARAMETER">right_type</replaceable> | NONE } ) [, ...] [ CASCADE | RESTRICT ]
</synopsis>
</refsynopsisdiv>
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index a682460..c5d2e60 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -836,15 +836,13 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
break;
}
case OBJECT_OPERATOR:
- Assert(list_length(objargs) == 2);
- address.classId = OperatorRelationId;
- address.objectId =
- LookupOperNameTypeNames(NULL, objname,
- (TypeName *) linitial(objargs),
- (TypeName *) lsecond(objargs),
- missing_ok, -1);
- address.objectSubId = 0;
- break;
+ {
+ FuncWithArgs *fwa = (FuncWithArgs *) linitial(objname);
+ address.classId = OperatorRelationId;
+ address.objectId = LookupOperWithArgs(fwa, missing_ok);
+ address.objectSubId = 0;
+ break;
+ }
case OBJECT_COLLATION:
address.classId = CollationRelationId;
address.objectId = get_collation_oid(objname, missing_ok);
@@ -1996,16 +1994,6 @@ pg_get_object_address(PG_FUNCTION_ARGS)
args = textarray_to_strvaluelist(argsarr);
}
- if (type == OBJECT_FUNCTION || type == OBJECT_AGGREGATE)
- {
- FuncWithArgs *fwa = makeNode(FuncWithArgs);
-
- fwa->funcname = name;
- fwa->funcargs = args;
- name = list_make1(fwa);
- args = NIL;
- }
-
/*
* get_object_name is pretty sensitive to the length its input lists;
* check that they're what it wants.
@@ -2046,6 +2034,16 @@ pg_get_object_address(PG_FUNCTION_ARGS)
break;
}
+ if (type == OBJECT_FUNCTION || type == OBJECT_AGGREGATE || type == OBJECT_OPERATOR)
+ {
+ FuncWithArgs *fwa = makeNode(FuncWithArgs);
+
+ fwa->funcname = name;
+ fwa->funcargs = args;
+ name = list_make1(fwa);
+ args = NIL;
+ }
+
addr = get_object_address(type, name, args,
&relation, AccessShareLock, false);
@@ -2119,7 +2117,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
case OBJECT_OPERATOR:
if (!pg_oper_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPER,
- NameListToString(objname));
+ NameListToString(((FuncWithArgs *) linitial(objname))->funcname));
break;
case OBJECT_SCHEMA:
if (!pg_namespace_ownercheck(address.objectId, roleid))
diff --git a/src/backend/commands/dropcmds.c b/src/backend/commands/dropcmds.c
index 32fe2e9..6c9786e 100644
--- a/src/backend/commands/dropcmds.c
+++ b/src/backend/commands/dropcmds.c
@@ -73,7 +73,7 @@ RemoveObjects(DropStmt *stmt)
objargs = lfirst(cell2);
}
- if (stmt->removeType == OBJECT_AGGREGATE || stmt->removeType == OBJECT_FUNCTION)
+ if (stmt->removeType == OBJECT_AGGREGATE || stmt->removeType == OBJECT_FUNCTION || stmt->removeType == OBJECT_OPERATOR)
objname = list_make1(objname);
/* Get an ObjectAddress for the object. */
@@ -356,11 +356,14 @@ does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs)
}
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);
+ FuncWithArgs *fwa = (FuncWithArgs *) linitial(objname);
+ if (!schema_does_not_exist_skipping(fwa->funcname, &msg, &name) &&
+ !type_in_list_does_not_exist_skipping(fwa->funcargs, &msg, &name))
+ {
+ msg = gettext_noop("operator %s does not exist, skipping");
+ name = NameListToString(fwa->funcname);
+ }
}
break;
case OBJECT_LANGUAGE:
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index db45f79..cfda571 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -479,14 +479,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
" must be between 1 and %d",
item->number, maxOpNumber)));
if (item->name->funcargs != NIL)
- {
- TypeName *typeName1 = (TypeName *) linitial(item->name->funcargs);
- TypeName *typeName2 = (TypeName *) lsecond(item->name->funcargs);
-
- operOid = LookupOperNameTypeNames(NULL, item->name->funcname,
- typeName1, typeName2,
- false, -1);
- }
+ operOid = LookupOperWithArgs(item->name, false);
else
{
/* Default to binary op on input datatype */
@@ -863,14 +856,7 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
" must be between 1 and %d",
item->number, maxOpNumber)));
if (item->name->funcargs != NIL)
- {
- TypeName *typeName1 = (TypeName *) linitial(item->name->funcargs);
- TypeName *typeName2 = (TypeName *) lsecond(item->name->funcargs);
-
- operOid = LookupOperNameTypeNames(NULL, item->name->funcname,
- typeName1, typeName2,
- false, -1);
- }
+ operOid = LookupOperWithArgs(item->name, false);
else
{
ereport(ERROR,
diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c
index 67d08d8..35b18b0 100644
--- a/src/backend/commands/operatorcmds.c
+++ b/src/backend/commands/operatorcmds.c
@@ -402,10 +402,7 @@ AlterOperator(AlterOperatorStmt *stmt)
Oid joinOid;
/* Look up the operator */
- oprId = LookupOperNameTypeNames(NULL, stmt->opername,
- (TypeName *) linitial(stmt->operargs),
- (TypeName *) lsecond(stmt->operargs),
- false, -1);
+ oprId = LookupOperWithArgs(stmt->opername, false);
catalog = heap_open(OperatorRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(oprId));
if (tup == NULL)
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 0da30b1..e794375 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -3272,7 +3272,6 @@ _copyAlterOperatorStmt(const AlterOperatorStmt *from)
AlterOperatorStmt *newnode = makeNode(AlterOperatorStmt);
COPY_NODE_FIELD(opername);
- COPY_NODE_FIELD(operargs);
COPY_NODE_FIELD(options);
return newnode;
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index ecff265..6ab3b84 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -1380,7 +1380,6 @@ static bool
_equalAlterOperatorStmt(const AlterOperatorStmt *a, const AlterOperatorStmt *b)
{
COMPARE_NODE_FIELD(opername);
- COMPARE_NODE_FIELD(operargs);
COMPARE_NODE_FIELD(options);
return true;
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 3681208..07086c6 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -338,8 +338,8 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <accesspriv> privilege
%type <list> privileges privilege_list
%type <privtarget> privilege_target
-%type <funwithargs> function_with_argtypes aggregate_with_argtypes
-%type <list> function_with_argtypes_list aggregate_with_argtypes_list
+%type <funwithargs> function_with_argtypes aggregate_with_argtypes operator_with_argtypes
+%type <list> function_with_argtypes_list aggregate_with_argtypes_list operator_with_argtypes_list
%type <ival> defacl_privilege_target
%type <defelt> DefACLOption
%type <list> DefACLOptionList
@@ -4004,14 +4004,13 @@ AlterExtensionContentsStmt:
n->objname = list_make1(makeString($7));
$$ = (Node *)n;
}
- | ALTER EXTENSION name add_drop OPERATOR any_operator oper_argtypes
+ | ALTER EXTENSION name add_drop OPERATOR operator_with_argtypes
{
AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_OPERATOR;
- n->objname = $6;
- n->objargs = $7;
+ n->objname = list_make1($6);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING access_method
@@ -5355,17 +5354,14 @@ opclass_item:
n->order_family = $4;
$$ = (Node *) n;
}
- | OPERATOR Iconst any_operator oper_argtypes opclass_purpose
+ | OPERATOR Iconst operator_with_argtypes opclass_purpose
opt_recheck
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
- FuncWithArgs *fwa = makeNode(FuncWithArgs);
- fwa->funcname = $3;
- fwa->funcargs = $4;
n->itemtype = OPCLASS_ITEM_OPERATOR;
- n->name = fwa;
+ n->name = $3;
n->number = $2;
- n->order_family = $5;
+ n->order_family = $4;
$$ = (Node *) n;
}
| FUNCTION Iconst function_with_argtypes
@@ -5789,13 +5785,13 @@ CommentStmt:
n->comment = $6;
$$ = (Node *) n;
}
- | COMMENT ON OPERATOR any_operator oper_argtypes IS comment_text
+ | COMMENT ON OPERATOR operator_with_argtypes IS comment_text
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_OPERATOR;
- n->objname = $4;
- n->objargs = $5;
- n->comment = $7;
+ n->objname = list_make1($4);
+ n->objargs = NIL;
+ n->comment = $6;
$$ = (Node *) n;
}
| COMMENT ON CONSTRAINT name ON any_name IS comment_text
@@ -7302,24 +7298,24 @@ RemoveAggrStmt:
;
RemoveOperStmt:
- DROP OPERATOR any_operator oper_argtypes opt_drop_behavior
+ DROP OPERATOR operator_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($3);
- n->arguments = list_make1($4);
- n->behavior = $5;
+ n->objects = $3;
+ n->arguments = NIL;
+ n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
$$ = (Node *)n;
}
- | DROP OPERATOR IF_P EXISTS any_operator oper_argtypes opt_drop_behavior
+ | DROP OPERATOR IF_P EXISTS operator_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($5);
- n->arguments = list_make1($6);
- n->behavior = $7;
+ n->objects = $5;
+ n->arguments = NIL;
+ n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
$$ = (Node *)n;
@@ -7350,6 +7346,22 @@ any_operator:
{ $$ = lcons(makeString($1), $3); }
;
+operator_with_argtypes_list:
+ operator_with_argtypes { $$ = list_make1($1); }
+ | operator_with_argtypes_list ',' operator_with_argtypes
+ { $$ = lappend($1, $3); }
+ ;
+
+operator_with_argtypes:
+ any_operator oper_argtypes
+ {
+ FuncWithArgs *n = makeNode(FuncWithArgs);
+ n->funcname = $1;
+ n->funcargs = $2;
+ $$ = n;
+ }
+ ;
+
/*****************************************************************************
*
* DO <anonymous code block> [ LANGUAGE language ]
@@ -8177,13 +8189,12 @@ AlterObjectSchemaStmt:
n->missing_ok = false;
$$ = (Node *)n;
}
- | ALTER OPERATOR any_operator oper_argtypes SET SCHEMA name
+ | ALTER OPERATOR operator_with_argtypes SET SCHEMA name
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_OPERATOR;
- n->object = $3;
- n->objarg = $4;
- n->newschema = $7;
+ n->object = list_make1($3);
+ n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
}
@@ -8349,12 +8360,11 @@ AlterObjectSchemaStmt:
*****************************************************************************/
AlterOperatorStmt:
- ALTER OPERATOR any_operator oper_argtypes SET '(' operator_def_list ')'
+ ALTER OPERATOR operator_with_argtypes SET '(' operator_def_list ')'
{
AlterOperatorStmt *n = makeNode(AlterOperatorStmt);
n->opername = $3;
- n->operargs = $4;
- n->options = $7;
+ n->options = $6;
$$ = (Node *)n;
}
;
@@ -8439,13 +8449,12 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
n->newowner = $7;
$$ = (Node *)n;
}
- | ALTER OPERATOR any_operator oper_argtypes OWNER TO RoleSpec
+ | ALTER OPERATOR operator_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_OPERATOR;
- n->object = $3;
- n->objarg = $4;
- n->newowner = $7;
+ n->object = list_make1($3);
+ n->newowner = $6;
$$ = (Node *)n;
}
| ALTER OPERATOR CLASS any_name USING access_method OWNER TO RoleSpec
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index aecda6d..006d978 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -132,32 +132,35 @@ LookupOperName(ParseState *pstate, List *opername, Oid oprleft, Oid oprright,
}
/*
- * LookupOperNameTypeNames
+ * LookupOperWithArgs
* Like LookupOperName, but the argument types are specified by
- * TypeName nodes.
- *
- * Pass oprleft = NULL for a prefix op, oprright = NULL for a postfix op.
+ * a FuncWithArg node.
*/
Oid
-LookupOperNameTypeNames(ParseState *pstate, List *opername,
- TypeName *oprleft, TypeName *oprright,
- bool noError, int location)
+LookupOperWithArgs(FuncWithArgs *oper,
+ bool noError)
{
+ TypeName *oprleft,
+ *oprright;
Oid leftoid,
rightoid;
+ Assert(list_length(oper->funcargs) == 2);
+ oprleft = linitial(oper->funcargs);
+ oprright = lsecond(oper->funcargs);
+
if (oprleft == NULL)
leftoid = InvalidOid;
else
- leftoid = LookupTypeNameOid(pstate, oprleft, noError);
+ leftoid = LookupTypeNameOid(NULL, oprleft, noError);
if (oprright == NULL)
rightoid = InvalidOid;
else
- rightoid = LookupTypeNameOid(pstate, oprright, noError);
+ rightoid = LookupTypeNameOid(NULL, oprright, noError);
- return LookupOperName(pstate, opername, leftoid, rightoid,
- noError, location);
+ return LookupOperName(NULL, oper->funcname, leftoid, rightoid,
+ noError, -1);
}
/*
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 564ed50..8a1f530 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2587,8 +2587,7 @@ typedef struct AlterOwnerStmt
typedef struct AlterOperatorStmt
{
NodeTag type;
- List *opername; /* operator name */
- List *operargs; /* operator's argument TypeNames */
+ FuncWithArgs *opername; /* operator name and argument types */
List *options; /* List of DefElem nodes */
} AlterOperatorStmt;
diff --git a/src/include/parser/parse_oper.h b/src/include/parser/parse_oper.h
index 03bb5b9..51c1247 100644
--- a/src/include/parser/parse_oper.h
+++ b/src/include/parser/parse_oper.h
@@ -15,6 +15,7 @@
#define PARSE_OPER_H
#include "access/htup.h"
+#include "nodes/parsenodes.h"
#include "parser/parse_node.h"
@@ -24,9 +25,7 @@ typedef HeapTuple Operator;
extern Oid LookupOperName(ParseState *pstate, List *opername,
Oid oprleft, Oid oprright,
bool noError, int location);
-extern Oid LookupOperNameTypeNames(ParseState *pstate, List *opername,
- TypeName *oprleft, TypeName *oprright,
- bool noError, int location);
+extern Oid LookupOperWithArgs(FuncWithArgs *oper, bool noError);
/* Routines to find operators matching a name and given input types */
/* NB: the selected operator may require coercion of the input types! */
--
2.10.2
Peter Eisentraut wrote:
Here is a patch series that implements several changes in the internal
grammar and node representation of function signatures. They are not
necessarily meant to be applied separately, but they explain the
progression of the changes nicely, so I left them like that for review.
I think patches 1-4 and 6 are pretty clearly straight cleanup and it
seems fine to me to push them ahead of the rest. I didn't review super
carefully but it looks good on a quick glance. I'd just advise to pay
special attention to the objectaddress.sql test and the UI involved
there (which you appear to have done already).
Patch 5 is obviously a new feature and I would put that one in a
separate commit from the first four plus six. (I'm not clear why you
put 6 after 5 instead of before.)
I'm not at all sure about patch 7. Maybe that one is okay, not sure,
but since it's bigger I didn't look at it.
--
�lvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Tue, Nov 1, 2016 at 2:55 AM, Peter Eisentraut <
peter.eisentraut@2ndquadrant.com> wrote:
Here is a patch series that implements several changes in the internal
grammar and node representation of function signatures. They are not
necessarily meant to be applied separately, but they explain the
progression of the changes nicely, so I left them like that for review.The end goal is to make some user-visible changes in DROP FUNCTION and
possibly other commands that refer to functions.With these patches, it is now possible to use DROP FUNCTION to drop
multiple functions at once: DROP FUNCTION func1(), func2(), func3().
Other DROP commands already supported that, but DROP FUNCTION didn't
because the internal representation was complicated and couldn't handle
it.
The next step after this would be to allow referring to functions
without having to supply the arguments, if the name is unique. This is
an SQL-standard feature and would be very useful for dealing "business
logic" functions with 10+ arguments. The details of that are to be
worked out, but with the help of the present changes, this would be a
quite localized change, because the grammar representation is well
encapsulated.
Really nice... just a little about 006, can't we reduce the code bellow?
@@ -823,8 +823,7 @@ get_object_address(ObjectType objtype, List *objname,
List *objargs,
{
FuncWithArgs *fwa = (FuncWithArgs *) linitial(objname);
address.classId = ProcedureRelationId;
- address.objectId =
- LookupAggNameTypeNames(fwa->funcname,
fwa->funcargs, missing_ok);
+ address.objectId = LookupAggWithArgs(fwa, missing_ok);
address.objectSubId = 0;
break;
}
@@ -832,8 +831,7 @@ get_object_address(ObjectType objtype, List *objname,
List *objargs,
{
FuncWithArgs *fwa = (FuncWithArgs *) linitial(objname);
address.classId = ProcedureRelationId;
- address.objectId =
- LookupFuncNameTypeNames(fwa->funcname,
fwa->funcargs, missing_ok);
+ address.objectId = LookupFuncWithArgs(fwa, missing_ok);
address.objectSubId = 0;
break;
}
Regards,
--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
Show quoted text
Timbira: http://www.timbira.com.br
Blog: http://fabriziomello.github.io
Linkedin: http://br.linkedin.com/in/fabriziomello
Twitter: http://twitter.com/fabriziomello
Github: http://github.com/fabriziomello
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
Peter Eisentraut wrote:
Here is a patch series that implements several changes in the internal
grammar and node representation of function signatures. They are not
necessarily meant to be applied separately, but they explain the
progression of the changes nicely, so I left them like that for review.
I think patches 1-4 and 6 are pretty clearly straight cleanup and it
seems fine to me to push them ahead of the rest. I didn't review super
carefully but it looks good on a quick glance. I'd just advise to pay
special attention to the objectaddress.sql test and the UI involved
there (which you appear to have done already).
I looked at this briefly. I agree that 0001-0003 are simple cleanup of
the grammar and could be pushed without further ado. However, starting
with 0004 I begin to get queasy. The plan seems to be that instead of
"objname" always being a List of strings, for functions (and then
aggregates and operators) it will be a one-element List of some new struct
that has then got a name list inside it. This seems seriously bug-prone.
It leads to code with random changes of data representation at seemingly
random places, like this bit from 0005:
+ if (stmt->removeType == OBJECT_AGGREGATE || stmt->removeType == OBJECT_FUNCTION)
+ objname = list_make1(objname);
I've got no confidence that you've found all the places that will be
broken by that, nor that it won't introduce new bugs later.
Also, it seems like the end goal ought to involve getting rid of the
separate objarg/objargs fields in places like RenameStmt, as well
as the separate objargs argument to get_object_address and friends,
but the patch mostly doesn't do that --- 0006 does change
CreateOpClassItem, and 0007 changes AlterOperatorStmt, but that seems
like just the tip of the iceberg.
I wonder whether it would be useful to invent an ObjectName node type
typedef struct ObjectName
{
NodeTag type;
List *names; /* list of String, representing possibly-qualified name */
List *args; /* list of TypeName, if needed for object type */
} ObjectName;
and replace all the places that currently have separate objname/objargs
fields or arguments with a uniform "ObjectName *" field/argument. (This
node type could replace FuncWithArgs, obviously.) Although that would
be more invasive, you could be certain that you'd looked at every place
that's affected by the change of representation.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 11/23/16 5:04 PM, Tom Lane wrote:
I looked at this briefly. I agree that 0001-0003 are simple cleanup of
the grammar and could be pushed without further ado.
Done.
However, starting
with 0004 I begin to get queasy. The plan seems to be that instead of
"objname" always being a List of strings, for functions (and then
aggregates and operators) it will be a one-element List of some new struct
that has then got a name list inside it.
I think the original idea of representing an object by a list of name
components plus optionally a list of arguments has accumulated too many
warts and should be replaced. For example: A Typename isn't a list, so
it has to be packed into a List to be able to pass it around. Some
objects only have a single-component string as a name. For a cast, we
arbitrarily put the source type into a the name list and the target type
into the argument list. For an operator class on the other hand we
create a cons of name and access method. The pending logical
replication patch has more such arbitrary examples. This pattern has to
be repeated consistently in gram.y for all cases where the object is
referenced (ALTER EXTENSION, DROP, COMMENT, RENAME, SET SCHEMA, OWNER
TO) and then consistently unpacked in objectaddress.c.
I think it would be better to get rid of objargs and have objname be a
general Node that can contain more specific node types so that there is
some amount of type tracking. FuncWithArgs would be one such type,
Typename would be another, Value would be used for simple strings, and
we could create some other ones, or stick with lcons for some simple
cases. But then we don't have to make stuff into one-item lists to just
to satisfy the currently required List.
That's the general idea. But that's a rather big change that I would
rather break down into smaller pieces. I have a separate patch in
progress for that, which I have attached here. It breaks some
regression tests in object_address.sql, which I haven't evaluated yet,
but that's the idea.
However, in these current patches I just wanted to take the first step
to normalize the representation of functions so that actual
functionality changes could be built in top of that.
It leads to code with random changes of data representation at seemingly
random places, like this bit from 0005:+ if (stmt->removeType == OBJECT_AGGREGATE || stmt->removeType == OBJECT_FUNCTION) + objname = list_make1(objname);
Yeah, the reason for that is that when we want to store something as
objname, it needs to be a list, and the convention is to wrap non-lists
into a single-member list. So then objectaddress.c is coded to linitial
such lists when working on object types such as functions or types.
RemoveObjects() takes the list it gets from the grammar and passes each
element to get_object_address(). But a function_with_argtypes_list is a
list of FuncWithArgs, so we have to make those into single-member lists
first. The reason this works for types is that type_name_list looks
like this:
type_name_list:
Typename { $$ = list_make1(list_make1($1)); }
| type_name_list ',' Typename { $$ = lappend($1, list_make1($3)); }
I suppose we could make function_with_argtypes look like that as well
(and later change it back if we redesign it as discussed above). I
think if we did it that way, it would get rid of the warts in this patch
set.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
0001-Remove-objargs.patchtext/x-patch; name=0001-Remove-objargs.patchDownload
From 3af0716745895bfe24b5e2e7ab1f0d4aaa3ec011 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Sat, 12 Nov 2016 12:00:00 -0500
Subject: [PATCH] Remove objargs
WIP
---
src/backend/catalog/objectaddress.c | 92 +++++++++++++-----------
src/backend/commands/alter.c | 9 ++-
src/backend/commands/comment.c | 4 +-
src/backend/commands/dropcmds.c | 50 ++++++-------
src/backend/commands/extension.c | 4 +-
src/backend/commands/seclabel.c | 4 +-
src/backend/commands/tablecmds.c | 1 -
src/backend/nodes/copyfuncs.c | 8 ---
src/backend/nodes/equalfuncs.c | 8 ---
src/backend/parser/gram.y | 136 ++++++++----------------------------
src/backend/parser/parse_utilcmd.c | 2 -
src/include/catalog/objectaddress.h | 6 +-
src/include/nodes/parsenodes.h | 8 ---
13 files changed, 117 insertions(+), 215 deletions(-)
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index d531d17..58d04fa 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -684,11 +684,11 @@ static ObjectAddress get_object_address_type(ObjectType objtype,
static ObjectAddress get_object_address_opcf(ObjectType objtype, List *objname,
bool missing_ok);
static ObjectAddress get_object_address_opf_member(ObjectType objtype,
- List *objname, List *objargs, bool missing_ok);
+ List *objname, bool missing_ok);
static ObjectAddress get_object_address_usermapping(List *objname,
- List *objargs, bool missing_ok);
-static ObjectAddress get_object_address_defacl(List *objname, List *objargs,
+ bool missing_ok);
+static ObjectAddress get_object_address_defacl(List *objname,
bool missing_ok);
static const ObjectPropertyType *get_object_property_data(Oid class_id);
@@ -733,7 +733,7 @@ static void getRelationIdentity(StringInfo buffer, Oid relid, List **objname);
* better to add some support for that in this function.
*/
ObjectAddress
-get_object_address(ObjectType objtype, List *objname, List *objargs,
+get_object_address(ObjectType objtype, List *objname,
Relation *relp, LOCKMODE lockmode, bool missing_ok)
{
ObjectAddress address;
@@ -793,7 +793,7 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
domaddr = get_object_address_type(OBJECT_DOMAIN,
list_head(objname), missing_ok);
- constrname = strVal(linitial(objargs));
+ constrname = strVal(lsecond(objname));
address.classId = ConstraintRelationId;
address.objectId = get_domain_constraint_oid(domaddr.objectId,
@@ -822,22 +822,22 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
case OBJECT_AGGREGATE:
address.classId = ProcedureRelationId;
address.objectId =
- LookupAggNameTypeNames(objname, objargs, missing_ok);
+ LookupAggNameTypeNames(linitial(objname), lsecond(objname), missing_ok);
address.objectSubId = 0;
break;
case OBJECT_FUNCTION:
address.classId = ProcedureRelationId;
address.objectId =
- LookupFuncNameTypeNames(objname, objargs, missing_ok);
+ LookupFuncNameTypeNames(linitial(objname), lsecond(objname), missing_ok);
address.objectSubId = 0;
break;
case OBJECT_OPERATOR:
- Assert(list_length(objargs) == 2);
+ Assert(list_length(lsecond(objname)) == 2);
address.classId = OperatorRelationId;
address.objectId =
- LookupOperNameTypeNames(NULL, objname,
- (TypeName *) linitial(objargs),
- (TypeName *) lsecond(objargs),
+ LookupOperNameTypeNames(NULL, linitial(objname),
+ (TypeName *) linitial(lsecond(objname)),
+ (TypeName *) lsecond(lsecond(objname)),
missing_ok, -1);
address.objectSubId = 0;
break;
@@ -857,8 +857,7 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
break;
case OBJECT_AMOP:
case OBJECT_AMPROC:
- address = get_object_address_opf_member(objtype, objname,
- objargs, missing_ok);
+ address = get_object_address_opf_member(objtype, objname, missing_ok);
break;
case OBJECT_LARGEOBJECT:
Assert(list_length(objname) == 1);
@@ -877,7 +876,7 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
case OBJECT_CAST:
{
TypeName *sourcetype = (TypeName *) linitial(objname);
- TypeName *targettype = (TypeName *) linitial(objargs);
+ TypeName *targettype = (TypeName *) lsecond(objname);
Oid sourcetypeid;
Oid targettypeid;
@@ -892,7 +891,7 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
case OBJECT_TRANSFORM:
{
TypeName *typename = (TypeName *) linitial(objname);
- char *langname = strVal(linitial(objargs));
+ char *langname = strVal(lsecond(objname));
Oid type_id = LookupTypeNameOid(NULL, typename, missing_ok);
Oid lang_id = get_language_oid(langname, missing_ok);
@@ -923,11 +922,11 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
address.objectSubId = 0;
break;
case OBJECT_USER_MAPPING:
- address = get_object_address_usermapping(objname, objargs,
+ address = get_object_address_usermapping(objname,
missing_ok);
break;
case OBJECT_DEFACL:
- address = get_object_address_defacl(objname, objargs,
+ address = get_object_address_defacl(objname,
missing_ok);
break;
default:
@@ -1024,7 +1023,7 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
*/
ObjectAddress
get_object_address_rv(ObjectType objtype, RangeVar *rel, List *objname,
- List *objargs, Relation *relp, LOCKMODE lockmode,
+ Relation *relp, LOCKMODE lockmode,
bool missing_ok)
{
if (rel)
@@ -1036,7 +1035,7 @@ get_object_address_rv(ObjectType objtype, RangeVar *rel, List *objname,
objname = lcons(makeString(rel->catalogname), objname);
}
- return get_object_address(objtype, objname, objargs,
+ return get_object_address(objtype, objname,
relp, lockmode, missing_ok);
}
@@ -1572,7 +1571,7 @@ get_object_address_opcf(ObjectType objtype, List *objname, bool missing_ok)
*/
static ObjectAddress
get_object_address_opf_member(ObjectType objtype,
- List *objname, List *objargs, bool missing_ok)
+ List *objname, bool missing_ok)
{
ObjectAddress famaddr;
ObjectAddress address;
@@ -1583,20 +1582,22 @@ get_object_address_opf_member(ObjectType objtype,
int membernum;
int i;
+ Assert(objtype == OBJECT_AMOP || objtype == OBJECT_AMPROC);
+
/*
* The last element of the objname list contains the strategy or procedure
* number. We need to strip that out before getting the opclass/family
* address. The rest can be used directly by get_object_address_opcf().
*/
- membernum = atoi(strVal(llast(objname)));
- copy = list_truncate(list_copy(objname), list_length(objname) - 1);
+ membernum = atoi(strVal(llast(linitial(objname))));
+ copy = list_truncate(list_copy(linitial(objname)), list_length(linitial(objname)) - 1);
/* no missing_ok support here */
famaddr = get_object_address_opcf(OBJECT_OPFAMILY, copy, false);
/* find out left/right type names and OIDs */
i = 0;
- foreach(cell, objargs)
+ foreach(cell, lsecond(objname))
{
ObjectAddress typaddr;
@@ -1677,7 +1678,7 @@ get_object_address_opf_member(ObjectType objtype,
* Find the ObjectAddress for a user mapping.
*/
static ObjectAddress
-get_object_address_usermapping(List *objname, List *objargs, bool missing_ok)
+get_object_address_usermapping(List *objname, bool missing_ok)
{
ObjectAddress address;
Oid userid;
@@ -1690,7 +1691,7 @@ get_object_address_usermapping(List *objname, List *objargs, bool missing_ok)
/* fetch string names from input lists, for error messages */
username = strVal(linitial(objname));
- servername = strVal(linitial(objargs));
+ servername = strVal(lsecond(objname));
/* look up pg_authid OID of mapped user; InvalidOid if PUBLIC */
if (strcmp(username, "public") == 0)
@@ -1746,7 +1747,7 @@ get_object_address_usermapping(List *objname, List *objargs, bool missing_ok)
* Find the ObjectAddress for a default ACL.
*/
static ObjectAddress
-get_object_address_defacl(List *objname, List *objargs, bool missing_ok)
+get_object_address_defacl(List *objname, bool missing_ok)
{
HeapTuple tp;
Oid userid;
@@ -1763,9 +1764,9 @@ get_object_address_defacl(List *objname, List *objargs, bool missing_ok)
* First figure out the textual attributes so that they can be used for
* error reporting.
*/
- username = strVal(linitial(objname));
- if (list_length(objname) >= 2)
- schema = (char *) strVal(lsecond(objname));
+ username = strVal(lsecond(objname));
+ if (list_length(objname) >= 3)
+ schema = (char *) strVal(lthird(objname));
else
schema = NULL;
@@ -1773,7 +1774,7 @@ get_object_address_defacl(List *objname, List *objargs, bool missing_ok)
* Decode defaclobjtype. Only first char is considered; the rest of the
* string, if any, is blissfully ignored.
*/
- objtype = ((char *) strVal(linitial(objargs)))[0];
+ objtype = ((char *) strVal(linitial(objname)))[0];
switch (objtype)
{
case DEFACLOBJ_RELATION:
@@ -2032,7 +2033,13 @@ pg_get_object_address(PG_FUNCTION_ARGS)
break;
}
- addr = get_object_address(type, name, args,
+ if (type == OBJECT_AGGREGATE || type == OBJECT_FUNCTION || type == OBJECT_CAST || type == OBJECT_USER_MAPPING || type == OBJECT_TRANSFORM)
+ name = list_make2(name, args);
+
+ if (type == OBJECT_DEFACL)
+ name = lcons(args, name);
+
+ addr = get_object_address(type, name,
&relation, AccessShareLock, false);
/* We don't need the relcache entry, thank you very much */
@@ -2065,7 +2072,7 @@ pg_get_object_address(PG_FUNCTION_ARGS)
*/
void
check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
- List *objname, List *objargs, Relation relation)
+ List *objname, Relation relation)
{
switch (objtype)
{
@@ -2100,12 +2107,12 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
case OBJECT_FUNCTION:
if (!pg_proc_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC,
- NameListToString(objname));
+ NameListToString(linitial(objname)));
break;
case OBJECT_OPERATOR:
if (!pg_oper_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPER,
- NameListToString(objname));
+ NameListToString(linitial(objname)));
break;
case OBJECT_SCHEMA:
if (!pg_namespace_ownercheck(address.objectId, roleid))
@@ -2169,7 +2176,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
{
/* We can only check permissions on the source/target types */
TypeName *sourcetype = (TypeName *) linitial(objname);
- TypeName *targettype = (TypeName *) linitial(objargs);
+ TypeName *targettype = (TypeName *) lsecond(objname);
Oid sourcetypeid = typenameTypeId(NULL, sourcetype);
Oid targettypeid = typenameTypeId(NULL, targettype);
@@ -2290,18 +2297,23 @@ get_object_namespace(const ObjectAddress *address)
int
read_objtype_from_string(const char *objtype)
{
+ ObjectType type;
int i;
for (i = 0; i < lengthof(ObjectTypeMap); i++)
{
if (strcmp(ObjectTypeMap[i].tm_name, objtype) == 0)
- return ObjectTypeMap[i].tm_type;
+ {
+ type = ObjectTypeMap[i].tm_type;
+ break;
+ }
}
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("unrecognized object type \"%s\"", objtype)));
+ if (i >= lengthof(ObjectTypeMap))
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("unrecognized object type \"%s\"", objtype)));
- return -1; /* keep compiler quiet */
+ return type;
}
/*
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 03c0433..caa92c8 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -369,7 +369,7 @@ ExecRenameStmt(RenameStmt *stmt)
Relation relation;
address = get_object_address(stmt->renameType,
- stmt->object, stmt->objarg,
+ stmt->object,
&relation,
AccessExclusiveLock, false);
Assert(relation == NULL);
@@ -406,7 +406,7 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre
address =
get_object_address_rv(stmt->objectType, stmt->relation, stmt->objname,
- stmt->objargs, &rel, AccessExclusiveLock, false);
+ &rel, AccessExclusiveLock, false);
/*
* If a relation was involved, it would have been opened and locked. We
@@ -416,7 +416,7 @@ ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddre
heap_close(rel, NoLock);
refAddr = get_object_address(OBJECT_EXTENSION, list_make1(stmt->extname),
- NULL, &rel, AccessExclusiveLock, false);
+ &rel, AccessExclusiveLock, false);
Assert(rel == NULL);
if (refAddress)
*refAddress = refAddr;
@@ -485,7 +485,6 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
address = get_object_address(stmt->objectType,
stmt->object,
- stmt->objarg,
&relation,
AccessExclusiveLock,
false);
@@ -757,6 +756,7 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
case OBJECT_TYPE:
case OBJECT_DOMAIN: /* same as TYPE */
return AlterTypeOwner(stmt->object, newowner, stmt->objectType);
+ break;
case OBJECT_FDW:
return AlterForeignDataWrapperOwner(strVal(linitial(stmt->object)),
@@ -791,7 +791,6 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
address = get_object_address(stmt->objectType,
stmt->object,
- stmt->objarg,
&relation,
AccessExclusiveLock,
false);
diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c
index a0d3f8d..5e79c8a 100644
--- a/src/backend/commands/comment.c
+++ b/src/backend/commands/comment.c
@@ -70,12 +70,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->objname,
&relation, ShareUpdateExclusiveLock, false);
/* Require ownership of the target object. */
check_object_ownership(GetUserId(), stmt->objtype, address,
- stmt->objname, stmt->objargs, relation);
+ stmt->objname, relation);
/* Perform other integrity checks as needed. */
switch (stmt->objtype)
diff --git a/src/backend/commands/dropcmds.c b/src/backend/commands/dropcmds.c
index 61ff8f2..440c31d 100644
--- a/src/backend/commands/dropcmds.c
+++ b/src/backend/commands/dropcmds.c
@@ -30,7 +30,7 @@
static void does_not_exist_skipping(ObjectType objtype,
- List *objname, List *objargs);
+ List *objname);
static bool owningrel_does_not_exist_skipping(List *objname,
const char **msg, char **name);
static bool schema_does_not_exist_skipping(List *objname,
@@ -55,7 +55,6 @@ RemoveObjects(DropStmt *stmt)
{
ObjectAddresses *objects;
ListCell *cell1;
- ListCell *cell2 = NULL;
objects = new_object_addresses();
@@ -63,19 +62,12 @@ RemoveObjects(DropStmt *stmt)
{
ObjectAddress address;
List *objname = lfirst(cell1);
- List *objargs = NIL;
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,
+ objname,
&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, objname);
continue;
}
@@ -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);
+ objname, relation);
/* Release any relcache reference count, but keep lock until commit. */
if (relation)
@@ -254,7 +246,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, List *objname)
{
const char *msg = NULL;
char *name = NULL;
@@ -329,29 +321,29 @@ does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs)
name = NameListToString(objname);
break;
case OBJECT_FUNCTION:
- if (!schema_does_not_exist_skipping(objname, &msg, &name) &&
- !type_in_list_does_not_exist_skipping(objargs, &msg, &name))
+ if (!schema_does_not_exist_skipping(linitial(objname), &msg, &name) &&
+ !type_in_list_does_not_exist_skipping(lsecond(objname), &msg, &name))
{
msg = gettext_noop("function %s(%s) does not exist, skipping");
- name = NameListToString(objname);
- args = TypeNameListToString(objargs);
+ name = NameListToString(linitial(objname));
+ args = TypeNameListToString(lsecond(objname));
}
break;
case OBJECT_AGGREGATE:
- if (!schema_does_not_exist_skipping(objname, &msg, &name) &&
- !type_in_list_does_not_exist_skipping(objargs, &msg, &name))
+ if (!schema_does_not_exist_skipping(linitial(objname), &msg, &name) &&
+ !type_in_list_does_not_exist_skipping(lsecond(objname), &msg, &name))
{
msg = gettext_noop("aggregate %s(%s) does not exist, skipping");
- name = NameListToString(objname);
- args = TypeNameListToString(objargs);
+ name = NameListToString(linitial(objname));
+ args = TypeNameListToString(lsecond(objname));
}
break;
case OBJECT_OPERATOR:
- if (!schema_does_not_exist_skipping(objname, &msg, &name) &&
- !type_in_list_does_not_exist_skipping(objargs, &msg, &name))
+ if (!schema_does_not_exist_skipping(linitial(objname), &msg, &name) &&
+ !type_in_list_does_not_exist_skipping(lsecond(objname), &msg, &name))
{
msg = gettext_noop("operator %s does not exist, skipping");
- name = NameListToString(objname);
+ name = NameListToString(linitial(objname));
}
break;
case OBJECT_LANGUAGE:
@@ -360,22 +352,22 @@ does_not_exist_skipping(ObjectType objtype, List *objname, List *objargs)
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(objname)), &msg, &name) &&
+ !type_in_list_does_not_exist_skipping(list_make1(lsecond(objname)), &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));
+ args = TypeNameToString((TypeName *) lsecond(objname));
}
}
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(objname)), &msg, &name))
{
msg = gettext_noop("transform for type %s language \"%s\" does not exist, skipping");
name = TypeNameToString((TypeName *) linitial(objname));
- args = strVal(linitial(objargs));
+ args = strVal(lsecond(objname));
}
break;
case OBJECT_TRIGGER:
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index f6c2c8a..074c855 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -3194,7 +3194,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->objname,
&relation, ShareUpdateExclusiveLock, false);
Assert(object.objectSubId == 0);
@@ -3203,7 +3203,7 @@ ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt,
/* Permission check: must own target object, too */
check_object_ownership(GetUserId(), stmt->objtype, object,
- stmt->objname, stmt->objargs, relation);
+ stmt->objname, relation);
/*
* Check existing extension membership.
diff --git a/src/backend/commands/seclabel.c b/src/backend/commands/seclabel.c
index 5bd7e12..ffc8d35 100644
--- a/src/backend/commands/seclabel.c
+++ b/src/backend/commands/seclabel.c
@@ -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->objname,
&relation, ShareUpdateExclusiveLock, false);
/* Require ownership of the target object. */
check_object_ownership(GetUserId(), stmt->objtype, address,
- stmt->objname, stmt->objargs, relation);
+ stmt->objname, relation);
/* Perform other integrity checks as needed. */
switch (stmt->objtype)
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 6322fa7..412322b 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8864,7 +8864,6 @@ RebuildConstraintComment(AlteredTableInfo *tab, int pass, Oid objid,
makeString(get_namespace_name(RelationGetNamespace(rel))),
makeString(RelationGetRelationName(rel)),
makeString(conname));
- cmd->objargs = NIL;
cmd->comment = comment_str;
/* Append it to list of commands */
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 04e49b7..6954dd6 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -3079,7 +3079,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);
@@ -3107,7 +3106,6 @@ _copyCommentStmt(const CommentStmt *from)
COPY_SCALAR_FIELD(objtype);
COPY_NODE_FIELD(objname);
- COPY_NODE_FIELD(objargs);
COPY_STRING_FIELD(comment);
return newnode;
@@ -3120,7 +3118,6 @@ _copySecLabelStmt(const SecLabelStmt *from)
COPY_SCALAR_FIELD(objtype);
COPY_NODE_FIELD(objname);
- COPY_NODE_FIELD(objargs);
COPY_STRING_FIELD(provider);
COPY_STRING_FIELD(label);
@@ -3226,7 +3223,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);
@@ -3243,7 +3239,6 @@ _copyAlterObjectDependsStmt(const AlterObjectDependsStmt *from)
COPY_SCALAR_FIELD(objectType);
COPY_NODE_FIELD(relation);
COPY_NODE_FIELD(objname);
- COPY_NODE_FIELD(objargs);
COPY_NODE_FIELD(extname);
return newnode;
@@ -3257,7 +3252,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);
@@ -3272,7 +3266,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;
@@ -3744,7 +3737,6 @@ _copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from)
COPY_SCALAR_FIELD(action);
COPY_SCALAR_FIELD(objtype);
COPY_NODE_FIELD(objname);
- COPY_NODE_FIELD(objargs);
return newnode;
}
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index 2eaf41c..d07598d 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -1203,7 +1203,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);
@@ -1227,7 +1226,6 @@ _equalCommentStmt(const CommentStmt *a, const CommentStmt *b)
{
COMPARE_SCALAR_FIELD(objtype);
COMPARE_NODE_FIELD(objname);
- COMPARE_NODE_FIELD(objargs);
COMPARE_STRING_FIELD(comment);
return true;
@@ -1238,7 +1236,6 @@ _equalSecLabelStmt(const SecLabelStmt *a, const SecLabelStmt *b)
{
COMPARE_SCALAR_FIELD(objtype);
COMPARE_NODE_FIELD(objname);
- COMPARE_NODE_FIELD(objargs);
COMPARE_STRING_FIELD(provider);
COMPARE_STRING_FIELD(label);
@@ -1330,7 +1327,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);
@@ -1345,7 +1341,6 @@ _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(extname);
return true;
@@ -1357,7 +1352,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);
@@ -1370,7 +1364,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;
@@ -1767,7 +1760,6 @@ _equalAlterExtensionContentsStmt(const AlterExtensionContentsStmt *a, const Alte
COMPARE_SCALAR_FIELD(action);
COMPARE_SCALAR_FIELD(objtype);
COMPARE_NODE_FIELD(objname);
- COMPARE_NODE_FIELD(objargs);
return true;
}
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 367bc2e..f418bb1 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -3775,7 +3775,6 @@ DropPLangStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_LANGUAGE;
n->objects = list_make1(list_make1(makeString($4)));
- n->arguments = NIL;
n->behavior = $5;
n->missing_ok = false;
n->concurrent = false;
@@ -3934,23 +3933,13 @@ alter_extension_opt_item:
*****************************************************************************/
AlterExtensionContentsStmt:
- ALTER EXTENSION name add_drop ACCESS METHOD name
- {
- AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
- n->extname = $3;
- n->action = $4;
- n->objtype = OBJECT_ACCESS_METHOD;
- n->objname = list_make1(makeString($7));
- $$ = (Node *)n;
- }
- | ALTER EXTENSION name add_drop AGGREGATE func_name aggr_args
+ ALTER EXTENSION name add_drop AGGREGATE func_name aggr_args
{
AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_AGGREGATE;
- n->objname = $6;
- n->objargs = extractAggrArgTypes($7);
+ n->objname = list_make2($6, extractAggrArgTypes($7));
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')'
@@ -3959,8 +3948,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_CAST;
- n->objname = list_make1($7);
- n->objargs = list_make1($9);
+ n->objname = list_make2($7, $9);
$$ = (Node *) n;
}
| ALTER EXTENSION name add_drop COLLATION any_name
@@ -3996,8 +3984,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_FUNCTION;
- n->objname = $6->funcname;
- n->objargs = $6->funcargs;
+ n->objname = list_make2($6->funcname, $6->funcargs);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop opt_procedural LANGUAGE name
@@ -4015,8 +4002,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_OPERATOR;
- n->objname = $6;
- n->objargs = $7;
+ n->objname = list_make2($6, $7);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING access_method
@@ -4160,8 +4146,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_TRANSFORM;
- n->objname = list_make1($7);
- n->objargs = list_make1(makeString($9));
+ n->objname = list_make2($7, makeString($9));
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop TYPE_P Typename
@@ -4221,7 +4206,6 @@ DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FDW;
n->objects = list_make1(list_make1(makeString($5)));
- n->arguments = NIL;
n->missing_ok = false;
n->behavior = $6;
n->concurrent = false;
@@ -4232,7 +4216,6 @@ DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FDW;
n->objects = list_make1(list_make1(makeString($7)));
- n->arguments = NIL;
n->missing_ok = true;
n->behavior = $8;
n->concurrent = false;
@@ -4383,7 +4366,6 @@ DropForeignServerStmt: DROP SERVER name opt_drop_behavior
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FOREIGN_SERVER;
n->objects = list_make1(list_make1(makeString($3)));
- n->arguments = NIL;
n->missing_ok = false;
n->behavior = $4;
n->concurrent = false;
@@ -4394,7 +4376,6 @@ DropForeignServerStmt: DROP SERVER name opt_drop_behavior
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FOREIGN_SERVER;
n->objects = list_make1(list_make1(makeString($5)));
- n->arguments = NIL;
n->missing_ok = true;
n->behavior = $6;
n->concurrent = false;
@@ -4672,7 +4653,6 @@ DropPolicyStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_POLICY;
n->objects = list_make1(lappend($5, makeString($3)));
- n->arguments = NIL;
n->behavior = $6;
n->missing_ok = false;
n->concurrent = false;
@@ -4683,7 +4663,6 @@ DropPolicyStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_POLICY;
n->objects = list_make1(lappend($7, makeString($5)));
- n->arguments = NIL;
n->behavior = $8;
n->missing_ok = true;
n->concurrent = false;
@@ -4978,7 +4957,6 @@ DropTrigStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_TRIGGER;
n->objects = list_make1(lappend($5, makeString($3)));
- n->arguments = NIL;
n->behavior = $6;
n->missing_ok = false;
n->concurrent = false;
@@ -4989,7 +4967,6 @@ DropTrigStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_TRIGGER;
n->objects = list_make1(lappend($7, makeString($5)));
- n->arguments = NIL;
n->behavior = $8;
n->missing_ok = true;
n->concurrent = false;
@@ -5099,7 +5076,6 @@ DropAssertStmt:
{
DropStmt *n = makeNode(DropStmt);
n->objects = NIL;
- n->arguments = NIL;
n->behavior = $4;
n->removeType = OBJECT_TRIGGER; /* XXX */
ereport(ERROR,
@@ -5619,7 +5595,6 @@ DropStmt: DROP drop_type IF_P EXISTS any_name_list opt_drop_behavior
n->removeType = $2;
n->missing_ok = TRUE;
n->objects = $5;
- n->arguments = NIL;
n->behavior = $6;
n->concurrent = false;
$$ = (Node *)n;
@@ -5630,7 +5605,6 @@ DropStmt: DROP drop_type IF_P EXISTS any_name_list opt_drop_behavior
n->removeType = $2;
n->missing_ok = FALSE;
n->objects = $3;
- n->arguments = NIL;
n->behavior = $4;
n->concurrent = false;
$$ = (Node *)n;
@@ -5681,7 +5655,6 @@ DropStmt: DROP drop_type IF_P EXISTS any_name_list opt_drop_behavior
n->removeType = OBJECT_INDEX;
n->missing_ok = FALSE;
n->objects = $4;
- n->arguments = NIL;
n->behavior = $5;
n->concurrent = true;
$$ = (Node *)n;
@@ -5692,7 +5665,6 @@ DropStmt: DROP drop_type IF_P EXISTS any_name_list opt_drop_behavior
n->removeType = OBJECT_INDEX;
n->missing_ok = TRUE;
n->objects = $6;
- n->arguments = NIL;
n->behavior = $7;
n->concurrent = true;
$$ = (Node *)n;
@@ -5797,7 +5769,6 @@ CommentStmt:
CommentStmt *n = makeNode(CommentStmt);
n->objtype = $3;
n->objname = $4;
- n->objargs = NIL;
n->comment = $6;
$$ = (Node *) n;
}
@@ -5806,7 +5777,6 @@ CommentStmt:
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_TYPE;
n->objname = list_make1($4);
- n->objargs = NIL;
n->comment = $6;
$$ = (Node *) n;
}
@@ -5815,7 +5785,6 @@ CommentStmt:
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_DOMAIN;
n->objname = list_make1($4);
- n->objargs = NIL;
n->comment = $6;
$$ = (Node *) n;
}
@@ -5823,8 +5792,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_AGGREGATE;
- n->objname = $4;
- n->objargs = extractAggrArgTypes($5);
+ n->objname = list_make2($4, extractAggrArgTypes($5));
n->comment = $7;
$$ = (Node *) n;
}
@@ -5832,8 +5800,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_FUNCTION;
- n->objname = $4;
- n->objargs = extractArgTypes($5);
+ n->objname = list_make2($4, extractArgTypes($5));
n->comment = $7;
$$ = (Node *) n;
}
@@ -5841,8 +5808,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_OPERATOR;
- n->objname = $4;
- n->objargs = $5;
+ n->objname = list_make2($4, $5);
n->comment = $7;
$$ = (Node *) n;
}
@@ -5851,7 +5817,6 @@ CommentStmt:
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_TABCONSTRAINT;
n->objname = lappend($6, makeString($4));
- n->objargs = NIL;
n->comment = $8;
$$ = (Node *) n;
}
@@ -5864,8 +5829,7 @@ CommentStmt:
* there's a shift/reduce conflict if we do that, so fix it
* up here.
*/
- n->objname = list_make1(makeTypeNameFromNameList($7));
- n->objargs = list_make1(makeString($4));
+ n->objname = list_make2(makeTypeNameFromNameList($7), makeString($4));
n->comment = $9;
$$ = (Node *) n;
}
@@ -5874,7 +5838,6 @@ CommentStmt:
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_POLICY;
n->objname = lappend($6, makeString($4));
- n->objargs = NIL;
n->comment = $8;
$$ = (Node *) n;
}
@@ -5883,7 +5846,6 @@ CommentStmt:
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_RULE;
n->objname = lappend($6, makeString($4));
- n->objargs = NIL;
n->comment = $8;
$$ = (Node *) n;
}
@@ -5893,7 +5855,6 @@ CommentStmt:
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_RULE;
n->objname = list_make1(makeString($4));
- n->objargs = NIL;
n->comment = $6;
$$ = (Node *) n;
}
@@ -5901,8 +5862,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_TRANSFORM;
- n->objname = list_make1($5);
- n->objargs = list_make1(makeString($7));
+ n->objname = list_make2($5, makeString($7));
n->comment = $9;
$$ = (Node *) n;
}
@@ -5911,7 +5871,6 @@ CommentStmt:
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_TRIGGER;
n->objname = lappend($6, makeString($4));
- n->objargs = NIL;
n->comment = $8;
$$ = (Node *) n;
}
@@ -5928,7 +5887,6 @@ CommentStmt:
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_OPFAMILY;
n->objname = lcons(makeString($7), $5);
- n->objargs = NIL;
n->comment = $9;
$$ = (Node *) n;
}
@@ -5937,7 +5895,6 @@ CommentStmt:
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_LARGEOBJECT;
n->objname = list_make1($5);
- n->objargs = NIL;
n->comment = $7;
$$ = (Node *) n;
}
@@ -5945,8 +5902,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_CAST;
- n->objname = list_make1($5);
- n->objargs = list_make1($7);
+ n->objname = list_make2($5, $7);
n->comment = $10;
$$ = (Node *) n;
}
@@ -5955,7 +5911,6 @@ CommentStmt:
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_LANGUAGE;
n->objname = $5;
- n->objargs = NIL;
n->comment = $7;
$$ = (Node *) n;
}
@@ -6009,7 +5964,6 @@ SecLabelStmt:
n->provider = $3;
n->objtype = $5;
n->objname = $6;
- n->objargs = NIL;
n->label = $8;
$$ = (Node *) n;
}
@@ -6020,7 +5974,6 @@ SecLabelStmt:
n->provider = $3;
n->objtype = OBJECT_TYPE;
n->objname = list_make1($6);
- n->objargs = NIL;
n->label = $8;
$$ = (Node *) n;
}
@@ -6031,7 +5984,6 @@ SecLabelStmt:
n->provider = $3;
n->objtype = OBJECT_TYPE;
n->objname = list_make1($6);
- n->objargs = NIL;
n->label = $8;
$$ = (Node *) n;
}
@@ -6041,8 +5993,7 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_AGGREGATE;
- n->objname = $6;
- n->objargs = extractAggrArgTypes($7);
+ n->objname = list_make2($6, extractAggrArgTypes($7));
n->label = $9;
$$ = (Node *) n;
}
@@ -6052,8 +6003,7 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_FUNCTION;
- n->objname = $6;
- n->objargs = extractArgTypes($7);
+ n->objname = list_make2($6, extractArgTypes($7));
n->label = $9;
$$ = (Node *) n;
}
@@ -6064,7 +6014,6 @@ SecLabelStmt:
n->provider = $3;
n->objtype = OBJECT_LARGEOBJECT;
n->objname = list_make1($7);
- n->objargs = NIL;
n->label = $9;
$$ = (Node *) n;
}
@@ -6075,7 +6024,6 @@ SecLabelStmt:
n->provider = $3;
n->objtype = OBJECT_LANGUAGE;
n->objname = $7;
- n->objargs = NIL;
n->label = $9;
$$ = (Node *) n;
}
@@ -7288,8 +7236,7 @@ RemoveFuncStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($3);
- n->arguments = list_make1(extractArgTypes($4));
+ n->objects = list_make1(list_make2($3, extractArgTypes($4)));
n->behavior = $5;
n->missing_ok = false;
n->concurrent = false;
@@ -7299,8 +7246,7 @@ RemoveFuncStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($5);
- n->arguments = list_make1(extractArgTypes($6));
+ n->objects = list_make1(list_make2($5, extractArgTypes($6)));
n->behavior = $7;
n->missing_ok = true;
n->concurrent = false;
@@ -7313,8 +7259,7 @@ RemoveAggrStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($3);
- n->arguments = list_make1(extractAggrArgTypes($4));
+ n->objects = list_make1(list_make2($3, extractAggrArgTypes($4)));
n->behavior = $5;
n->missing_ok = false;
n->concurrent = false;
@@ -7324,8 +7269,7 @@ RemoveAggrStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($5);
- n->arguments = list_make1(extractAggrArgTypes($6));
+ n->objects = list_make1(list_make2($5, extractAggrArgTypes($6)));
n->behavior = $7;
n->missing_ok = true;
n->concurrent = false;
@@ -7338,8 +7282,7 @@ RemoveOperStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($3);
- n->arguments = list_make1($4);
+ n->objects = list_make1(list_make2($3, $4));
n->behavior = $5;
n->missing_ok = false;
n->concurrent = false;
@@ -7349,8 +7292,7 @@ RemoveOperStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($5);
- n->arguments = list_make1($6);
+ n->objects = list_make1(list_make2($5, $6));
n->behavior = $7;
n->missing_ok = true;
n->concurrent = false;
@@ -7466,8 +7408,7 @@ DropCastStmt: DROP CAST opt_if_exists '(' Typename AS Typename ')' opt_drop_beha
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_CAST;
- n->objects = list_make1(list_make1($5));
- n->arguments = list_make1(list_make1($7));
+ n->objects = list_make1(list_make2($5, $7));
n->behavior = $9;
n->missing_ok = $3;
n->concurrent = false;
@@ -7521,8 +7462,7 @@ DropTransformStmt: DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_d
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_TRANSFORM;
- n->objects = list_make1(list_make1($5));
- n->arguments = list_make1(list_make1(makeString($7)));
+ n->objects = list_make1(list_make2($5, makeString($7)));
n->behavior = $8;
n->missing_ok = $3;
$$ = (Node *)n;
@@ -7629,8 +7569,7 @@ RenameStmt: ALTER AGGREGATE func_name aggr_args RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_AGGREGATE;
- n->object = $3;
- n->objarg = extractAggrArgTypes($4);
+ n->object = list_make2($3, extractAggrArgTypes($4));
n->newname = $7;
n->missing_ok = false;
$$ = (Node *)n;
@@ -7693,8 +7632,7 @@ RenameStmt: ALTER AGGREGATE func_name aggr_args RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_FUNCTION;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = list_make2($3->funcname, $3->funcargs);
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8113,8 +8051,7 @@ AlterObjectDependsStmt:
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_FUNCTION;
n->relation = NULL;
- n->objname = $3->funcname;
- n->objargs = $3->funcargs;
+ n->objname = list_make2($3->funcname, $3->funcargs);
n->extname = makeString($7);
$$ = (Node *)n;
}
@@ -8124,7 +8061,6 @@ AlterObjectDependsStmt:
n->objectType = OBJECT_TRIGGER;
n->relation = $5;
n->objname = list_make1(makeString($3));
- n->objargs = NIL;
n->extname = makeString($9);
$$ = (Node *)n;
}
@@ -8134,7 +8070,6 @@ AlterObjectDependsStmt:
n->objectType = OBJECT_MATVIEW;
n->relation = $4;
n->objname = NIL;
- n->objargs = NIL;
n->extname = makeString($8);
$$ = (Node *)n;
}
@@ -8144,7 +8079,6 @@ AlterObjectDependsStmt:
n->objectType = OBJECT_INDEX;
n->relation = $3;
n->objname = NIL;
- n->objargs = NIL;
n->extname = makeString($7);
$$ = (Node *)n;
}
@@ -8161,8 +8095,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_AGGREGATE;
- n->object = $3;
- n->objarg = extractAggrArgTypes($4);
+ n->object = list_make2($3, extractAggrArgTypes($4));
n->newschema = $7;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8207,8 +8140,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_FUNCTION;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = list_make2($3->funcname, $3->funcargs);
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8217,8 +8149,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_OPERATOR;
- n->object = $3;
- n->objarg = $4;
+ n->object = list_make2($3, $4);
n->newschema = $7;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8415,8 +8346,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_AGGREGATE;
- n->object = $3;
- n->objarg = extractAggrArgTypes($4);
+ n->object = list_make2($3, extractAggrArgTypes($4));
n->newowner = $7;
$$ = (Node *)n;
}
@@ -8456,8 +8386,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_FUNCTION;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = list_make2($3->funcname, $3->funcargs);
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8481,8 +8410,7 @@ AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_OPERATOR;
- n->object = $3;
- n->objarg = $4;
+ n->object = list_make2($3, $4);
n->newowner = $7;
$$ = (Node *)n;
}
@@ -8645,7 +8573,6 @@ DropRuleStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_RULE;
n->objects = list_make1(lappend($5, makeString($3)));
- n->arguments = NIL;
n->behavior = $6;
n->missing_ok = false;
n->concurrent = false;
@@ -8656,7 +8583,6 @@ DropRuleStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_RULE;
n->objects = list_make1(lappend($7, makeString($5)));
- n->arguments = NIL;
n->behavior = $8;
n->missing_ok = true;
n->concurrent = false;
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index 0670bc2..61b3d17 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -895,7 +895,6 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
stmt->objname = 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);
@@ -961,7 +960,6 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
stmt->objname = 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);
diff --git a/src/include/catalog/objectaddress.h b/src/include/catalog/objectaddress.h
index 583a120..fd1391e 100644
--- a/src/include/catalog/objectaddress.h
+++ b/src/include/catalog/objectaddress.h
@@ -41,16 +41,16 @@ extern const ObjectAddress InvalidObjectAddress;
ObjectAddressSubSet(addr, class_id, object_id, 0)
extern ObjectAddress get_object_address(ObjectType objtype, List *objname,
- List *objargs, Relation *relp,
+ Relation *relp,
LOCKMODE lockmode, bool missing_ok);
extern ObjectAddress get_object_address_rv(ObjectType objtype, RangeVar *rel,
- List *objname, List *objargs, Relation *relp,
+ List *objname, Relation *relp,
LOCKMODE lockmode, bool missing_ok);
extern void check_object_ownership(Oid roleid,
ObjectType objtype, ObjectAddress address,
- List *objname, List *objargs, Relation relation);
+ List *objname, Relation relation);
extern Oid get_object_namespace(const ObjectAddress *address);
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 04b1c2f..13c8cef 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -1955,7 +1955,6 @@ typedef struct AlterExtensionContentsStmt
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) */
} AlterExtensionContentsStmt;
/* ----------------------
@@ -2338,7 +2337,6 @@ typedef struct DropStmt
{
NodeTag type;
List *objects; /* list of sublists of names (as Values) */
- List *arguments; /* list of sublists of arguments (as Values) */
ObjectType removeType; /* object type */
DropBehavior behavior; /* RESTRICT or CASCADE behavior */
bool missing_ok; /* skip error if object is missing? */
@@ -2366,7 +2364,6 @@ 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) */
char *comment; /* Comment to insert, or NULL to remove */
} CommentStmt;
@@ -2379,7 +2376,6 @@ 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) */
char *provider; /* Label provider (or NULL) */
char *label; /* New security label to be assigned */
} SecLabelStmt;
@@ -2554,7 +2550,6 @@ typedef struct RenameStmt
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 */
char *subname; /* name of contained object (column, rule,
* trigger, etc) */
char *newname; /* the new name */
@@ -2572,7 +2567,6 @@ typedef struct AlterObjectDependsStmt
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 */
Value *extname; /* extension name */
} AlterObjectDependsStmt;
@@ -2586,7 +2580,6 @@ typedef struct AlterObjectSchemaStmt
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 */
char *newschema; /* the new schema */
bool missing_ok; /* skip error if missing? */
} AlterObjectSchemaStmt;
@@ -2601,7 +2594,6 @@ typedef struct AlterOwnerStmt
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 *newowner; /* the new owner */
} AlterOwnerStmt;
--
2.10.2
On Fri, Dec 2, 2016 at 1:32 PM, Peter Eisentraut <
peter.eisentraut@2ndquadrant.com> wrote:
On 11/23/16 5:04 PM, Tom Lane wrote:
I looked at this briefly. I agree that 0001-0003 are simple cleanup of
the grammar and could be pushed without further ado.Done.
However, starting
with 0004 I begin to get queasy. The plan seems to be that instead of
"objname" always being a List of strings, for functions (and then
aggregates and operators) it will be a one-element List of some newstruct
that has then got a name list inside it.
I think the original idea of representing an object by a list of name
components plus optionally a list of arguments has accumulated too many
warts and should be replaced. For example: A Typename isn't a list, so
it has to be packed into a List to be able to pass it around. Some
objects only have a single-component string as a name. For a cast, we
arbitrarily put the source type into a the name list and the target type
into the argument list. For an operator class on the other hand we
create a cons of name and access method. The pending logical
replication patch has more such arbitrary examples. This pattern has to
be repeated consistently in gram.y for all cases where the object is
referenced (ALTER EXTENSION, DROP, COMMENT, RENAME, SET SCHEMA, OWNER
TO) and then consistently unpacked in objectaddress.c.I think it would be better to get rid of objargs and have objname be a
general Node that can contain more specific node types so that there is
some amount of type tracking. FuncWithArgs would be one such type,
Typename would be another, Value would be used for simple strings, and
we could create some other ones, or stick with lcons for some simple
cases. But then we don't have to make stuff into one-item lists to just
to satisfy the currently required List.That's the general idea. But that's a rather big change that I would
rather break down into smaller pieces. I have a separate patch in
progress for that, which I have attached here. It breaks some
regression tests in object_address.sql, which I haven't evaluated yet,
but that's the idea.However, in these current patches I just wanted to take the first step
to normalize the representation of functions so that actual
functionality changes could be built in top of that.It leads to code with random changes of data representation at seemingly
random places, like this bit from 0005:+ if (stmt->removeType == OBJECT_AGGREGATE ||
stmt->removeType == OBJECT_FUNCTION)
+ objname = list_make1(objname);
Yeah, the reason for that is that when we want to store something as
objname, it needs to be a list, and the convention is to wrap non-lists
into a single-member list. So then objectaddress.c is coded to linitial
such lists when working on object types such as functions or types.
RemoveObjects() takes the list it gets from the grammar and passes each
element to get_object_address(). But a function_with_argtypes_list is a
list of FuncWithArgs, so we have to make those into single-member lists
first. The reason this works for types is that type_name_list looks
like this:type_name_list:
Typename { $$ = list_make1(list_make1($1)); }
| type_name_list ',' Typename { $$ = lappend($1, list_make1($3)); }I suppose we could make function_with_argtypes look like that as well
(and later change it back if we redesign it as discussed above). I
think if we did it that way, it would get rid of the warts in this patch
set.
Moved to next CF with "needs review" status.
Regards,
Hari Babu
Fujitsu Australia
On Thu, Dec 1, 2016 at 9:32 PM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
I think it would be better to get rid of objargs and have objname be a
general Node that can contain more specific node types so that there is
some amount of type tracking. FuncWithArgs would be one such type,
Typename would be another, Value would be used for simple strings, and
we could create some other ones, or stick with lcons for some simple
cases. But then we don't have to make stuff into one-item lists to just
to satisfy the currently required List.That's the general idea. But that's a rather big change that I would
rather break down into smaller pieces. I have a separate patch in
progress for that, which I have attached here. It breaks some
regression tests in object_address.sql, which I haven't evaluated yet,
but that's the idea.
I think I disagree with this concept. I wouldn't shed many tears if
objname and objargs got replaced with some other kind of name
representation. But I don't think that should be done incrementally,
because then we'll be in this transitional zone where it's unclear
what the right way to do things is for a long time, possibly forever.
I'd be fine with a plan to rip out objname/objargs and replace it with
something less arbitrary, but until that's done I think new code
should stick with the existing representations.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 12/1/16 9:32 PM, Peter Eisentraut wrote:
I think it would be better to get rid of objargs and have objname be a
general Node that can contain more specific node types so that there is
some amount of type tracking. FuncWithArgs would be one such type,
Typename would be another, Value would be used for simple strings, and
we could create some other ones, or stick with lcons for some simple
cases. But then we don't have to make stuff into one-item lists to just
to satisfy the currently required List.That's the general idea. But that's a rather big change that I would
rather break down into smaller pieces.
People wanted to the whole thing at once, so here it is.
Patches 0001 and 0002 are some prep work. Patch 0003 is the main patch
that removes the objargs fields and changes the objname to a generic
Node*. 0004 is an API simplification that could be committed together
with 0003 but I kept it separate for easier review. 0005 accomplishes
the DROP FUNCTION changes. 0006 is some other cleanup that fell out of
this.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
0006-Combine-DROP-FDW-and-DROP-SERVER-grammar-into-generi.patchtext/x-patch; name=0006-Combine-DROP-FDW-and-DROP-SERVER-grammar-into-generi.patchDownload
From aa0192b1ed1b16b26e1835a6383ac836ad181cf0 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Wed, 28 Dec 2016 12:00:00 -0500
Subject: [PATCH 6/6] Combine DROP FDW and DROP SERVER grammar into generic
DropStmt
---
doc/src/sgml/ref/drop_foreign_data_wrapper.sgml | 2 +-
doc/src/sgml/ref/drop_server.sgml | 2 +-
src/backend/parser/gram.y | 66 ++-----------------------
3 files changed, 6 insertions(+), 64 deletions(-)
diff --git a/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml b/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml
index 824d72c176..702cc021db 100644
--- a/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml
+++ b/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml
@@ -21,7 +21,7 @@
<refsynopsisdiv>
<synopsis>
-DROP FOREIGN DATA WRAPPER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [ CASCADE | RESTRICT ]
+DROP FOREIGN DATA WRAPPER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
</synopsis>
</refsynopsisdiv>
diff --git a/doc/src/sgml/ref/drop_server.sgml b/doc/src/sgml/ref/drop_server.sgml
index f08dd7767d..42acdd41dc 100644
--- a/doc/src/sgml/ref/drop_server.sgml
+++ b/doc/src/sgml/ref/drop_server.sgml
@@ -21,7 +21,7 @@
<refsynopsisdiv>
<synopsis>
-DROP SERVER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [ CASCADE | RESTRICT ]
+DROP SERVER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
</synopsis>
</refsynopsisdiv>
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 1eacdf1e82..7a9f76151d 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -255,9 +255,9 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
CreatedbStmt DeclareCursorStmt DefineStmt DeleteStmt DiscardStmt DoStmt
DropGroupStmt DropOpClassStmt DropOpFamilyStmt DropPLangStmt DropStmt
DropAssertStmt DropTrigStmt DropRuleStmt DropCastStmt DropRoleStmt
- DropPolicyStmt DropUserStmt DropdbStmt DropTableSpaceStmt DropFdwStmt
+ DropPolicyStmt DropUserStmt DropdbStmt DropTableSpaceStmt
DropTransformStmt
- DropForeignServerStmt DropUserMappingStmt ExplainStmt FetchStmt
+ DropUserMappingStmt ExplainStmt FetchStmt
GrantStmt GrantRoleStmt ImportForeignSchemaStmt IndexStmt InsertStmt
ListenStmt LoadStmt LockStmt NotifyStmt ExplainableStmt PreparableStmt
CreateFunctionStmt AlterFunctionStmt ReindexStmt RemoveAggrStmt
@@ -850,8 +850,6 @@ stmt :
| DoStmt
| DropAssertStmt
| DropCastStmt
- | DropFdwStmt
- | DropForeignServerStmt
| DropGroupStmt
| DropOpClassStmt
| DropOpFamilyStmt
@@ -4476,35 +4474,6 @@ opt_fdw_options:
/*****************************************************************************
*
* QUERY :
- * DROP FOREIGN DATA WRAPPER name
- *
- ****************************************************************************/
-
-DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior
- {
- DropStmt *n = makeNode(DropStmt);
- n->removeType = OBJECT_FDW;
- n->objects = list_make1(makeString($5));
- n->missing_ok = false;
- n->behavior = $6;
- n->concurrent = false;
- $$ = (Node *) n;
- }
- | DROP FOREIGN DATA_P WRAPPER IF_P EXISTS name opt_drop_behavior
- {
- DropStmt *n = makeNode(DropStmt);
- n->removeType = OBJECT_FDW;
- n->objects = list_make1(makeString($7));
- n->missing_ok = true;
- n->behavior = $8;
- n->concurrent = false;
- $$ = (Node *) n;
- }
- ;
-
-/*****************************************************************************
- *
- * QUERY :
* ALTER FOREIGN DATA WRAPPER name options
*
****************************************************************************/
@@ -4636,35 +4605,6 @@ opt_foreign_server_version:
/*****************************************************************************
*
* QUERY :
- * DROP SERVER name
- *
- ****************************************************************************/
-
-DropForeignServerStmt: DROP SERVER name opt_drop_behavior
- {
- DropStmt *n = makeNode(DropStmt);
- n->removeType = OBJECT_FOREIGN_SERVER;
- n->objects = list_make1(makeString($3));
- n->missing_ok = false;
- n->behavior = $4;
- n->concurrent = false;
- $$ = (Node *) n;
- }
- | DROP SERVER IF_P EXISTS name opt_drop_behavior
- {
- DropStmt *n = makeNode(DropStmt);
- n->removeType = OBJECT_FOREIGN_SERVER;
- n->objects = list_make1(makeString($5));
- n->missing_ok = true;
- n->behavior = $6;
- n->concurrent = false;
- $$ = (Node *) n;
- }
- ;
-
-/*****************************************************************************
- *
- * QUERY :
* ALTER SERVER name [VERSION] [OPTIONS]
*
****************************************************************************/
@@ -6052,7 +5992,9 @@ drop_type1: TABLE { $$ = OBJECT_TABLE; }
drop_type2: ACCESS METHOD { $$ = OBJECT_ACCESS_METHOD; }
| EVENT TRIGGER { $$ = OBJECT_EVENT_TRIGGER; }
| EXTENSION { $$ = OBJECT_EXTENSION; }
+ | FOREIGN DATA_P WRAPPER { $$ = OBJECT_FDW; }
| SCHEMA { $$ = OBJECT_SCHEMA; }
+ | SERVER { $$ = OBJECT_FOREIGN_SERVER; }
;
any_name_list:
--
2.11.0
0001-Add-operator_with_argtypes-grammar-rule.patchtext/x-patch; name=0001-Add-operator_with_argtypes-grammar-rule.patchDownload
From 52fe09fea08367927dcf3e4ff5396d077f1abfe3 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Wed, 28 Dec 2016 12:00:00 -0500
Subject: [PATCH 1/6] Add operator_with_argtypes grammar rule
This makes the handling of operators similar to that of functions and
aggregates.
---
src/backend/parser/gram.y | 74 +++++++++++++++++++++++++++--------------------
1 file changed, 42 insertions(+), 32 deletions(-)
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 08cf5b78f5..43d1e26650 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -345,7 +345,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <accesspriv> privilege
%type <list> privileges privilege_list
%type <privtarget> privilege_target
-%type <funwithargs> function_with_argtypes aggregate_with_argtypes
+%type <funwithargs> function_with_argtypes aggregate_with_argtypes operator_with_argtypes
%type <list> function_with_argtypes_list
%type <ival> defacl_privilege_target
%type <defelt> DefACLOption
@@ -4279,14 +4279,14 @@ AlterExtensionContentsStmt:
n->objname = list_make1(makeString($7));
$$ = (Node *)n;
}
- | ALTER EXTENSION name add_drop OPERATOR any_operator oper_argtypes
+ | ALTER EXTENSION name add_drop OPERATOR operator_with_argtypes
{
AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_OPERATOR;
- n->objname = $6;
- n->objargs = $7;
+ n->objname = $6->funcname;
+ n->objargs = $6->funcargs;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING access_method
@@ -5737,15 +5737,15 @@ opclass_item:
n->order_family = $4;
$$ = (Node *) n;
}
- | OPERATOR Iconst any_operator oper_argtypes opclass_purpose
+ | OPERATOR Iconst operator_with_argtypes opclass_purpose
opt_recheck
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_OPERATOR;
- n->name = $3;
- n->args = $4;
+ n->name = $3->funcname;
+ n->args = $3->funcargs;
n->number = $2;
- n->order_family = $5;
+ n->order_family = $4;
$$ = (Node *) n;
}
| FUNCTION Iconst function_with_argtypes
@@ -6171,13 +6171,13 @@ CommentStmt:
n->comment = $6;
$$ = (Node *) n;
}
- | COMMENT ON OPERATOR any_operator oper_argtypes IS comment_text
+ | COMMENT ON OPERATOR operator_with_argtypes IS comment_text
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_OPERATOR;
- n->objname = $4;
- n->objargs = $5;
- n->comment = $7;
+ n->objname = $4->funcname;
+ n->objargs = $4->funcargs;
+ n->comment = $6;
$$ = (Node *) n;
}
| COMMENT ON CONSTRAINT name ON any_name IS comment_text
@@ -7678,24 +7678,24 @@ RemoveAggrStmt:
;
RemoveOperStmt:
- DROP OPERATOR any_operator oper_argtypes opt_drop_behavior
+ DROP OPERATOR operator_with_argtypes opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($3);
- n->arguments = list_make1($4);
- n->behavior = $5;
+ n->objects = list_make1($3->funcname);
+ n->arguments = list_make1($3->funcargs);
+ n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
$$ = (Node *)n;
}
- | DROP OPERATOR IF_P EXISTS any_operator oper_argtypes opt_drop_behavior
+ | DROP OPERATOR IF_P EXISTS operator_with_argtypes opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($5);
- n->arguments = list_make1($6);
- n->behavior = $7;
+ n->objects = list_make1($5->funcname);
+ n->arguments = list_make1($5->funcargs);
+ n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
$$ = (Node *)n;
@@ -7726,6 +7726,16 @@ any_operator:
{ $$ = lcons(makeString($1), $3); }
;
+operator_with_argtypes:
+ any_operator oper_argtypes
+ {
+ FuncWithArgs *n = makeNode(FuncWithArgs);
+ n->funcname = $1;
+ n->funcargs = $2;
+ $$ = n;
+ }
+ ;
+
/*****************************************************************************
*
* DO <anonymous code block> [ LANGUAGE language ]
@@ -8557,13 +8567,13 @@ AlterObjectSchemaStmt:
n->missing_ok = false;
$$ = (Node *)n;
}
- | ALTER OPERATOR any_operator oper_argtypes SET SCHEMA name
+ | ALTER OPERATOR operator_with_argtypes SET SCHEMA name
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_OPERATOR;
- n->object = $3;
- n->objarg = $4;
- n->newschema = $7;
+ n->object = $3->funcname;
+ n->objarg = $3->funcargs;
+ n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
}
@@ -8729,12 +8739,12 @@ AlterObjectSchemaStmt:
*****************************************************************************/
AlterOperatorStmt:
- ALTER OPERATOR any_operator oper_argtypes SET '(' operator_def_list ')'
+ ALTER OPERATOR operator_with_argtypes SET '(' operator_def_list ')'
{
AlterOperatorStmt *n = makeNode(AlterOperatorStmt);
- n->opername = $3;
- n->operargs = $4;
- n->options = $7;
+ n->opername = $3->funcname;
+ n->operargs = $3->funcargs;
+ n->options = $6;
$$ = (Node *)n;
}
;
@@ -8821,13 +8831,13 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
n->newowner = $7;
$$ = (Node *)n;
}
- | ALTER OPERATOR any_operator oper_argtypes OWNER TO RoleSpec
+ | ALTER OPERATOR operator_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_OPERATOR;
- n->object = $3;
- n->objarg = $4;
- n->newowner = $7;
+ n->object = $3->funcname;
+ n->objarg = $3->funcargs;
+ n->newowner = $6;
$$ = (Node *)n;
}
| ALTER OPERATOR CLASS any_name USING access_method OWNER TO RoleSpec
--
2.11.0
0002-Use-class_args-field-in-opclass_drop.patchtext/x-patch; name=0002-Use-class_args-field-in-opclass_drop.patchDownload
From 6d978a40959de927a0d122f27cfecfd1e3c7bc22 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Wed, 28 Dec 2016 12:00:00 -0500
Subject: [PATCH 2/6] Use class_args field in opclass_drop
This makes it consistent with the usage in opclass_item.
---
src/backend/commands/opclasscmds.c | 4 ++--
src/backend/parser/gram.y | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index f4dfdb9642..1d2f8d12c1 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -996,7 +996,7 @@ AlterOpFamilyDrop(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
errmsg("invalid operator number %d,"
" must be between 1 and %d",
item->number, maxOpNumber)));
- processTypesSpec(item->args, &lefttype, &righttype);
+ processTypesSpec(item->class_args, &lefttype, &righttype);
/* Save the info */
member = (OpFamilyMember *) palloc0(sizeof(OpFamilyMember));
member->number = item->number;
@@ -1011,7 +1011,7 @@ AlterOpFamilyDrop(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
errmsg("invalid procedure number %d,"
" must be between 1 and %d",
item->number, maxProcNumber)));
- processTypesSpec(item->args, &lefttype, &righttype);
+ processTypesSpec(item->class_args, &lefttype, &righttype);
/* Save the info */
member = (OpFamilyMember *) palloc0(sizeof(OpFamilyMember));
member->number = item->number;
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 43d1e26650..645c95909e 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -5849,7 +5849,7 @@ opclass_drop:
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_OPERATOR;
n->number = $2;
- n->args = $4;
+ n->class_args = $4;
$$ = (Node *) n;
}
| FUNCTION Iconst '(' type_list ')'
@@ -5857,7 +5857,7 @@ opclass_drop:
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION;
n->number = $2;
- n->args = $4;
+ n->class_args = $4;
$$ = (Node *) n;
}
;
--
2.11.0
0003-Remove-objname-objargs-split-for-referring-to-object.patchtext/x-patch; name=0003-Remove-objname-objargs-split-for-referring-to-object.patchDownload
From 01c66cf13a43aaee3fe89e65d90936cc6dd5856a Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Sat, 12 Nov 2016 12:00:00 -0500
Subject: [PATCH 3/6] 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 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 FuncWithArgs node
type. Some of the more obscure object types still use somewhat
arbitrary nested lists.
---
src/backend/catalog/objectaddress.c | 330 +++++++++++---------
src/backend/commands/alter.c | 29 +-
src/backend/commands/comment.c | 11 +-
src/backend/commands/dropcmds.c | 151 +++++-----
src/backend/commands/extension.c | 13 +-
src/backend/commands/seclabel.c | 4 +-
src/backend/commands/tablecmds.c | 10 +-
src/backend/commands/typecmds.c | 2 +-
src/backend/nodes/copyfuncs.c | 8 -
src/backend/nodes/equalfuncs.c | 8 -
src/backend/parser/gram.y | 431 +++++++++++++--------------
src/backend/parser/parse_utilcmd.c | 14 +-
src/include/catalog/objectaddress.h | 8 +-
src/include/commands/extension.h | 2 +-
src/include/nodes/parsenodes.h | 24 +-
src/test/regress/expected/event_trigger.out | 3 -
src/test/regress/expected/object_address.out | 20 +-
src/test/regress/sql/event_trigger.sql | 3 -
18 files changed, 518 insertions(+), 553 deletions(-)
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index bb4b080b00..e444604071 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -667,7 +667,7 @@ const ObjectAddress InvalidObjectAddress =
};
static ObjectAddress get_object_address_unqualified(ObjectType objtype,
- List *qualname, bool missing_ok);
+ Value *strval, bool missing_ok);
static ObjectAddress get_relation_by_qualified_name(ObjectType objtype,
List *objname, Relation *relp,
LOCKMODE lockmode, bool missing_ok);
@@ -680,15 +680,15 @@ static ObjectAddress get_object_address_attrdef(ObjectType objtype,
List *objname, Relation *relp, LOCKMODE lockmode,
bool missing_ok);
static ObjectAddress get_object_address_type(ObjectType objtype,
- ListCell *typecell, bool missing_ok);
+ TypeName *typename, bool missing_ok);
static ObjectAddress get_object_address_opcf(ObjectType objtype, List *objname,
bool missing_ok);
static ObjectAddress get_object_address_opf_member(ObjectType objtype,
- List *objname, List *objargs, bool missing_ok);
+ List *objname, bool missing_ok);
static ObjectAddress get_object_address_usermapping(List *objname,
- List *objargs, bool missing_ok);
-static ObjectAddress get_object_address_defacl(List *objname, List *objargs,
+ bool missing_ok);
+static ObjectAddress get_object_address_defacl(List *objname,
bool missing_ok);
static const ObjectPropertyType *get_object_property_data(Oid class_id);
@@ -733,7 +733,7 @@ static void getRelationIdentity(StringInfo buffer, Oid relid, List **objname);
* better to add some support for that in this function.
*/
ObjectAddress
-get_object_address(ObjectType objtype, List *objname, List *objargs,
+get_object_address(ObjectType objtype, Node *objname,
Relation *relp, LOCKMODE lockmode, bool missing_ok)
{
ObjectAddress address;
@@ -763,19 +763,19 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
case OBJECT_MATVIEW:
case OBJECT_FOREIGN_TABLE:
address =
- get_relation_by_qualified_name(objtype, objname,
+ get_relation_by_qualified_name(objtype, (List *) objname,
&relation, lockmode,
missing_ok);
break;
case OBJECT_COLUMN:
address =
- get_object_address_attribute(objtype, objname,
+ get_object_address_attribute(objtype, (List *) objname,
&relation, lockmode,
missing_ok);
break;
case OBJECT_DEFAULT:
address =
- get_object_address_attrdef(objtype, objname,
+ get_object_address_attrdef(objtype, (List *) objname,
&relation, lockmode,
missing_ok);
break;
@@ -783,7 +783,7 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
case OBJECT_TRIGGER:
case OBJECT_TABCONSTRAINT:
case OBJECT_POLICY:
- address = get_object_address_relobject(objtype, objname,
+ address = get_object_address_relobject(objtype, (List *) objname,
&relation, missing_ok);
break;
case OBJECT_DOMCONSTRAINT:
@@ -792,8 +792,8 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
char *constrname;
domaddr = get_object_address_type(OBJECT_DOMAIN,
- list_head(objname), missing_ok);
- constrname = strVal(linitial(objargs));
+ (TypeName *) linitial((List *) objname), missing_ok);
+ constrname = strVal(lsecond((List *) objname));
address.classId = ConstraintRelationId;
address.objectId = get_domain_constraint_oid(domaddr.objectId,
@@ -813,57 +813,64 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
case OBJECT_EVENT_TRIGGER:
case OBJECT_ACCESS_METHOD:
address = get_object_address_unqualified(objtype,
- objname, missing_ok);
+ (Value *) objname, missing_ok);
break;
case OBJECT_TYPE:
case OBJECT_DOMAIN:
- address = get_object_address_type(objtype, list_head(objname), missing_ok);
+ address = get_object_address_type(objtype, (TypeName *) objname, missing_ok);
break;
case OBJECT_AGGREGATE:
- address.classId = ProcedureRelationId;
- address.objectId =
- LookupAggNameTypeNames(objname, objargs, missing_ok);
- address.objectSubId = 0;
- break;
+ {
+ FuncWithArgs *fwa = (FuncWithArgs *) objname;
+ address.classId = ProcedureRelationId;
+ address.objectId =
+ LookupAggNameTypeNames(fwa->funcname, fwa->funcargs, missing_ok);
+ address.objectSubId = 0;
+ break;
+ }
case OBJECT_FUNCTION:
- address.classId = ProcedureRelationId;
- address.objectId =
- LookupFuncNameTypeNames(objname, objargs, missing_ok);
- address.objectSubId = 0;
- break;
+ {
+ FuncWithArgs *fwa = (FuncWithArgs *) objname;
+ address.classId = ProcedureRelationId;
+ address.objectId =
+ LookupFuncNameTypeNames(fwa->funcname, fwa->funcargs, missing_ok);
+ address.objectSubId = 0;
+ break;
+ }
case OBJECT_OPERATOR:
- Assert(list_length(objargs) == 2);
- address.classId = OperatorRelationId;
- address.objectId =
- LookupOperNameTypeNames(NULL, objname,
- (TypeName *) linitial(objargs),
- (TypeName *) lsecond(objargs),
- missing_ok, -1);
- address.objectSubId = 0;
- break;
+ {
+ FuncWithArgs *fwa = (FuncWithArgs *) objname;
+ address.classId = OperatorRelationId;
+ Assert(list_length(fwa->funcargs) == 2);
+ address.objectId =
+ LookupOperNameTypeNames(NULL, fwa->funcname,
+ (TypeName *) linitial(fwa->funcargs),
+ (TypeName *) lsecond(fwa->funcargs),
+ missing_ok, -1);
+ address.objectSubId = 0;
+ break;
+ }
case OBJECT_COLLATION:
address.classId = CollationRelationId;
- address.objectId = get_collation_oid(objname, missing_ok);
+ address.objectId = get_collation_oid((List *) objname, missing_ok);
address.objectSubId = 0;
break;
case OBJECT_CONVERSION:
address.classId = ConversionRelationId;
- address.objectId = get_conversion_oid(objname, missing_ok);
+ address.objectId = get_conversion_oid((List *) objname, missing_ok);
address.objectSubId = 0;
break;
case OBJECT_OPCLASS:
case OBJECT_OPFAMILY:
- address = get_object_address_opcf(objtype, objname, missing_ok);
+ address = get_object_address_opcf(objtype, (List *) objname, missing_ok);
break;
case OBJECT_AMOP:
case OBJECT_AMPROC:
- address = get_object_address_opf_member(objtype, objname,
- objargs, missing_ok);
+ address = get_object_address_opf_member(objtype, (List *) objname, missing_ok);
break;
case OBJECT_LARGEOBJECT:
- Assert(list_length(objname) == 1);
address.classId = LargeObjectRelationId;
- address.objectId = oidparse(linitial(objname));
+ address.objectId = oidparse(objname);
address.objectSubId = 0;
if (!LargeObjectExists(address.objectId))
{
@@ -876,8 +883,8 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
break;
case OBJECT_CAST:
{
- TypeName *sourcetype = (TypeName *) linitial(objname);
- TypeName *targettype = (TypeName *) linitial(objargs);
+ TypeName *sourcetype = (TypeName *) linitial((List *) objname);
+ TypeName *targettype = (TypeName *) lsecond((List *) objname);
Oid sourcetypeid;
Oid targettypeid;
@@ -891,8 +898,8 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
break;
case OBJECT_TRANSFORM:
{
- TypeName *typename = (TypeName *) linitial(objname);
- char *langname = strVal(linitial(objargs));
+ TypeName *typename = (TypeName *) linitial((List *) objname);
+ char *langname = strVal(lsecond((List *) objname));
Oid type_id = LookupTypeNameOid(NULL, typename, missing_ok);
Oid lang_id = get_language_oid(langname, missing_ok);
@@ -904,30 +911,30 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
break;
case OBJECT_TSPARSER:
address.classId = TSParserRelationId;
- address.objectId = get_ts_parser_oid(objname, missing_ok);
+ address.objectId = get_ts_parser_oid((List *) objname, missing_ok);
address.objectSubId = 0;
break;
case OBJECT_TSDICTIONARY:
address.classId = TSDictionaryRelationId;
- address.objectId = get_ts_dict_oid(objname, missing_ok);
+ address.objectId = get_ts_dict_oid((List *) objname, missing_ok);
address.objectSubId = 0;
break;
case OBJECT_TSTEMPLATE:
address.classId = TSTemplateRelationId;
- address.objectId = get_ts_template_oid(objname, missing_ok);
+ address.objectId = get_ts_template_oid((List *) objname, missing_ok);
address.objectSubId = 0;
break;
case OBJECT_TSCONFIGURATION:
address.classId = TSConfigRelationId;
- address.objectId = get_ts_config_oid(objname, missing_ok);
+ address.objectId = get_ts_config_oid((List *) objname, missing_ok);
address.objectSubId = 0;
break;
case OBJECT_USER_MAPPING:
- address = get_object_address_usermapping(objname, objargs,
+ address = get_object_address_usermapping((List *) objname,
missing_ok);
break;
case OBJECT_DEFACL:
- address = get_object_address_defacl(objname, objargs,
+ address = get_object_address_defacl((List *) objname,
missing_ok);
break;
default:
@@ -1024,7 +1031,7 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
*/
ObjectAddress
get_object_address_rv(ObjectType objtype, RangeVar *rel, List *objname,
- List *objargs, Relation *relp, LOCKMODE lockmode,
+ Relation *relp, LOCKMODE lockmode,
bool missing_ok)
{
if (rel)
@@ -1036,7 +1043,7 @@ get_object_address_rv(ObjectType objtype, RangeVar *rel, List *objname,
objname = lcons(makeString(rel->catalogname), objname);
}
- return get_object_address(objtype, objname, objargs,
+ return get_object_address(objtype, (Node *) objname,
relp, lockmode, missing_ok);
}
@@ -1046,62 +1053,12 @@ get_object_address_rv(ObjectType objtype, RangeVar *rel, List *objname,
*/
static ObjectAddress
get_object_address_unqualified(ObjectType objtype,
- List *qualname, bool missing_ok)
+ Value *strval, bool missing_ok)
{
const char *name;
ObjectAddress address;
- /*
- * The types of names handled by this function are not permitted to be
- * schema-qualified or catalog-qualified.
- */
- if (list_length(qualname) != 1)
- {
- const char *msg;
-
- switch (objtype)
- {
- case OBJECT_ACCESS_METHOD:
- msg = gettext_noop("access method name cannot be qualified");
- break;
- case OBJECT_DATABASE:
- msg = gettext_noop("database name cannot be qualified");
- break;
- case OBJECT_EXTENSION:
- msg = gettext_noop("extension name cannot be qualified");
- break;
- case OBJECT_TABLESPACE:
- msg = gettext_noop("tablespace name cannot be qualified");
- break;
- case OBJECT_ROLE:
- msg = gettext_noop("role name cannot be qualified");
- break;
- case OBJECT_SCHEMA:
- msg = gettext_noop("schema name cannot be qualified");
- break;
- case OBJECT_LANGUAGE:
- msg = gettext_noop("language name cannot be qualified");
- break;
- case OBJECT_FDW:
- msg = gettext_noop("foreign-data wrapper name cannot be qualified");
- break;
- case OBJECT_FOREIGN_SERVER:
- msg = gettext_noop("server name cannot be qualified");
- break;
- case OBJECT_EVENT_TRIGGER:
- msg = gettext_noop("event trigger name cannot be qualified");
- break;
- default:
- elog(ERROR, "unrecognized objtype: %d", (int) objtype);
- msg = NULL; /* placate compiler */
- }
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("%s", _(msg))));
- }
-
- /* Format is valid, extract the actual name. */
- name = strVal(linitial(qualname));
+ name = strVal(strval);
/* Translate name to OID. */
switch (objtype)
@@ -1492,14 +1449,11 @@ get_object_address_attrdef(ObjectType objtype, List *objname,
* Find the ObjectAddress for a type or domain
*/
static ObjectAddress
-get_object_address_type(ObjectType objtype, ListCell *typecell, bool missing_ok)
+get_object_address_type(ObjectType objtype, TypeName *typename, bool missing_ok)
{
ObjectAddress address;
- TypeName *typename;
Type tup;
- typename = (TypeName *) lfirst(typecell);
-
address.classId = TypeRelationId;
address.objectId = InvalidOid;
address.objectSubId = 0;
@@ -1573,7 +1527,7 @@ get_object_address_opcf(ObjectType objtype, List *objname, bool missing_ok)
*/
static ObjectAddress
get_object_address_opf_member(ObjectType objtype,
- List *objname, List *objargs, bool missing_ok)
+ List *objname, bool missing_ok)
{
ObjectAddress famaddr;
ObjectAddress address;
@@ -1589,20 +1543,20 @@ get_object_address_opf_member(ObjectType objtype,
* number. We need to strip that out before getting the opclass/family
* address. The rest can be used directly by get_object_address_opcf().
*/
- membernum = atoi(strVal(llast(objname)));
- copy = list_truncate(list_copy(objname), list_length(objname) - 1);
+ membernum = atoi(strVal(llast(linitial(objname))));
+ copy = list_truncate(list_copy(linitial(objname)), list_length(linitial(objname)) - 1);
/* no missing_ok support here */
famaddr = get_object_address_opcf(OBJECT_OPFAMILY, copy, false);
/* find out left/right type names and OIDs */
i = 0;
- foreach(cell, objargs)
+ foreach(cell, lsecond(objname))
{
ObjectAddress typaddr;
typenames[i] = strVal(lfirst(cell));
- typaddr = get_object_address_type(OBJECT_TYPE, cell, missing_ok);
+ typaddr = get_object_address_type(OBJECT_TYPE, (TypeName *) lfirst(cell), missing_ok);
typeoids[i] = typaddr.objectId;
if (++i >= 2)
break;
@@ -1678,7 +1632,7 @@ get_object_address_opf_member(ObjectType objtype,
* Find the ObjectAddress for a user mapping.
*/
static ObjectAddress
-get_object_address_usermapping(List *objname, List *objargs, bool missing_ok)
+get_object_address_usermapping(List *objname, bool missing_ok)
{
ObjectAddress address;
Oid userid;
@@ -1691,7 +1645,7 @@ get_object_address_usermapping(List *objname, List *objargs, bool missing_ok)
/* fetch string names from input lists, for error messages */
username = strVal(linitial(objname));
- servername = strVal(linitial(objargs));
+ servername = strVal(lsecond(objname));
/* look up pg_authid OID of mapped user; InvalidOid if PUBLIC */
if (strcmp(username, "public") == 0)
@@ -1747,7 +1701,7 @@ get_object_address_usermapping(List *objname, List *objargs, bool missing_ok)
* Find the ObjectAddress for a default ACL.
*/
static ObjectAddress
-get_object_address_defacl(List *objname, List *objargs, bool missing_ok)
+get_object_address_defacl(List *objname, bool missing_ok)
{
HeapTuple tp;
Oid userid;
@@ -1764,9 +1718,9 @@ get_object_address_defacl(List *objname, List *objargs, bool missing_ok)
* First figure out the textual attributes so that they can be used for
* error reporting.
*/
- username = strVal(linitial(objname));
- if (list_length(objname) >= 2)
- schema = (char *) strVal(lsecond(objname));
+ username = strVal(lsecond(objname));
+ if (list_length(objname) >= 3)
+ schema = (char *) strVal(lthird(objname));
else
schema = NULL;
@@ -1774,7 +1728,7 @@ get_object_address_defacl(List *objname, List *objargs, bool missing_ok)
* Decode defaclobjtype. Only first char is considered; the rest of the
* string, if any, is blissfully ignored.
*/
- objtype = ((char *) strVal(linitial(objargs)))[0];
+ objtype = ((char *) strVal(linitial(objname)))[0];
switch (objtype)
{
case DEFACLOBJ_RELATION:
@@ -1889,8 +1843,10 @@ pg_get_object_address(PG_FUNCTION_ARGS)
ArrayType *argsarr = PG_GETARG_ARRAYTYPE_P(2);
int itype;
ObjectType type;
- List *name;
- List *args;
+ List *name = NIL;
+ TypeName *typename = NULL;
+ List *args = NIL;
+ Node *objnode = NULL;
ObjectAddress addr;
TupleDesc tupdesc;
Datum values[3];
@@ -1928,7 +1884,7 @@ pg_get_object_address(PG_FUNCTION_ARGS)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("name or argument lists may not contain nulls")));
- name = list_make1(typeStringToTypeName(TextDatumGetCString(elems[0])));
+ typename = typeStringToTypeName(TextDatumGetCString(elems[0]));
}
else if (type == OBJECT_LARGEOBJECT)
{
@@ -1946,7 +1902,7 @@ pg_get_object_address(PG_FUNCTION_ARGS)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("large object OID may not be null")));
- name = list_make1(makeFloat(TextDatumGetCString(elems[0])));
+ objnode = (Node *) makeFloat(TextDatumGetCString(elems[0]));
}
else
{
@@ -2033,7 +1989,91 @@ pg_get_object_address(PG_FUNCTION_ARGS)
break;
}
- addr = get_object_address(type, name, args,
+ /*
+ * Now build the Node type that get_object_name() expects for the given
+ * type.
+ */
+ switch (type)
+ {
+ case OBJECT_TABLE:
+ case OBJECT_SEQUENCE:
+ case OBJECT_VIEW:
+ case OBJECT_MATVIEW:
+ case OBJECT_INDEX:
+ case OBJECT_FOREIGN_TABLE:
+ case OBJECT_COLUMN:
+ case OBJECT_ATTRIBUTE:
+ case OBJECT_COLLATION:
+ case OBJECT_CONVERSION:
+ case OBJECT_TSPARSER:
+ case OBJECT_TSDICTIONARY:
+ case OBJECT_TSTEMPLATE:
+ case OBJECT_TSCONFIGURATION:
+ case OBJECT_DEFAULT:
+ case OBJECT_POLICY:
+ case OBJECT_RULE:
+ case OBJECT_TRIGGER:
+ case OBJECT_TABCONSTRAINT:
+ case OBJECT_OPCLASS:
+ case OBJECT_OPFAMILY:
+ objnode = (Node *) name;
+ break;
+ case OBJECT_ACCESS_METHOD:
+ case OBJECT_DATABASE:
+ case OBJECT_EVENT_TRIGGER:
+ case OBJECT_EXTENSION:
+ case OBJECT_FDW:
+ case OBJECT_FOREIGN_SERVER:
+ case OBJECT_LANGUAGE:
+ case OBJECT_ROLE:
+ case OBJECT_SCHEMA:
+ case OBJECT_TABLESPACE:
+ if (list_length(name) != 1)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("name list length must be exactly %d", 1)));
+ objnode = linitial(name);
+ break;
+ case OBJECT_TYPE:
+ case OBJECT_DOMAIN:
+ objnode = (Node *) typename;
+ break;
+ case OBJECT_CAST:
+ case OBJECT_DOMCONSTRAINT:
+ case OBJECT_TRANSFORM:
+ objnode = (Node *) list_make2(typename, linitial(args));
+ break;
+ case OBJECT_USER_MAPPING:
+ objnode = (Node *) list_make2(linitial(name), linitial(args));
+ break;
+ case OBJECT_DEFACL:
+ objnode = (Node *) lcons(linitial(args), name);
+ break;
+ case OBJECT_AMOP:
+ case OBJECT_AMPROC:
+ objnode = (Node *) list_make2(name, args);
+ break;
+ case OBJECT_FUNCTION:
+ case OBJECT_AGGREGATE:
+ case OBJECT_OPERATOR:
+ {
+ FuncWithArgs *fwa = makeNode(FuncWithArgs);
+
+ fwa->funcname = name;
+ fwa->funcargs = args;
+ objnode = (Node *) fwa;
+ break;
+ }
+ case OBJECT_LARGEOBJECT:
+ /* already handled above */
+ break;
+ /* no default, to let compiler warn about missing case */
+ }
+
+ if (objnode == NULL)
+ elog(ERROR, "unrecognized object type: %d", type);
+
+ addr = get_object_address(type, objnode,
&relation, AccessShareLock, false);
/* We don't need the relcache entry, thank you very much */
@@ -2066,7 +2106,7 @@ pg_get_object_address(PG_FUNCTION_ARGS)
*/
void
check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
- List *objname, List *objargs, Relation relation)
+ Node *objname, Relation relation)
{
switch (objtype)
{
@@ -2088,7 +2128,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
case OBJECT_DATABASE:
if (!pg_database_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE,
- NameListToString(objname));
+ strVal((Value *) objname));
break;
case OBJECT_TYPE:
case OBJECT_DOMAIN:
@@ -2101,62 +2141,62 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
case OBJECT_FUNCTION:
if (!pg_proc_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC,
- NameListToString(objname));
+ NameListToString(((FuncWithArgs *) objname)->funcname));
break;
case OBJECT_OPERATOR:
if (!pg_oper_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPER,
- NameListToString(objname));
+ NameListToString(((FuncWithArgs *) objname)->funcname));
break;
case OBJECT_SCHEMA:
if (!pg_namespace_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_NAMESPACE,
- NameListToString(objname));
+ strVal((Value *) objname));
break;
case OBJECT_COLLATION:
if (!pg_collation_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_COLLATION,
- NameListToString(objname));
+ NameListToString((List *) objname));
break;
case OBJECT_CONVERSION:
if (!pg_conversion_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CONVERSION,
- NameListToString(objname));
+ NameListToString((List *) objname));
break;
case OBJECT_EXTENSION:
if (!pg_extension_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_EXTENSION,
- NameListToString(objname));
+ strVal((Value *) objname));
break;
case OBJECT_FDW:
if (!pg_foreign_data_wrapper_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_FDW,
- NameListToString(objname));
+ strVal((Value *) objname));
break;
case OBJECT_FOREIGN_SERVER:
if (!pg_foreign_server_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_FOREIGN_SERVER,
- NameListToString(objname));
+ strVal((Value *) objname));
break;
case OBJECT_EVENT_TRIGGER:
if (!pg_event_trigger_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_EVENT_TRIGGER,
- NameListToString(objname));
+ strVal((Value *) objname));
break;
case OBJECT_LANGUAGE:
if (!pg_language_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_LANGUAGE,
- NameListToString(objname));
+ strVal((Value *) objname));
break;
case OBJECT_OPCLASS:
if (!pg_opclass_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPCLASS,
- NameListToString(objname));
+ NameListToString((List *) objname));
break;
case OBJECT_OPFAMILY:
if (!pg_opfamily_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPFAMILY,
- NameListToString(objname));
+ NameListToString((List *) objname));
break;
case OBJECT_LARGEOBJECT:
if (!lo_compat_privileges &&
@@ -2169,8 +2209,8 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
case OBJECT_CAST:
{
/* We can only check permissions on the source/target types */
- TypeName *sourcetype = (TypeName *) linitial(objname);
- TypeName *targettype = (TypeName *) linitial(objargs);
+ TypeName *sourcetype = (TypeName *) linitial((List *) objname);
+ TypeName *targettype = (TypeName *) lsecond((List *) objname);
Oid sourcetypeid = typenameTypeId(NULL, sourcetype);
Oid targettypeid = typenameTypeId(NULL, targettype);
@@ -2185,7 +2225,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
break;
case OBJECT_TRANSFORM:
{
- TypeName *typename = (TypeName *) linitial(objname);
+ TypeName *typename = (TypeName *) linitial((List *) objname);
Oid typeid = typenameTypeId(NULL, typename);
if (!pg_type_ownercheck(typeid, roleid))
@@ -2195,17 +2235,17 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
case OBJECT_TABLESPACE:
if (!pg_tablespace_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TABLESPACE,
- NameListToString(objname));
+ strVal((Value *) objname));
break;
case OBJECT_TSDICTIONARY:
if (!pg_ts_dict_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TSDICTIONARY,
- NameListToString(objname));
+ NameListToString((List *) objname));
break;
case OBJECT_TSCONFIGURATION:
if (!pg_ts_config_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TSCONFIGURATION,
- NameListToString(objname));
+ NameListToString((List *) objname));
break;
case OBJECT_ROLE:
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index 03c0433992..2ce535e1ec 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -369,7 +369,7 @@ ExecRenameStmt(RenameStmt *stmt)
Relation relation;
address = get_object_address(stmt->renameType,
- stmt->object, stmt->objarg,
+ stmt->object,
&relation,
AccessExclusiveLock, false);
Assert(relation == NULL);
@@ -405,8 +405,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->objname,
+ &rel, AccessExclusiveLock, false);
/*
* If a relation was involved, it would have been opened and locked. We
@@ -415,8 +415,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;
@@ -445,7 +445,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;
@@ -460,7 +460,7 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
case OBJECT_DOMAIN:
case OBJECT_TYPE:
- address = AlterTypeNamespace(stmt->object, stmt->newschema,
+ address = AlterTypeNamespace((List *) stmt->object, stmt->newschema,
stmt->objectType,
oldSchemaAddr ? &oldNspOid : NULL);
break;
@@ -485,7 +485,6 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
address = get_object_address(stmt->objectType,
stmt->object,
- stmt->objarg,
&relation,
AccessExclusiveLock,
false);
@@ -749,25 +748,26 @@ 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((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);
/* Generic cases */
@@ -791,7 +791,6 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
address = get_object_address(stmt->objectType,
stmt->object,
- stmt->objarg,
&relation,
AccessExclusiveLock,
false);
diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c
index a0d3f8d01d..2af10bcf1a 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->objname);
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->objname,
&relation, ShareUpdateExclusiveLock, false);
/* Require ownership of the target object. */
check_object_ownership(GetUserId(), stmt->objtype, address,
- stmt->objname, stmt->objargs, relation);
+ stmt->objname, relation);
/* Perform other integrity checks as needed. */
switch (stmt->objtype)
diff --git a/src/backend/commands/dropcmds.c b/src/backend/commands/dropcmds.c
index 61ff8f2190..011d6867ce 100644
--- a/src/backend/commands/dropcmds.c
+++ b/src/backend/commands/dropcmds.c
@@ -30,7 +30,7 @@
static void does_not_exist_skipping(ObjectType objtype,
- List *objname, List *objargs);
+ Node *objname);
static bool owningrel_does_not_exist_skipping(List *objname,
const char **msg, char **name);
static bool schema_does_not_exist_skipping(List *objname,
@@ -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 *objname = 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,
+ objname,
&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, objname);
continue;
}
@@ -110,7 +102,7 @@ RemoveObjects(DropStmt *stmt)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is an aggregate function",
- NameListToString(objname)),
+ NameListToString(((FuncWithArgs *) objname)->funcname)),
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);
+ objname, relation);
/* Release any relcache reference count, but keep lock until commit. */
if (relation)
@@ -254,7 +246,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 *objname)
{
const char *msg = NULL;
char *name = NULL;
@@ -264,12 +256,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 *) objname);
break;
case OBJECT_TYPE:
case OBJECT_DOMAIN:
{
- TypeName *typ = linitial(objname);
+ TypeName *typ = (TypeName *) objname;
if (!schema_does_not_exist_skipping(typ->names, &msg, &name))
{
@@ -279,165 +271,174 @@ 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((List *) objname, &msg, &name))
{
msg = gettext_noop("collation \"%s\" does not exist, skipping");
- name = NameListToString(objname);
+ name = NameListToString((List *) objname);
}
break;
case OBJECT_CONVERSION:
- if (!schema_does_not_exist_skipping(objname, &msg, &name))
+ if (!schema_does_not_exist_skipping((List *) objname, &msg, &name))
{
msg = gettext_noop("conversion \"%s\" does not exist, skipping");
- name = NameListToString(objname);
+ name = NameListToString((List *) objname);
}
break;
case OBJECT_SCHEMA:
msg = gettext_noop("schema \"%s\" does not exist, skipping");
- name = NameListToString(objname);
+ name = strVal((Value *) objname);
break;
case OBJECT_TSPARSER:
- if (!schema_does_not_exist_skipping(objname, &msg, &name))
+ if (!schema_does_not_exist_skipping((List *) objname, &msg, &name))
{
msg = gettext_noop("text search parser \"%s\" does not exist, skipping");
- name = NameListToString(objname);
+ name = NameListToString((List *) objname);
}
break;
case OBJECT_TSDICTIONARY:
- if (!schema_does_not_exist_skipping(objname, &msg, &name))
+ if (!schema_does_not_exist_skipping((List *) objname, &msg, &name))
{
msg = gettext_noop("text search dictionary \"%s\" does not exist, skipping");
- name = NameListToString(objname);
+ name = NameListToString((List *) objname);
}
break;
case OBJECT_TSTEMPLATE:
- if (!schema_does_not_exist_skipping(objname, &msg, &name))
+ if (!schema_does_not_exist_skipping((List *) objname, &msg, &name))
{
msg = gettext_noop("text search template \"%s\" does not exist, skipping");
- name = NameListToString(objname);
+ name = NameListToString((List *) objname);
}
break;
case OBJECT_TSCONFIGURATION:
- if (!schema_does_not_exist_skipping(objname, &msg, &name))
+ if (!schema_does_not_exist_skipping((List *) objname, &msg, &name))
{
msg = gettext_noop("text search configuration \"%s\" does not exist, skipping");
- name = NameListToString(objname);
+ name = NameListToString((List *) objname);
}
break;
case OBJECT_EXTENSION:
msg = gettext_noop("extension \"%s\" does not exist, skipping");
- name = NameListToString(objname);
+ name = strVal((Value *) objname);
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);
+ FuncWithArgs *fwa = (FuncWithArgs *) objname;
+ if (!schema_does_not_exist_skipping(fwa->funcname, &msg, &name) &&
+ !type_in_list_does_not_exist_skipping(fwa->funcargs, &msg, &name))
+ {
+ msg = gettext_noop("function %s(%s) does not exist, skipping");
+ name = NameListToString(fwa->funcname);
+ args = TypeNameListToString(fwa->funcargs);
+ }
+ 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);
+ FuncWithArgs *fwa = (FuncWithArgs *) objname;
+ if (!schema_does_not_exist_skipping(fwa->funcname, &msg, &name) &&
+ !type_in_list_does_not_exist_skipping(fwa->funcargs, &msg, &name))
+ {
+ msg = gettext_noop("aggregate %s(%s) does not exist, skipping");
+ name = NameListToString(fwa->funcname);
+ args = TypeNameListToString(fwa->funcargs);
+ }
+ 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);
+ FuncWithArgs *fwa = (FuncWithArgs *) objname;
+ if (!schema_does_not_exist_skipping(fwa->funcname, &msg, &name) &&
+ !type_in_list_does_not_exist_skipping(fwa->funcargs, &msg, &name))
+ {
+ msg = gettext_noop("operator %s does not exist, skipping");
+ name = NameListToString(fwa->funcname);
+ }
+ break;
}
- break;
case OBJECT_LANGUAGE:
msg = gettext_noop("language \"%s\" does not exist, skipping");
- name = NameListToString(objname);
+ name = strVal((Value *) objname);
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((List *) objname)), &msg, &name) &&
+ !type_in_list_does_not_exist_skipping(list_make1(lsecond((List *) objname)), &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((TypeName *) linitial((List *) objname));
+ args = TypeNameToString((TypeName *) lsecond((List *) objname));
}
}
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((List *) objname)), &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((TypeName *) linitial((List *) objname));
+ args = strVal(lsecond((List *) objname));
}
break;
case OBJECT_TRIGGER:
- if (!owningrel_does_not_exist_skipping(objname, &msg, &name))
+ if (!owningrel_does_not_exist_skipping((List *) objname, &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((List *) objname));
+ args = NameListToString(list_truncate(list_copy((List *) objname),
+ list_length((List *) objname) - 1));
}
break;
case OBJECT_POLICY:
- if (!owningrel_does_not_exist_skipping(objname, &msg, &name))
+ if (!owningrel_does_not_exist_skipping((List *) objname, &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((List *) objname));
+ args = NameListToString(list_truncate(list_copy((List *) objname),
+ list_length((List *) objname) - 1));
}
break;
case OBJECT_EVENT_TRIGGER:
msg = gettext_noop("event trigger \"%s\" does not exist, skipping");
- name = NameListToString(objname);
+ name = strVal((Value *) objname);
break;
case OBJECT_RULE:
- if (!owningrel_does_not_exist_skipping(objname, &msg, &name))
+ if (!owningrel_does_not_exist_skipping((List *) objname, &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((List *) objname));
+ args = NameListToString(list_truncate(list_copy((List *) objname),
+ list_length((List *) objname) - 1));
}
break;
case OBJECT_FDW:
msg = gettext_noop("foreign-data wrapper \"%s\" does not exist, skipping");
- name = NameListToString(objname);
+ name = strVal((Value *) objname);
break;
case OBJECT_FOREIGN_SERVER:
msg = gettext_noop("server \"%s\" does not exist, skipping");
- name = NameListToString(objname);
+ name = strVal((Value *) objname);
break;
case OBJECT_OPCLASS:
{
- List *opcname = list_copy_tail(objname, 1);
+ List *opcname = list_copy_tail((List *) objname, 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((List *) objname));
}
}
break;
case OBJECT_OPFAMILY:
{
- List *opfname = list_copy_tail(objname, 1);
+ List *opfname = list_copy_tail((List *) objname, 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((List *) objname));
}
}
break;
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index f6c2c8af91..f883db33f6 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -2673,9 +2673,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;
@@ -2691,12 +2690,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);
@@ -3194,7 +3187,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->objname,
&relation, ShareUpdateExclusiveLock, false);
Assert(object.objectSubId == 0);
@@ -3203,7 +3196,7 @@ ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt,
/* Permission check: must own target object, too */
check_object_ownership(GetUserId(), stmt->objtype, object,
- stmt->objname, stmt->objargs, relation);
+ stmt->objname, relation);
/*
* Check existing extension membership.
diff --git a/src/backend/commands/seclabel.c b/src/backend/commands/seclabel.c
index 2b0ae34830..8fb7af5e79 100644
--- a/src/backend/commands/seclabel.c
+++ b/src/backend/commands/seclabel.c
@@ -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->objname,
&relation, ShareUpdateExclusiveLock, false);
/* Require ownership of the target object. */
check_object_ownership(GetUserId(), stmt->objtype, address,
- stmt->objname, stmt->objargs, relation);
+ stmt->objname, relation);
/* Perform other integrity checks as needed. */
switch (stmt->objtype)
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 2f605ce83d..237783afbc 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -2778,7 +2778,7 @@ RenameConstraint(RenameStmt *stmt)
Relation rel;
HeapTuple tup;
- typid = typenameTypeId(NULL, makeTypeNameFromNameList(stmt->object));
+ typid = typenameTypeId(NULL, makeTypeNameFromNameList((List *) stmt->object));
rel = heap_open(TypeRelationId, RowExclusiveLock);
tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
if (!HeapTupleIsValid(tup))
@@ -9366,11 +9366,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->objname = (Node *) list_make3(makeString(get_namespace_name(RelationGetNamespace(rel))),
+ makeString(RelationGetRelationName(rel)),
+ makeString(conname));
cmd->comment = comment_str;
/* Append it to list of commands */
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index 5e3989acd2..9304ad11e6 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -3106,7 +3106,7 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
ObjectAddress
RenameType(RenameStmt *stmt)
{
- List *names = stmt->object;
+ List *names = (List *) stmt->object;
const char *newTypeName = stmt->newname;
TypeName *typename;
Oid typeOid;
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 6955298577..13f7f110fb 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -3080,7 +3080,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);
@@ -3108,7 +3107,6 @@ _copyCommentStmt(const CommentStmt *from)
COPY_SCALAR_FIELD(objtype);
COPY_NODE_FIELD(objname);
- COPY_NODE_FIELD(objargs);
COPY_STRING_FIELD(comment);
return newnode;
@@ -3121,7 +3119,6 @@ _copySecLabelStmt(const SecLabelStmt *from)
COPY_SCALAR_FIELD(objtype);
COPY_NODE_FIELD(objname);
- COPY_NODE_FIELD(objargs);
COPY_STRING_FIELD(provider);
COPY_STRING_FIELD(label);
@@ -3227,7 +3224,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);
@@ -3244,7 +3240,6 @@ _copyAlterObjectDependsStmt(const AlterObjectDependsStmt *from)
COPY_SCALAR_FIELD(objectType);
COPY_NODE_FIELD(relation);
COPY_NODE_FIELD(objname);
- COPY_NODE_FIELD(objargs);
COPY_NODE_FIELD(extname);
return newnode;
@@ -3258,7 +3253,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);
@@ -3273,7 +3267,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;
@@ -3745,7 +3738,6 @@ _copyAlterExtensionContentsStmt(const AlterExtensionContentsStmt *from)
COPY_SCALAR_FIELD(action);
COPY_SCALAR_FIELD(objtype);
COPY_NODE_FIELD(objname);
- COPY_NODE_FIELD(objargs);
return newnode;
}
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index 548a2aa876..3538932662 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -1205,7 +1205,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);
@@ -1229,7 +1228,6 @@ _equalCommentStmt(const CommentStmt *a, const CommentStmt *b)
{
COMPARE_SCALAR_FIELD(objtype);
COMPARE_NODE_FIELD(objname);
- COMPARE_NODE_FIELD(objargs);
COMPARE_STRING_FIELD(comment);
return true;
@@ -1240,7 +1238,6 @@ _equalSecLabelStmt(const SecLabelStmt *a, const SecLabelStmt *b)
{
COMPARE_SCALAR_FIELD(objtype);
COMPARE_NODE_FIELD(objname);
- COMPARE_NODE_FIELD(objargs);
COMPARE_STRING_FIELD(provider);
COMPARE_STRING_FIELD(label);
@@ -1332,7 +1329,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);
@@ -1347,7 +1343,6 @@ _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(extname);
return true;
@@ -1359,7 +1354,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);
@@ -1372,7 +1366,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;
@@ -1769,7 +1762,6 @@ _equalAlterExtensionContentsStmt(const AlterExtensionContentsStmt *a, const Alte
COMPARE_SCALAR_FIELD(action);
COMPARE_SCALAR_FIELD(objtype);
COMPARE_NODE_FIELD(objname);
- COMPARE_NODE_FIELD(objargs);
return true;
}
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 645c95909e..c7d08784f4 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -425,7 +425,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <boolean> copy_from opt_program
%type <ival> opt_column event cursor_options opt_hold opt_set_data
-%type <objtype> drop_type comment_type security_label_type
+%type <objtype> drop_type1 drop_type2 comment_type1 comment_type2 security_label_type1 security_label_type2
%type <node> fetch_args limit_clause select_limit_value
offset_clause select_offset_value
@@ -4044,8 +4044,7 @@ DropPLangStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_LANGUAGE;
- n->objects = list_make1(list_make1(makeString($4)));
- n->arguments = NIL;
+ n->objects = list_make1(makeString($4));
n->behavior = $5;
n->missing_ok = false;
n->concurrent = false;
@@ -4055,7 +4054,7 @@ DropPLangStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_LANGUAGE;
- n->objects = list_make1(list_make1(makeString($6)));
+ n->objects = list_make1(makeString($6));
n->behavior = $7;
n->missing_ok = true;
n->concurrent = false;
@@ -4210,7 +4209,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_ACCESS_METHOD;
- n->objname = list_make1(makeString($7));
+ n->objname = (Node *) makeString($7);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop AGGREGATE aggregate_with_argtypes
@@ -4219,8 +4218,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_AGGREGATE;
- n->objname = $6->funcname;
- n->objargs = $6->funcargs;
+ n->objname = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')'
@@ -4229,8 +4227,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_CAST;
- n->objname = list_make1($7);
- n->objargs = list_make1($9);
+ n->objname = (Node *) list_make2($7, $9);
$$ = (Node *) n;
}
| ALTER EXTENSION name add_drop COLLATION any_name
@@ -4239,7 +4236,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_COLLATION;
- n->objname = $6;
+ n->objname = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop CONVERSION_P any_name
@@ -4248,7 +4245,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_CONVERSION;
- n->objname = $6;
+ n->objname = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop DOMAIN_P Typename
@@ -4257,7 +4254,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_DOMAIN;
- n->objname = list_make1($6);
+ n->objname = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop FUNCTION function_with_argtypes
@@ -4266,8 +4263,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_FUNCTION;
- n->objname = $6->funcname;
- n->objargs = $6->funcargs;
+ n->objname = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop opt_procedural LANGUAGE name
@@ -4276,7 +4272,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_LANGUAGE;
- n->objname = list_make1(makeString($7));
+ n->objname = (Node *) makeString($7);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop OPERATOR operator_with_argtypes
@@ -4285,8 +4281,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_OPERATOR;
- n->objname = $6->funcname;
- n->objargs = $6->funcargs;
+ n->objname = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING access_method
@@ -4295,7 +4290,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_OPCLASS;
- n->objname = lcons(makeString($9), $7);
+ n->objname = (Node *) lcons(makeString($9), $7);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop OPERATOR FAMILY any_name USING access_method
@@ -4304,7 +4299,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_OPFAMILY;
- n->objname = lcons(makeString($9), $7);
+ n->objname = (Node *) lcons(makeString($9), $7);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop SCHEMA name
@@ -4313,7 +4308,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_SCHEMA;
- n->objname = list_make1(makeString($6));
+ n->objname = (Node *) makeString($6);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop EVENT TRIGGER name
@@ -4322,7 +4317,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_EVENT_TRIGGER;
- n->objname = list_make1(makeString($7));
+ n->objname = (Node *) makeString($7);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop TABLE any_name
@@ -4331,7 +4326,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_TABLE;
- n->objname = $6;
+ n->objname = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop TEXT_P SEARCH PARSER any_name
@@ -4340,7 +4335,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_TSPARSER;
- n->objname = $8;
+ n->objname = (Node *) $8;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop TEXT_P SEARCH DICTIONARY any_name
@@ -4349,7 +4344,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_TSDICTIONARY;
- n->objname = $8;
+ n->objname = (Node *) $8;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop TEXT_P SEARCH TEMPLATE any_name
@@ -4358,7 +4353,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_TSTEMPLATE;
- n->objname = $8;
+ n->objname = (Node *) $8;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop TEXT_P SEARCH CONFIGURATION any_name
@@ -4367,7 +4362,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_TSCONFIGURATION;
- n->objname = $8;
+ n->objname = (Node *) $8;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop SEQUENCE any_name
@@ -4376,7 +4371,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_SEQUENCE;
- n->objname = $6;
+ n->objname = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop VIEW any_name
@@ -4385,7 +4380,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_VIEW;
- n->objname = $6;
+ n->objname = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop MATERIALIZED VIEW any_name
@@ -4394,7 +4389,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_MATVIEW;
- n->objname = $7;
+ n->objname = (Node *) $7;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop FOREIGN TABLE any_name
@@ -4403,7 +4398,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_FOREIGN_TABLE;
- n->objname = $7;
+ n->objname = (Node *) $7;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop FOREIGN DATA_P WRAPPER name
@@ -4412,7 +4407,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_FDW;
- n->objname = list_make1(makeString($8));
+ n->objname = (Node *) makeString($8);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop SERVER name
@@ -4421,7 +4416,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_FOREIGN_SERVER;
- n->objname = list_make1(makeString($6));
+ n->objname = (Node *) makeString($6);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop TRANSFORM FOR Typename LANGUAGE name
@@ -4430,8 +4425,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_TRANSFORM;
- n->objname = list_make1($7);
- n->objargs = list_make1(makeString($9));
+ n->objname = (Node *) list_make2($7, makeString($9));
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop TYPE_P Typename
@@ -4440,7 +4434,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_TYPE;
- n->objname = list_make1($6);
+ n->objname = (Node *) $6;
$$ = (Node *)n;
}
;
@@ -4490,8 +4484,7 @@ DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FDW;
- n->objects = list_make1(list_make1(makeString($5)));
- n->arguments = NIL;
+ n->objects = list_make1(makeString($5));
n->missing_ok = false;
n->behavior = $6;
n->concurrent = false;
@@ -4501,8 +4494,7 @@ DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FDW;
- n->objects = list_make1(list_make1(makeString($7)));
- n->arguments = NIL;
+ n->objects = list_make1(makeString($7));
n->missing_ok = true;
n->behavior = $8;
n->concurrent = false;
@@ -4652,8 +4644,7 @@ DropForeignServerStmt: DROP SERVER name opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FOREIGN_SERVER;
- n->objects = list_make1(list_make1(makeString($3)));
- n->arguments = NIL;
+ n->objects = list_make1(makeString($3));
n->missing_ok = false;
n->behavior = $4;
n->concurrent = false;
@@ -4663,8 +4654,7 @@ DropForeignServerStmt: DROP SERVER name opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FOREIGN_SERVER;
- n->objects = list_make1(list_make1(makeString($5)));
- n->arguments = NIL;
+ n->objects = list_make1(makeString($5));
n->missing_ok = true;
n->behavior = $6;
n->concurrent = false;
@@ -4988,7 +4978,6 @@ DropPolicyStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_POLICY;
n->objects = list_make1(lappend($5, makeString($3)));
- n->arguments = NIL;
n->behavior = $6;
n->missing_ok = false;
n->concurrent = false;
@@ -4999,7 +4988,6 @@ DropPolicyStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_POLICY;
n->objects = list_make1(lappend($7, makeString($5)));
- n->arguments = NIL;
n->behavior = $8;
n->missing_ok = true;
n->concurrent = false;
@@ -5312,7 +5300,6 @@ DropTrigStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_TRIGGER;
n->objects = list_make1(lappend($5, makeString($3)));
- n->arguments = NIL;
n->behavior = $6;
n->missing_ok = false;
n->concurrent = false;
@@ -5323,7 +5310,6 @@ DropTrigStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_TRIGGER;
n->objects = list_make1(lappend($7, makeString($5)));
- n->arguments = NIL;
n->behavior = $8;
n->missing_ok = true;
n->concurrent = false;
@@ -5433,7 +5419,6 @@ DropAssertStmt:
{
DropStmt *n = makeNode(DropStmt);
n->objects = NIL;
- n->arguments = NIL;
n->behavior = $4;
n->removeType = OBJECT_TRIGGER; /* XXX */
ereport(ERROR,
@@ -5947,24 +5932,42 @@ ReassignOwnedStmt:
*
*****************************************************************************/
-DropStmt: DROP drop_type IF_P EXISTS any_name_list opt_drop_behavior
+DropStmt: DROP drop_type1 IF_P EXISTS any_name_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = $2;
n->missing_ok = TRUE;
n->objects = $5;
- n->arguments = NIL;
n->behavior = $6;
n->concurrent = false;
$$ = (Node *)n;
}
- | DROP drop_type any_name_list opt_drop_behavior
+ | DROP drop_type1 any_name_list opt_drop_behavior
+ {
+ DropStmt *n = makeNode(DropStmt);
+ n->removeType = $2;
+ n->missing_ok = FALSE;
+ n->objects = $3;
+ n->behavior = $4;
+ n->concurrent = false;
+ $$ = (Node *)n;
+ }
+ | DROP drop_type2 IF_P EXISTS name_list opt_drop_behavior
+ {
+ DropStmt *n = makeNode(DropStmt);
+ n->removeType = $2;
+ n->missing_ok = TRUE;
+ n->objects = $5;
+ n->behavior = $6;
+ n->concurrent = false;
+ $$ = (Node *)n;
+ }
+ | DROP drop_type2 name_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = $2;
n->missing_ok = FALSE;
n->objects = $3;
- n->arguments = NIL;
n->behavior = $4;
n->concurrent = false;
$$ = (Node *)n;
@@ -6015,7 +6018,6 @@ DropStmt: DROP drop_type IF_P EXISTS any_name_list opt_drop_behavior
n->removeType = OBJECT_INDEX;
n->missing_ok = FALSE;
n->objects = $4;
- n->arguments = NIL;
n->behavior = $5;
n->concurrent = true;
$$ = (Node *)n;
@@ -6026,32 +6028,34 @@ DropStmt: DROP drop_type IF_P EXISTS any_name_list opt_drop_behavior
n->removeType = OBJECT_INDEX;
n->missing_ok = TRUE;
n->objects = $6;
- n->arguments = NIL;
n->behavior = $7;
n->concurrent = true;
$$ = (Node *)n;
}
;
-
-drop_type: TABLE { $$ = OBJECT_TABLE; }
+/* object types taking any_name_list */
+drop_type1: TABLE { $$ = OBJECT_TABLE; }
| SEQUENCE { $$ = OBJECT_SEQUENCE; }
| VIEW { $$ = OBJECT_VIEW; }
| MATERIALIZED VIEW { $$ = OBJECT_MATVIEW; }
| INDEX { $$ = OBJECT_INDEX; }
| FOREIGN TABLE { $$ = OBJECT_FOREIGN_TABLE; }
- | ACCESS METHOD { $$ = OBJECT_ACCESS_METHOD; }
- | EVENT TRIGGER { $$ = OBJECT_EVENT_TRIGGER; }
| COLLATION { $$ = OBJECT_COLLATION; }
| CONVERSION_P { $$ = OBJECT_CONVERSION; }
- | SCHEMA { $$ = OBJECT_SCHEMA; }
- | EXTENSION { $$ = OBJECT_EXTENSION; }
| TEXT_P SEARCH PARSER { $$ = OBJECT_TSPARSER; }
| TEXT_P SEARCH DICTIONARY { $$ = OBJECT_TSDICTIONARY; }
| TEXT_P SEARCH TEMPLATE { $$ = OBJECT_TSTEMPLATE; }
| TEXT_P SEARCH CONFIGURATION { $$ = OBJECT_TSCONFIGURATION; }
;
+/* object types taking name_list */
+drop_type2: ACCESS METHOD { $$ = OBJECT_ACCESS_METHOD; }
+ | EVENT TRIGGER { $$ = OBJECT_EVENT_TRIGGER; }
+ | EXTENSION { $$ = OBJECT_EXTENSION; }
+ | SCHEMA { $$ = OBJECT_SCHEMA; }
+ ;
+
any_name_list:
any_name { $$ = list_make1($1); }
| any_name_list ',' any_name { $$ = lappend($1, $3); }
@@ -6068,8 +6072,8 @@ attrs: '.' attr_name
;
type_name_list:
- Typename { $$ = list_make1(list_make1($1)); }
- | type_name_list ',' Typename { $$ = lappend($1, list_make1($3)); }
+ Typename { $$ = list_make1($1); }
+ | type_name_list ',' Typename { $$ = lappend($1, $3); }
/*****************************************************************************
*
@@ -6126,12 +6130,19 @@ opt_restart_seqs:
*****************************************************************************/
CommentStmt:
- COMMENT ON comment_type any_name IS comment_text
+ COMMENT ON comment_type1 any_name IS comment_text
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = $3;
- n->objname = $4;
- n->objargs = NIL;
+ n->objname = (Node *) $4;
+ n->comment = $6;
+ $$ = (Node *) n;
+ }
+ | COMMENT ON comment_type2 name IS comment_text
+ {
+ CommentStmt *n = makeNode(CommentStmt);
+ n->objtype = $3;
+ n->objname = (Node *) makeString($4);
n->comment = $6;
$$ = (Node *) n;
}
@@ -6139,8 +6150,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_TYPE;
- n->objname = list_make1($4);
- n->objargs = NIL;
+ n->objname = (Node *) $4;
n->comment = $6;
$$ = (Node *) n;
}
@@ -6148,8 +6158,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_DOMAIN;
- n->objname = list_make1($4);
- n->objargs = NIL;
+ n->objname = (Node *) $4;
n->comment = $6;
$$ = (Node *) n;
}
@@ -6157,8 +6166,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_AGGREGATE;
- n->objname = $4->funcname;
- n->objargs = $4->funcargs;
+ n->objname = (Node *) $4;
n->comment = $6;
$$ = (Node *) n;
}
@@ -6166,8 +6174,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_FUNCTION;
- n->objname = $4->funcname;
- n->objargs = $4->funcargs;
+ n->objname = (Node *) $4;
n->comment = $6;
$$ = (Node *) n;
}
@@ -6175,8 +6182,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_OPERATOR;
- n->objname = $4->funcname;
- n->objargs = $4->funcargs;
+ n->objname = (Node *) $4;
n->comment = $6;
$$ = (Node *) n;
}
@@ -6184,8 +6190,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_TABCONSTRAINT;
- n->objname = lappend($6, makeString($4));
- n->objargs = NIL;
+ n->objname = (Node *) lappend($6, makeString($4));
n->comment = $8;
$$ = (Node *) n;
}
@@ -6198,8 +6203,7 @@ CommentStmt:
* there's a shift/reduce conflict if we do that, so fix it
* up here.
*/
- n->objname = list_make1(makeTypeNameFromNameList($7));
- n->objargs = list_make1(makeString($4));
+ n->objname = (Node *) list_make2(makeTypeNameFromNameList($7), makeString($4));
n->comment = $9;
$$ = (Node *) n;
}
@@ -6207,8 +6211,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_POLICY;
- n->objname = lappend($6, makeString($4));
- n->objargs = NIL;
+ n->objname = (Node *) lappend($6, makeString($4));
n->comment = $8;
$$ = (Node *) n;
}
@@ -6216,8 +6219,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_RULE;
- n->objname = lappend($6, makeString($4));
- n->objargs = NIL;
+ n->objname = (Node *) lappend($6, makeString($4));
n->comment = $8;
$$ = (Node *) n;
}
@@ -6226,8 +6228,7 @@ CommentStmt:
/* Obsolete syntax supported for awhile for compatibility */
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_RULE;
- n->objname = list_make1(makeString($4));
- n->objargs = NIL;
+ n->objname = (Node *) list_make1(makeString($4));
n->comment = $6;
$$ = (Node *) n;
}
@@ -6235,8 +6236,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_TRANSFORM;
- n->objname = list_make1($5);
- n->objargs = list_make1(makeString($7));
+ n->objname = (Node *) list_make2($5, makeString($7));
n->comment = $9;
$$ = (Node *) n;
}
@@ -6244,8 +6244,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_TRIGGER;
- n->objname = lappend($6, makeString($4));
- n->objargs = NIL;
+ n->objname = (Node *) lappend($6, makeString($4));
n->comment = $8;
$$ = (Node *) n;
}
@@ -6253,7 +6252,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_OPCLASS;
- n->objname = lcons(makeString($7), $5);
+ n->objname = (Node *) lcons(makeString($7), $5);
n->comment = $9;
$$ = (Node *) n;
}
@@ -6261,8 +6260,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_OPFAMILY;
- n->objname = lcons(makeString($7), $5);
- n->objargs = NIL;
+ n->objname = (Node *) lcons(makeString($7), $5);
n->comment = $9;
$$ = (Node *) n;
}
@@ -6270,8 +6268,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_LARGEOBJECT;
- n->objname = list_make1($5);
- n->objargs = NIL;
+ n->objname = (Node *) $5;
n->comment = $7;
$$ = (Node *) n;
}
@@ -6279,27 +6276,15 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_CAST;
- n->objname = list_make1($5);
- n->objargs = list_make1($7);
+ n->objname = (Node *) list_make2($5, $7);
n->comment = $10;
$$ = (Node *) n;
}
- | COMMENT ON opt_procedural LANGUAGE any_name IS comment_text
- {
- CommentStmt *n = makeNode(CommentStmt);
- n->objtype = OBJECT_LANGUAGE;
- n->objname = $5;
- n->objargs = NIL;
- n->comment = $7;
- $$ = (Node *) n;
- }
;
-comment_type:
- ACCESS METHOD { $$ = OBJECT_ACCESS_METHOD; }
- | COLUMN { $$ = OBJECT_COLUMN; }
- | DATABASE { $$ = OBJECT_DATABASE; }
- | SCHEMA { $$ = OBJECT_SCHEMA; }
+/* object types taking any_name */
+comment_type1:
+ COLUMN { $$ = OBJECT_COLUMN; }
| INDEX { $$ = OBJECT_INDEX; }
| SEQUENCE { $$ = OBJECT_SEQUENCE; }
| TABLE { $$ = OBJECT_TABLE; }
@@ -6307,19 +6292,27 @@ comment_type:
| MATERIALIZED VIEW { $$ = OBJECT_MATVIEW; }
| COLLATION { $$ = OBJECT_COLLATION; }
| CONVERSION_P { $$ = OBJECT_CONVERSION; }
- | TABLESPACE { $$ = OBJECT_TABLESPACE; }
- | EXTENSION { $$ = OBJECT_EXTENSION; }
- | ROLE { $$ = OBJECT_ROLE; }
| FOREIGN TABLE { $$ = OBJECT_FOREIGN_TABLE; }
- | SERVER { $$ = OBJECT_FOREIGN_SERVER; }
- | FOREIGN DATA_P WRAPPER { $$ = OBJECT_FDW; }
- | EVENT TRIGGER { $$ = OBJECT_EVENT_TRIGGER; }
| TEXT_P SEARCH CONFIGURATION { $$ = OBJECT_TSCONFIGURATION; }
| TEXT_P SEARCH DICTIONARY { $$ = OBJECT_TSDICTIONARY; }
| TEXT_P SEARCH PARSER { $$ = OBJECT_TSPARSER; }
| TEXT_P SEARCH TEMPLATE { $$ = OBJECT_TSTEMPLATE; }
;
+/* object types taking name */
+comment_type2:
+ ACCESS METHOD { $$ = OBJECT_ACCESS_METHOD; }
+ | DATABASE { $$ = OBJECT_DATABASE; }
+ | EVENT TRIGGER { $$ = OBJECT_EVENT_TRIGGER; }
+ | EXTENSION { $$ = OBJECT_EXTENSION; }
+ | FOREIGN DATA_P WRAPPER { $$ = OBJECT_FDW; }
+ | opt_procedural LANGUAGE { $$ = OBJECT_LANGUAGE; }
+ | ROLE { $$ = OBJECT_ROLE; }
+ | SCHEMA { $$ = OBJECT_SCHEMA; }
+ | SERVER { $$ = OBJECT_FOREIGN_SERVER; }
+ | TABLESPACE { $$ = OBJECT_TABLESPACE; }
+ ;
+
comment_text:
Sconst { $$ = $1; }
| NULL_P { $$ = NULL; }
@@ -6336,14 +6329,23 @@ comment_text:
*****************************************************************************/
SecLabelStmt:
- SECURITY LABEL opt_provider ON security_label_type any_name
+ SECURITY LABEL opt_provider ON security_label_type1 any_name
IS security_label
{
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = $5;
- n->objname = $6;
- n->objargs = NIL;
+ n->objname = (Node *) $6;
+ n->label = $8;
+ $$ = (Node *) n;
+ }
+ | SECURITY LABEL opt_provider ON security_label_type2 name
+ IS security_label
+ {
+ SecLabelStmt *n = makeNode(SecLabelStmt);
+ n->provider = $3;
+ n->objtype = $5;
+ n->objname = (Node *) makeString($6);
n->label = $8;
$$ = (Node *) n;
}
@@ -6353,8 +6355,7 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_TYPE;
- n->objname = list_make1($6);
- n->objargs = NIL;
+ n->objname = (Node *) $6;
n->label = $8;
$$ = (Node *) n;
}
@@ -6364,8 +6365,7 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_TYPE;
- n->objname = list_make1($6);
- n->objargs = NIL;
+ n->objname = (Node *) $6;
n->label = $8;
$$ = (Node *) n;
}
@@ -6375,8 +6375,7 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_AGGREGATE;
- n->objname = $6->funcname;
- n->objargs = $6->funcargs;
+ n->objname = (Node *) $6;
n->label = $8;
$$ = (Node *) n;
}
@@ -6386,8 +6385,7 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_FUNCTION;
- n->objname = $6->funcname;
- n->objargs = $6->funcargs;
+ n->objname = (Node *) $6;
n->label = $8;
$$ = (Node *) n;
}
@@ -6397,19 +6395,7 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_LARGEOBJECT;
- n->objname = list_make1($7);
- n->objargs = NIL;
- n->label = $9;
- $$ = (Node *) n;
- }
- | SECURITY LABEL opt_provider ON opt_procedural LANGUAGE any_name
- IS security_label
- {
- SecLabelStmt *n = makeNode(SecLabelStmt);
- n->provider = $3;
- n->objtype = OBJECT_LANGUAGE;
- n->objname = $7;
- n->objargs = NIL;
+ n->objname = (Node *) $7;
n->label = $9;
$$ = (Node *) n;
}
@@ -6419,20 +6405,26 @@ opt_provider: FOR NonReservedWord_or_Sconst { $$ = $2; }
| /* empty */ { $$ = NULL; }
;
-security_label_type:
+/* object types taking any_name */
+security_label_type1:
COLUMN { $$ = OBJECT_COLUMN; }
- | DATABASE { $$ = OBJECT_DATABASE; }
- | EVENT TRIGGER { $$ = OBJECT_EVENT_TRIGGER; }
| FOREIGN TABLE { $$ = OBJECT_FOREIGN_TABLE; }
- | SCHEMA { $$ = OBJECT_SCHEMA; }
| SEQUENCE { $$ = OBJECT_SEQUENCE; }
| TABLE { $$ = OBJECT_TABLE; }
- | ROLE { $$ = OBJECT_ROLE; }
- | TABLESPACE { $$ = OBJECT_TABLESPACE; }
| VIEW { $$ = OBJECT_VIEW; }
| MATERIALIZED VIEW { $$ = OBJECT_MATVIEW; }
;
+/* object types taking name */
+security_label_type2:
+ DATABASE { $$ = OBJECT_DATABASE; }
+ | EVENT TRIGGER { $$ = OBJECT_EVENT_TRIGGER; }
+ | opt_procedural LANGUAGE { $$ = OBJECT_LANGUAGE; }
+ | ROLE { $$ = OBJECT_ROLE; }
+ | SCHEMA { $$ = OBJECT_SCHEMA; }
+ | TABLESPACE { $$ = OBJECT_TABLESPACE; }
+ ;
+
security_label: Sconst { $$ = $1; }
| NULL_P { $$ = NULL; }
;
@@ -7632,8 +7624,7 @@ RemoveFuncStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($3->funcname);
- n->arguments = list_make1($3->funcargs);
+ n->objects = list_make1($3);
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
@@ -7643,8 +7634,7 @@ RemoveFuncStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($5->funcname);
- n->arguments = list_make1($5->funcargs);
+ n->objects = list_make1($5);
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7657,8 +7647,7 @@ RemoveAggrStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($3->funcname);
- n->arguments = list_make1($3->funcargs);
+ n->objects = list_make1($3);
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
@@ -7668,8 +7657,7 @@ RemoveAggrStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($5->funcname);
- n->arguments = list_make1($5->funcargs);
+ n->objects = list_make1($5);
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7682,8 +7670,7 @@ RemoveOperStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($3->funcname);
- n->arguments = list_make1($3->funcargs);
+ n->objects = list_make1($3);
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
@@ -7693,8 +7680,7 @@ RemoveOperStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($5->funcname);
- n->arguments = list_make1($5->funcargs);
+ n->objects = list_make1($5);
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7820,8 +7806,7 @@ DropCastStmt: DROP CAST opt_if_exists '(' Typename AS Typename ')' opt_drop_beha
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_CAST;
- n->objects = list_make1(list_make1($5));
- n->arguments = list_make1(list_make1($7));
+ n->objects = list_make1(list_make2($5, $7));
n->behavior = $9;
n->missing_ok = $3;
n->concurrent = false;
@@ -7875,8 +7860,7 @@ DropTransformStmt: DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_d
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_TRANSFORM;
- n->objects = list_make1(list_make1($5));
- n->arguments = list_make1(list_make1(makeString($7)));
+ n->objects = list_make1(list_make2($5, makeString($7)));
n->behavior = $8;
n->missing_ok = $3;
$$ = (Node *)n;
@@ -7983,8 +7967,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_AGGREGATE;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = (Node *) $3;
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -7993,7 +7976,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_COLLATION;
- n->object = $3;
+ n->object = (Node *) $3;
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8002,7 +7985,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_CONVERSION;
- n->object = $3;
+ n->object = (Node *) $3;
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8020,7 +8003,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_DOMAIN;
- n->object = $3;
+ n->object = (Node *) $3;
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8029,7 +8012,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_DOMCONSTRAINT;
- n->object = $3;
+ n->object = (Node *) $3;
n->subname = $6;
n->newname = $8;
$$ = (Node *)n;
@@ -8038,7 +8021,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_FDW;
- n->object = list_make1(makeString($5));
+ n->object = (Node *) makeString($5);
n->newname = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8047,8 +8030,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_FUNCTION;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = (Node *) $3;
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8066,7 +8048,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_LANGUAGE;
- n->object = list_make1(makeString($4));
+ n->object = (Node *) makeString($4);
n->newname = $7;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8075,7 +8057,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_OPCLASS;
- n->object = lcons(makeString($6), $4);
+ n->object = (Node *) lcons(makeString($6), $4);
n->newname = $9;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8084,7 +8066,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_OPFAMILY;
- n->object = lcons(makeString($6), $4);
+ n->object = (Node *) lcons(makeString($6), $4);
n->newname = $9;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8122,7 +8104,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_FOREIGN_SERVER;
- n->object = list_make1(makeString($3));
+ n->object = (Node *) makeString($3);
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8357,7 +8339,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_EVENT_TRIGGER;
- n->object = list_make1(makeString($4));
+ n->object = (Node *) makeString($4);
n->newname = $7;
$$ = (Node *)n;
}
@@ -8392,7 +8374,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_TSPARSER;
- n->object = $5;
+ n->object = (Node *) $5;
n->newname = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8401,7 +8383,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_TSDICTIONARY;
- n->object = $5;
+ n->object = (Node *) $5;
n->newname = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8410,7 +8392,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_TSTEMPLATE;
- n->object = $5;
+ n->object = (Node *) $5;
n->newname = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8419,7 +8401,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_TSCONFIGURATION;
- n->object = $5;
+ n->object = (Node *) $5;
n->newname = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8428,7 +8410,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_TYPE;
- n->object = $3;
+ n->object = (Node *) $3;
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8466,9 +8448,7 @@ AlterObjectDependsStmt:
{
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_FUNCTION;
- n->relation = NULL;
- n->objname = $3->funcname;
- n->objargs = $3->funcargs;
+ n->objname = (Node *) $3;
n->extname = makeString($7);
$$ = (Node *)n;
}
@@ -8477,8 +8457,7 @@ AlterObjectDependsStmt:
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_TRIGGER;
n->relation = $5;
- n->objname = list_make1(makeString($3));
- n->objargs = NIL;
+ n->objname = (Node *) list_make1(makeString($3));
n->extname = makeString($9);
$$ = (Node *)n;
}
@@ -8487,8 +8466,6 @@ AlterObjectDependsStmt:
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_MATVIEW;
n->relation = $4;
- n->objname = NIL;
- n->objargs = NIL;
n->extname = makeString($8);
$$ = (Node *)n;
}
@@ -8497,8 +8474,6 @@ AlterObjectDependsStmt:
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_INDEX;
n->relation = $3;
- n->objname = NIL;
- n->objargs = NIL;
n->extname = makeString($7);
$$ = (Node *)n;
}
@@ -8515,8 +8490,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_AGGREGATE;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = (Node *) $3;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8525,7 +8499,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_COLLATION;
- n->object = $3;
+ n->object = (Node *) $3;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8534,7 +8508,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_CONVERSION;
- n->object = $3;
+ n->object = (Node *) $3;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8543,16 +8517,16 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_DOMAIN;
- n->object = $3;
+ n->object = (Node *) $3;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
}
- | ALTER EXTENSION any_name SET SCHEMA name
+ | ALTER EXTENSION name SET SCHEMA name
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_EXTENSION;
- n->object = $3;
+ n->object = (Node *) makeString($3);
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8561,8 +8535,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_FUNCTION;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = (Node *) $3;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8571,8 +8544,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_OPERATOR;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = (Node *) $3;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8581,7 +8553,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_OPCLASS;
- n->object = lcons(makeString($6), $4);
+ n->object = (Node *) lcons(makeString($6), $4);
n->newschema = $9;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8590,7 +8562,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_OPFAMILY;
- n->object = lcons(makeString($6), $4);
+ n->object = (Node *) lcons(makeString($6), $4);
n->newschema = $9;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8617,7 +8589,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_TSPARSER;
- n->object = $5;
+ n->object = (Node *) $5;
n->newschema = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8626,7 +8598,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_TSDICTIONARY;
- n->object = $5;
+ n->object = (Node *) $5;
n->newschema = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8635,7 +8607,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_TSTEMPLATE;
- n->object = $5;
+ n->object = (Node *) $5;
n->newschema = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8644,7 +8616,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_TSCONFIGURATION;
- n->object = $5;
+ n->object = (Node *) $5;
n->newschema = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8725,7 +8697,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_TYPE;
- n->object = $3;
+ n->object = (Node *) $3;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8769,8 +8741,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_AGGREGATE;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = (Node *) $3;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8778,7 +8749,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_COLLATION;
- n->object = $3;
+ n->object = (Node *) $3;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8786,7 +8757,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_CONVERSION;
- n->object = $3;
+ n->object = (Node *) $3;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8794,7 +8765,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_DATABASE;
- n->object = list_make1(makeString($3));
+ n->object = (Node *) makeString($3);
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8802,7 +8773,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_DOMAIN;
- n->object = $3;
+ n->object = (Node *) $3;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8810,8 +8781,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_FUNCTION;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = (Node *) $3;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8819,7 +8789,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_LANGUAGE;
- n->object = list_make1(makeString($4));
+ n->object = (Node *) makeString($4);
n->newowner = $7;
$$ = (Node *)n;
}
@@ -8827,7 +8797,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_LARGEOBJECT;
- n->object = list_make1($4);
+ n->object = (Node *) $4;
n->newowner = $7;
$$ = (Node *)n;
}
@@ -8835,8 +8805,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_OPERATOR;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = (Node *) $3;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8844,7 +8813,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_OPCLASS;
- n->object = lcons(makeString($6), $4);
+ n->object = (Node *) lcons(makeString($6), $4);
n->newowner = $9;
$$ = (Node *)n;
}
@@ -8852,7 +8821,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_OPFAMILY;
- n->object = lcons(makeString($6), $4);
+ n->object = (Node *) lcons(makeString($6), $4);
n->newowner = $9;
$$ = (Node *)n;
}
@@ -8860,7 +8829,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_SCHEMA;
- n->object = list_make1(makeString($3));
+ n->object = (Node *) makeString($3);
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8868,7 +8837,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_TYPE;
- n->object = $3;
+ n->object = (Node *) $3;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8876,7 +8845,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_TABLESPACE;
- n->object = list_make1(makeString($3));
+ n->object = (Node *) makeString($3);
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8884,7 +8853,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_TSDICTIONARY;
- n->object = $5;
+ n->object = (Node *) $5;
n->newowner = $8;
$$ = (Node *)n;
}
@@ -8892,7 +8861,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_TSCONFIGURATION;
- n->object = $5;
+ n->object = (Node *) $5;
n->newowner = $8;
$$ = (Node *)n;
}
@@ -8900,7 +8869,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_FDW;
- n->object = list_make1(makeString($5));
+ n->object = (Node *) makeString($5);
n->newowner = $8;
$$ = (Node *)n;
}
@@ -8908,7 +8877,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_FOREIGN_SERVER;
- n->object = list_make1(makeString($3));
+ n->object = (Node *) makeString($3);
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8916,7 +8885,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_EVENT_TRIGGER;
- n->object = list_make1(makeString($4));
+ n->object = (Node *) makeString($4);
n->newowner = $7;
$$ = (Node *)n;
}
@@ -8999,7 +8968,6 @@ DropRuleStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_RULE;
n->objects = list_make1(lappend($5, makeString($3)));
- n->arguments = NIL;
n->behavior = $6;
n->missing_ok = false;
n->concurrent = false;
@@ -9010,7 +8978,6 @@ DropRuleStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_RULE;
n->objects = list_make1(lappend($7, makeString($5)));
- n->arguments = NIL;
n->behavior = $8;
n->missing_ok = true;
n->concurrent = false;
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index 4f74208633..7bdb73cecc 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -948,10 +948,9 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
CommentStmt *stmt = makeNode(CommentStmt);
stmt->objtype = OBJECT_COLUMN;
- stmt->objname = list_make3(makeString(cxt->relation->schemaname),
- makeString(cxt->relation->relname),
- makeString(def->colname));
- stmt->objargs = NIL;
+ stmt->objname = (Node *) list_make3(makeString(cxt->relation->schemaname),
+ makeString(cxt->relation->relname),
+ makeString(def->colname));
stmt->comment = comment;
cxt->alist = lappend(cxt->alist, stmt);
@@ -1014,10 +1013,9 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
CommentStmt *stmt = makeNode(CommentStmt);
stmt->objtype = OBJECT_TABCONSTRAINT;
- stmt->objname = list_make3(makeString(cxt->relation->schemaname),
- makeString(cxt->relation->relname),
- makeString(n->conname));
- stmt->objargs = NIL;
+ stmt->objname = (Node *) list_make3(makeString(cxt->relation->schemaname),
+ makeString(cxt->relation->relname),
+ makeString(n->conname));
stmt->comment = comment;
cxt->alist = lappend(cxt->alist, stmt);
diff --git a/src/include/catalog/objectaddress.h b/src/include/catalog/objectaddress.h
index 583a1206f3..91bb7d1905 100644
--- a/src/include/catalog/objectaddress.h
+++ b/src/include/catalog/objectaddress.h
@@ -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 *objname,
+ Relation *relp,
LOCKMODE lockmode, bool missing_ok);
extern ObjectAddress get_object_address_rv(ObjectType objtype, RangeVar *rel,
- List *objname, List *objargs, Relation *relp,
+ List *objname, 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 *objname, Relation relation);
extern Oid get_object_namespace(const ObjectAddress *address);
diff --git a/src/include/commands/extension.h b/src/include/commands/extension.h
index c0e08ddf7d..ed9a7aac81 100644
--- a/src/include/commands/extension.h
+++ b/src/include/commands/extension.h
@@ -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);
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 9d8ef775e4..9fe6e9ed09 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2038,8 +2038,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 *objname; /* Qualified name of the object */
} AlterExtensionContentsStmt;
/* ----------------------
@@ -2422,8 +2421,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? */
@@ -2450,8 +2448,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 *objname; /* Qualified name of the object */
char *comment; /* Comment to insert, or NULL to remove */
} CommentStmt;
@@ -2463,8 +2460,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 *objname; /* Qualified name of the object */
char *provider; /* Label provider (or NULL) */
char *label; /* New security label to be assigned */
} SecLabelStmt;
@@ -2638,8 +2634,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 */
@@ -2656,8 +2651,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 *objname; /* name of the object */
Value *extname; /* extension name */
} AlterObjectDependsStmt;
@@ -2670,8 +2664,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;
@@ -2685,8 +2678,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;
diff --git a/src/test/regress/expected/event_trigger.out b/src/test/regress/expected/event_trigger.out
index e12455201e..906dcb8b31 100644
--- a/src/test/regress/expected/event_trigger.out
+++ b/src/test/regress/expected/event_trigger.out
@@ -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;
diff --git a/src/test/regress/expected/object_address.out b/src/test/regress/expected/object_address.out
index 7e81cdd087..b1795f6916 100644
--- a/src/test/regress/expected/object_address.out
+++ b/src/test/regress/expected/object_address.out
@@ -287,7 +287,7 @@ WARNING: error for function of access method,{eins,zwei,drei},{integer}: argume
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}', '{}');
@@ -297,39 +297,39 @@ 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
-- test successful cases
WITH objects (type, name, args) AS (VALUES
('table', '{addr_nsp, gentable}'::text[], '{}'::text[]),
diff --git a/src/test/regress/sql/event_trigger.sql b/src/test/regress/sql/event_trigger.sql
index 534f532a9e..b65bf3ec66 100644
--- a/src/test/regress/sql/event_trigger.sql
+++ b/src/test/regress/sql/event_trigger.sql
@@ -82,9 +82,6 @@
-- 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;
--
2.11.0
0004-Replace-LookupFuncNameTypeNames-with-LookupFuncWithA.patchtext/x-patch; name=0004-Replace-LookupFuncNameTypeNames-with-LookupFuncWithA.patchDownload
From 9a8a71f28fcb1f4fe453155902360eaebfc050dc Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Wed, 28 Dec 2016 12:00:00 -0500
Subject: [PATCH 4/6] Replace LookupFuncNameTypeNames() with
LookupFuncWithArgs()
The old function took function name and function argument list as
separate arguments. Now that all function signatures are passed around
as a FuncWithArgs struct, this is no longer necessary and can be
replaced by a function that takes FuncWithArgs directly. Similarly for
aggregates and operators.
---
src/backend/catalog/aclchk.c | 3 +--
src/backend/catalog/objectaddress.c | 40 +++++++++++--------------------------
src/backend/commands/functioncmds.c | 12 ++++-------
src/backend/commands/opclasscmds.c | 30 +++++++---------------------
src/backend/commands/operatorcmds.c | 5 +----
src/backend/nodes/copyfuncs.c | 2 --
src/backend/nodes/equalfuncs.c | 2 --
src/backend/parser/gram.y | 18 ++++++++---------
src/backend/parser/parse_func.c | 32 ++++++++++++++---------------
src/backend/parser/parse_oper.c | 24 ++++++++++++----------
src/include/nodes/parsenodes.h | 7 ++-----
src/include/parser/parse_func.h | 4 ++--
src/include/parser/parse_oper.h | 5 ++---
13 files changed, 68 insertions(+), 116 deletions(-)
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index fb6c276eaf..0f3e43de4c 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -661,8 +661,7 @@ objectNamesToOids(GrantObjectType objtype, List *objnames)
FuncWithArgs *func = (FuncWithArgs *) lfirst(cell);
Oid funcid;
- funcid = LookupFuncNameTypeNames(func->funcname,
- func->funcargs, false);
+ funcid = LookupFuncWithArgs(func, false);
objects = lappend_oid(objects, funcid);
}
break;
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index e444604071..e05cea7ab6 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -820,36 +820,20 @@ get_object_address(ObjectType objtype, Node *objname,
address = get_object_address_type(objtype, (TypeName *) objname, missing_ok);
break;
case OBJECT_AGGREGATE:
- {
- FuncWithArgs *fwa = (FuncWithArgs *) objname;
- address.classId = ProcedureRelationId;
- address.objectId =
- LookupAggNameTypeNames(fwa->funcname, fwa->funcargs, missing_ok);
- address.objectSubId = 0;
- break;
- }
+ address.classId = ProcedureRelationId;
+ address.objectId = LookupAggWithArgs((FuncWithArgs *) objname, missing_ok);
+ address.objectSubId = 0;
+ break;
case OBJECT_FUNCTION:
- {
- FuncWithArgs *fwa = (FuncWithArgs *) objname;
- address.classId = ProcedureRelationId;
- address.objectId =
- LookupFuncNameTypeNames(fwa->funcname, fwa->funcargs, missing_ok);
- address.objectSubId = 0;
- break;
- }
+ address.classId = ProcedureRelationId;
+ address.objectId = LookupFuncWithArgs((FuncWithArgs *) objname, missing_ok);
+ address.objectSubId = 0;
+ break;
case OBJECT_OPERATOR:
- {
- FuncWithArgs *fwa = (FuncWithArgs *) objname;
- address.classId = OperatorRelationId;
- Assert(list_length(fwa->funcargs) == 2);
- address.objectId =
- LookupOperNameTypeNames(NULL, fwa->funcname,
- (TypeName *) linitial(fwa->funcargs),
- (TypeName *) lsecond(fwa->funcargs),
- missing_ok, -1);
- address.objectSubId = 0;
- break;
- }
+ address.classId = OperatorRelationId;
+ address.objectId = LookupOperWithArgs((FuncWithArgs *) objname, missing_ok);
+ address.objectSubId = 0;
+ break;
case OBJECT_COLLATION:
address.classId = CollationRelationId;
address.objectId = get_collation_oid((List *) objname, missing_ok);
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index becafc3045..94aa34867c 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -1184,9 +1184,7 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
rel = heap_open(ProcedureRelationId, RowExclusiveLock);
- funcOid = LookupFuncNameTypeNames(stmt->func->funcname,
- stmt->func->funcargs,
- false);
+ funcOid = LookupFuncWithArgs(stmt->func, false);
tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
@@ -1461,9 +1459,7 @@ CreateCast(CreateCastStmt *stmt)
{
Form_pg_proc procstruct;
- funcid = LookupFuncNameTypeNames(stmt->func->funcname,
- stmt->func->funcargs,
- false);
+ funcid = LookupFuncWithArgs(stmt->func, false);
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tuple))
@@ -1843,7 +1839,7 @@ CreateTransform(CreateTransformStmt *stmt)
*/
if (stmt->fromsql)
{
- fromsqlfuncid = LookupFuncNameTypeNames(stmt->fromsql->funcname, stmt->fromsql->funcargs, false);
+ fromsqlfuncid = LookupFuncWithArgs(stmt->fromsql, false);
if (!pg_proc_ownercheck(fromsqlfuncid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->fromsql->funcname));
@@ -1868,7 +1864,7 @@ CreateTransform(CreateTransformStmt *stmt)
if (stmt->tosql)
{
- tosqlfuncid = LookupFuncNameTypeNames(stmt->tosql->funcname, stmt->tosql->funcargs, false);
+ tosqlfuncid = LookupFuncWithArgs(stmt->tosql, false);
if (!pg_proc_ownercheck(tosqlfuncid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->tosql->funcname));
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 1d2f8d12c1..cfda571a3e 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -478,19 +478,12 @@ DefineOpClass(CreateOpClassStmt *stmt)
errmsg("invalid operator number %d,"
" must be between 1 and %d",
item->number, maxOpNumber)));
- if (item->args != NIL)
- {
- TypeName *typeName1 = (TypeName *) linitial(item->args);
- TypeName *typeName2 = (TypeName *) lsecond(item->args);
-
- operOid = LookupOperNameTypeNames(NULL, item->name,
- typeName1, typeName2,
- false, -1);
- }
+ if (item->name->funcargs != NIL)
+ operOid = LookupOperWithArgs(item->name, false);
else
{
/* Default to binary op on input datatype */
- operOid = LookupOperName(NULL, item->name,
+ operOid = LookupOperName(NULL, item->name->funcname,
typeoid, typeoid,
false, -1);
}
@@ -529,8 +522,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
errmsg("invalid procedure number %d,"
" must be between 1 and %d",
item->number, maxProcNumber)));
- funcOid = LookupFuncNameTypeNames(item->name, item->args,
- false);
+ funcOid = LookupFuncWithArgs(item->name, false);
#ifdef NOT_USED
/* XXX this is unnecessary given the superuser check above */
/* Caller must own function */
@@ -863,15 +855,8 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
errmsg("invalid operator number %d,"
" must be between 1 and %d",
item->number, maxOpNumber)));
- if (item->args != NIL)
- {
- TypeName *typeName1 = (TypeName *) linitial(item->args);
- TypeName *typeName2 = (TypeName *) lsecond(item->args);
-
- operOid = LookupOperNameTypeNames(NULL, item->name,
- typeName1, typeName2,
- false, -1);
- }
+ if (item->name->funcargs != NIL)
+ operOid = LookupOperWithArgs(item->name, false);
else
{
ereport(ERROR,
@@ -914,8 +899,7 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
errmsg("invalid procedure number %d,"
" must be between 1 and %d",
item->number, maxProcNumber)));
- funcOid = LookupFuncNameTypeNames(item->name, item->args,
- false);
+ funcOid = LookupFuncWithArgs(item->name, false);
#ifdef NOT_USED
/* XXX this is unnecessary given the superuser check above */
/* Caller must own function */
diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c
index 67d08d862b..35b18b0577 100644
--- a/src/backend/commands/operatorcmds.c
+++ b/src/backend/commands/operatorcmds.c
@@ -402,10 +402,7 @@ AlterOperator(AlterOperatorStmt *stmt)
Oid joinOid;
/* Look up the operator */
- oprId = LookupOperNameTypeNames(NULL, stmt->opername,
- (TypeName *) linitial(stmt->operargs),
- (TypeName *) lsecond(stmt->operargs),
- false, -1);
+ oprId = LookupOperWithArgs(stmt->opername, false);
catalog = heap_open(OperatorRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(oprId));
if (tup == NULL)
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 13f7f110fb..b36718ad93 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -3278,7 +3278,6 @@ _copyAlterOperatorStmt(const AlterOperatorStmt *from)
AlterOperatorStmt *newnode = makeNode(AlterOperatorStmt);
COPY_NODE_FIELD(opername);
- COPY_NODE_FIELD(operargs);
COPY_NODE_FIELD(options);
return newnode;
@@ -3451,7 +3450,6 @@ _copyCreateOpClassItem(const CreateOpClassItem *from)
COPY_SCALAR_FIELD(itemtype);
COPY_NODE_FIELD(name);
- COPY_NODE_FIELD(args);
COPY_SCALAR_FIELD(number);
COPY_NODE_FIELD(order_family);
COPY_NODE_FIELD(class_args);
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index 3538932662..dcaac81975 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -1375,7 +1375,6 @@ static bool
_equalAlterOperatorStmt(const AlterOperatorStmt *a, const AlterOperatorStmt *b)
{
COMPARE_NODE_FIELD(opername);
- COMPARE_NODE_FIELD(operargs);
COMPARE_NODE_FIELD(options);
return true;
@@ -1520,7 +1519,6 @@ _equalCreateOpClassItem(const CreateOpClassItem *a, const CreateOpClassItem *b)
{
COMPARE_SCALAR_FIELD(itemtype);
COMPARE_NODE_FIELD(name);
- COMPARE_NODE_FIELD(args);
COMPARE_SCALAR_FIELD(number);
COMPARE_NODE_FIELD(order_family);
COMPARE_NODE_FIELD(class_args);
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index c7d08784f4..6d15297bee 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -5715,9 +5715,11 @@ opclass_item:
OPERATOR Iconst any_operator opclass_purpose opt_recheck
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
+ FuncWithArgs *fwa = makeNode(FuncWithArgs);
+ fwa->funcname = $3;
+ fwa->funcargs = NIL;
n->itemtype = OPCLASS_ITEM_OPERATOR;
- n->name = $3;
- n->args = NIL;
+ n->name = fwa;
n->number = $2;
n->order_family = $4;
$$ = (Node *) n;
@@ -5727,8 +5729,7 @@ opclass_item:
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_OPERATOR;
- n->name = $3->funcname;
- n->args = $3->funcargs;
+ n->name = $3;
n->number = $2;
n->order_family = $4;
$$ = (Node *) n;
@@ -5737,8 +5738,7 @@ opclass_item:
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION;
- n->name = $3->funcname;
- n->args = $3->funcargs;
+ n->name = $3;
n->number = $2;
$$ = (Node *) n;
}
@@ -5746,8 +5746,7 @@ opclass_item:
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION;
- n->name = $6->funcname;
- n->args = $6->funcargs;
+ n->name = $6;
n->number = $2;
n->class_args = $4;
$$ = (Node *) n;
@@ -8714,8 +8713,7 @@ AlterOperatorStmt:
ALTER OPERATOR operator_with_argtypes SET '(' operator_def_list ')'
{
AlterOperatorStmt *n = makeNode(AlterOperatorStmt);
- n->opername = $3->funcname;
- n->operargs = $3->funcargs;
+ n->opername = $3;
n->options = $6;
$$ = (Node *)n;
}
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index 7d9b4157d4..c46b226cfd 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -1933,19 +1933,19 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError)
}
/*
- * LookupFuncNameTypeNames
+ * LookupFuncWithArgs
* Like LookupFuncName, but the argument types are specified by a
- * list of TypeName nodes.
+ * FuncWithArgs node.
*/
Oid
-LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
+LookupFuncWithArgs(FuncWithArgs *func, bool noError)
{
Oid argoids[FUNC_MAX_ARGS];
int argcount;
int i;
ListCell *args_item;
- argcount = list_length(argtypes);
+ argcount = list_length(func->funcargs);
if (argcount > FUNC_MAX_ARGS)
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
@@ -1954,7 +1954,7 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
FUNC_MAX_ARGS,
FUNC_MAX_ARGS)));
- args_item = list_head(argtypes);
+ args_item = list_head(func->funcargs);
for (i = 0; i < argcount; i++)
{
TypeName *t = (TypeName *) lfirst(args_item);
@@ -1963,19 +1963,19 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
args_item = lnext(args_item);
}
- return LookupFuncName(funcname, argcount, argoids, noError);
+ return LookupFuncName(func->funcname, argcount, argoids, noError);
}
/*
- * LookupAggNameTypeNames
- * Find an aggregate function given a name and list of TypeName nodes.
+ * LookupAggWithArgs
+ * Find an aggregate function from a given FuncWithArgs node.
*
- * This is almost like LookupFuncNameTypeNames, but the error messages refer
+ * This is almost like LookupFuncWithArgs, but the error messages refer
* to aggregates rather than plain functions, and we verify that the found
* function really is an aggregate.
*/
Oid
-LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
+LookupAggWithArgs(FuncWithArgs *agg, bool noError)
{
Oid argoids[FUNC_MAX_ARGS];
int argcount;
@@ -1985,7 +1985,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
HeapTuple ftup;
Form_pg_proc pform;
- argcount = list_length(argtypes);
+ argcount = list_length(agg->funcargs);
if (argcount > FUNC_MAX_ARGS)
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
@@ -1995,7 +1995,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
FUNC_MAX_ARGS)));
i = 0;
- foreach(lc, argtypes)
+ foreach(lc, agg->funcargs)
{
TypeName *t = (TypeName *) lfirst(lc);
@@ -2003,7 +2003,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
i++;
}
- oid = LookupFuncName(aggname, argcount, argoids, true);
+ oid = LookupFuncName(agg->funcname, argcount, argoids, true);
if (!OidIsValid(oid))
{
@@ -2013,12 +2013,12 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("aggregate %s(*) does not exist",
- NameListToString(aggname))));
+ NameListToString(agg->funcname))));
else
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("aggregate %s does not exist",
- func_signature_string(aggname, argcount,
+ func_signature_string(agg->funcname, argcount,
NIL, argoids))));
}
@@ -2037,7 +2037,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("function %s is not an aggregate",
- func_signature_string(aggname, argcount,
+ func_signature_string(agg->funcname, argcount,
NIL, argoids))));
}
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index aecda6d933..3747a870f3 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -132,32 +132,34 @@ LookupOperName(ParseState *pstate, List *opername, Oid oprleft, Oid oprright,
}
/*
- * LookupOperNameTypeNames
+ * LookupOperWithArgs
* Like LookupOperName, but the argument types are specified by
- * TypeName nodes.
- *
- * Pass oprleft = NULL for a prefix op, oprright = NULL for a postfix op.
+ * a FuncWithArg node.
*/
Oid
-LookupOperNameTypeNames(ParseState *pstate, List *opername,
- TypeName *oprleft, TypeName *oprright,
- bool noError, int location)
+LookupOperWithArgs(FuncWithArgs *oper, bool noError)
{
+ TypeName *oprleft,
+ *oprright;
Oid leftoid,
rightoid;
+ Assert(list_length(oper->funcargs) == 2);
+ oprleft = linitial(oper->funcargs);
+ oprright = lsecond(oper->funcargs);
+
if (oprleft == NULL)
leftoid = InvalidOid;
else
- leftoid = LookupTypeNameOid(pstate, oprleft, noError);
+ leftoid = LookupTypeNameOid(NULL, oprleft, noError);
if (oprright == NULL)
rightoid = InvalidOid;
else
- rightoid = LookupTypeNameOid(pstate, oprright, noError);
+ rightoid = LookupTypeNameOid(NULL, oprright, noError);
- return LookupOperName(pstate, opername, leftoid, rightoid,
- noError, location);
+ return LookupOperName(NULL, oper->funcname, leftoid, rightoid,
+ noError, -1);
}
/*
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 9fe6e9ed09..e10b8da99f 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2379,9 +2379,7 @@ typedef struct CreateOpClassItem
{
NodeTag type;
int itemtype; /* see codes above */
- /* fields used for an operator or function item: */
- List *name; /* operator or function name */
- List *args; /* argument types */
+ FuncWithArgs *name; /* operator or function name and args */
int number; /* strategy num or support proc num */
List *order_family; /* only used for ordering operators */
List *class_args; /* only used for functions */
@@ -2690,8 +2688,7 @@ typedef struct AlterOwnerStmt
typedef struct AlterOperatorStmt
{
NodeTag type;
- List *opername; /* operator name */
- List *operargs; /* operator's argument TypeNames */
+ FuncWithArgs *opername; /* operator name and argument types */
List *options; /* List of DefElem nodes */
} AlterOperatorStmt;
diff --git a/src/include/parser/parse_func.h b/src/include/parser/parse_func.h
index ed16d36982..b1a5494d73 100644
--- a/src/include/parser/parse_func.h
+++ b/src/include/parser/parse_func.h
@@ -62,9 +62,9 @@ extern const char *func_signature_string(List *funcname, int nargs,
extern Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes,
bool noError);
-extern Oid LookupFuncNameTypeNames(List *funcname, List *argtypes,
+extern Oid LookupFuncWithArgs(FuncWithArgs *func,
bool noError);
-extern Oid LookupAggNameTypeNames(List *aggname, List *argtypes,
+extern Oid LookupAggWithArgs(FuncWithArgs *agg,
bool noError);
extern void check_srf_call_placement(ParseState *pstate, int location);
diff --git a/src/include/parser/parse_oper.h b/src/include/parser/parse_oper.h
index 03bb5b9a14..51c1247a61 100644
--- a/src/include/parser/parse_oper.h
+++ b/src/include/parser/parse_oper.h
@@ -15,6 +15,7 @@
#define PARSE_OPER_H
#include "access/htup.h"
+#include "nodes/parsenodes.h"
#include "parser/parse_node.h"
@@ -24,9 +25,7 @@ typedef HeapTuple Operator;
extern Oid LookupOperName(ParseState *pstate, List *opername,
Oid oprleft, Oid oprright,
bool noError, int location);
-extern Oid LookupOperNameTypeNames(ParseState *pstate, List *opername,
- TypeName *oprleft, TypeName *oprright,
- bool noError, int location);
+extern Oid LookupOperWithArgs(FuncWithArgs *oper, bool noError);
/* Routines to find operators matching a name and given input types */
/* NB: the selected operator may require coercion of the input types! */
--
2.11.0
0005-Allow-dropping-multiple-functions-at-once.patchtext/x-patch; name=0005-Allow-dropping-multiple-functions-at-once.patchDownload
From 99be3fd1b79108c0f040a94de4615bd45cc16a9e Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Wed, 28 Dec 2016 12:00:00 -0500
Subject: [PATCH 5/6] Allow dropping multiple functions at once
The generic drop support already supported dropping multiple objects of
the same kind at once. But the previous representation
of function signatures across two grammar symbols and structure members
made this cumbersome to do for functions, so it was not supported. Now
that function signatures are represented by a single structure, it's
trivial to add this support. Same for aggregates and operators.
---
doc/src/sgml/ref/drop_aggregate.sgml | 2 +-
doc/src/sgml/ref/drop_function.sgml | 2 +-
doc/src/sgml/ref/drop_operator.sgml | 2 +-
src/backend/parser/gram.y | 38 ++++++++++++++++---------
src/test/regress/expected/create_function_3.out | 6 ++--
src/test/regress/sql/create_function_3.sql | 2 ++
6 files changed, 32 insertions(+), 20 deletions(-)
diff --git a/doc/src/sgml/ref/drop_aggregate.sgml b/doc/src/sgml/ref/drop_aggregate.sgml
index c27c5eadf9..f239d39dda 100644
--- a/doc/src/sgml/ref/drop_aggregate.sgml
+++ b/doc/src/sgml/ref/drop_aggregate.sgml
@@ -21,7 +21,7 @@
<refsynopsisdiv>
<synopsis>
-DROP AGGREGATE [ IF EXISTS ] <replaceable>name</replaceable> ( <replaceable>aggregate_signature</replaceable> ) [ CASCADE | RESTRICT ]
+DROP AGGREGATE [ IF EXISTS ] <replaceable>name</replaceable> ( <replaceable>aggregate_signature</replaceable> ) [, ...] [ CASCADE | RESTRICT ]
<phrase>where <replaceable>aggregate_signature</replaceable> is:</phrase>
diff --git a/doc/src/sgml/ref/drop_function.sgml b/doc/src/sgml/ref/drop_function.sgml
index 5883d13811..ad76c954de 100644
--- a/doc/src/sgml/ref/drop_function.sgml
+++ b/doc/src/sgml/ref/drop_function.sgml
@@ -21,7 +21,7 @@
<refsynopsisdiv>
<synopsis>
-DROP FUNCTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] )
+DROP FUNCTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) [, ...]
[ CASCADE | RESTRICT ]
</synopsis>
</refsynopsisdiv>
diff --git a/doc/src/sgml/ref/drop_operator.sgml b/doc/src/sgml/ref/drop_operator.sgml
index 13dd974f38..e196547499 100644
--- a/doc/src/sgml/ref/drop_operator.sgml
+++ b/doc/src/sgml/ref/drop_operator.sgml
@@ -21,7 +21,7 @@
<refsynopsisdiv>
<synopsis>
-DROP OPERATOR [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> ( { <replaceable class="PARAMETER">left_type</replaceable> | NONE } , { <replaceable class="PARAMETER">right_type</replaceable> | NONE } ) [ CASCADE | RESTRICT ]
+DROP OPERATOR [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> ( { <replaceable class="PARAMETER">left_type</replaceable> | NONE } , { <replaceable class="PARAMETER">right_type</replaceable> | NONE } ) [, ...] [ CASCADE | RESTRICT ]
</synopsis>
</refsynopsisdiv>
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 6d15297bee..1eacdf1e82 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -346,7 +346,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <list> privileges privilege_list
%type <privtarget> privilege_target
%type <funwithargs> function_with_argtypes aggregate_with_argtypes operator_with_argtypes
-%type <list> function_with_argtypes_list
+%type <list> function_with_argtypes_list aggregate_with_argtypes_list operator_with_argtypes_list
%type <ival> defacl_privilege_target
%type <defelt> DefACLOption
%type <list> DefACLOptionList
@@ -7438,6 +7438,12 @@ aggregate_with_argtypes:
}
;
+aggregate_with_argtypes_list:
+ aggregate_with_argtypes { $$ = list_make1($1); }
+ | aggregate_with_argtypes_list ',' aggregate_with_argtypes
+ { $$ = lappend($1, $3); }
+ ;
+
createfunc_opt_list:
/* Must be at least one to prevent conflict */
createfunc_opt_item { $$ = list_make1($1); }
@@ -7619,21 +7625,21 @@ opt_restrict:
*****************************************************************************/
RemoveFuncStmt:
- DROP FUNCTION function_with_argtypes opt_drop_behavior
+ DROP FUNCTION function_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($3);
+ n->objects = $3;
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
$$ = (Node *)n;
}
- | DROP FUNCTION IF_P EXISTS function_with_argtypes opt_drop_behavior
+ | DROP FUNCTION IF_P EXISTS function_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($5);
+ n->objects = $5;
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7642,21 +7648,21 @@ RemoveFuncStmt:
;
RemoveAggrStmt:
- DROP AGGREGATE aggregate_with_argtypes opt_drop_behavior
+ DROP AGGREGATE aggregate_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($3);
+ n->objects = $3;
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
$$ = (Node *)n;
}
- | DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes opt_drop_behavior
+ | DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($5);
+ n->objects = $5;
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7665,21 +7671,21 @@ RemoveAggrStmt:
;
RemoveOperStmt:
- DROP OPERATOR operator_with_argtypes opt_drop_behavior
+ DROP OPERATOR operator_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($3);
+ n->objects = $3;
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
$$ = (Node *)n;
}
- | DROP OPERATOR IF_P EXISTS operator_with_argtypes opt_drop_behavior
+ | DROP OPERATOR IF_P EXISTS operator_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($5);
+ n->objects = $5;
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7711,6 +7717,12 @@ any_operator:
{ $$ = lcons(makeString($1), $3); }
;
+operator_with_argtypes_list:
+ operator_with_argtypes { $$ = list_make1($1); }
+ | operator_with_argtypes_list ',' operator_with_argtypes
+ { $$ = lappend($1, $3); }
+ ;
+
operator_with_argtypes:
any_operator oper_argtypes
{
diff --git a/src/test/regress/expected/create_function_3.out b/src/test/regress/expected/create_function_3.out
index 7bb957b51b..cc4e98a1d4 100644
--- a/src/test/regress/expected/create_function_3.out
+++ b/src/test/regress/expected/create_function_3.out
@@ -217,9 +217,10 @@ SELECT routine_name, ordinal_position, parameter_name, parameter_default
functest_is_3 | 2 | b |
(7 rows)
+DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int);
-- Cleanups
DROP SCHEMA temp_func_test CASCADE;
-NOTICE: drop cascades to 19 other objects
+NOTICE: drop cascades to 16 other objects
DETAIL: drop cascades to function functest_a_1(text,date)
drop cascades to function functest_a_2(text[])
drop cascades to function functest_a_3()
@@ -236,8 +237,5 @@ drop cascades to function functext_f_1(integer)
drop cascades to function functext_f_2(integer)
drop cascades to function functext_f_3(integer)
drop cascades to function functext_f_4(integer)
-drop cascades to function functest_is_1(integer,integer,text)
-drop cascades to function functest_is_2(integer)
-drop cascades to function functest_is_3(integer)
DROP USER regress_unpriv_user;
RESET search_path;
diff --git a/src/test/regress/sql/create_function_3.sql b/src/test/regress/sql/create_function_3.sql
index 43454ef2f7..66a463b089 100644
--- a/src/test/regress/sql/create_function_3.sql
+++ b/src/test/regress/sql/create_function_3.sql
@@ -156,6 +156,8 @@ CREATE FUNCTION functest_IS_3(a int default 1, out b int)
WHERE routine_schema = 'temp_func_test' AND routine_name ~ '^functest_is_'
ORDER BY 1, 2;
+DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int);
+
-- Cleanups
DROP SCHEMA temp_func_test CASCADE;
--
2.11.0
On Sat, Dec 31, 2016 at 11:17 AM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
On 12/1/16 9:32 PM, Peter Eisentraut wrote:
I think it would be better to get rid of objargs and have objname be a
general Node that can contain more specific node types so that there is
some amount of type tracking. FuncWithArgs would be one such type,
Typename would be another, Value would be used for simple strings, and
we could create some other ones, or stick with lcons for some simple
cases. But then we don't have to make stuff into one-item lists to just
to satisfy the currently required List.That's the general idea. But that's a rather big change that I would
rather break down into smaller pieces.People wanted to the whole thing at once, so here it is.
Patches 0001 and 0002 are some prep work. Patch 0003 is the main patch
that removes the objargs fields and changes the objname to a generic
Node*. 0004 is an API simplification that could be committed together
with 0003 but I kept it separate for easier review. 0005 accomplishes
the DROP FUNCTION changes. 0006 is some other cleanup that fell out of
this.
I haven't reviewed this in any detail but I think the general approach
is sensible.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Forwarding some comments I neglected to send to the list...
On 1/3/17 9:16 AM, Peter Eisentraut wrote:
On 1/2/17 1:04 PM, Jim Nasby wrote:
On 12/31/16 10:17 AM, Peter Eisentraut wrote:
--- a/src/test/regress/expected/event_trigger.out +++ b/src/test/regress/expected/event_trigger.out @@ -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 failI'm guessing that's a spurious change...
Well, the test is no longer useful as it was before, because the parser
just rejects the command.Ah. I would have just left it in to make sure a sane error was still
generated, so I was wondering if something else was going on.
+++ b/src/test/regress/expected/object_address.out @@ -287,7 +287,7 @@ WARNING: error for function of access method,{eins,zwei,drei},{integer}: argume 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 1Arguably, in this usage, that should be array length, not list length.
IIRC there's a function that will map an object type to it's name, so it
wouldn't be hard to restore the previous error message if you wanted to
go that route. pg_get_object_address() has to do a bunch of similar
error checks too, maybe there's a way to combine this stuff.It's somewhat unfortunate that
pg_get_object_address()/pg_identify_object_as_address() won't match
these changes, but I don't see any good way to fix that.BTW, it would also be damn nice if there was some form of wildcard
available for DROP FUNCTION (and maybe ALTER). If you've created several
overloaded versions of a function, making sure you change all of them
can be a PITA.Yeah, that's the next patch after this. ;-)
Yay :)
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532)
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Import Notes
Reply to msg id not found: cfe537ff-1ae8-d7c7-a5c2-72d23bcdd713@BlueTreble.com
On Sun, Jan 1, 2017 at 1:17 AM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
On 12/1/16 9:32 PM, Peter Eisentraut wrote:
I think it would be better to get rid of objargs and have objname be a
general Node that can contain more specific node types so that there is
some amount of type tracking. FuncWithArgs would be one such type,
Typename would be another, Value would be used for simple strings, and
we could create some other ones, or stick with lcons for some simple
cases. But then we don't have to make stuff into one-item lists to just
to satisfy the currently required List.That's the general idea. But that's a rather big change that I would
rather break down into smaller pieces.People wanted to the whole thing at once, so here it is.
Patches 0001 and 0002 are some prep work. Patch 0003 is the main patch
that removes the objargs fields and changes the objname to a generic
Node*. 0004 is an API simplification that could be committed together
with 0003 but I kept it separate for easier review. 0005 accomplishes
the DROP FUNCTION changes. 0006 is some other cleanup that fell out of
this.
I don't see any problems with 0001. In 0002, the comment of
class_args/CreateOpClassItem in parsenodes.h needs to be updated,
because this becomes used by operators as well.
Regarding 0003, which is large, but actually quite simple... The
approach makes sense. All the checks on the object formats are moved
out of the static routines in objectaddress.c and moved into a single
place.
+ if (list_length(name) != 1)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("name list length must be exactly %d", 1)));
+ objnode = linitial(name);
Those are the sanity checks for each object are moved to
pg_get_object_address(). This has as result some loss of verbosity in
the error messages. As the object type is passed by the user when
calling the SQL-callable interface, this new way looks fine to me.
One comment though: there are still many list_make2() or even
list_make3 calls for some object types. Would it make sense to replace
those lists with a decided number of items by a Node and simplify the
interface? Using a Node instead of a list would save some cycles. OK
that's really few though as that's basically comparing a list lookup
with a direct pointer lookup.
+ | DROP drop_type1 any_name_list opt_drop_behavior
+ {
+ DropStmt *n = makeNode(DropStmt);
+ n->removeType = $2;
+ n->missing_ok = FALSE;
+ n->objects = $3;
+ n->behavior = $4;
+ n->concurrent = false;
+ $$ = (Node *)n;
+ }
+ | DROP drop_type2 IF_P EXISTS name_list opt_drop_behavior
+ {
drop_type1 and drop_type2 are not really explicit, especially after
reading that one allows schema-qualified names, not the other. Could
you use something like drop_type_qualified? The same applies to
comment_type and security_label.
0004 could be merged with 0002, no? That looks good to me.
In 0005, a nit:
+DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int),
functest_IS_3(int);
-- Cleanups
The DROP query could be moved below the cleanup comment.
It may be a good idea to add an example of query dropping two
functions at once in the docs.
Could you add some regression tests for the drop of aggregates and
operators to stress the parsing code path?
While looking at 0006... DROP POLICY and DROP RULE could be unified. I
just noticed that while reading the code.
This patch series look in rather good shape to me at the end.
--
Michael
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 1/10/17 1:52 AM, Michael Paquier wrote:
I don't see any problems with 0001.
I was wondering, should we rename funcname -> name, and funcargs ->
args, or perhaps the whole FuncWithArgs struct, so there is no confusion
when used with operators?
In 0002, the comment of
class_args/CreateOpClassItem in parsenodes.h needs to be updated,
because this becomes used by operators as well.
I think that aspect might be a mistake in my patch. I'll check this
further, but I think the comment ought to remain true.
One comment though: there are still many list_make2() or even
list_make3 calls for some object types. Would it make sense to replace
those lists with a decided number of items by a Node and simplify the
interface?
(I don't see any list_make3.) It would be nice to refine this further,
but the remaining uses are quite marginal. The main problem was that
before you had to create singleton lists and then unpack them, because
there was no other way. The remaining uses are more genuine lists or lcons.
drop_type1 and drop_type2 are not really explicit, especially after
reading that one allows schema-qualified names, not the other. Could
you use something like drop_type_qualified? The same applies to
comment_type and security_label.
Yeah, I'll try to find better names.
0004 could be merged with 0002, no? That looks good to me.
I think 0001 through 0004 would be committed together. The split is
just for review.
In 0005, a nit: +DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int); -- Cleanups The DROP query could be moved below the cleanup comment.
I can do that, but the idea was that the commands below the cleanups
line weren't really tests.
It may be a good idea to add an example of query dropping two
functions at once in the docs.
Yes.
Could you add some regression tests for the drop of aggregates and
operators to stress the parsing code path?
Yes.
While looking at 0006... DROP POLICY and DROP RULE could be unified. I
just noticed that while reading the code.
DROP TRIGGER also looks similar. drop_type3 then. ;-)
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Wed, Jan 18, 2017 at 5:26 AM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
On 1/10/17 1:52 AM, Michael Paquier wrote:
I don't see any problems with 0001.
I was wondering, should we rename funcname -> name, and funcargs ->
args, or perhaps the whole FuncWithArgs struct, so there is no confusion
when used with operators?
FuncWithArgs implies that this is related to a function, so removing
func as prefix may make things cleaner.
One comment though: there are still many list_make2() or even
list_make3 calls for some object types. Would it make sense to replace
those lists with a decided number of items by a Node and simplify the
interface?(I don't see any list_make3.)
Indeed, I am watching too much code.
It would be nice to refine this further,
but the remaining uses are quite marginal. The main problem was that
before you had to create singleton lists and then unpack them, because
there was no other way. The remaining uses are more genuine lists or lcons.
OK. Of course, I am not saying that this patch in particular should
shake more the world. I have been just trying to point out future
potential improvements and keep a trace of them in the archives while
thinking about it.
In 0005, a nit: +DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int); -- Cleanups The DROP query could be moved below the cleanup comment.I can do that, but the idea was that the commands below the cleanups
line weren't really tests.
That's a nit, you can ignore that.
While looking at 0006... DROP POLICY and DROP RULE could be unified. I
just noticed that while reading the code.DROP TRIGGER also looks similar. drop_type3 then. ;-)
Or drop_type_on, drop_type_on_table, etc.
--
Michael
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Wed, Jan 18, 2017 at 2:00 PM, Michael Paquier
<michael.paquier@gmail.com> wrote:
On Wed, Jan 18, 2017 at 5:26 AM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:On 1/10/17 1:52 AM, Michael Paquier wrote:
I don't see any problems with 0001.
I was wondering, should we rename funcname -> name, and funcargs ->
args, or perhaps the whole FuncWithArgs struct, so there is no confusion
when used with operators?FuncWithArgs implies that this is related to a function, so removing
func as prefix may make things cleaner.One comment though: there are still many list_make2() or even
list_make3 calls for some object types. Would it make sense to replace
those lists with a decided number of items by a Node and simplify the
interface?(I don't see any list_make3.)
Indeed, I am watching too much code.
It would be nice to refine this further,
but the remaining uses are quite marginal. The main problem was that
before you had to create singleton lists and then unpack them, because
there was no other way. The remaining uses are more genuine lists or lcons.OK. Of course, I am not saying that this patch in particular should
shake more the world. I have been just trying to point out future
potential improvements and keep a trace of them in the archives while
thinking about it.In 0005, a nit: +DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int); -- Cleanups The DROP query could be moved below the cleanup comment.I can do that, but the idea was that the commands below the cleanups
line weren't really tests.That's a nit, you can ignore that.
While looking at 0006... DROP POLICY and DROP RULE could be unified. I
just noticed that while reading the code.DROP TRIGGER also looks similar. drop_type3 then. ;-)
Or drop_type_on, drop_type_on_table, etc.
I am marking the patch as returned with feedback, as this thread has
died 2 weeks ago.
--
Michael
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Here is a new patch set that addresses your comments. The structure is
still the same, just a bunch of things have been renamed based on
suggestions.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
v2-0001-Use-class_args-field-in-opclass_drop.patchtext/x-patch; name=v2-0001-Use-class_args-field-in-opclass_drop.patchDownload
From 40b5d7d7baefdd824283597adad866ea42dcdc42 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Wed, 28 Dec 2016 12:00:00 -0500
Subject: [PATCH v2 1/6] Use class_args field in opclass_drop
This makes it consistent with the usage in opclass_item.
---
src/backend/commands/opclasscmds.c | 4 ++--
src/backend/parser/gram.y | 4 ++--
src/include/nodes/parsenodes.h | 3 ++-
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 5f2364bccf..9bd50a3bec 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -989,7 +989,7 @@ AlterOpFamilyDrop(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
errmsg("invalid operator number %d,"
" must be between 1 and %d",
item->number, maxOpNumber)));
- processTypesSpec(item->args, &lefttype, &righttype);
+ processTypesSpec(item->class_args, &lefttype, &righttype);
/* Save the info */
member = (OpFamilyMember *) palloc0(sizeof(OpFamilyMember));
member->number = item->number;
@@ -1004,7 +1004,7 @@ AlterOpFamilyDrop(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
errmsg("invalid procedure number %d,"
" must be between 1 and %d",
item->number, maxProcNumber)));
- processTypesSpec(item->args, &lefttype, &righttype);
+ processTypesSpec(item->class_args, &lefttype, &righttype);
/* Save the info */
member = (OpFamilyMember *) palloc0(sizeof(OpFamilyMember));
member->number = item->number;
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index e833b2eba5..4921b8a1ad 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -5910,7 +5910,7 @@ opclass_drop:
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_OPERATOR;
n->number = $2;
- n->args = $4;
+ n->class_args = $4;
$$ = (Node *) n;
}
| FUNCTION Iconst '(' type_list ')'
@@ -5918,7 +5918,7 @@ opclass_drop:
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION;
n->number = $2;
- n->args = $4;
+ n->class_args = $4;
$$ = (Node *) n;
}
;
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 5afc3ebea0..a9d0d08b53 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2424,7 +2424,8 @@ typedef struct CreateOpClassItem
List *args; /* argument types */
int number; /* strategy num or support proc num */
List *order_family; /* only used for ordering operators */
- List *class_args; /* only used for functions */
+ List *class_args; /* amproclefttype/amprocrighttype or
+ * amoplefttype/amoprighttype */
/* fields used for a storagetype item: */
TypeName *storedtype; /* datatype stored in index */
} CreateOpClassItem;
--
2.11.1
v2-0002-Add-operator_with_argtypes-grammar-rule.patchtext/x-patch; name=v2-0002-Add-operator_with_argtypes-grammar-rule.patchDownload
From 57f738d114f4d5a313e05493f6fd34856babd521 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Wed, 28 Dec 2016 12:00:00 -0500
Subject: [PATCH v2 2/6] Add operator_with_argtypes grammar rule
This makes the handling of operators similar to that of functions and
aggregates.
Rename node FuncWithArgs to ObjectWithArgs, to reflect the expanded use.
---
src/backend/catalog/aclchk.c | 6 +-
src/backend/commands/functioncmds.c | 24 +++---
src/backend/nodes/copyfuncs.c | 14 +--
src/backend/nodes/equalfuncs.c | 10 +--
src/backend/parser/gram.y | 164 +++++++++++++++++++-----------------
src/include/nodes/nodes.h | 2 +-
src/include/nodes/parsenodes.h | 20 ++---
src/tools/pgindent/typedefs.list | 2 +-
8 files changed, 126 insertions(+), 116 deletions(-)
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index 79b7fd5370..7e9ed76b80 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -667,11 +667,11 @@ objectNamesToOids(GrantObjectType objtype, List *objnames)
case ACL_OBJECT_FUNCTION:
foreach(cell, objnames)
{
- FuncWithArgs *func = (FuncWithArgs *) lfirst(cell);
+ ObjectWithArgs *func = (ObjectWithArgs *) lfirst(cell);
Oid funcid;
- funcid = LookupFuncNameTypeNames(func->funcname,
- func->funcargs, false);
+ funcid = LookupFuncNameTypeNames(func->objname,
+ func->objargs, false);
objects = lappend_oid(objects, funcid);
}
break;
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index 8b1285a542..3d1b64549e 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -1181,8 +1181,8 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
rel = heap_open(ProcedureRelationId, RowExclusiveLock);
- funcOid = LookupFuncNameTypeNames(stmt->func->funcname,
- stmt->func->funcargs,
+ funcOid = LookupFuncNameTypeNames(stmt->func->objname,
+ stmt->func->objargs,
false);
tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(funcOid));
@@ -1194,13 +1194,13 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
/* Permission check: must own function */
if (!pg_proc_ownercheck(funcOid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC,
- NameListToString(stmt->func->funcname));
+ NameListToString(stmt->func->objname));
if (procForm->proisagg)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is an aggregate function",
- NameListToString(stmt->func->funcname))));
+ NameListToString(stmt->func->objname))));
/* Examine requested actions. */
foreach(l, stmt->actions)
@@ -1453,8 +1453,8 @@ CreateCast(CreateCastStmt *stmt)
{
Form_pg_proc procstruct;
- funcid = LookupFuncNameTypeNames(stmt->func->funcname,
- stmt->func->funcargs,
+ funcid = LookupFuncNameTypeNames(stmt->func->objname,
+ stmt->func->objargs,
false);
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
@@ -1836,14 +1836,14 @@ CreateTransform(CreateTransformStmt *stmt)
*/
if (stmt->fromsql)
{
- fromsqlfuncid = LookupFuncNameTypeNames(stmt->fromsql->funcname, stmt->fromsql->funcargs, false);
+ fromsqlfuncid = LookupFuncNameTypeNames(stmt->fromsql->objname, stmt->fromsql->objargs, false);
if (!pg_proc_ownercheck(fromsqlfuncid, GetUserId()))
- aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->fromsql->funcname));
+ aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->fromsql->objname));
aclresult = pg_proc_aclcheck(fromsqlfuncid, GetUserId(), ACL_EXECUTE);
if (aclresult != ACLCHECK_OK)
- aclcheck_error(aclresult, ACL_KIND_PROC, NameListToString(stmt->fromsql->funcname));
+ aclcheck_error(aclresult, ACL_KIND_PROC, NameListToString(stmt->fromsql->objname));
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(fromsqlfuncid));
if (!HeapTupleIsValid(tuple))
@@ -1862,14 +1862,14 @@ CreateTransform(CreateTransformStmt *stmt)
if (stmt->tosql)
{
- tosqlfuncid = LookupFuncNameTypeNames(stmt->tosql->funcname, stmt->tosql->funcargs, false);
+ tosqlfuncid = LookupFuncNameTypeNames(stmt->tosql->objname, stmt->tosql->objargs, false);
if (!pg_proc_ownercheck(tosqlfuncid, GetUserId()))
- aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->tosql->funcname));
+ aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->tosql->objname));
aclresult = pg_proc_aclcheck(tosqlfuncid, GetUserId(), ACL_EXECUTE);
if (aclresult != ACLCHECK_OK)
- aclcheck_error(aclresult, ACL_KIND_PROC, NameListToString(stmt->tosql->funcname));
+ aclcheck_error(aclresult, ACL_KIND_PROC, NameListToString(stmt->tosql->objname));
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(tosqlfuncid));
if (!HeapTupleIsValid(tuple))
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 05d8538717..35fec87842 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -2954,13 +2954,13 @@ _copyGrantStmt(const GrantStmt *from)
return newnode;
}
-static FuncWithArgs *
-_copyFuncWithArgs(const FuncWithArgs *from)
+static ObjectWithArgs *
+_copyObjectWithArgs(const ObjectWithArgs *from)
{
- FuncWithArgs *newnode = makeNode(FuncWithArgs);
+ ObjectWithArgs *newnode = makeNode(ObjectWithArgs);
- COPY_NODE_FIELD(funcname);
- COPY_NODE_FIELD(funcargs);
+ COPY_NODE_FIELD(objname);
+ COPY_NODE_FIELD(objargs);
return newnode;
}
@@ -5274,8 +5274,8 @@ copyObject(const void *from)
case T_CommonTableExpr:
retval = _copyCommonTableExpr(from);
break;
- case T_FuncWithArgs:
- retval = _copyFuncWithArgs(from);
+ case T_ObjectWithArgs:
+ retval = _copyObjectWithArgs(from);
break;
case T_AccessPriv:
retval = _copyAccessPriv(from);
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index d595cd7481..e526ef96b7 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -1095,10 +1095,10 @@ _equalGrantStmt(const GrantStmt *a, const GrantStmt *b)
}
static bool
-_equalFuncWithArgs(const FuncWithArgs *a, const FuncWithArgs *b)
+_equalObjectWithArgs(const ObjectWithArgs *a, const ObjectWithArgs *b)
{
- COMPARE_NODE_FIELD(funcname);
- COMPARE_NODE_FIELD(funcargs);
+ COMPARE_NODE_FIELD(objname);
+ COMPARE_NODE_FIELD(objargs);
return true;
}
@@ -3532,8 +3532,8 @@ equal(const void *a, const void *b)
case T_CommonTableExpr:
retval = _equalCommonTableExpr(a, b);
break;
- case T_FuncWithArgs:
- retval = _equalFuncWithArgs(a, b);
+ case T_ObjectWithArgs:
+ retval = _equalObjectWithArgs(a, b);
break;
case T_AccessPriv:
retval = _equalAccessPriv(a, b);
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 4921b8a1ad..d9696b0bd5 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -218,7 +218,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
TypeName *typnam;
FunctionParameter *fun_param;
FunctionParameterMode fun_param_mode;
- FuncWithArgs *funwithargs;
+ ObjectWithArgs *objwithargs;
DefElem *defelt;
SortBy *sortby;
WindowDef *windef;
@@ -357,7 +357,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <accesspriv> privilege
%type <list> privileges privilege_list
%type <privtarget> privilege_target
-%type <funwithargs> function_with_argtypes aggregate_with_argtypes
+%type <objwithargs> function_with_argtypes aggregate_with_argtypes operator_with_argtypes
%type <list> function_with_argtypes_list
%type <ival> defacl_privilege_target
%type <defelt> DefACLOption
@@ -4255,8 +4255,8 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_AGGREGATE;
- n->objname = $6->funcname;
- n->objargs = $6->funcargs;
+ n->objname = $6->objname;
+ n->objargs = $6->objargs;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')'
@@ -4302,8 +4302,8 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_FUNCTION;
- n->objname = $6->funcname;
- n->objargs = $6->funcargs;
+ n->objname = $6->objname;
+ n->objargs = $6->objargs;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop opt_procedural LANGUAGE name
@@ -4315,14 +4315,14 @@ AlterExtensionContentsStmt:
n->objname = list_make1(makeString($7));
$$ = (Node *)n;
}
- | ALTER EXTENSION name add_drop OPERATOR any_operator oper_argtypes
+ | ALTER EXTENSION name add_drop OPERATOR operator_with_argtypes
{
AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_OPERATOR;
- n->objname = $6;
- n->objargs = $7;
+ n->objname = $6->objname;
+ n->objargs = $6->objargs;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING access_method
@@ -5798,23 +5798,23 @@ opclass_item:
n->order_family = $4;
$$ = (Node *) n;
}
- | OPERATOR Iconst any_operator oper_argtypes opclass_purpose
+ | OPERATOR Iconst operator_with_argtypes opclass_purpose
opt_recheck
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_OPERATOR;
- n->name = $3;
- n->args = $4;
+ n->name = $3->objname;
+ n->args = $3->objargs;
n->number = $2;
- n->order_family = $5;
+ n->order_family = $4;
$$ = (Node *) n;
}
| FUNCTION Iconst function_with_argtypes
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION;
- n->name = $3->funcname;
- n->args = $3->funcargs;
+ n->name = $3->objname;
+ n->args = $3->objargs;
n->number = $2;
$$ = (Node *) n;
}
@@ -5822,8 +5822,8 @@ opclass_item:
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION;
- n->name = $6->funcname;
- n->args = $6->funcargs;
+ n->name = $6->objname;
+ n->args = $6->objargs;
n->number = $2;
n->class_args = $4;
$$ = (Node *) n;
@@ -6219,8 +6219,8 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_AGGREGATE;
- n->objname = $4->funcname;
- n->objargs = $4->funcargs;
+ n->objname = $4->objname;
+ n->objargs = $4->objargs;
n->comment = $6;
$$ = (Node *) n;
}
@@ -6228,18 +6228,18 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_FUNCTION;
- n->objname = $4->funcname;
- n->objargs = $4->funcargs;
+ n->objname = $4->objname;
+ n->objargs = $4->objargs;
n->comment = $6;
$$ = (Node *) n;
}
- | COMMENT ON OPERATOR any_operator oper_argtypes IS comment_text
+ | COMMENT ON OPERATOR operator_with_argtypes IS comment_text
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_OPERATOR;
- n->objname = $4;
- n->objargs = $5;
- n->comment = $7;
+ n->objname = $4->objname;
+ n->objargs = $4->objargs;
+ n->comment = $6;
$$ = (Node *) n;
}
| COMMENT ON CONSTRAINT name ON any_name IS comment_text
@@ -6427,8 +6427,8 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_AGGREGATE;
- n->objname = $6->funcname;
- n->objargs = $6->funcargs;
+ n->objname = $6->objname;
+ n->objargs = $6->objargs;
n->label = $8;
$$ = (Node *) n;
}
@@ -6438,8 +6438,8 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_FUNCTION;
- n->objname = $6->funcname;
- n->objargs = $6->funcargs;
+ n->objname = $6->objname;
+ n->objargs = $6->objargs;
n->label = $8;
$$ = (Node *) n;
}
@@ -7280,9 +7280,9 @@ function_with_argtypes_list:
function_with_argtypes:
func_name func_args
{
- FuncWithArgs *n = makeNode(FuncWithArgs);
- n->funcname = $1;
- n->funcargs = extractArgTypes($2);
+ ObjectWithArgs *n = makeNode(ObjectWithArgs);
+ n->objname = $1;
+ n->objargs = extractArgTypes($2);
$$ = n;
}
;
@@ -7492,9 +7492,9 @@ aggr_args_list:
aggregate_with_argtypes:
func_name aggr_args
{
- FuncWithArgs *n = makeNode(FuncWithArgs);
- n->funcname = $1;
- n->funcargs = extractAggrArgTypes($2);
+ ObjectWithArgs *n = makeNode(ObjectWithArgs);
+ n->objname = $1;
+ n->objargs = extractAggrArgTypes($2);
$$ = n;
}
;
@@ -7684,8 +7684,8 @@ RemoveFuncStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($3->funcname);
- n->arguments = list_make1($3->funcargs);
+ n->objects = list_make1($3->objname);
+ n->arguments = list_make1($3->objargs);
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
@@ -7695,8 +7695,8 @@ RemoveFuncStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($5->funcname);
- n->arguments = list_make1($5->funcargs);
+ n->objects = list_make1($5->objname);
+ n->arguments = list_make1($5->objargs);
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7709,8 +7709,8 @@ RemoveAggrStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($3->funcname);
- n->arguments = list_make1($3->funcargs);
+ n->objects = list_make1($3->objname);
+ n->arguments = list_make1($3->objargs);
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
@@ -7720,8 +7720,8 @@ RemoveAggrStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($5->funcname);
- n->arguments = list_make1($5->funcargs);
+ n->objects = list_make1($5->objname);
+ n->arguments = list_make1($5->objargs);
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7730,24 +7730,24 @@ RemoveAggrStmt:
;
RemoveOperStmt:
- DROP OPERATOR any_operator oper_argtypes opt_drop_behavior
+ DROP OPERATOR operator_with_argtypes opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($3);
- n->arguments = list_make1($4);
- n->behavior = $5;
+ n->objects = list_make1($3->objname);
+ n->arguments = list_make1($3->objargs);
+ n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
$$ = (Node *)n;
}
- | DROP OPERATOR IF_P EXISTS any_operator oper_argtypes opt_drop_behavior
+ | DROP OPERATOR IF_P EXISTS operator_with_argtypes opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($5);
- n->arguments = list_make1($6);
- n->behavior = $7;
+ n->objects = list_make1($5->objname);
+ n->arguments = list_make1($5->objargs);
+ n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
$$ = (Node *)n;
@@ -7778,6 +7778,16 @@ any_operator:
{ $$ = lcons(makeString($1), $3); }
;
+operator_with_argtypes:
+ any_operator oper_argtypes
+ {
+ ObjectWithArgs *n = makeNode(ObjectWithArgs);
+ n->objname = $1;
+ n->objargs = $2;
+ $$ = n;
+ }
+ ;
+
/*****************************************************************************
*
* DO <anonymous code block> [ LANGUAGE language ]
@@ -8025,8 +8035,8 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_AGGREGATE;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = $3->objname;
+ n->objarg = $3->objargs;
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8089,8 +8099,8 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_FUNCTION;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = $3->objname;
+ n->objarg = $3->objargs;
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8509,8 +8519,8 @@ AlterObjectDependsStmt:
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_FUNCTION;
n->relation = NULL;
- n->objname = $3->funcname;
- n->objargs = $3->funcargs;
+ n->objname = $3->objname;
+ n->objargs = $3->objargs;
n->extname = makeString($7);
$$ = (Node *)n;
}
@@ -8557,8 +8567,8 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_AGGREGATE;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = $3->objname;
+ n->objarg = $3->objargs;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8603,19 +8613,19 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_FUNCTION;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = $3->objname;
+ n->objarg = $3->objargs;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
}
- | ALTER OPERATOR any_operator oper_argtypes SET SCHEMA name
+ | ALTER OPERATOR operator_with_argtypes SET SCHEMA name
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_OPERATOR;
- n->object = $3;
- n->objarg = $4;
- n->newschema = $7;
+ n->object = $3->objname;
+ n->objarg = $3->objargs;
+ n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
}
@@ -8781,12 +8791,12 @@ AlterObjectSchemaStmt:
*****************************************************************************/
AlterOperatorStmt:
- ALTER OPERATOR any_operator oper_argtypes SET '(' operator_def_list ')'
+ ALTER OPERATOR operator_with_argtypes SET '(' operator_def_list ')'
{
AlterOperatorStmt *n = makeNode(AlterOperatorStmt);
- n->opername = $3;
- n->operargs = $4;
- n->options = $7;
+ n->opername = $3->objname;
+ n->operargs = $3->objargs;
+ n->options = $6;
$$ = (Node *)n;
}
;
@@ -8811,8 +8821,8 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_AGGREGATE;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = $3->objname;
+ n->objarg = $3->objargs;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8852,8 +8862,8 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_FUNCTION;
- n->object = $3->funcname;
- n->objarg = $3->funcargs;
+ n->object = $3->objname;
+ n->objarg = $3->objargs;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8873,13 +8883,13 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
n->newowner = $7;
$$ = (Node *)n;
}
- | ALTER OPERATOR any_operator oper_argtypes OWNER TO RoleSpec
+ | ALTER OPERATOR operator_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_OPERATOR;
- n->object = $3;
- n->objarg = $4;
- n->newowner = $7;
+ n->object = $3->objname;
+ n->objarg = $3->objargs;
+ n->newowner = $6;
$$ = (Node *)n;
}
| ALTER OPERATOR CLASS any_name USING access_method OWNER TO RoleSpec
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index 95dd8baadd..58ad290be2 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -450,7 +450,7 @@ typedef enum NodeTag
T_SortGroupClause,
T_GroupingSet,
T_WindowClause,
- T_FuncWithArgs,
+ T_ObjectWithArgs,
T_AccessPriv,
T_CreateOpClassItem,
T_TableLikeClause,
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index a9d0d08b53..97993f5198 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -1753,7 +1753,7 @@ typedef struct GrantStmt
bool is_grant; /* true = GRANT, false = REVOKE */
GrantTargetType targtype; /* type of the grant target */
GrantObjectType objtype; /* kind of object being operated on */
- List *objects; /* list of RangeVar nodes, FuncWithArgs nodes,
+ List *objects; /* list of RangeVar nodes, ObjectWithArgs nodes,
* or plain names (as Value strings) */
List *privileges; /* list of AccessPriv nodes */
/* privileges == NIL denotes ALL PRIVILEGES */
@@ -1763,16 +1763,16 @@ typedef struct GrantStmt
} GrantStmt;
/*
- * Note: FuncWithArgs carries only the types of the input parameters of the
+ * Note: ObjectWithArgs carries only the types of the input parameters of the
* function. So it is sufficient to identify an existing function, but it
* is not enough info to define a function nor to call it.
*/
-typedef struct FuncWithArgs
+typedef struct ObjectWithArgs
{
NodeTag type;
- List *funcname; /* qualified name of function */
- List *funcargs; /* list of Typename nodes */
-} FuncWithArgs;
+ List *objname; /* qualified name of function/operator */
+ List *objargs; /* list of Typename nodes */
+} ObjectWithArgs;
/*
* An access privilege, with optional list of column names
@@ -2644,7 +2644,7 @@ typedef struct FunctionParameter
typedef struct AlterFunctionStmt
{
NodeTag type;
- FuncWithArgs *func; /* name and args of function */
+ ObjectWithArgs *func; /* name and args of function */
List *actions; /* list of DefElem */
} AlterFunctionStmt;
@@ -3138,7 +3138,7 @@ typedef struct CreateCastStmt
NodeTag type;
TypeName *sourcetype;
TypeName *targettype;
- FuncWithArgs *func;
+ ObjectWithArgs *func;
CoercionContext context;
bool inout;
} CreateCastStmt;
@@ -3153,8 +3153,8 @@ typedef struct CreateTransformStmt
bool replace;
TypeName *type_name;
char *lang;
- FuncWithArgs *fromsql;
- FuncWithArgs *tosql;
+ ObjectWithArgs *fromsql;
+ ObjectWithArgs *tosql;
} CreateTransformStmt;
/* ----------------------
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index 9f876ae264..5a47a1fe17 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -745,7 +745,6 @@ FuncDetailCode
FuncExpr
FuncExprState
FuncInfo
-FuncWithArgs
FunctionCallInfo
FunctionCallInfoData
FunctionParameter
@@ -1228,6 +1227,7 @@ ObjectAddresses
ObjectClass
ObjectPropertyType
ObjectType
+ObjectWithArgs
Offset
OffsetNumber
OffsetVarNodes_context
--
2.11.1
v2-0003-Remove-objname-objargs-split-for-referring-to-obj.patchtext/x-patch; name=v2-0003-Remove-objname-objargs-split-for-referring-to-obj.patchDownload
From b3317fe19c74fae5a301bcd3a21212ddf9d77b30 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Sat, 12 Nov 2016 12:00:00 -0500
Subject: [PATCH v2 3/6] 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.
---
src/backend/catalog/objectaddress.c | 447 +++++++++++++++------------
src/backend/commands/alter.c | 33 +-
src/backend/commands/comment.c | 11 +-
src/backend/commands/dropcmds.c | 175 +++++------
src/backend/commands/extension.c | 13 +-
src/backend/commands/seclabel.c | 4 +-
src/backend/commands/tablecmds.c | 10 +-
src/backend/commands/typecmds.c | 2 +-
src/backend/nodes/copyfuncs.c | 16 +-
src/backend/nodes/equalfuncs.c | 16 +-
src/backend/parser/gram.y | 436 ++++++++++++--------------
src/backend/parser/parse_utilcmd.c | 14 +-
src/include/catalog/objectaddress.h | 8 +-
src/include/commands/extension.h | 2 +-
src/include/nodes/parsenodes.h | 24 +-
src/test/regress/expected/event_trigger.out | 3 -
src/test/regress/expected/object_address.out | 24 +-
src/test/regress/sql/event_trigger.sql | 3 -
18 files changed, 608 insertions(+), 633 deletions(-)
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index cc636e2e3e..b6b3ff3db1 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -707,31 +707,31 @@ const ObjectAddress InvalidObjectAddress =
};
static ObjectAddress get_object_address_unqualified(ObjectType objtype,
- List *qualname, bool missing_ok);
+ Value *strval, bool missing_ok);
static ObjectAddress get_relation_by_qualified_name(ObjectType objtype,
- List *objname, Relation *relp,
+ List *object, Relation *relp,
LOCKMODE lockmode, bool missing_ok);
static ObjectAddress get_object_address_relobject(ObjectType objtype,
- List *objname, Relation *relp, bool missing_ok);
+ List *object, Relation *relp, bool missing_ok);
static ObjectAddress get_object_address_attribute(ObjectType objtype,
- List *objname, Relation *relp,
+ List *object, Relation *relp,
LOCKMODE lockmode, bool missing_ok);
static ObjectAddress get_object_address_attrdef(ObjectType objtype,
- List *objname, Relation *relp, LOCKMODE lockmode,
+ List *object, Relation *relp, LOCKMODE lockmode,
bool missing_ok);
static ObjectAddress get_object_address_type(ObjectType objtype,
- ListCell *typecell, bool missing_ok);
-static ObjectAddress get_object_address_opcf(ObjectType objtype, List *objname,
+ TypeName *typename, bool missing_ok);
+static ObjectAddress get_object_address_opcf(ObjectType objtype, List *object,
bool missing_ok);
static ObjectAddress get_object_address_opf_member(ObjectType objtype,
- List *objname, List *objargs, bool missing_ok);
+ List *object, bool missing_ok);
-static ObjectAddress get_object_address_usermapping(List *objname,
- List *objargs, bool missing_ok);
-static ObjectAddress get_object_address_publication_rel(List *objname,
- List *objargs, Relation *relp,
+static ObjectAddress get_object_address_usermapping(List *object,
+ bool missing_ok);
+static ObjectAddress get_object_address_publication_rel(List *object,
+ Relation *relp,
bool missing_ok);
-static ObjectAddress get_object_address_defacl(List *objname, List *objargs,
+static ObjectAddress get_object_address_defacl(List *object,
bool missing_ok);
static const ObjectPropertyType *get_object_property_data(Oid class_id);
@@ -741,8 +741,8 @@ static void getRelationTypeDescription(StringInfo buffer, Oid relid,
int32 objectSubId);
static void getProcedureTypeDescription(StringInfo buffer, Oid procid);
static void getConstraintTypeDescription(StringInfo buffer, Oid constroid);
-static void getOpFamilyIdentity(StringInfo buffer, Oid opfid, List **objname);
-static void getRelationIdentity(StringInfo buffer, Oid relid, List **objname);
+static void getOpFamilyIdentity(StringInfo buffer, Oid opfid, List **object);
+static void getRelationIdentity(StringInfo buffer, Oid relid, List **object);
/*
* Translate an object name and arguments (as passed by the parser) to an
@@ -776,7 +776,7 @@ static void getRelationIdentity(StringInfo buffer, Oid relid, List **objname);
* better to add some support for that in this function.
*/
ObjectAddress
-get_object_address(ObjectType objtype, List *objname, List *objargs,
+get_object_address(ObjectType objtype, Node *object,
Relation *relp, LOCKMODE lockmode, bool missing_ok)
{
ObjectAddress address;
@@ -806,19 +806,19 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
case OBJECT_MATVIEW:
case OBJECT_FOREIGN_TABLE:
address =
- get_relation_by_qualified_name(objtype, objname,
+ get_relation_by_qualified_name(objtype, castNode(List, object),
&relation, lockmode,
missing_ok);
break;
case OBJECT_COLUMN:
address =
- get_object_address_attribute(objtype, objname,
+ get_object_address_attribute(objtype, castNode(List, object),
&relation, lockmode,
missing_ok);
break;
case OBJECT_DEFAULT:
address =
- get_object_address_attrdef(objtype, objname,
+ get_object_address_attrdef(objtype, castNode(List, object),
&relation, lockmode,
missing_ok);
break;
@@ -826,17 +826,20 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
case OBJECT_TRIGGER:
case OBJECT_TABCONSTRAINT:
case OBJECT_POLICY:
- address = get_object_address_relobject(objtype, objname,
+ address = get_object_address_relobject(objtype, castNode(List, object),
&relation, missing_ok);
break;
case OBJECT_DOMCONSTRAINT:
{
+ List *objlist;
ObjectAddress domaddr;
char *constrname;
+ objlist = castNode(List, object);
domaddr = get_object_address_type(OBJECT_DOMAIN,
- list_head(objname), missing_ok);
- constrname = strVal(linitial(objargs));
+ castNode(TypeName, linitial(objlist)),
+ missing_ok);
+ constrname = strVal(lsecond(objlist));
address.classId = ConstraintRelationId;
address.objectId = get_domain_constraint_oid(domaddr.objectId,
@@ -858,57 +861,64 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
case OBJECT_PUBLICATION:
case OBJECT_SUBSCRIPTION:
address = get_object_address_unqualified(objtype,
- objname, missing_ok);
+ (Value *) object, missing_ok);
break;
case OBJECT_TYPE:
case OBJECT_DOMAIN:
- address = get_object_address_type(objtype, list_head(objname), missing_ok);
+ address = get_object_address_type(objtype, castNode(TypeName, object), missing_ok);
break;
case OBJECT_AGGREGATE:
- address.classId = ProcedureRelationId;
- address.objectId =
- LookupAggNameTypeNames(objname, objargs, missing_ok);
- address.objectSubId = 0;
- break;
+ {
+ ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
+ address.classId = ProcedureRelationId;
+ address.objectId =
+ LookupAggNameTypeNames(owa->objname, owa->objargs, missing_ok);
+ address.objectSubId = 0;
+ break;
+ }
case OBJECT_FUNCTION:
- address.classId = ProcedureRelationId;
- address.objectId =
- LookupFuncNameTypeNames(objname, objargs, missing_ok);
- address.objectSubId = 0;
- break;
+ {
+ ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
+ address.classId = ProcedureRelationId;
+ address.objectId =
+ LookupFuncNameTypeNames(owa->objname, owa->objargs, missing_ok);
+ address.objectSubId = 0;
+ break;
+ }
case OBJECT_OPERATOR:
- Assert(list_length(objargs) == 2);
- address.classId = OperatorRelationId;
- address.objectId =
- LookupOperNameTypeNames(NULL, objname,
- (TypeName *) linitial(objargs),
- (TypeName *) lsecond(objargs),
- missing_ok, -1);
- address.objectSubId = 0;
- break;
+ {
+ ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
+ address.classId = OperatorRelationId;
+ Assert(list_length(owa->objargs) == 2);
+ address.objectId =
+ LookupOperNameTypeNames(NULL, owa->objname,
+ castNode(TypeName, linitial(owa->objargs)),
+ castNode(TypeName, lsecond(owa->objargs)),
+ missing_ok, -1);
+ address.objectSubId = 0;
+ break;
+ }
case OBJECT_COLLATION:
address.classId = CollationRelationId;
- address.objectId = get_collation_oid(objname, missing_ok);
+ address.objectId = get_collation_oid(castNode(List, object), missing_ok);
address.objectSubId = 0;
break;
case OBJECT_CONVERSION:
address.classId = ConversionRelationId;
- address.objectId = get_conversion_oid(objname, missing_ok);
+ address.objectId = get_conversion_oid(castNode(List, object), missing_ok);
address.objectSubId = 0;
break;
case OBJECT_OPCLASS:
case OBJECT_OPFAMILY:
- address = get_object_address_opcf(objtype, objname, missing_ok);
+ address = get_object_address_opcf(objtype, castNode(List, object), missing_ok);
break;
case OBJECT_AMOP:
case OBJECT_AMPROC:
- address = get_object_address_opf_member(objtype, objname,
- objargs, missing_ok);
+ address = get_object_address_opf_member(objtype, castNode(List, object), missing_ok);
break;
case OBJECT_LARGEOBJECT:
- Assert(list_length(objname) == 1);
address.classId = LargeObjectRelationId;
- address.objectId = oidparse(linitial(objname));
+ address.objectId = oidparse(object);
address.objectSubId = 0;
if (!LargeObjectExists(address.objectId))
{
@@ -921,8 +931,8 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
break;
case OBJECT_CAST:
{
- TypeName *sourcetype = (TypeName *) linitial(objname);
- TypeName *targettype = (TypeName *) linitial(objargs);
+ TypeName *sourcetype = castNode(TypeName, linitial(castNode(List, object)));
+ TypeName *targettype = castNode(TypeName, lsecond(castNode(List, object)));
Oid sourcetypeid;
Oid targettypeid;
@@ -936,8 +946,8 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
break;
case OBJECT_TRANSFORM:
{
- TypeName *typename = (TypeName *) linitial(objname);
- char *langname = strVal(linitial(objargs));
+ TypeName *typename = castNode(TypeName, linitial(castNode(List, object)));
+ char *langname = strVal(lsecond(castNode(List, object)));
Oid type_id = LookupTypeNameOid(NULL, typename, missing_ok);
Oid lang_id = get_language_oid(langname, missing_ok);
@@ -949,35 +959,35 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
break;
case OBJECT_TSPARSER:
address.classId = TSParserRelationId;
- address.objectId = get_ts_parser_oid(objname, missing_ok);
+ address.objectId = get_ts_parser_oid(castNode(List, object), missing_ok);
address.objectSubId = 0;
break;
case OBJECT_TSDICTIONARY:
address.classId = TSDictionaryRelationId;
- address.objectId = get_ts_dict_oid(objname, missing_ok);
+ address.objectId = get_ts_dict_oid(castNode(List, object), missing_ok);
address.objectSubId = 0;
break;
case OBJECT_TSTEMPLATE:
address.classId = TSTemplateRelationId;
- address.objectId = get_ts_template_oid(objname, missing_ok);
+ address.objectId = get_ts_template_oid(castNode(List, object), missing_ok);
address.objectSubId = 0;
break;
case OBJECT_TSCONFIGURATION:
address.classId = TSConfigRelationId;
- address.objectId = get_ts_config_oid(objname, missing_ok);
+ address.objectId = get_ts_config_oid(castNode(List, object), missing_ok);
address.objectSubId = 0;
break;
case OBJECT_USER_MAPPING:
- address = get_object_address_usermapping(objname, objargs,
+ address = get_object_address_usermapping(castNode(List, object),
missing_ok);
break;
case OBJECT_PUBLICATION_REL:
- address = get_object_address_publication_rel(objname, objargs,
+ address = get_object_address_publication_rel(castNode(List, object),
&relation,
missing_ok);
break;
case OBJECT_DEFACL:
- address = get_object_address_defacl(objname, objargs,
+ address = get_object_address_defacl(castNode(List, object),
missing_ok);
break;
default:
@@ -1068,25 +1078,25 @@ get_object_address(ObjectType objtype, List *objname, List *objargs,
/*
* Return an ObjectAddress based on a RangeVar and an object name. The
* name of the relation identified by the RangeVar is prepended to the
- * (possibly empty) list passed in as objname. This is useful to find
+ * (possibly empty) list passed in as object. This is useful to find
* the ObjectAddress of objects that depend on a relation. All other
* considerations are exactly as for get_object_address above.
*/
ObjectAddress
-get_object_address_rv(ObjectType objtype, RangeVar *rel, List *objname,
- List *objargs, Relation *relp, LOCKMODE lockmode,
+get_object_address_rv(ObjectType objtype, RangeVar *rel, List *object,
+ Relation *relp, LOCKMODE lockmode,
bool missing_ok)
{
if (rel)
{
- objname = lcons(makeString(rel->relname), objname);
+ object = lcons(makeString(rel->relname), object);
if (rel->schemaname)
- objname = lcons(makeString(rel->schemaname), objname);
+ object = lcons(makeString(rel->schemaname), object);
if (rel->catalogname)
- objname = lcons(makeString(rel->catalogname), objname);
+ object = lcons(makeString(rel->catalogname), object);
}
- return get_object_address(objtype, objname, objargs,
+ return get_object_address(objtype, (Node *) object,
relp, lockmode, missing_ok);
}
@@ -1096,68 +1106,12 @@ get_object_address_rv(ObjectType objtype, RangeVar *rel, List *objname,
*/
static ObjectAddress
get_object_address_unqualified(ObjectType objtype,
- List *qualname, bool missing_ok)
+ Value *strval, bool missing_ok)
{
const char *name;
ObjectAddress address;
- /*
- * The types of names handled by this function are not permitted to be
- * schema-qualified or catalog-qualified.
- */
- if (list_length(qualname) != 1)
- {
- const char *msg;
-
- switch (objtype)
- {
- case OBJECT_ACCESS_METHOD:
- msg = gettext_noop("access method name cannot be qualified");
- break;
- case OBJECT_DATABASE:
- msg = gettext_noop("database name cannot be qualified");
- break;
- case OBJECT_EXTENSION:
- msg = gettext_noop("extension name cannot be qualified");
- break;
- case OBJECT_TABLESPACE:
- msg = gettext_noop("tablespace name cannot be qualified");
- break;
- case OBJECT_ROLE:
- msg = gettext_noop("role name cannot be qualified");
- break;
- case OBJECT_SCHEMA:
- msg = gettext_noop("schema name cannot be qualified");
- break;
- case OBJECT_LANGUAGE:
- msg = gettext_noop("language name cannot be qualified");
- break;
- case OBJECT_FDW:
- msg = gettext_noop("foreign-data wrapper name cannot be qualified");
- break;
- case OBJECT_FOREIGN_SERVER:
- msg = gettext_noop("server name cannot be qualified");
- break;
- case OBJECT_EVENT_TRIGGER:
- msg = gettext_noop("event trigger name cannot be qualified");
- break;
- case OBJECT_PUBLICATION:
- msg = gettext_noop("publication name cannot be qualified");
- break;
- case OBJECT_SUBSCRIPTION:
- msg = gettext_noop("subscription name cannot be qualified");
- break;
- default:
- elog(ERROR, "unrecognized objtype: %d", (int) objtype);
- msg = NULL; /* placate compiler */
- }
- ereport(ERROR,
- (errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("%s", _(msg))));
- }
-
- /* Format is valid, extract the actual name. */
- name = strVal(linitial(qualname));
+ name = strVal(strval);
/* Translate name to OID. */
switch (objtype)
@@ -1237,7 +1191,7 @@ get_object_address_unqualified(ObjectType objtype,
* Locate a relation by qualified name.
*/
static ObjectAddress
-get_relation_by_qualified_name(ObjectType objtype, List *objname,
+get_relation_by_qualified_name(ObjectType objtype, List *object,
Relation *relp, LOCKMODE lockmode,
bool missing_ok)
{
@@ -1248,7 +1202,7 @@ get_relation_by_qualified_name(ObjectType objtype, List *objname,
address.objectId = InvalidOid;
address.objectSubId = 0;
- relation = relation_openrv_extended(makeRangeVarFromNameList(objname),
+ relation = relation_openrv_extended(makeRangeVarFromNameList(object),
lockmode, missing_ok);
if (!relation)
return address;
@@ -1318,7 +1272,7 @@ get_relation_by_qualified_name(ObjectType objtype, List *objname,
* mode for the object itself, not the relation to which it is attached.
*/
static ObjectAddress
-get_object_address_relobject(ObjectType objtype, List *objname,
+get_object_address_relobject(ObjectType objtype, List *object,
Relation *relp, bool missing_ok)
{
ObjectAddress address;
@@ -1329,17 +1283,17 @@ get_object_address_relobject(ObjectType objtype, List *objname,
Oid reloid;
/* Extract name of dependent object. */
- depname = strVal(llast(objname));
+ depname = strVal(llast(object));
/* Separate relation name from dependent object name. */
- nnames = list_length(objname);
+ nnames = list_length(object);
if (nnames < 2)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("must specify relation and object name")));
/* Extract relation name and open relation. */
- relname = list_truncate(list_copy(objname), nnames - 1);
+ relname = list_truncate(list_copy(object), nnames - 1);
relation = heap_openrv_extended(makeRangeVarFromNameList(relname),
AccessShareLock,
missing_ok);
@@ -1397,7 +1351,7 @@ get_object_address_relobject(ObjectType objtype, List *objname,
* Find the ObjectAddress for an attribute.
*/
static ObjectAddress
-get_object_address_attribute(ObjectType objtype, List *objname,
+get_object_address_attribute(ObjectType objtype, List *object,
Relation *relp, LOCKMODE lockmode,
bool missing_ok)
{
@@ -1409,12 +1363,12 @@ get_object_address_attribute(ObjectType objtype, List *objname,
AttrNumber attnum;
/* Extract relation name and open relation. */
- if (list_length(objname) < 2)
+ if (list_length(object) < 2)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("column name must be qualified")));
- attname = strVal(lfirst(list_tail(objname)));
- relname = list_truncate(list_copy(objname), list_length(objname) - 1);
+ attname = strVal(lfirst(list_tail(object)));
+ relname = list_truncate(list_copy(object), list_length(object) - 1);
/* XXX no missing_ok support here */
relation = relation_openrv(makeRangeVarFromNameList(relname), lockmode);
reloid = RelationGetRelid(relation);
@@ -1448,7 +1402,7 @@ get_object_address_attribute(ObjectType objtype, List *objname,
* Find the ObjectAddress for an attribute's default value.
*/
static ObjectAddress
-get_object_address_attrdef(ObjectType objtype, List *objname,
+get_object_address_attrdef(ObjectType objtype, List *object,
Relation *relp, LOCKMODE lockmode,
bool missing_ok)
{
@@ -1462,12 +1416,12 @@ get_object_address_attrdef(ObjectType objtype, List *objname,
Oid defoid;
/* Extract relation name and open relation. */
- if (list_length(objname) < 2)
+ if (list_length(object) < 2)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("column name must be qualified")));
- attname = strVal(llast(objname));
- relname = list_truncate(list_copy(objname), list_length(objname) - 1);
+ attname = strVal(llast(object));
+ relname = list_truncate(list_copy(object), list_length(object) - 1);
/* XXX no missing_ok support here */
relation = relation_openrv(makeRangeVarFromNameList(relname), lockmode);
reloid = RelationGetRelid(relation);
@@ -1530,14 +1484,11 @@ get_object_address_attrdef(ObjectType objtype, List *objname,
* Find the ObjectAddress for a type or domain
*/
static ObjectAddress
-get_object_address_type(ObjectType objtype, ListCell *typecell, bool missing_ok)
+get_object_address_type(ObjectType objtype, TypeName *typename, bool missing_ok)
{
ObjectAddress address;
- TypeName *typename;
Type tup;
- typename = (TypeName *) lfirst(typecell);
-
address.classId = TypeRelationId;
address.objectId = InvalidOid;
address.objectSubId = 0;
@@ -1572,25 +1523,25 @@ get_object_address_type(ObjectType objtype, ListCell *typecell, bool missing_ok)
* Find the ObjectAddress for an opclass or opfamily.
*/
static ObjectAddress
-get_object_address_opcf(ObjectType objtype, List *objname, bool missing_ok)
+get_object_address_opcf(ObjectType objtype, List *object, bool missing_ok)
{
Oid amoid;
ObjectAddress address;
/* XXX no missing_ok support here */
- amoid = get_index_am_oid(strVal(linitial(objname)), false);
- objname = list_copy_tail(objname, 1);
+ amoid = get_index_am_oid(strVal(linitial(object)), false);
+ object = list_copy_tail(object, 1);
switch (objtype)
{
case OBJECT_OPCLASS:
address.classId = OperatorClassRelationId;
- address.objectId = get_opclass_oid(amoid, objname, missing_ok);
+ address.objectId = get_opclass_oid(amoid, object, missing_ok);
address.objectSubId = 0;
break;
case OBJECT_OPFAMILY:
address.classId = OperatorFamilyRelationId;
- address.objectId = get_opfamily_oid(amoid, objname, missing_ok);
+ address.objectId = get_opfamily_oid(amoid, object, missing_ok);
address.objectSubId = 0;
break;
default:
@@ -1611,7 +1562,7 @@ get_object_address_opcf(ObjectType objtype, List *objname, bool missing_ok)
*/
static ObjectAddress
get_object_address_opf_member(ObjectType objtype,
- List *objname, List *objargs, bool missing_ok)
+ List *object, bool missing_ok)
{
ObjectAddress famaddr;
ObjectAddress address;
@@ -1623,24 +1574,24 @@ get_object_address_opf_member(ObjectType objtype,
int i;
/*
- * The last element of the objname list contains the strategy or procedure
+ * The last element of the object list contains the strategy or procedure
* number. We need to strip that out before getting the opclass/family
* address. The rest can be used directly by get_object_address_opcf().
*/
- membernum = atoi(strVal(llast(objname)));
- copy = list_truncate(list_copy(objname), list_length(objname) - 1);
+ membernum = atoi(strVal(llast(linitial(object))));
+ copy = list_truncate(list_copy(linitial(object)), list_length(linitial(object)) - 1);
/* no missing_ok support here */
famaddr = get_object_address_opcf(OBJECT_OPFAMILY, copy, false);
/* find out left/right type names and OIDs */
i = 0;
- foreach(cell, objargs)
+ foreach(cell, lsecond(object))
{
ObjectAddress typaddr;
typenames[i] = strVal(lfirst(cell));
- typaddr = get_object_address_type(OBJECT_TYPE, cell, missing_ok);
+ typaddr = get_object_address_type(OBJECT_TYPE, castNode(TypeName, lfirst(cell)), missing_ok);
typeoids[i] = typaddr.objectId;
if (++i >= 2)
break;
@@ -1716,7 +1667,7 @@ get_object_address_opf_member(ObjectType objtype,
* Find the ObjectAddress for a user mapping.
*/
static ObjectAddress
-get_object_address_usermapping(List *objname, List *objargs, bool missing_ok)
+get_object_address_usermapping(List *object, bool missing_ok)
{
ObjectAddress address;
Oid userid;
@@ -1728,8 +1679,8 @@ get_object_address_usermapping(List *objname, List *objargs, bool missing_ok)
ObjectAddressSet(address, UserMappingRelationId, InvalidOid);
/* fetch string names from input lists, for error messages */
- username = strVal(linitial(objname));
- servername = strVal(linitial(objargs));
+ username = strVal(linitial(object));
+ servername = strVal(lsecond(object));
/* look up pg_authid OID of mapped user; InvalidOid if PUBLIC */
if (strcmp(username, "public") == 0)
@@ -1782,27 +1733,30 @@ get_object_address_usermapping(List *objname, List *objargs, bool missing_ok)
}
/*
- * Find the ObjectAddress for a publication relation. The objname parameter
- * is the relation name; objargs contains the publication name.
+ * Find the ObjectAddress for a publication relation. The first element of
+ * the object parameter is the relation name, the second is the
+ * publication name.
*/
static ObjectAddress
-get_object_address_publication_rel(List *objname, List *objargs,
+get_object_address_publication_rel(List *object,
Relation *relp, bool missing_ok)
{
ObjectAddress address;
Relation relation;
+ List *relname;
char *pubname;
Publication *pub;
ObjectAddressSet(address, PublicationRelRelationId, InvalidOid);
- relation = relation_openrv_extended(makeRangeVarFromNameList(objname),
+ relname = linitial(object);
+ relation = relation_openrv_extended(makeRangeVarFromNameList(relname),
AccessShareLock, missing_ok);
if (!relation)
return address;
/* fetch publication name from input list */
- pubname = strVal(linitial(objargs));
+ pubname = strVal(lsecond(object));
/* Now look up the pg_publication tuple */
pub = GetPublicationByName(pubname, missing_ok);
@@ -1836,7 +1790,7 @@ get_object_address_publication_rel(List *objname, List *objargs,
* Find the ObjectAddress for a default ACL.
*/
static ObjectAddress
-get_object_address_defacl(List *objname, List *objargs, bool missing_ok)
+get_object_address_defacl(List *object, bool missing_ok)
{
HeapTuple tp;
Oid userid;
@@ -1853,9 +1807,9 @@ get_object_address_defacl(List *objname, List *objargs, bool missing_ok)
* First figure out the textual attributes so that they can be used for
* error reporting.
*/
- username = strVal(linitial(objname));
- if (list_length(objname) >= 2)
- schema = (char *) strVal(lsecond(objname));
+ username = strVal(lsecond(object));
+ if (list_length(object) >= 3)
+ schema = (char *) strVal(lthird(object));
else
schema = NULL;
@@ -1863,7 +1817,7 @@ get_object_address_defacl(List *objname, List *objargs, bool missing_ok)
* Decode defaclobjtype. Only first char is considered; the rest of the
* string, if any, is blissfully ignored.
*/
- objtype = ((char *) strVal(linitial(objargs)))[0];
+ objtype = ((char *) strVal(linitial(object)))[0];
switch (objtype)
{
case DEFACLOBJ_RELATION:
@@ -1978,8 +1932,10 @@ pg_get_object_address(PG_FUNCTION_ARGS)
ArrayType *argsarr = PG_GETARG_ARRAYTYPE_P(2);
int itype;
ObjectType type;
- List *name;
- List *args;
+ List *name = NIL;
+ TypeName *typename = NULL;
+ List *args = NIL;
+ Node *objnode = NULL;
ObjectAddress addr;
TupleDesc tupdesc;
Datum values[3];
@@ -2017,7 +1973,7 @@ pg_get_object_address(PG_FUNCTION_ARGS)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("name or argument lists may not contain nulls")));
- name = list_make1(typeStringToTypeName(TextDatumGetCString(elems[0])));
+ typename = typeStringToTypeName(TextDatumGetCString(elems[0]));
}
else if (type == OBJECT_LARGEOBJECT)
{
@@ -2035,7 +1991,7 @@ pg_get_object_address(PG_FUNCTION_ARGS)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("large object OID may not be null")));
- name = list_make1(makeFloat(TextDatumGetCString(elems[0])));
+ objnode = (Node *) makeFloat(TextDatumGetCString(elems[0]));
}
else
{
@@ -2123,7 +2079,96 @@ pg_get_object_address(PG_FUNCTION_ARGS)
break;
}
- addr = get_object_address(type, name, args,
+ /*
+ * Now build the Node type that get_object_name() expects for the given
+ * type.
+ */
+ switch (type)
+ {
+ case OBJECT_TABLE:
+ case OBJECT_SEQUENCE:
+ case OBJECT_VIEW:
+ case OBJECT_MATVIEW:
+ case OBJECT_INDEX:
+ case OBJECT_FOREIGN_TABLE:
+ case OBJECT_COLUMN:
+ case OBJECT_ATTRIBUTE:
+ case OBJECT_COLLATION:
+ case OBJECT_CONVERSION:
+ case OBJECT_TSPARSER:
+ case OBJECT_TSDICTIONARY:
+ case OBJECT_TSTEMPLATE:
+ case OBJECT_TSCONFIGURATION:
+ case OBJECT_DEFAULT:
+ case OBJECT_POLICY:
+ case OBJECT_RULE:
+ case OBJECT_TRIGGER:
+ case OBJECT_TABCONSTRAINT:
+ case OBJECT_OPCLASS:
+ case OBJECT_OPFAMILY:
+ objnode = (Node *) name;
+ break;
+ case OBJECT_ACCESS_METHOD:
+ case OBJECT_DATABASE:
+ case OBJECT_EVENT_TRIGGER:
+ case OBJECT_EXTENSION:
+ case OBJECT_FDW:
+ case OBJECT_FOREIGN_SERVER:
+ case OBJECT_LANGUAGE:
+ case OBJECT_PUBLICATION:
+ case OBJECT_ROLE:
+ case OBJECT_SCHEMA:
+ case OBJECT_SUBSCRIPTION:
+ case OBJECT_TABLESPACE:
+ if (list_length(name) != 1)
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("name list length must be exactly %d", 1)));
+ objnode = linitial(name);
+ break;
+ case OBJECT_TYPE:
+ case OBJECT_DOMAIN:
+ objnode = (Node *) typename;
+ break;
+ case OBJECT_CAST:
+ case OBJECT_DOMCONSTRAINT:
+ case OBJECT_TRANSFORM:
+ objnode = (Node *) list_make2(typename, linitial(args));
+ break;
+ case OBJECT_PUBLICATION_REL:
+ objnode = (Node *) list_make2(name, linitial(args));
+ break;
+ case OBJECT_USER_MAPPING:
+ objnode = (Node *) list_make2(linitial(name), linitial(args));
+ break;
+ case OBJECT_DEFACL:
+ objnode = (Node *) lcons(linitial(args), name);
+ break;
+ case OBJECT_AMOP:
+ case OBJECT_AMPROC:
+ objnode = (Node *) list_make2(name, args);
+ break;
+ case OBJECT_FUNCTION:
+ case OBJECT_AGGREGATE:
+ case OBJECT_OPERATOR:
+ {
+ ObjectWithArgs *owa = makeNode(ObjectWithArgs);
+
+ owa->objname = name;
+ owa->objargs = args;
+ objnode = (Node *) owa;
+ break;
+ }
+ case OBJECT_LARGEOBJECT:
+ /* already handled above */
+ break;
+ /* no default, to let compiler warn about missing case */
+ }
+
+ if (objnode == NULL)
+ elog(ERROR, "unrecognized object type: %d", type);
+
+ addr = get_object_address(type, objnode,
&relation, AccessShareLock, false);
/* We don't need the relcache entry, thank you very much */
@@ -2156,7 +2201,7 @@ pg_get_object_address(PG_FUNCTION_ARGS)
*/
void
check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
- List *objname, List *objargs, Relation relation)
+ Node *object, Relation relation)
{
switch (objtype)
{
@@ -2178,7 +2223,7 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
case OBJECT_DATABASE:
if (!pg_database_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE,
- NameListToString(objname));
+ strVal((Value *) object));
break;
case OBJECT_TYPE:
case OBJECT_DOMAIN:
@@ -2191,62 +2236,62 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
case OBJECT_FUNCTION:
if (!pg_proc_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC,
- NameListToString(objname));
+ NameListToString((castNode(ObjectWithArgs, object))->objname));
break;
case OBJECT_OPERATOR:
if (!pg_oper_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPER,
- NameListToString(objname));
+ NameListToString((castNode(ObjectWithArgs, object))->objname));
break;
case OBJECT_SCHEMA:
if (!pg_namespace_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_NAMESPACE,
- NameListToString(objname));
+ strVal((Value *) object));
break;
case OBJECT_COLLATION:
if (!pg_collation_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_COLLATION,
- NameListToString(objname));
+ NameListToString(castNode(List, object)));
break;
case OBJECT_CONVERSION:
if (!pg_conversion_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CONVERSION,
- NameListToString(objname));
+ NameListToString(castNode(List, object)));
break;
case OBJECT_EXTENSION:
if (!pg_extension_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_EXTENSION,
- NameListToString(objname));
+ strVal((Value *) object));
break;
case OBJECT_FDW:
if (!pg_foreign_data_wrapper_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_FDW,
- NameListToString(objname));
+ strVal((Value *) object));
break;
case OBJECT_FOREIGN_SERVER:
if (!pg_foreign_server_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_FOREIGN_SERVER,
- NameListToString(objname));
+ strVal((Value *) object));
break;
case OBJECT_EVENT_TRIGGER:
if (!pg_event_trigger_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_EVENT_TRIGGER,
- NameListToString(objname));
+ strVal((Value *) object));
break;
case OBJECT_LANGUAGE:
if (!pg_language_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_LANGUAGE,
- NameListToString(objname));
+ strVal((Value *) object));
break;
case OBJECT_OPCLASS:
if (!pg_opclass_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPCLASS,
- NameListToString(objname));
+ NameListToString(castNode(List, object)));
break;
case OBJECT_OPFAMILY:
if (!pg_opfamily_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_OPFAMILY,
- NameListToString(objname));
+ NameListToString(castNode(List, object)));
break;
case OBJECT_LARGEOBJECT:
if (!lo_compat_privileges &&
@@ -2259,8 +2304,8 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
case OBJECT_CAST:
{
/* We can only check permissions on the source/target types */
- TypeName *sourcetype = (TypeName *) linitial(objname);
- TypeName *targettype = (TypeName *) linitial(objargs);
+ TypeName *sourcetype = castNode(TypeName, linitial(castNode(List, object)));
+ TypeName *targettype = castNode(TypeName, lsecond(castNode(List, object)));
Oid sourcetypeid = typenameTypeId(NULL, sourcetype);
Oid targettypeid = typenameTypeId(NULL, targettype);
@@ -2276,16 +2321,16 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
case OBJECT_PUBLICATION:
if (!pg_publication_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PUBLICATION,
- NameListToString(objname));
+ strVal((Value *) object));
break;
case OBJECT_SUBSCRIPTION:
if (!pg_subscription_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_SUBSCRIPTION,
- NameListToString(objname));
+ strVal((Value *) object));
break;
case OBJECT_TRANSFORM:
{
- TypeName *typename = (TypeName *) linitial(objname);
+ TypeName *typename = castNode(TypeName, linitial(castNode(List, object)));
Oid typeid = typenameTypeId(NULL, typename);
if (!pg_type_ownercheck(typeid, roleid))
@@ -2295,17 +2340,17 @@ check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address,
case OBJECT_TABLESPACE:
if (!pg_tablespace_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TABLESPACE,
- NameListToString(objname));
+ strVal((Value *) object));
break;
case OBJECT_TSDICTIONARY:
if (!pg_ts_dict_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TSDICTIONARY,
- NameListToString(objname));
+ NameListToString(castNode(List, object)));
break;
case OBJECT_TSCONFIGURATION:
if (!pg_ts_config_ownercheck(address.objectId, roleid))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TSCONFIGURATION,
- NameListToString(objname));
+ NameListToString(castNode(List, object)));
break;
case OBJECT_ROLE:
@@ -4868,7 +4913,7 @@ getObjectIdentityParts(const ObjectAddress *object,
}
static void
-getOpFamilyIdentity(StringInfo buffer, Oid opfid, List **objname)
+getOpFamilyIdentity(StringInfo buffer, Oid opfid, List **object)
{
HeapTuple opfTup;
Form_pg_opfamily opfForm;
@@ -4893,8 +4938,8 @@ getOpFamilyIdentity(StringInfo buffer, Oid opfid, List **objname)
NameStr(opfForm->opfname)),
NameStr(amForm->amname));
- if (objname)
- *objname = list_make3(pstrdup(NameStr(amForm->amname)),
+ if (object)
+ *object = list_make3(pstrdup(NameStr(amForm->amname)),
pstrdup(schema),
pstrdup(NameStr(opfForm->opfname)));
@@ -4907,7 +4952,7 @@ getOpFamilyIdentity(StringInfo buffer, Oid opfid, List **objname)
* StringInfo.
*/
static void
-getRelationIdentity(StringInfo buffer, Oid relid, List **objname)
+getRelationIdentity(StringInfo buffer, Oid relid, List **object)
{
HeapTuple relTup;
Form_pg_class relForm;
@@ -4923,8 +4968,8 @@ getRelationIdentity(StringInfo buffer, Oid relid, List **objname)
appendStringInfoString(buffer,
quote_qualified_identifier(schema,
NameStr(relForm->relname)));
- if (objname)
- *objname = list_make2(schema, pstrdup(NameStr(relForm->relname)));
+ if (object)
+ *object = list_make2(schema, pstrdup(NameStr(relForm->relname)));
ReleaseSysCache(relTup);
}
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index d6195e49f5..77ffe65b25 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -370,7 +370,7 @@ ExecRenameStmt(RenameStmt *stmt)
Relation relation;
address = get_object_address(stmt->renameType,
- stmt->object, stmt->objarg,
+ stmt->object,
&relation,
AccessExclusiveLock, false);
Assert(relation == NULL);
@@ -406,8 +406,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
@@ -416,8 +416,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;
@@ -446,7 +446,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;
@@ -461,7 +461,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;
@@ -486,7 +486,6 @@ ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt,
address = get_object_address(stmt->objectType,
stmt->object,
- stmt->objarg,
&relation,
AccessExclusiveLock,
false);
@@ -749,33 +748,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 */
@@ -799,7 +799,6 @@ ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
address = get_object_address(stmt->objectType,
stmt->object,
- stmt->objarg,
&relation,
AccessExclusiveLock,
false);
diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c
index 87ca62f240..b5569bddaf 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)
diff --git a/src/backend/commands/dropcmds.c b/src/backend/commands/dropcmds.c
index ff3108ce72..ab73fbf961 100644
--- a/src/backend/commands/dropcmds.c
+++ b/src/backend/commands/dropcmds.c
@@ -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);
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index 325f5b74b8..585fcce98e 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -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.
diff --git a/src/backend/commands/seclabel.c b/src/backend/commands/seclabel.c
index 422da8b6b0..5f16d6cf1c 100644
--- a/src/backend/commands/seclabel.c
+++ b/src/backend/commands/seclabel.c
@@ -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)
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 3cea220421..4421afe5ba 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -2766,7 +2766,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))
@@ -9371,11 +9371,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 */
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index d8bd8a50dd..c765e97fa8 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -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;
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 35fec87842..598ba944a1 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -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;
}
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index e526ef96b7..876b8aabb9 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -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;
}
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index d9696b0bd5..53ee3a963e 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -440,7 +440,9 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <boolean> copy_from opt_program
%type <ival> opt_column event cursor_options opt_hold opt_set_data
-%type <objtype> drop_type comment_type security_label_type
+%type <objtype> drop_type_any_name drop_type_name
+ comment_type_any_name comment_type_name
+ security_label_type_any_name security_label_type_name
%type <node> fetch_args limit_clause select_limit_value
offset_clause select_offset_value
@@ -4080,8 +4082,7 @@ DropPLangStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_LANGUAGE;
- n->objects = list_make1(list_make1(makeString($4)));
- n->arguments = NIL;
+ n->objects = list_make1(makeString($4));
n->behavior = $5;
n->missing_ok = false;
n->concurrent = false;
@@ -4091,7 +4092,7 @@ DropPLangStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_LANGUAGE;
- n->objects = list_make1(list_make1(makeString($6)));
+ n->objects = list_make1(makeString($6));
n->behavior = $7;
n->missing_ok = true;
n->concurrent = false;
@@ -4246,7 +4247,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_ACCESS_METHOD;
- n->objname = list_make1(makeString($7));
+ n->object = (Node *) makeString($7);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop AGGREGATE aggregate_with_argtypes
@@ -4255,8 +4256,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_AGGREGATE;
- n->objname = $6->objname;
- n->objargs = $6->objargs;
+ n->object = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')'
@@ -4265,8 +4265,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_CAST;
- n->objname = list_make1($7);
- n->objargs = list_make1($9);
+ n->object = (Node *) list_make2($7, $9);
$$ = (Node *) n;
}
| ALTER EXTENSION name add_drop COLLATION any_name
@@ -4275,7 +4274,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_COLLATION;
- n->objname = $6;
+ n->object = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop CONVERSION_P any_name
@@ -4284,7 +4283,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_CONVERSION;
- n->objname = $6;
+ n->object = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop DOMAIN_P Typename
@@ -4293,7 +4292,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_DOMAIN;
- n->objname = list_make1($6);
+ n->object = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop FUNCTION function_with_argtypes
@@ -4302,8 +4301,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_FUNCTION;
- n->objname = $6->objname;
- n->objargs = $6->objargs;
+ n->object = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop opt_procedural LANGUAGE name
@@ -4312,7 +4310,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_LANGUAGE;
- n->objname = list_make1(makeString($7));
+ n->object = (Node *) makeString($7);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop OPERATOR operator_with_argtypes
@@ -4321,8 +4319,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_OPERATOR;
- n->objname = $6->objname;
- n->objargs = $6->objargs;
+ n->object = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop OPERATOR CLASS any_name USING access_method
@@ -4331,7 +4328,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_OPCLASS;
- n->objname = lcons(makeString($9), $7);
+ n->object = (Node *) lcons(makeString($9), $7);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop OPERATOR FAMILY any_name USING access_method
@@ -4340,7 +4337,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_OPFAMILY;
- n->objname = lcons(makeString($9), $7);
+ n->object = (Node *) lcons(makeString($9), $7);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop SCHEMA name
@@ -4349,7 +4346,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_SCHEMA;
- n->objname = list_make1(makeString($6));
+ n->object = (Node *) makeString($6);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop EVENT TRIGGER name
@@ -4358,7 +4355,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_EVENT_TRIGGER;
- n->objname = list_make1(makeString($7));
+ n->object = (Node *) makeString($7);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop TABLE any_name
@@ -4367,7 +4364,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_TABLE;
- n->objname = $6;
+ n->object = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop TEXT_P SEARCH PARSER any_name
@@ -4376,7 +4373,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_TSPARSER;
- n->objname = $8;
+ n->object = (Node *) $8;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop TEXT_P SEARCH DICTIONARY any_name
@@ -4385,7 +4382,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_TSDICTIONARY;
- n->objname = $8;
+ n->object = (Node *) $8;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop TEXT_P SEARCH TEMPLATE any_name
@@ -4394,7 +4391,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_TSTEMPLATE;
- n->objname = $8;
+ n->object = (Node *) $8;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop TEXT_P SEARCH CONFIGURATION any_name
@@ -4403,7 +4400,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_TSCONFIGURATION;
- n->objname = $8;
+ n->object = (Node *) $8;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop SEQUENCE any_name
@@ -4412,7 +4409,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_SEQUENCE;
- n->objname = $6;
+ n->object = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop VIEW any_name
@@ -4421,7 +4418,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_VIEW;
- n->objname = $6;
+ n->object = (Node *) $6;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop MATERIALIZED VIEW any_name
@@ -4430,7 +4427,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_MATVIEW;
- n->objname = $7;
+ n->object = (Node *) $7;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop FOREIGN TABLE any_name
@@ -4439,7 +4436,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_FOREIGN_TABLE;
- n->objname = $7;
+ n->object = (Node *) $7;
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop FOREIGN DATA_P WRAPPER name
@@ -4448,7 +4445,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_FDW;
- n->objname = list_make1(makeString($8));
+ n->object = (Node *) makeString($8);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop SERVER name
@@ -4457,7 +4454,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_FOREIGN_SERVER;
- n->objname = list_make1(makeString($6));
+ n->object = (Node *) makeString($6);
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop TRANSFORM FOR Typename LANGUAGE name
@@ -4466,8 +4463,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_TRANSFORM;
- n->objname = list_make1($7);
- n->objargs = list_make1(makeString($9));
+ n->object = (Node *) list_make2($7, makeString($9));
$$ = (Node *)n;
}
| ALTER EXTENSION name add_drop TYPE_P Typename
@@ -4476,7 +4472,7 @@ AlterExtensionContentsStmt:
n->extname = $3;
n->action = $4;
n->objtype = OBJECT_TYPE;
- n->objname = list_make1($6);
+ n->object = (Node *) $6;
$$ = (Node *)n;
}
;
@@ -4526,8 +4522,7 @@ DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FDW;
- n->objects = list_make1(list_make1(makeString($5)));
- n->arguments = NIL;
+ n->objects = list_make1(makeString($5));
n->missing_ok = false;
n->behavior = $6;
n->concurrent = false;
@@ -4537,8 +4532,7 @@ DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FDW;
- n->objects = list_make1(list_make1(makeString($7)));
- n->arguments = NIL;
+ n->objects = list_make1(makeString($7));
n->missing_ok = true;
n->behavior = $8;
n->concurrent = false;
@@ -4688,8 +4682,7 @@ DropForeignServerStmt: DROP SERVER name opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FOREIGN_SERVER;
- n->objects = list_make1(list_make1(makeString($3)));
- n->arguments = NIL;
+ n->objects = list_make1(makeString($3));
n->missing_ok = false;
n->behavior = $4;
n->concurrent = false;
@@ -4699,8 +4692,7 @@ DropForeignServerStmt: DROP SERVER name opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FOREIGN_SERVER;
- n->objects = list_make1(list_make1(makeString($5)));
- n->arguments = NIL;
+ n->objects = list_make1(makeString($5));
n->missing_ok = true;
n->behavior = $6;
n->concurrent = false;
@@ -5024,7 +5016,6 @@ DropPolicyStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_POLICY;
n->objects = list_make1(lappend($5, makeString($3)));
- n->arguments = NIL;
n->behavior = $6;
n->missing_ok = false;
n->concurrent = false;
@@ -5035,7 +5026,6 @@ DropPolicyStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_POLICY;
n->objects = list_make1(lappend($7, makeString($5)));
- n->arguments = NIL;
n->behavior = $8;
n->missing_ok = true;
n->concurrent = false;
@@ -5348,7 +5338,6 @@ DropTrigStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_TRIGGER;
n->objects = list_make1(lappend($5, makeString($3)));
- n->arguments = NIL;
n->behavior = $6;
n->missing_ok = false;
n->concurrent = false;
@@ -5359,7 +5348,6 @@ DropTrigStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_TRIGGER;
n->objects = list_make1(lappend($7, makeString($5)));
- n->arguments = NIL;
n->behavior = $8;
n->missing_ok = true;
n->concurrent = false;
@@ -5469,7 +5457,6 @@ DropAssertStmt:
{
DropStmt *n = makeNode(DropStmt);
n->objects = NIL;
- n->arguments = NIL;
n->behavior = $4;
n->removeType = OBJECT_TRIGGER; /* XXX */
ereport(ERROR,
@@ -6008,24 +5995,42 @@ ReassignOwnedStmt:
*
*****************************************************************************/
-DropStmt: DROP drop_type IF_P EXISTS any_name_list opt_drop_behavior
+DropStmt: DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = $2;
n->missing_ok = TRUE;
n->objects = $5;
- n->arguments = NIL;
n->behavior = $6;
n->concurrent = false;
$$ = (Node *)n;
}
- | DROP drop_type any_name_list opt_drop_behavior
+ | DROP drop_type_any_name any_name_list opt_drop_behavior
+ {
+ DropStmt *n = makeNode(DropStmt);
+ n->removeType = $2;
+ n->missing_ok = FALSE;
+ n->objects = $3;
+ n->behavior = $4;
+ n->concurrent = false;
+ $$ = (Node *)n;
+ }
+ | DROP drop_type_name IF_P EXISTS name_list opt_drop_behavior
+ {
+ DropStmt *n = makeNode(DropStmt);
+ n->removeType = $2;
+ n->missing_ok = TRUE;
+ n->objects = $5;
+ n->behavior = $6;
+ n->concurrent = false;
+ $$ = (Node *)n;
+ }
+ | DROP drop_type_name name_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = $2;
n->missing_ok = FALSE;
n->objects = $3;
- n->arguments = NIL;
n->behavior = $4;
n->concurrent = false;
$$ = (Node *)n;
@@ -6076,7 +6081,6 @@ DropStmt: DROP drop_type IF_P EXISTS any_name_list opt_drop_behavior
n->removeType = OBJECT_INDEX;
n->missing_ok = FALSE;
n->objects = $4;
- n->arguments = NIL;
n->behavior = $5;
n->concurrent = true;
$$ = (Node *)n;
@@ -6087,31 +6091,35 @@ DropStmt: DROP drop_type IF_P EXISTS any_name_list opt_drop_behavior
n->removeType = OBJECT_INDEX;
n->missing_ok = TRUE;
n->objects = $6;
- n->arguments = NIL;
n->behavior = $7;
n->concurrent = true;
$$ = (Node *)n;
}
;
-
-drop_type: TABLE { $$ = OBJECT_TABLE; }
+/* object types taking any_name_list */
+drop_type_any_name:
+ TABLE { $$ = OBJECT_TABLE; }
| SEQUENCE { $$ = OBJECT_SEQUENCE; }
| VIEW { $$ = OBJECT_VIEW; }
| MATERIALIZED VIEW { $$ = OBJECT_MATVIEW; }
| INDEX { $$ = OBJECT_INDEX; }
| FOREIGN TABLE { $$ = OBJECT_FOREIGN_TABLE; }
- | ACCESS METHOD { $$ = OBJECT_ACCESS_METHOD; }
- | EVENT TRIGGER { $$ = OBJECT_EVENT_TRIGGER; }
| COLLATION { $$ = OBJECT_COLLATION; }
| CONVERSION_P { $$ = OBJECT_CONVERSION; }
- | SCHEMA { $$ = OBJECT_SCHEMA; }
- | EXTENSION { $$ = OBJECT_EXTENSION; }
| TEXT_P SEARCH PARSER { $$ = OBJECT_TSPARSER; }
| TEXT_P SEARCH DICTIONARY { $$ = OBJECT_TSDICTIONARY; }
| TEXT_P SEARCH TEMPLATE { $$ = OBJECT_TSTEMPLATE; }
| TEXT_P SEARCH CONFIGURATION { $$ = OBJECT_TSCONFIGURATION; }
+ ;
+
+/* object types taking name_list */
+drop_type_name:
+ ACCESS METHOD { $$ = OBJECT_ACCESS_METHOD; }
+ | EVENT TRIGGER { $$ = OBJECT_EVENT_TRIGGER; }
+ | EXTENSION { $$ = OBJECT_EXTENSION; }
| PUBLICATION { $$ = OBJECT_PUBLICATION; }
+ | SCHEMA { $$ = OBJECT_SCHEMA; }
;
any_name_list:
@@ -6130,8 +6138,8 @@ attrs: '.' attr_name
;
type_name_list:
- Typename { $$ = list_make1(list_make1($1)); }
- | type_name_list ',' Typename { $$ = lappend($1, list_make1($3)); }
+ Typename { $$ = list_make1($1); }
+ | type_name_list ',' Typename { $$ = lappend($1, $3); }
/*****************************************************************************
*
@@ -6188,12 +6196,19 @@ opt_restart_seqs:
*****************************************************************************/
CommentStmt:
- COMMENT ON comment_type any_name IS comment_text
+ COMMENT ON comment_type_any_name any_name IS comment_text
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = $3;
- n->objname = $4;
- n->objargs = NIL;
+ n->object = (Node *) $4;
+ n->comment = $6;
+ $$ = (Node *) n;
+ }
+ | COMMENT ON comment_type_name name IS comment_text
+ {
+ CommentStmt *n = makeNode(CommentStmt);
+ n->objtype = $3;
+ n->object = (Node *) makeString($4);
n->comment = $6;
$$ = (Node *) n;
}
@@ -6201,8 +6216,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_TYPE;
- n->objname = list_make1($4);
- n->objargs = NIL;
+ n->object = (Node *) $4;
n->comment = $6;
$$ = (Node *) n;
}
@@ -6210,8 +6224,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_DOMAIN;
- n->objname = list_make1($4);
- n->objargs = NIL;
+ n->object = (Node *) $4;
n->comment = $6;
$$ = (Node *) n;
}
@@ -6219,8 +6232,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_AGGREGATE;
- n->objname = $4->objname;
- n->objargs = $4->objargs;
+ n->object = (Node *) $4;
n->comment = $6;
$$ = (Node *) n;
}
@@ -6228,8 +6240,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_FUNCTION;
- n->objname = $4->objname;
- n->objargs = $4->objargs;
+ n->object = (Node *) $4;
n->comment = $6;
$$ = (Node *) n;
}
@@ -6237,8 +6248,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_OPERATOR;
- n->objname = $4->objname;
- n->objargs = $4->objargs;
+ n->object = (Node *) $4;
n->comment = $6;
$$ = (Node *) n;
}
@@ -6246,8 +6256,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_TABCONSTRAINT;
- n->objname = lappend($6, makeString($4));
- n->objargs = NIL;
+ n->object = (Node *) lappend($6, makeString($4));
n->comment = $8;
$$ = (Node *) n;
}
@@ -6260,8 +6269,7 @@ CommentStmt:
* there's a shift/reduce conflict if we do that, so fix it
* up here.
*/
- n->objname = list_make1(makeTypeNameFromNameList($7));
- n->objargs = list_make1(makeString($4));
+ n->object = (Node *) list_make2(makeTypeNameFromNameList($7), makeString($4));
n->comment = $9;
$$ = (Node *) n;
}
@@ -6269,8 +6277,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_POLICY;
- n->objname = lappend($6, makeString($4));
- n->objargs = NIL;
+ n->object = (Node *) lappend($6, makeString($4));
n->comment = $8;
$$ = (Node *) n;
}
@@ -6278,8 +6285,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_RULE;
- n->objname = lappend($6, makeString($4));
- n->objargs = NIL;
+ n->object = (Node *) lappend($6, makeString($4));
n->comment = $8;
$$ = (Node *) n;
}
@@ -6287,8 +6293,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_TRANSFORM;
- n->objname = list_make1($5);
- n->objargs = list_make1(makeString($7));
+ n->object = (Node *) list_make2($5, makeString($7));
n->comment = $9;
$$ = (Node *) n;
}
@@ -6296,8 +6301,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_TRIGGER;
- n->objname = lappend($6, makeString($4));
- n->objargs = NIL;
+ n->object = (Node *) lappend($6, makeString($4));
n->comment = $8;
$$ = (Node *) n;
}
@@ -6305,7 +6309,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_OPCLASS;
- n->objname = lcons(makeString($7), $5);
+ n->object = (Node *) lcons(makeString($7), $5);
n->comment = $9;
$$ = (Node *) n;
}
@@ -6313,8 +6317,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_OPFAMILY;
- n->objname = lcons(makeString($7), $5);
- n->objargs = NIL;
+ n->object = (Node *) lcons(makeString($7), $5);
n->comment = $9;
$$ = (Node *) n;
}
@@ -6322,8 +6325,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_LARGEOBJECT;
- n->objname = list_make1($5);
- n->objargs = NIL;
+ n->object = (Node *) $5;
n->comment = $7;
$$ = (Node *) n;
}
@@ -6331,27 +6333,15 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_CAST;
- n->objname = list_make1($5);
- n->objargs = list_make1($7);
+ n->object = (Node *) list_make2($5, $7);
n->comment = $10;
$$ = (Node *) n;
}
- | COMMENT ON opt_procedural LANGUAGE any_name IS comment_text
- {
- CommentStmt *n = makeNode(CommentStmt);
- n->objtype = OBJECT_LANGUAGE;
- n->objname = $5;
- n->objargs = NIL;
- n->comment = $7;
- $$ = (Node *) n;
- }
;
-comment_type:
- ACCESS METHOD { $$ = OBJECT_ACCESS_METHOD; }
- | COLUMN { $$ = OBJECT_COLUMN; }
- | DATABASE { $$ = OBJECT_DATABASE; }
- | SCHEMA { $$ = OBJECT_SCHEMA; }
+/* object types taking any_name */
+comment_type_any_name:
+ COLUMN { $$ = OBJECT_COLUMN; }
| INDEX { $$ = OBJECT_INDEX; }
| SEQUENCE { $$ = OBJECT_SEQUENCE; }
| TABLE { $$ = OBJECT_TABLE; }
@@ -6359,19 +6349,27 @@ comment_type:
| MATERIALIZED VIEW { $$ = OBJECT_MATVIEW; }
| COLLATION { $$ = OBJECT_COLLATION; }
| CONVERSION_P { $$ = OBJECT_CONVERSION; }
- | TABLESPACE { $$ = OBJECT_TABLESPACE; }
- | EXTENSION { $$ = OBJECT_EXTENSION; }
- | ROLE { $$ = OBJECT_ROLE; }
| FOREIGN TABLE { $$ = OBJECT_FOREIGN_TABLE; }
- | SERVER { $$ = OBJECT_FOREIGN_SERVER; }
- | FOREIGN DATA_P WRAPPER { $$ = OBJECT_FDW; }
- | EVENT TRIGGER { $$ = OBJECT_EVENT_TRIGGER; }
| TEXT_P SEARCH CONFIGURATION { $$ = OBJECT_TSCONFIGURATION; }
| TEXT_P SEARCH DICTIONARY { $$ = OBJECT_TSDICTIONARY; }
| TEXT_P SEARCH PARSER { $$ = OBJECT_TSPARSER; }
| TEXT_P SEARCH TEMPLATE { $$ = OBJECT_TSTEMPLATE; }
;
+/* object types taking name */
+comment_type_name:
+ ACCESS METHOD { $$ = OBJECT_ACCESS_METHOD; }
+ | DATABASE { $$ = OBJECT_DATABASE; }
+ | EVENT TRIGGER { $$ = OBJECT_EVENT_TRIGGER; }
+ | EXTENSION { $$ = OBJECT_EXTENSION; }
+ | FOREIGN DATA_P WRAPPER { $$ = OBJECT_FDW; }
+ | opt_procedural LANGUAGE { $$ = OBJECT_LANGUAGE; }
+ | ROLE { $$ = OBJECT_ROLE; }
+ | SCHEMA { $$ = OBJECT_SCHEMA; }
+ | SERVER { $$ = OBJECT_FOREIGN_SERVER; }
+ | TABLESPACE { $$ = OBJECT_TABLESPACE; }
+ ;
+
comment_text:
Sconst { $$ = $1; }
| NULL_P { $$ = NULL; }
@@ -6388,14 +6386,23 @@ comment_text:
*****************************************************************************/
SecLabelStmt:
- SECURITY LABEL opt_provider ON security_label_type any_name
+ SECURITY LABEL opt_provider ON security_label_type_any_name any_name
IS security_label
{
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = $5;
- n->objname = $6;
- n->objargs = NIL;
+ n->object = (Node *) $6;
+ n->label = $8;
+ $$ = (Node *) n;
+ }
+ | SECURITY LABEL opt_provider ON security_label_type_name name
+ IS security_label
+ {
+ SecLabelStmt *n = makeNode(SecLabelStmt);
+ n->provider = $3;
+ n->objtype = $5;
+ n->object = (Node *) makeString($6);
n->label = $8;
$$ = (Node *) n;
}
@@ -6405,8 +6412,7 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_TYPE;
- n->objname = list_make1($6);
- n->objargs = NIL;
+ n->object = (Node *) $6;
n->label = $8;
$$ = (Node *) n;
}
@@ -6416,8 +6422,7 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_TYPE;
- n->objname = list_make1($6);
- n->objargs = NIL;
+ n->object = (Node *) $6;
n->label = $8;
$$ = (Node *) n;
}
@@ -6427,8 +6432,7 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_AGGREGATE;
- n->objname = $6->objname;
- n->objargs = $6->objargs;
+ n->object = (Node *) $6;
n->label = $8;
$$ = (Node *) n;
}
@@ -6438,8 +6442,7 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_FUNCTION;
- n->objname = $6->objname;
- n->objargs = $6->objargs;
+ n->object = (Node *) $6;
n->label = $8;
$$ = (Node *) n;
}
@@ -6449,19 +6452,7 @@ SecLabelStmt:
SecLabelStmt *n = makeNode(SecLabelStmt);
n->provider = $3;
n->objtype = OBJECT_LARGEOBJECT;
- n->objname = list_make1($7);
- n->objargs = NIL;
- n->label = $9;
- $$ = (Node *) n;
- }
- | SECURITY LABEL opt_provider ON opt_procedural LANGUAGE any_name
- IS security_label
- {
- SecLabelStmt *n = makeNode(SecLabelStmt);
- n->provider = $3;
- n->objtype = OBJECT_LANGUAGE;
- n->objname = $7;
- n->objargs = NIL;
+ n->object = (Node *) $7;
n->label = $9;
$$ = (Node *) n;
}
@@ -6471,20 +6462,26 @@ opt_provider: FOR NonReservedWord_or_Sconst { $$ = $2; }
| /* empty */ { $$ = NULL; }
;
-security_label_type:
+/* object types taking any_name */
+security_label_type_any_name:
COLUMN { $$ = OBJECT_COLUMN; }
- | DATABASE { $$ = OBJECT_DATABASE; }
- | EVENT TRIGGER { $$ = OBJECT_EVENT_TRIGGER; }
| FOREIGN TABLE { $$ = OBJECT_FOREIGN_TABLE; }
- | SCHEMA { $$ = OBJECT_SCHEMA; }
| SEQUENCE { $$ = OBJECT_SEQUENCE; }
| TABLE { $$ = OBJECT_TABLE; }
- | ROLE { $$ = OBJECT_ROLE; }
- | TABLESPACE { $$ = OBJECT_TABLESPACE; }
| VIEW { $$ = OBJECT_VIEW; }
| MATERIALIZED VIEW { $$ = OBJECT_MATVIEW; }
;
+/* object types taking name */
+security_label_type_name:
+ DATABASE { $$ = OBJECT_DATABASE; }
+ | EVENT TRIGGER { $$ = OBJECT_EVENT_TRIGGER; }
+ | opt_procedural LANGUAGE { $$ = OBJECT_LANGUAGE; }
+ | ROLE { $$ = OBJECT_ROLE; }
+ | SCHEMA { $$ = OBJECT_SCHEMA; }
+ | TABLESPACE { $$ = OBJECT_TABLESPACE; }
+ ;
+
security_label: Sconst { $$ = $1; }
| NULL_P { $$ = NULL; }
;
@@ -7684,8 +7681,7 @@ RemoveFuncStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($3->objname);
- n->arguments = list_make1($3->objargs);
+ n->objects = list_make1($3);
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
@@ -7695,8 +7691,7 @@ RemoveFuncStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($5->objname);
- n->arguments = list_make1($5->objargs);
+ n->objects = list_make1($5);
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7709,8 +7704,7 @@ RemoveAggrStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($3->objname);
- n->arguments = list_make1($3->objargs);
+ n->objects = list_make1($3);
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
@@ -7720,8 +7714,7 @@ RemoveAggrStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($5->objname);
- n->arguments = list_make1($5->objargs);
+ n->objects = list_make1($5);
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7734,8 +7727,7 @@ RemoveOperStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($3->objname);
- n->arguments = list_make1($3->objargs);
+ n->objects = list_make1($3);
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
@@ -7745,8 +7737,7 @@ RemoveOperStmt:
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($5->objname);
- n->arguments = list_make1($5->objargs);
+ n->objects = list_make1($5);
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7872,8 +7863,7 @@ DropCastStmt: DROP CAST opt_if_exists '(' Typename AS Typename ')' opt_drop_beha
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_CAST;
- n->objects = list_make1(list_make1($5));
- n->arguments = list_make1(list_make1($7));
+ n->objects = list_make1(list_make2($5, $7));
n->behavior = $9;
n->missing_ok = $3;
n->concurrent = false;
@@ -7927,8 +7917,7 @@ DropTransformStmt: DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_d
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_TRANSFORM;
- n->objects = list_make1(list_make1($5));
- n->arguments = list_make1(list_make1(makeString($7)));
+ n->objects = list_make1(list_make2($5, makeString($7)));
n->behavior = $8;
n->missing_ok = $3;
$$ = (Node *)n;
@@ -8035,8 +8024,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_AGGREGATE;
- n->object = $3->objname;
- n->objarg = $3->objargs;
+ n->object = (Node *) $3;
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8045,7 +8033,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_COLLATION;
- n->object = $3;
+ n->object = (Node *) $3;
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8054,7 +8042,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_CONVERSION;
- n->object = $3;
+ n->object = (Node *) $3;
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8072,7 +8060,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_DOMAIN;
- n->object = $3;
+ n->object = (Node *) $3;
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8081,7 +8069,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_DOMCONSTRAINT;
- n->object = $3;
+ n->object = (Node *) $3;
n->subname = $6;
n->newname = $8;
$$ = (Node *)n;
@@ -8090,7 +8078,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_FDW;
- n->object = list_make1(makeString($5));
+ n->object = (Node *) makeString($5);
n->newname = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8099,8 +8087,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_FUNCTION;
- n->object = $3->objname;
- n->objarg = $3->objargs;
+ n->object = (Node *) $3;
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8118,7 +8105,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_LANGUAGE;
- n->object = list_make1(makeString($4));
+ n->object = (Node *) makeString($4);
n->newname = $7;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8127,7 +8114,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_OPCLASS;
- n->object = lcons(makeString($6), $4);
+ n->object = (Node *) lcons(makeString($6), $4);
n->newname = $9;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8136,7 +8123,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_OPFAMILY;
- n->object = lcons(makeString($6), $4);
+ n->object = (Node *) lcons(makeString($6), $4);
n->newname = $9;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8174,7 +8161,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_FOREIGN_SERVER;
- n->object = list_make1(makeString($3));
+ n->object = (Node *) makeString($3);
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8409,7 +8396,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_EVENT_TRIGGER;
- n->object = list_make1(makeString($4));
+ n->object = (Node *) makeString($4);
n->newname = $7;
$$ = (Node *)n;
}
@@ -8444,7 +8431,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_TSPARSER;
- n->object = $5;
+ n->object = (Node *) $5;
n->newname = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8453,7 +8440,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_TSDICTIONARY;
- n->object = $5;
+ n->object = (Node *) $5;
n->newname = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8462,7 +8449,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_TSTEMPLATE;
- n->object = $5;
+ n->object = (Node *) $5;
n->newname = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8471,7 +8458,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_TSCONFIGURATION;
- n->object = $5;
+ n->object = (Node *) $5;
n->newname = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8480,7 +8467,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
{
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_TYPE;
- n->object = $3;
+ n->object = (Node *) $3;
n->newname = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8518,9 +8505,7 @@ AlterObjectDependsStmt:
{
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_FUNCTION;
- n->relation = NULL;
- n->objname = $3->objname;
- n->objargs = $3->objargs;
+ n->object = (Node *) $3;
n->extname = makeString($7);
$$ = (Node *)n;
}
@@ -8529,8 +8514,7 @@ AlterObjectDependsStmt:
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_TRIGGER;
n->relation = $5;
- n->objname = list_make1(makeString($3));
- n->objargs = NIL;
+ n->object = (Node *) list_make1(makeString($3));
n->extname = makeString($9);
$$ = (Node *)n;
}
@@ -8539,8 +8523,6 @@ AlterObjectDependsStmt:
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_MATVIEW;
n->relation = $4;
- n->objname = NIL;
- n->objargs = NIL;
n->extname = makeString($8);
$$ = (Node *)n;
}
@@ -8549,8 +8531,6 @@ AlterObjectDependsStmt:
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_INDEX;
n->relation = $3;
- n->objname = NIL;
- n->objargs = NIL;
n->extname = makeString($7);
$$ = (Node *)n;
}
@@ -8567,8 +8547,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_AGGREGATE;
- n->object = $3->objname;
- n->objarg = $3->objargs;
+ n->object = (Node *) $3;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8577,7 +8556,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_COLLATION;
- n->object = $3;
+ n->object = (Node *) $3;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8586,7 +8565,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_CONVERSION;
- n->object = $3;
+ n->object = (Node *) $3;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8595,16 +8574,16 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_DOMAIN;
- n->object = $3;
+ n->object = (Node *) $3;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
}
- | ALTER EXTENSION any_name SET SCHEMA name
+ | ALTER EXTENSION name SET SCHEMA name
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_EXTENSION;
- n->object = $3;
+ n->object = (Node *) makeString($3);
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8613,8 +8592,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_FUNCTION;
- n->object = $3->objname;
- n->objarg = $3->objargs;
+ n->object = (Node *) $3;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8623,8 +8601,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_OPERATOR;
- n->object = $3->objname;
- n->objarg = $3->objargs;
+ n->object = (Node *) $3;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8633,7 +8610,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_OPCLASS;
- n->object = lcons(makeString($6), $4);
+ n->object = (Node *) lcons(makeString($6), $4);
n->newschema = $9;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8642,7 +8619,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_OPFAMILY;
- n->object = lcons(makeString($6), $4);
+ n->object = (Node *) lcons(makeString($6), $4);
n->newschema = $9;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8669,7 +8646,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_TSPARSER;
- n->object = $5;
+ n->object = (Node *) $5;
n->newschema = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8678,7 +8655,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_TSDICTIONARY;
- n->object = $5;
+ n->object = (Node *) $5;
n->newschema = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8687,7 +8664,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_TSTEMPLATE;
- n->object = $5;
+ n->object = (Node *) $5;
n->newschema = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8696,7 +8673,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_TSCONFIGURATION;
- n->object = $5;
+ n->object = (Node *) $5;
n->newschema = $8;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8777,7 +8754,7 @@ AlterObjectSchemaStmt:
{
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_TYPE;
- n->object = $3;
+ n->object = (Node *) $3;
n->newschema = $6;
n->missing_ok = false;
$$ = (Node *)n;
@@ -8821,8 +8798,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_AGGREGATE;
- n->object = $3->objname;
- n->objarg = $3->objargs;
+ n->object = (Node *) $3;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8830,7 +8806,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_COLLATION;
- n->object = $3;
+ n->object = (Node *) $3;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8838,7 +8814,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_CONVERSION;
- n->object = $3;
+ n->object = (Node *) $3;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8846,7 +8822,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_DATABASE;
- n->object = list_make1(makeString($3));
+ n->object = (Node *) makeString($3);
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8854,7 +8830,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_DOMAIN;
- n->object = $3;
+ n->object = (Node *) $3;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8862,8 +8838,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_FUNCTION;
- n->object = $3->objname;
- n->objarg = $3->objargs;
+ n->object = (Node *) $3;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8871,7 +8846,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_LANGUAGE;
- n->object = list_make1(makeString($4));
+ n->object = (Node *) makeString($4);
n->newowner = $7;
$$ = (Node *)n;
}
@@ -8879,7 +8854,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_LARGEOBJECT;
- n->object = list_make1($4);
+ n->object = (Node *) $4;
n->newowner = $7;
$$ = (Node *)n;
}
@@ -8887,8 +8862,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_OPERATOR;
- n->object = $3->objname;
- n->objarg = $3->objargs;
+ n->object = (Node *) $3;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8896,7 +8870,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_OPCLASS;
- n->object = lcons(makeString($6), $4);
+ n->object = (Node *) lcons(makeString($6), $4);
n->newowner = $9;
$$ = (Node *)n;
}
@@ -8904,7 +8878,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_OPFAMILY;
- n->object = lcons(makeString($6), $4);
+ n->object = (Node *) lcons(makeString($6), $4);
n->newowner = $9;
$$ = (Node *)n;
}
@@ -8912,7 +8886,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_SCHEMA;
- n->object = list_make1(makeString($3));
+ n->object = (Node *) makeString($3);
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8920,7 +8894,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_TYPE;
- n->object = $3;
+ n->object = (Node *) $3;
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8928,7 +8902,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_TABLESPACE;
- n->object = list_make1(makeString($3));
+ n->object = (Node *) makeString($3);
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8936,7 +8910,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_TSDICTIONARY;
- n->object = $5;
+ n->object = (Node *) $5;
n->newowner = $8;
$$ = (Node *)n;
}
@@ -8944,7 +8918,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_TSCONFIGURATION;
- n->object = $5;
+ n->object = (Node *) $5;
n->newowner = $8;
$$ = (Node *)n;
}
@@ -8952,7 +8926,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_FDW;
- n->object = list_make1(makeString($5));
+ n->object = (Node *) makeString($5);
n->newowner = $8;
$$ = (Node *)n;
}
@@ -8960,7 +8934,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_FOREIGN_SERVER;
- n->object = list_make1(makeString($3));
+ n->object = (Node *) makeString($3);
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8968,7 +8942,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_EVENT_TRIGGER;
- n->object = list_make1(makeString($4));
+ n->object = (Node *) makeString($4);
n->newowner = $7;
$$ = (Node *)n;
}
@@ -8976,7 +8950,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_PUBLICATION;
- n->object = list_make1(makeString($3));
+ n->object = (Node *) makeString($3);
n->newowner = $6;
$$ = (Node *)n;
}
@@ -8984,7 +8958,7 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
n->objectType = OBJECT_SUBSCRIPTION;
- n->object = list_make1(makeString($3));
+ n->object = (Node *) makeString($3);
n->newowner = $6;
$$ = (Node *)n;
}
@@ -9279,7 +9253,6 @@ DropRuleStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_RULE;
n->objects = list_make1(lappend($5, makeString($3)));
- n->arguments = NIL;
n->behavior = $6;
n->missing_ok = false;
n->concurrent = false;
@@ -9290,7 +9263,6 @@ DropRuleStmt:
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_RULE;
n->objects = list_make1(lappend($7, makeString($5)));
- n->arguments = NIL;
n->behavior = $8;
n->missing_ok = true;
n->concurrent = false;
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index ff2bab6551..673276a9d3 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -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),
- makeString(cxt->relation->relname),
- makeString(def->colname));
- stmt->objargs = NIL;
+ stmt->object = (Node *) list_make3(makeString(cxt->relation->schemaname),
+ makeString(cxt->relation->relname),
+ makeString(def->colname));
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),
- makeString(cxt->relation->relname),
- makeString(n->conname));
- stmt->objargs = NIL;
+ stmt->object = (Node *) list_make3(makeString(cxt->relation->schemaname),
+ makeString(cxt->relation->relname),
+ makeString(n->conname));
stmt->comment = comment;
cxt->alist = lappend(cxt->alist, stmt);
diff --git a/src/include/catalog/objectaddress.h b/src/include/catalog/objectaddress.h
index 1a5afe1bed..406c38bc73 100644
--- a/src/include/catalog/objectaddress.h
+++ b/src/include/catalog/objectaddress.h
@@ -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);
diff --git a/src/include/commands/extension.h b/src/include/commands/extension.h
index 3f14c90267..7f027d9dc7 100644
--- a/src/include/commands/extension.h
+++ b/src/include/commands/extension.h
@@ -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);
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 97993f5198..7c7530bd3f 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -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;
diff --git a/src/test/regress/expected/event_trigger.out b/src/test/regress/expected/event_trigger.out
index e12455201e..906dcb8b31 100644
--- a/src/test/regress/expected/event_trigger.out
+++ b/src/test/regress/expected/event_trigger.out
@@ -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;
diff --git a/src/test/regress/expected/object_address.out b/src/test/regress/expected/object_address.out
index 4766975746..fc9f1cb2ff 100644
--- a/src/test/regress/expected/object_address.out
+++ b/src/test/regress/expected/object_address.out
@@ -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[]),
diff --git a/src/test/regress/sql/event_trigger.sql b/src/test/regress/sql/event_trigger.sql
index 534f532a9e..b65bf3ec66 100644
--- a/src/test/regress/sql/event_trigger.sql
+++ b/src/test/regress/sql/event_trigger.sql
@@ -82,9 +82,6 @@
-- 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;
--
2.11.1
v2-0004-Replace-LookupFuncNameTypeNames-with-LookupFuncWi.patchtext/x-patch; name=v2-0004-Replace-LookupFuncNameTypeNames-with-LookupFuncWi.patchDownload
From 943cf8461aa995fa3fe6c0347a683dd05b4eae7e Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Wed, 28 Dec 2016 12:00:00 -0500
Subject: [PATCH v2 4/6] Replace LookupFuncNameTypeNames() with
LookupFuncWithArgs()
The old function took function name and function argument list as
separate arguments. Now that all function signatures are passed around
as ObjectWithArgs structs, this is no longer necessary and can be
replaced by a function that takes ObjectWithArgs directly. Similarly
for aggregates and operators.
---
src/backend/catalog/aclchk.c | 3 +--
src/backend/catalog/objectaddress.c | 40 +++++++++++--------------------------
src/backend/commands/functioncmds.c | 12 ++++-------
src/backend/commands/opclasscmds.c | 30 +++++++---------------------
src/backend/commands/operatorcmds.c | 5 +----
src/backend/nodes/copyfuncs.c | 2 --
src/backend/nodes/equalfuncs.c | 2 --
src/backend/parser/gram.y | 18 ++++++++---------
src/backend/parser/parse_func.c | 32 ++++++++++++++---------------
src/backend/parser/parse_oper.c | 24 ++++++++++++----------
src/include/nodes/parsenodes.h | 7 ++-----
src/include/parser/parse_func.h | 4 ++--
src/include/parser/parse_oper.h | 5 ++---
13 files changed, 68 insertions(+), 116 deletions(-)
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index 7e9ed76b80..be86d76a59 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -670,8 +670,7 @@ objectNamesToOids(GrantObjectType objtype, List *objnames)
ObjectWithArgs *func = (ObjectWithArgs *) lfirst(cell);
Oid funcid;
- funcid = LookupFuncNameTypeNames(func->objname,
- func->objargs, false);
+ funcid = LookupFuncWithArgs(func, false);
objects = lappend_oid(objects, funcid);
}
break;
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index b6b3ff3db1..a9ef313dc5 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -868,36 +868,20 @@ get_object_address(ObjectType objtype, Node *object,
address = get_object_address_type(objtype, castNode(TypeName, object), missing_ok);
break;
case OBJECT_AGGREGATE:
- {
- ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
- address.classId = ProcedureRelationId;
- address.objectId =
- LookupAggNameTypeNames(owa->objname, owa->objargs, missing_ok);
- address.objectSubId = 0;
- break;
- }
+ address.classId = ProcedureRelationId;
+ address.objectId = LookupAggWithArgs(castNode(ObjectWithArgs, object), missing_ok);
+ address.objectSubId = 0;
+ break;
case OBJECT_FUNCTION:
- {
- ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
- address.classId = ProcedureRelationId;
- address.objectId =
- LookupFuncNameTypeNames(owa->objname, owa->objargs, missing_ok);
- address.objectSubId = 0;
- break;
- }
+ address.classId = ProcedureRelationId;
+ address.objectId = LookupFuncWithArgs(castNode(ObjectWithArgs, object), missing_ok);
+ address.objectSubId = 0;
+ break;
case OBJECT_OPERATOR:
- {
- ObjectWithArgs *owa = castNode(ObjectWithArgs, object);
- address.classId = OperatorRelationId;
- Assert(list_length(owa->objargs) == 2);
- address.objectId =
- LookupOperNameTypeNames(NULL, owa->objname,
- castNode(TypeName, linitial(owa->objargs)),
- castNode(TypeName, lsecond(owa->objargs)),
- missing_ok, -1);
- address.objectSubId = 0;
- break;
- }
+ address.classId = OperatorRelationId;
+ address.objectId = LookupOperWithArgs(castNode(ObjectWithArgs, object), missing_ok);
+ address.objectSubId = 0;
+ break;
case OBJECT_COLLATION:
address.classId = CollationRelationId;
address.objectId = get_collation_oid(castNode(List, object), missing_ok);
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index 3d1b64549e..b9aedb2292 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -1181,9 +1181,7 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
rel = heap_open(ProcedureRelationId, RowExclusiveLock);
- funcOid = LookupFuncNameTypeNames(stmt->func->objname,
- stmt->func->objargs,
- false);
+ funcOid = LookupFuncWithArgs(stmt->func, false);
tup = SearchSysCacheCopy1(PROCOID, ObjectIdGetDatum(funcOid));
if (!HeapTupleIsValid(tup)) /* should not happen */
@@ -1453,9 +1451,7 @@ CreateCast(CreateCastStmt *stmt)
{
Form_pg_proc procstruct;
- funcid = LookupFuncNameTypeNames(stmt->func->objname,
- stmt->func->objargs,
- false);
+ funcid = LookupFuncWithArgs(stmt->func, false);
tuple = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
if (!HeapTupleIsValid(tuple))
@@ -1836,7 +1832,7 @@ CreateTransform(CreateTransformStmt *stmt)
*/
if (stmt->fromsql)
{
- fromsqlfuncid = LookupFuncNameTypeNames(stmt->fromsql->objname, stmt->fromsql->objargs, false);
+ fromsqlfuncid = LookupFuncWithArgs(stmt->fromsql, false);
if (!pg_proc_ownercheck(fromsqlfuncid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->fromsql->objname));
@@ -1862,7 +1858,7 @@ CreateTransform(CreateTransformStmt *stmt)
if (stmt->tosql)
{
- tosqlfuncid = LookupFuncNameTypeNames(stmt->tosql->objname, stmt->tosql->objargs, false);
+ tosqlfuncid = LookupFuncWithArgs(stmt->tosql, false);
if (!pg_proc_ownercheck(tosqlfuncid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_PROC, NameListToString(stmt->tosql->objname));
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 9bd50a3bec..822b331e0d 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -475,19 +475,12 @@ DefineOpClass(CreateOpClassStmt *stmt)
errmsg("invalid operator number %d,"
" must be between 1 and %d",
item->number, maxOpNumber)));
- if (item->args != NIL)
- {
- TypeName *typeName1 = (TypeName *) linitial(item->args);
- TypeName *typeName2 = (TypeName *) lsecond(item->args);
-
- operOid = LookupOperNameTypeNames(NULL, item->name,
- typeName1, typeName2,
- false, -1);
- }
+ if (item->name->objargs != NIL)
+ operOid = LookupOperWithArgs(item->name, false);
else
{
/* Default to binary op on input datatype */
- operOid = LookupOperName(NULL, item->name,
+ operOid = LookupOperName(NULL, item->name->objname,
typeoid, typeoid,
false, -1);
}
@@ -526,8 +519,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
errmsg("invalid procedure number %d,"
" must be between 1 and %d",
item->number, maxProcNumber)));
- funcOid = LookupFuncNameTypeNames(item->name, item->args,
- false);
+ funcOid = LookupFuncWithArgs(item->name, false);
#ifdef NOT_USED
/* XXX this is unnecessary given the superuser check above */
/* Caller must own function */
@@ -857,15 +849,8 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
errmsg("invalid operator number %d,"
" must be between 1 and %d",
item->number, maxOpNumber)));
- if (item->args != NIL)
- {
- TypeName *typeName1 = (TypeName *) linitial(item->args);
- TypeName *typeName2 = (TypeName *) lsecond(item->args);
-
- operOid = LookupOperNameTypeNames(NULL, item->name,
- typeName1, typeName2,
- false, -1);
- }
+ if (item->name->objargs != NIL)
+ operOid = LookupOperWithArgs(item->name, false);
else
{
ereport(ERROR,
@@ -908,8 +893,7 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
errmsg("invalid procedure number %d,"
" must be between 1 and %d",
item->number, maxProcNumber)));
- funcOid = LookupFuncNameTypeNames(item->name, item->args,
- false);
+ funcOid = LookupFuncWithArgs(item->name, false);
#ifdef NOT_USED
/* XXX this is unnecessary given the superuser check above */
/* Caller must own function */
diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c
index b063467bbd..739d5875eb 100644
--- a/src/backend/commands/operatorcmds.c
+++ b/src/backend/commands/operatorcmds.c
@@ -402,10 +402,7 @@ AlterOperator(AlterOperatorStmt *stmt)
Oid joinOid;
/* Look up the operator */
- oprId = LookupOperNameTypeNames(NULL, stmt->opername,
- (TypeName *) linitial(stmt->operargs),
- (TypeName *) lsecond(stmt->operargs),
- false, -1);
+ oprId = LookupOperWithArgs(stmt->opername, false);
catalog = heap_open(OperatorRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(oprId));
if (tup == NULL)
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 598ba944a1..bb2a8a3586 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -3314,7 +3314,6 @@ _copyAlterOperatorStmt(const AlterOperatorStmt *from)
AlterOperatorStmt *newnode = makeNode(AlterOperatorStmt);
COPY_NODE_FIELD(opername);
- COPY_NODE_FIELD(operargs);
COPY_NODE_FIELD(options);
return newnode;
@@ -3487,7 +3486,6 @@ _copyCreateOpClassItem(const CreateOpClassItem *from)
COPY_SCALAR_FIELD(itemtype);
COPY_NODE_FIELD(name);
- COPY_NODE_FIELD(args);
COPY_SCALAR_FIELD(number);
COPY_NODE_FIELD(order_family);
COPY_NODE_FIELD(class_args);
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index 876b8aabb9..9fa83b9453 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -1390,7 +1390,6 @@ static bool
_equalAlterOperatorStmt(const AlterOperatorStmt *a, const AlterOperatorStmt *b)
{
COMPARE_NODE_FIELD(opername);
- COMPARE_NODE_FIELD(operargs);
COMPARE_NODE_FIELD(options);
return true;
@@ -1535,7 +1534,6 @@ _equalCreateOpClassItem(const CreateOpClassItem *a, const CreateOpClassItem *b)
{
COMPARE_SCALAR_FIELD(itemtype);
COMPARE_NODE_FIELD(name);
- COMPARE_NODE_FIELD(args);
COMPARE_SCALAR_FIELD(number);
COMPARE_NODE_FIELD(order_family);
COMPARE_NODE_FIELD(class_args);
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 53ee3a963e..41daab57c7 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -5778,9 +5778,11 @@ opclass_item:
OPERATOR Iconst any_operator opclass_purpose opt_recheck
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
+ ObjectWithArgs *owa = makeNode(ObjectWithArgs);
+ owa->objname = $3;
+ owa->objargs = NIL;
n->itemtype = OPCLASS_ITEM_OPERATOR;
- n->name = $3;
- n->args = NIL;
+ n->name = owa;
n->number = $2;
n->order_family = $4;
$$ = (Node *) n;
@@ -5790,8 +5792,7 @@ opclass_item:
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_OPERATOR;
- n->name = $3->objname;
- n->args = $3->objargs;
+ n->name = $3;
n->number = $2;
n->order_family = $4;
$$ = (Node *) n;
@@ -5800,8 +5801,7 @@ opclass_item:
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION;
- n->name = $3->objname;
- n->args = $3->objargs;
+ n->name = $3;
n->number = $2;
$$ = (Node *) n;
}
@@ -5809,8 +5809,7 @@ opclass_item:
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION;
- n->name = $6->objname;
- n->args = $6->objargs;
+ n->name = $6;
n->number = $2;
n->class_args = $4;
$$ = (Node *) n;
@@ -8771,8 +8770,7 @@ AlterOperatorStmt:
ALTER OPERATOR operator_with_argtypes SET '(' operator_def_list ')'
{
AlterOperatorStmt *n = makeNode(AlterOperatorStmt);
- n->opername = $3->objname;
- n->operargs = $3->objargs;
+ n->opername = $3;
n->options = $6;
$$ = (Node *)n;
}
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index 672f7f65f1..dd9749f205 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -1932,19 +1932,19 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError)
}
/*
- * LookupFuncNameTypeNames
+ * LookupFuncWithArgs
* Like LookupFuncName, but the argument types are specified by a
- * list of TypeName nodes.
+ * ObjectWithArgs node.
*/
Oid
-LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
+LookupFuncWithArgs(ObjectWithArgs *func, bool noError)
{
Oid argoids[FUNC_MAX_ARGS];
int argcount;
int i;
ListCell *args_item;
- argcount = list_length(argtypes);
+ argcount = list_length(func->objargs);
if (argcount > FUNC_MAX_ARGS)
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
@@ -1953,7 +1953,7 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
FUNC_MAX_ARGS,
FUNC_MAX_ARGS)));
- args_item = list_head(argtypes);
+ args_item = list_head(func->objargs);
for (i = 0; i < argcount; i++)
{
TypeName *t = (TypeName *) lfirst(args_item);
@@ -1962,19 +1962,19 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
args_item = lnext(args_item);
}
- return LookupFuncName(funcname, argcount, argoids, noError);
+ return LookupFuncName(func->objname, argcount, argoids, noError);
}
/*
- * LookupAggNameTypeNames
- * Find an aggregate function given a name and list of TypeName nodes.
+ * LookupAggWithArgs
+ * Find an aggregate function from a given ObjectWithArgs node.
*
- * This is almost like LookupFuncNameTypeNames, but the error messages refer
+ * This is almost like LookupFuncWithArgs, but the error messages refer
* to aggregates rather than plain functions, and we verify that the found
* function really is an aggregate.
*/
Oid
-LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
+LookupAggWithArgs(ObjectWithArgs *agg, bool noError)
{
Oid argoids[FUNC_MAX_ARGS];
int argcount;
@@ -1984,7 +1984,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
HeapTuple ftup;
Form_pg_proc pform;
- argcount = list_length(argtypes);
+ argcount = list_length(agg->objargs);
if (argcount > FUNC_MAX_ARGS)
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
@@ -1994,7 +1994,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
FUNC_MAX_ARGS)));
i = 0;
- foreach(lc, argtypes)
+ foreach(lc, agg->objargs)
{
TypeName *t = (TypeName *) lfirst(lc);
@@ -2002,7 +2002,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
i++;
}
- oid = LookupFuncName(aggname, argcount, argoids, true);
+ oid = LookupFuncName(agg->objname, argcount, argoids, true);
if (!OidIsValid(oid))
{
@@ -2012,12 +2012,12 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("aggregate %s(*) does not exist",
- NameListToString(aggname))));
+ NameListToString(agg->objname))));
else
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("aggregate %s does not exist",
- func_signature_string(aggname, argcount,
+ func_signature_string(agg->objname, argcount,
NIL, argoids))));
}
@@ -2036,7 +2036,7 @@ LookupAggNameTypeNames(List *aggname, List *argtypes, bool noError)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("function %s is not an aggregate",
- func_signature_string(aggname, argcount,
+ func_signature_string(agg->objname, argcount,
NIL, argoids))));
}
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index 894e900073..e40b10d4f6 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -132,32 +132,34 @@ LookupOperName(ParseState *pstate, List *opername, Oid oprleft, Oid oprright,
}
/*
- * LookupOperNameTypeNames
+ * LookupOperWithArgs
* Like LookupOperName, but the argument types are specified by
- * TypeName nodes.
- *
- * Pass oprleft = NULL for a prefix op, oprright = NULL for a postfix op.
+ * a ObjectWithArg node.
*/
Oid
-LookupOperNameTypeNames(ParseState *pstate, List *opername,
- TypeName *oprleft, TypeName *oprright,
- bool noError, int location)
+LookupOperWithArgs(ObjectWithArgs *oper, bool noError)
{
+ TypeName *oprleft,
+ *oprright;
Oid leftoid,
rightoid;
+ Assert(list_length(oper->objargs) == 2);
+ oprleft = linitial(oper->objargs);
+ oprright = lsecond(oper->objargs);
+
if (oprleft == NULL)
leftoid = InvalidOid;
else
- leftoid = LookupTypeNameOid(pstate, oprleft, noError);
+ leftoid = LookupTypeNameOid(NULL, oprleft, noError);
if (oprright == NULL)
rightoid = InvalidOid;
else
- rightoid = LookupTypeNameOid(pstate, oprright, noError);
+ rightoid = LookupTypeNameOid(NULL, oprright, noError);
- return LookupOperName(pstate, opername, leftoid, rightoid,
- noError, location);
+ return LookupOperName(NULL, oper->objname, leftoid, rightoid,
+ noError, -1);
}
/*
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 7c7530bd3f..956f99830c 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -2418,9 +2418,7 @@ typedef struct CreateOpClassItem
{
NodeTag type;
int itemtype; /* see codes above */
- /* fields used for an operator or function item: */
- List *name; /* operator or function name */
- List *args; /* argument types */
+ ObjectWithArgs *name; /* operator or function name and args */
int number; /* strategy num or support proc num */
List *order_family; /* only used for ordering operators */
List *class_args; /* amproclefttype/amprocrighttype or
@@ -2730,8 +2728,7 @@ typedef struct AlterOwnerStmt
typedef struct AlterOperatorStmt
{
NodeTag type;
- List *opername; /* operator name */
- List *operargs; /* operator's argument TypeNames */
+ ObjectWithArgs *opername; /* operator name and argument types */
List *options; /* List of DefElem nodes */
} AlterOperatorStmt;
diff --git a/src/include/parser/parse_func.h b/src/include/parser/parse_func.h
index 1c914065c0..8ccf7a9538 100644
--- a/src/include/parser/parse_func.h
+++ b/src/include/parser/parse_func.h
@@ -62,9 +62,9 @@ extern const char *func_signature_string(List *funcname, int nargs,
extern Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes,
bool noError);
-extern Oid LookupFuncNameTypeNames(List *funcname, List *argtypes,
+extern Oid LookupFuncWithArgs(ObjectWithArgs *func,
bool noError);
-extern Oid LookupAggNameTypeNames(List *aggname, List *argtypes,
+extern Oid LookupAggWithArgs(ObjectWithArgs *agg,
bool noError);
extern void check_srf_call_placement(ParseState *pstate, int location);
diff --git a/src/include/parser/parse_oper.h b/src/include/parser/parse_oper.h
index b8d46637be..a8f75b5921 100644
--- a/src/include/parser/parse_oper.h
+++ b/src/include/parser/parse_oper.h
@@ -15,6 +15,7 @@
#define PARSE_OPER_H
#include "access/htup.h"
+#include "nodes/parsenodes.h"
#include "parser/parse_node.h"
@@ -24,9 +25,7 @@ typedef HeapTuple Operator;
extern Oid LookupOperName(ParseState *pstate, List *opername,
Oid oprleft, Oid oprright,
bool noError, int location);
-extern Oid LookupOperNameTypeNames(ParseState *pstate, List *opername,
- TypeName *oprleft, TypeName *oprright,
- bool noError, int location);
+extern Oid LookupOperWithArgs(ObjectWithArgs *oper, bool noError);
/* Routines to find operators matching a name and given input types */
/* NB: the selected operator may require coercion of the input types! */
--
2.11.1
v2-0005-Allow-dropping-multiple-functions-at-once.patchtext/x-patch; name=v2-0005-Allow-dropping-multiple-functions-at-once.patchDownload
From d64c3bfd82775b9b5c9018fd861caf7a80af1c89 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Wed, 28 Dec 2016 12:00:00 -0500
Subject: [PATCH v2 5/6] Allow dropping multiple functions at once
The generic drop support already supported dropping multiple objects of
the same kind at once. But the previous representation
of function signatures across two grammar symbols and structure members
made this cumbersome to do for functions, so it was not supported. Now
that function signatures are represented by a single structure, it's
trivial to add this support. Same for aggregates and operators.
---
doc/src/sgml/ref/drop_aggregate.sgml | 2 +-
doc/src/sgml/ref/drop_function.sgml | 8 +++++-
doc/src/sgml/ref/drop_operator.sgml | 2 +-
src/backend/parser/gram.y | 38 ++++++++++++++++---------
src/test/regress/expected/create_function_3.out | 6 ++--
src/test/regress/sql/create_function_3.sql | 2 ++
6 files changed, 38 insertions(+), 20 deletions(-)
diff --git a/doc/src/sgml/ref/drop_aggregate.sgml b/doc/src/sgml/ref/drop_aggregate.sgml
index c27c5eadf9..f239d39dda 100644
--- a/doc/src/sgml/ref/drop_aggregate.sgml
+++ b/doc/src/sgml/ref/drop_aggregate.sgml
@@ -21,7 +21,7 @@
<refsynopsisdiv>
<synopsis>
-DROP AGGREGATE [ IF EXISTS ] <replaceable>name</replaceable> ( <replaceable>aggregate_signature</replaceable> ) [ CASCADE | RESTRICT ]
+DROP AGGREGATE [ IF EXISTS ] <replaceable>name</replaceable> ( <replaceable>aggregate_signature</replaceable> ) [, ...] [ CASCADE | RESTRICT ]
<phrase>where <replaceable>aggregate_signature</replaceable> is:</phrase>
diff --git a/doc/src/sgml/ref/drop_function.sgml b/doc/src/sgml/ref/drop_function.sgml
index 5883d13811..5969b084b4 100644
--- a/doc/src/sgml/ref/drop_function.sgml
+++ b/doc/src/sgml/ref/drop_function.sgml
@@ -21,7 +21,7 @@
<refsynopsisdiv>
<synopsis>
-DROP FUNCTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] )
+DROP FUNCTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable> ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) [, ...]
[ CASCADE | RESTRICT ]
</synopsis>
</refsynopsisdiv>
@@ -135,6 +135,12 @@ <title>Examples</title>
<programlisting>
DROP FUNCTION sqrt(integer);
</programlisting></para>
+
+ <para>
+ Drop multiple functions in one command:
+<programlisting>
+DROP FUNCTION sqrt(integer), sqrt(bigint);
+</programlisting></para>
</refsect1>
<refsect1 id="SQL-DROPFUNCTION-compatibility">
diff --git a/doc/src/sgml/ref/drop_operator.sgml b/doc/src/sgml/ref/drop_operator.sgml
index 13dd974f38..e196547499 100644
--- a/doc/src/sgml/ref/drop_operator.sgml
+++ b/doc/src/sgml/ref/drop_operator.sgml
@@ -21,7 +21,7 @@
<refsynopsisdiv>
<synopsis>
-DROP OPERATOR [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> ( { <replaceable class="PARAMETER">left_type</replaceable> | NONE } , { <replaceable class="PARAMETER">right_type</replaceable> | NONE } ) [ CASCADE | RESTRICT ]
+DROP OPERATOR [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> ( { <replaceable class="PARAMETER">left_type</replaceable> | NONE } , { <replaceable class="PARAMETER">right_type</replaceable> | NONE } ) [, ...] [ CASCADE | RESTRICT ]
</synopsis>
</refsynopsisdiv>
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 41daab57c7..92b11a399e 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -358,7 +358,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <list> privileges privilege_list
%type <privtarget> privilege_target
%type <objwithargs> function_with_argtypes aggregate_with_argtypes operator_with_argtypes
-%type <list> function_with_argtypes_list
+%type <list> function_with_argtypes_list aggregate_with_argtypes_list operator_with_argtypes_list
%type <ival> defacl_privilege_target
%type <defelt> DefACLOption
%type <list> DefACLOptionList
@@ -7495,6 +7495,12 @@ aggregate_with_argtypes:
}
;
+aggregate_with_argtypes_list:
+ aggregate_with_argtypes { $$ = list_make1($1); }
+ | aggregate_with_argtypes_list ',' aggregate_with_argtypes
+ { $$ = lappend($1, $3); }
+ ;
+
createfunc_opt_list:
/* Must be at least one to prevent conflict */
createfunc_opt_item { $$ = list_make1($1); }
@@ -7676,21 +7682,21 @@ opt_restrict:
*****************************************************************************/
RemoveFuncStmt:
- DROP FUNCTION function_with_argtypes opt_drop_behavior
+ DROP FUNCTION function_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($3);
+ n->objects = $3;
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
$$ = (Node *)n;
}
- | DROP FUNCTION IF_P EXISTS function_with_argtypes opt_drop_behavior
+ | DROP FUNCTION IF_P EXISTS function_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_FUNCTION;
- n->objects = list_make1($5);
+ n->objects = $5;
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7699,21 +7705,21 @@ RemoveFuncStmt:
;
RemoveAggrStmt:
- DROP AGGREGATE aggregate_with_argtypes opt_drop_behavior
+ DROP AGGREGATE aggregate_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($3);
+ n->objects = $3;
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
$$ = (Node *)n;
}
- | DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes opt_drop_behavior
+ | DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_AGGREGATE;
- n->objects = list_make1($5);
+ n->objects = $5;
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7722,21 +7728,21 @@ RemoveAggrStmt:
;
RemoveOperStmt:
- DROP OPERATOR operator_with_argtypes opt_drop_behavior
+ DROP OPERATOR operator_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($3);
+ n->objects = $3;
n->behavior = $4;
n->missing_ok = false;
n->concurrent = false;
$$ = (Node *)n;
}
- | DROP OPERATOR IF_P EXISTS operator_with_argtypes opt_drop_behavior
+ | DROP OPERATOR IF_P EXISTS operator_with_argtypes_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_OPERATOR;
- n->objects = list_make1($5);
+ n->objects = $5;
n->behavior = $6;
n->missing_ok = true;
n->concurrent = false;
@@ -7768,6 +7774,12 @@ any_operator:
{ $$ = lcons(makeString($1), $3); }
;
+operator_with_argtypes_list:
+ operator_with_argtypes { $$ = list_make1($1); }
+ | operator_with_argtypes_list ',' operator_with_argtypes
+ { $$ = lappend($1, $3); }
+ ;
+
operator_with_argtypes:
any_operator oper_argtypes
{
diff --git a/src/test/regress/expected/create_function_3.out b/src/test/regress/expected/create_function_3.out
index 7bb957b51b..cc4e98a1d4 100644
--- a/src/test/regress/expected/create_function_3.out
+++ b/src/test/regress/expected/create_function_3.out
@@ -217,9 +217,10 @@ SELECT routine_name, ordinal_position, parameter_name, parameter_default
functest_is_3 | 2 | b |
(7 rows)
+DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int);
-- Cleanups
DROP SCHEMA temp_func_test CASCADE;
-NOTICE: drop cascades to 19 other objects
+NOTICE: drop cascades to 16 other objects
DETAIL: drop cascades to function functest_a_1(text,date)
drop cascades to function functest_a_2(text[])
drop cascades to function functest_a_3()
@@ -236,8 +237,5 @@ drop cascades to function functext_f_1(integer)
drop cascades to function functext_f_2(integer)
drop cascades to function functext_f_3(integer)
drop cascades to function functext_f_4(integer)
-drop cascades to function functest_is_1(integer,integer,text)
-drop cascades to function functest_is_2(integer)
-drop cascades to function functest_is_3(integer)
DROP USER regress_unpriv_user;
RESET search_path;
diff --git a/src/test/regress/sql/create_function_3.sql b/src/test/regress/sql/create_function_3.sql
index 43454ef2f7..66a463b089 100644
--- a/src/test/regress/sql/create_function_3.sql
+++ b/src/test/regress/sql/create_function_3.sql
@@ -156,6 +156,8 @@ CREATE FUNCTION functest_IS_3(a int default 1, out b int)
WHERE routine_schema = 'temp_func_test' AND routine_name ~ '^functest_is_'
ORDER BY 1, 2;
+DROP FUNCTION functest_IS_1(int, int, text), functest_IS_2(int), functest_IS_3(int);
+
-- Cleanups
DROP SCHEMA temp_func_test CASCADE;
--
2.11.1
v2-0006-Combine-several-DROP-variants-into-generic-DropSt.patchtext/x-patch; name=v2-0006-Combine-several-DROP-variants-into-generic-DropSt.patchDownload
From 1c4d429e85e92ff00f3904b0043c5fc1c4760a78 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Tue, 21 Feb 2017 23:10:07 -0500
Subject: [PATCH v2 6/6] Combine several DROP variants into generic DropStmt
Combine DROP of FOREIGN DATA WRAPPER, SERVER, POLICY, RULE, and TRIGGER
into generic DropStmt grammar.
---
doc/src/sgml/ref/drop_foreign_data_wrapper.sgml | 2 +-
doc/src/sgml/ref/drop_server.sgml | 2 +-
src/backend/parser/gram.y | 173 +++++-------------------
3 files changed, 35 insertions(+), 142 deletions(-)
diff --git a/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml b/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml
index 824d72c176..702cc021db 100644
--- a/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml
+++ b/doc/src/sgml/ref/drop_foreign_data_wrapper.sgml
@@ -21,7 +21,7 @@
<refsynopsisdiv>
<synopsis>
-DROP FOREIGN DATA WRAPPER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [ CASCADE | RESTRICT ]
+DROP FOREIGN DATA WRAPPER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
</synopsis>
</refsynopsisdiv>
diff --git a/doc/src/sgml/ref/drop_server.sgml b/doc/src/sgml/ref/drop_server.sgml
index f08dd7767d..42acdd41dc 100644
--- a/doc/src/sgml/ref/drop_server.sgml
+++ b/doc/src/sgml/ref/drop_server.sgml
@@ -21,7 +21,7 @@
<refsynopsisdiv>
<synopsis>
-DROP SERVER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [ CASCADE | RESTRICT ]
+DROP SERVER [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [, ...] [ CASCADE | RESTRICT ]
</synopsis>
</refsynopsisdiv>
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 92b11a399e..ec07056617 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -263,10 +263,10 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
CreateUserStmt CreateUserMappingStmt CreateRoleStmt CreatePolicyStmt
CreatedbStmt DeclareCursorStmt DefineStmt DeleteStmt DiscardStmt DoStmt
DropGroupStmt DropOpClassStmt DropOpFamilyStmt DropPLangStmt DropStmt
- DropAssertStmt DropTrigStmt DropRuleStmt DropCastStmt DropRoleStmt
- DropPolicyStmt DropUserStmt DropdbStmt DropTableSpaceStmt DropFdwStmt
+ DropAssertStmt DropCastStmt DropRoleStmt
+ DropUserStmt DropdbStmt DropTableSpaceStmt
DropTransformStmt
- DropForeignServerStmt DropUserMappingStmt ExplainStmt FetchStmt
+ DropUserMappingStmt ExplainStmt FetchStmt
GrantStmt GrantRoleStmt ImportForeignSchemaStmt IndexStmt InsertStmt
ListenStmt LoadStmt LockStmt NotifyStmt ExplainableStmt PreparableStmt
CreateFunctionStmt AlterFunctionStmt ReindexStmt RemoveAggrStmt
@@ -440,7 +440,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <boolean> copy_from opt_program
%type <ival> opt_column event cursor_options opt_hold opt_set_data
-%type <objtype> drop_type_any_name drop_type_name
+%type <objtype> drop_type_any_name drop_type_name drop_type_name_on_any_name
comment_type_any_name comment_type_name
security_label_type_any_name security_label_type_name
@@ -885,20 +885,15 @@ stmt :
| DoStmt
| DropAssertStmt
| DropCastStmt
- | DropFdwStmt
- | DropForeignServerStmt
| DropGroupStmt
| DropOpClassStmt
| DropOpFamilyStmt
| DropOwnedStmt
- | DropPolicyStmt
| DropPLangStmt
- | DropRuleStmt
| DropStmt
| DropSubscriptionStmt
| DropTableSpaceStmt
| DropTransformStmt
- | DropTrigStmt
| DropRoleStmt
| DropUserStmt
| DropUserMappingStmt
@@ -4514,35 +4509,6 @@ opt_fdw_options:
/*****************************************************************************
*
* QUERY :
- * DROP FOREIGN DATA WRAPPER name
- *
- ****************************************************************************/
-
-DropFdwStmt: DROP FOREIGN DATA_P WRAPPER name opt_drop_behavior
- {
- DropStmt *n = makeNode(DropStmt);
- n->removeType = OBJECT_FDW;
- n->objects = list_make1(makeString($5));
- n->missing_ok = false;
- n->behavior = $6;
- n->concurrent = false;
- $$ = (Node *) n;
- }
- | DROP FOREIGN DATA_P WRAPPER IF_P EXISTS name opt_drop_behavior
- {
- DropStmt *n = makeNode(DropStmt);
- n->removeType = OBJECT_FDW;
- n->objects = list_make1(makeString($7));
- n->missing_ok = true;
- n->behavior = $8;
- n->concurrent = false;
- $$ = (Node *) n;
- }
- ;
-
-/*****************************************************************************
- *
- * QUERY :
* ALTER FOREIGN DATA WRAPPER name options
*
****************************************************************************/
@@ -4674,35 +4640,6 @@ opt_foreign_server_version:
/*****************************************************************************
*
* QUERY :
- * DROP SERVER name
- *
- ****************************************************************************/
-
-DropForeignServerStmt: DROP SERVER name opt_drop_behavior
- {
- DropStmt *n = makeNode(DropStmt);
- n->removeType = OBJECT_FOREIGN_SERVER;
- n->objects = list_make1(makeString($3));
- n->missing_ok = false;
- n->behavior = $4;
- n->concurrent = false;
- $$ = (Node *) n;
- }
- | DROP SERVER IF_P EXISTS name opt_drop_behavior
- {
- DropStmt *n = makeNode(DropStmt);
- n->removeType = OBJECT_FOREIGN_SERVER;
- n->objects = list_make1(makeString($5));
- n->missing_ok = true;
- n->behavior = $6;
- n->concurrent = false;
- $$ = (Node *) n;
- }
- ;
-
-/*****************************************************************************
- *
- * QUERY :
* ALTER SERVER name [VERSION] [OPTIONS]
*
****************************************************************************/
@@ -4975,7 +4912,6 @@ AlterUserMappingStmt: ALTER USER MAPPING FOR auth_ident SERVER name alter_generi
* [USING (qual)] [WITH CHECK (with check qual)]
* ALTER POLICY name ON table [TO role, ...]
* [USING (qual)] [WITH CHECK (with check qual)]
- * DROP POLICY name ON table
*
*****************************************************************************/
@@ -5010,29 +4946,6 @@ AlterPolicyStmt:
}
;
-DropPolicyStmt:
- DROP POLICY name ON any_name opt_drop_behavior
- {
- DropStmt *n = makeNode(DropStmt);
- n->removeType = OBJECT_POLICY;
- n->objects = list_make1(lappend($5, makeString($3)));
- n->behavior = $6;
- n->missing_ok = false;
- n->concurrent = false;
- $$ = (Node *) n;
- }
- | DROP POLICY IF_P EXISTS name ON any_name opt_drop_behavior
- {
- DropStmt *n = makeNode(DropStmt);
- n->removeType = OBJECT_POLICY;
- n->objects = list_make1(lappend($7, makeString($5)));
- n->behavior = $8;
- n->missing_ok = true;
- n->concurrent = false;
- $$ = (Node *) n;
- }
- ;
-
RowSecurityOptionalExpr:
USING '(' a_expr ')' { $$ = $3; }
| /* EMPTY */ { $$ = NULL; }
@@ -5105,7 +5018,6 @@ CreateAmStmt: CREATE ACCESS METHOD name TYPE_P INDEX HANDLER handler_name
*
* QUERIES :
* CREATE TRIGGER ...
- * DROP TRIGGER ...
*
*****************************************************************************/
@@ -5332,30 +5244,6 @@ ConstraintAttributeElem:
;
-DropTrigStmt:
- DROP TRIGGER name ON any_name opt_drop_behavior
- {
- DropStmt *n = makeNode(DropStmt);
- n->removeType = OBJECT_TRIGGER;
- n->objects = list_make1(lappend($5, makeString($3)));
- n->behavior = $6;
- n->missing_ok = false;
- n->concurrent = false;
- $$ = (Node *) n;
- }
- | DROP TRIGGER IF_P EXISTS name ON any_name opt_drop_behavior
- {
- DropStmt *n = makeNode(DropStmt);
- n->removeType = OBJECT_TRIGGER;
- n->objects = list_make1(lappend($7, makeString($5)));
- n->behavior = $8;
- n->missing_ok = true;
- n->concurrent = false;
- $$ = (Node *) n;
- }
- ;
-
-
/*****************************************************************************
*
* QUERIES :
@@ -6034,6 +5922,26 @@ DropStmt: DROP drop_type_any_name IF_P EXISTS any_name_list opt_drop_behavior
n->concurrent = false;
$$ = (Node *)n;
}
+ | DROP drop_type_name_on_any_name name ON any_name opt_drop_behavior
+ {
+ DropStmt *n = makeNode(DropStmt);
+ n->removeType = $2;
+ n->objects = list_make1(lappend($5, makeString($3)));
+ n->behavior = $6;
+ n->missing_ok = false;
+ n->concurrent = false;
+ $$ = (Node *) n;
+ }
+ | DROP drop_type_name_on_any_name IF_P EXISTS name ON any_name opt_drop_behavior
+ {
+ DropStmt *n = makeNode(DropStmt);
+ n->removeType = $2;
+ n->objects = list_make1(lappend($7, makeString($5)));
+ n->behavior = $8;
+ n->missing_ok = true;
+ n->concurrent = false;
+ $$ = (Node *) n;
+ }
| DROP TYPE_P type_name_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
@@ -6117,8 +6025,17 @@ drop_type_name:
ACCESS METHOD { $$ = OBJECT_ACCESS_METHOD; }
| EVENT TRIGGER { $$ = OBJECT_EVENT_TRIGGER; }
| EXTENSION { $$ = OBJECT_EXTENSION; }
+ | FOREIGN DATA_P WRAPPER { $$ = OBJECT_FDW; }
| PUBLICATION { $$ = OBJECT_PUBLICATION; }
| SCHEMA { $$ = OBJECT_SCHEMA; }
+ | SERVER { $$ = OBJECT_FOREIGN_SERVER; }
+ ;
+
+/* object types attached to a table */
+drop_type_name_on_any_name:
+ POLICY { $$ = OBJECT_POLICY; }
+ | RULE { $$ = OBJECT_RULE; }
+ | TRIGGER { $$ = OBJECT_TRIGGER; }
;
any_name_list:
@@ -9257,30 +9174,6 @@ opt_instead:
;
-DropRuleStmt:
- DROP RULE name ON any_name opt_drop_behavior
- {
- DropStmt *n = makeNode(DropStmt);
- n->removeType = OBJECT_RULE;
- n->objects = list_make1(lappend($5, makeString($3)));
- n->behavior = $6;
- n->missing_ok = false;
- n->concurrent = false;
- $$ = (Node *) n;
- }
- | DROP RULE IF_P EXISTS name ON any_name opt_drop_behavior
- {
- DropStmt *n = makeNode(DropStmt);
- n->removeType = OBJECT_RULE;
- n->objects = list_make1(lappend($7, makeString($5)));
- n->behavior = $8;
- n->missing_ok = true;
- n->concurrent = false;
- $$ = (Node *) n;
- }
- ;
-
-
/*****************************************************************************
*
* QUERY:
--
2.11.1
On Sat, Feb 25, 2017 at 10:27 PM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
Here is a new patch set that addresses your comments. The structure is
still the same, just a bunch of things have been renamed based on
suggestions.
+ <para>
+ Drop multiple functions in one command:
+<programlisting>
+DROP FUNCTION sqrt(integer), sqrt(bigint);
+</programlisting></para>
</refsect1>
Perhaps adding as well on the page of DROP OPERATOR an example
dropping multiple operators at once?
-DropPolicyStmt:
- DROP POLICY name ON any_name opt_drop_behavior
- {
Oh, nice. I can see that you have decided to bit the bullet. Thanks
for considering that.
I am marking this patch as ready for committer, aka you.
--
Michael
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On 2/27/17 01:46, Michael Paquier wrote:
On Sat, Feb 25, 2017 at 10:27 PM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:Here is a new patch set that addresses your comments. The structure is
still the same, just a bunch of things have been renamed based on
suggestions.+ <para> + Drop multiple functions in one command: +<programlisting> +DROP FUNCTION sqrt(integer), sqrt(bigint); +</programlisting></para> </refsect1> Perhaps adding as well on the page of DROP OPERATOR an example dropping multiple operators at once?
Committed with additional documentation. Thanks.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers