Skip to content

Commit b999c24

Browse files
committed
Add aggregate_with_argtypes and use it consistently
This works like function_with_argtypes, but aggregates allow slightly different arguments. Reviewed-by: Alvaro Herrera <alvherre@2ndquadrant.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
1 parent e696dcc commit b999c24

File tree

1 file changed

+42
-32
lines changed

1 file changed

+42
-32
lines changed

src/backend/parser/gram.y

+42-32
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
341341
%type <accesspriv> privilege
342342
%type <list> privileges privilege_list
343343
%type <privtarget> privilege_target
344-
%type <funwithargs> function_with_argtypes
344+
%type <funwithargs> function_with_argtypes aggregate_with_argtypes
345345
%type <list> function_with_argtypes_list
346346
%type <ival> defacl_privilege_target
347347
%type <defelt> DefACLOption
@@ -3943,14 +3943,14 @@ AlterExtensionContentsStmt:
39433943
n->objname = list_make1(makeString($7));
39443944
$$ = (Node *)n;
39453945
}
3946-
| ALTER EXTENSION name add_drop AGGREGATE func_name aggr_args
3946+
| ALTER EXTENSION name add_drop AGGREGATE aggregate_with_argtypes
39473947
{
39483948
AlterExtensionContentsStmt *n = makeNode(AlterExtensionContentsStmt);
39493949
n->extname = $3;
39503950
n->action = $4;
39513951
n->objtype = OBJECT_AGGREGATE;
3952-
n->objname = $6;
3953-
n->objargs = extractAggrArgTypes($7);
3952+
n->objname = $6->funcname;
3953+
n->objargs = $6->funcargs;
39543954
$$ = (Node *)n;
39553955
}
39563956
| ALTER EXTENSION name add_drop CAST '(' Typename AS Typename ')'
@@ -5819,13 +5819,13 @@ CommentStmt:
58195819
n->comment = $6;
58205820
$$ = (Node *) n;
58215821
}
5822-
| COMMENT ON AGGREGATE func_name aggr_args IS comment_text
5822+
| COMMENT ON AGGREGATE aggregate_with_argtypes IS comment_text
58235823
{
58245824
CommentStmt *n = makeNode(CommentStmt);
58255825
n->objtype = OBJECT_AGGREGATE;
5826-
n->objname = $4;
5827-
n->objargs = extractAggrArgTypes($5);
5828-
n->comment = $7;
5826+
n->objname = $4->funcname;
5827+
n->objargs = $4->funcargs;
5828+
n->comment = $6;
58295829
$$ = (Node *) n;
58305830
}
58315831
| COMMENT ON FUNCTION function_with_argtypes IS comment_text
@@ -6035,15 +6035,15 @@ SecLabelStmt:
60356035
n->label = $8;
60366036
$$ = (Node *) n;
60376037
}
6038-
| SECURITY LABEL opt_provider ON AGGREGATE func_name aggr_args
6038+
| SECURITY LABEL opt_provider ON AGGREGATE aggregate_with_argtypes
60396039
IS security_label
60406040
{
60416041
SecLabelStmt *n = makeNode(SecLabelStmt);
60426042
n->provider = $3;
60436043
n->objtype = OBJECT_AGGREGATE;
6044-
n->objname = $6;
6045-
n->objargs = extractAggrArgTypes($7);
6046-
n->label = $9;
6044+
n->objname = $6->funcname;
6045+
n->objargs = $6->funcargs;
6046+
n->label = $8;
60476047
$$ = (Node *) n;
60486048
}
60496049
| SECURITY LABEL opt_provider ON FUNCTION function_with_argtypes
@@ -7103,6 +7103,16 @@ aggr_args_list:
71037103
| aggr_args_list ',' aggr_arg { $$ = lappend($1, $3); }
71047104
;
71057105

7106+
aggregate_with_argtypes:
7107+
func_name aggr_args
7108+
{
7109+
FuncWithArgs *n = makeNode(FuncWithArgs);
7110+
n->funcname = $1;
7111+
n->funcargs = extractAggrArgTypes($2);
7112+
$$ = n;
7113+
}
7114+
;
7115+
71067116
createfunc_opt_list:
71077117
/* Must be at least one to prevent conflict */
71087118
createfunc_opt_item { $$ = list_make1($1); }
@@ -7309,24 +7319,24 @@ RemoveFuncStmt:
73097319
;
73107320

73117321
RemoveAggrStmt:
7312-
DROP AGGREGATE func_name aggr_args opt_drop_behavior
7322+
DROP AGGREGATE aggregate_with_argtypes opt_drop_behavior
73137323
{
73147324
DropStmt *n = makeNode(DropStmt);
73157325
n->removeType = OBJECT_AGGREGATE;
7316-
n->objects = list_make1($3);
7317-
n->arguments = list_make1(extractAggrArgTypes($4));
7318-
n->behavior = $5;
7326+
n->objects = list_make1($3->funcname);
7327+
n->arguments = list_make1($3->funcargs);
7328+
n->behavior = $4;
73197329
n->missing_ok = false;
73207330
n->concurrent = false;
73217331
$$ = (Node *)n;
73227332
}
7323-
| DROP AGGREGATE IF_P EXISTS func_name aggr_args opt_drop_behavior
7333+
| DROP AGGREGATE IF_P EXISTS aggregate_with_argtypes opt_drop_behavior
73247334
{
73257335
DropStmt *n = makeNode(DropStmt);
73267336
n->removeType = OBJECT_AGGREGATE;
7327-
n->objects = list_make1($5);
7328-
n->arguments = list_make1(extractAggrArgTypes($6));
7329-
n->behavior = $7;
7337+
n->objects = list_make1($5->funcname);
7338+
n->arguments = list_make1($5->funcargs);
7339+
n->behavior = $6;
73307340
n->missing_ok = true;
73317341
n->concurrent = false;
73327342
$$ = (Node *)n;
@@ -7625,13 +7635,13 @@ AlterTblSpcStmt:
76257635
*
76267636
*****************************************************************************/
76277637

7628-
RenameStmt: ALTER AGGREGATE func_name aggr_args RENAME TO name
7638+
RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
76297639
{
76307640
RenameStmt *n = makeNode(RenameStmt);
76317641
n->renameType = OBJECT_AGGREGATE;
7632-
n->object = $3;
7633-
n->objarg = extractAggrArgTypes($4);
7634-
n->newname = $7;
7642+
n->object = $3->funcname;
7643+
n->objarg = $3->funcargs;
7644+
n->newname = $6;
76357645
n->missing_ok = false;
76367646
$$ = (Node *)n;
76377647
}
@@ -8157,13 +8167,13 @@ AlterObjectDependsStmt:
81578167
*****************************************************************************/
81588168

81598169
AlterObjectSchemaStmt:
8160-
ALTER AGGREGATE func_name aggr_args SET SCHEMA name
8170+
ALTER AGGREGATE aggregate_with_argtypes SET SCHEMA name
81618171
{
81628172
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
81638173
n->objectType = OBJECT_AGGREGATE;
8164-
n->object = $3;
8165-
n->objarg = extractAggrArgTypes($4);
8166-
n->newschema = $7;
8174+
n->object = $3->funcname;
8175+
n->objarg = $3->funcargs;
8176+
n->newschema = $6;
81678177
n->missing_ok = false;
81688178
$$ = (Node *)n;
81698179
}
@@ -8411,13 +8421,13 @@ operator_def_elem: ColLabel '=' NONE
84118421
*
84128422
*****************************************************************************/
84138423

8414-
AlterOwnerStmt: ALTER AGGREGATE func_name aggr_args OWNER TO RoleSpec
8424+
AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
84158425
{
84168426
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
84178427
n->objectType = OBJECT_AGGREGATE;
8418-
n->object = $3;
8419-
n->objarg = extractAggrArgTypes($4);
8420-
n->newowner = $7;
8428+
n->object = $3->funcname;
8429+
n->objarg = $3->funcargs;
8430+
n->newowner = $6;
84218431
$$ = (Node *)n;
84228432
}
84238433
| ALTER COLLATION any_name OWNER TO RoleSpec

0 commit comments

Comments
 (0)