1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

DROP AGGREGATE and COMMENT ON AGGREGATE now accept the expected syntax

'aggname (aggtype)'.  The old syntax 'aggname aggtype' is still accepted
for backwards compatibility.  Fix pg_dump, which was actually broken for
most cases of user-defined aggregates.  Clean up error messages associated
with these commands.
This commit is contained in:
Tom Lane
2001-10-03 20:54:22 +00:00
parent 16def00ffb
commit 2e5fda7b7e
14 changed files with 137 additions and 157 deletions

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.199 2001/10/03 05:29:12 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.200 2001/10/03 20:54:20 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2811,8 +2811,10 @@ transformTypeRefsList(ParseState *pstate, List *l)
foreach(ele, l)
{
if (IsA(lfirst(ele), TypeName))
transformTypeRef(pstate, (TypeName *) lfirst(ele));
Node *elem = lfirst(ele);
if (elem && IsA(elem, TypeName))
transformTypeRef(pstate, (TypeName *) elem);
}
}

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.257 2001/10/03 05:29:12 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.258 2001/10/03 20:54:21 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -217,8 +217,7 @@ static void doNegateFloat(Value *v);
%type <boolean> opt_freeze, analyze_keyword
%type <ival> copy_dirn, direction, reindex_type, drop_type,
opt_column, event, comment_type, comment_cl,
comment_ag, comment_fn, comment_op, comment_tg
opt_column, event, comment_type
%type <ival> fetch_how_many
@@ -2011,7 +2010,7 @@ TruncateStmt: TRUNCATE opt_table relation_name
* the object associated with the comment. The form of the statement is:
*
* COMMENT ON [ [ DATABASE | INDEX | RULE | SEQUENCE | TABLE | TYPE | VIEW ]
* <objname> | AGGREGATE <aggname> <aggtype> | FUNCTION
* <objname> | AGGREGATE <aggname> (<aggtype>) | FUNCTION
* <funcname> (arg1, arg2, ...) | OPERATOR <op>
* (leftoperand_typ rightoperand_typ) | TRIGGER <triggername> ON
* <relname> ] IS 'text'
@@ -2028,50 +2027,61 @@ CommentStmt: COMMENT ON comment_type name IS comment_text
n->comment = $6;
$$ = (Node *) n;
}
| COMMENT ON comment_cl relation_name '.' attr_name IS comment_text
| COMMENT ON COLUMN relation_name '.' attr_name IS comment_text
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = $3;
n->objtype = COLUMN;
n->objname = $4;
n->objproperty = $6;
n->objlist = NULL;
n->comment = $8;
$$ = (Node *) n;
}
| COMMENT ON comment_ag name aggr_argtype IS comment_text
| COMMENT ON AGGREGATE name '(' aggr_argtype ')' IS comment_text
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = $3;
n->objtype = AGGREGATE;
n->objname = $4;
n->objproperty = NULL;
n->objlist = makeList1($6);
n->comment = $9;
$$ = (Node *) n;
}
| COMMENT ON AGGREGATE name aggr_argtype IS comment_text
{
/* Obsolete syntax, but must support for awhile */
CommentStmt *n = makeNode(CommentStmt);
n->objtype = AGGREGATE;
n->objname = $4;
n->objproperty = NULL;
n->objlist = makeList1($5);
n->comment = $7;
$$ = (Node *) n;
}
| COMMENT ON comment_fn func_name func_args IS comment_text
| COMMENT ON FUNCTION func_name func_args IS comment_text
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = $3;
n->objtype = FUNCTION;
n->objname = $4;
n->objproperty = NULL;
n->objlist = $5;
n->comment = $7;
$$ = (Node *) n;
}
| COMMENT ON comment_op all_Op '(' oper_argtypes ')' IS comment_text
| COMMENT ON OPERATOR all_Op '(' oper_argtypes ')' IS comment_text
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = $3;
n->objtype = OPERATOR;
n->objname = $4;
n->objproperty = NULL;
n->objlist = $6;
n->comment = $9;
$$ = (Node *) n;
}
| COMMENT ON comment_tg name ON relation_name IS comment_text
| COMMENT ON TRIGGER name ON relation_name IS comment_text
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = $3;
n->objtype = TRIGGER;
n->objname = $4;
n->objproperty = $6;
n->objlist = NULL;
@@ -2089,21 +2099,6 @@ comment_type: DATABASE { $$ = DATABASE; }
| VIEW { $$ = VIEW; }
;
comment_cl: COLUMN { $$ = COLUMN; }
;
comment_ag: AGGREGATE { $$ = AGGREGATE; }
;
comment_fn: FUNCTION { $$ = FUNCTION; }
;
comment_op: OPERATOR { $$ = OPERATOR; }
;
comment_tg: TRIGGER { $$ = TRIGGER; }
;
comment_text: Sconst { $$ = $1; }
| NULL_P { $$ = NULL; }
;
@@ -2601,7 +2596,7 @@ func_type: Typename
* QUERY:
*
* DROP FUNCTION funcname (arg1, arg2, ...)
* DROP AGGREGATE aggname aggtype
* DROP AGGREGATE aggname (aggtype)
* DROP OPERATOR opname (leftoperand_typ rightoperand_typ)
*
*****************************************************************************/
@@ -2615,8 +2610,16 @@ RemoveFuncStmt: DROP FUNCTION func_name func_args
}
;
RemoveAggrStmt: DROP AGGREGATE func_name aggr_argtype
RemoveAggrStmt: DROP AGGREGATE func_name '(' aggr_argtype ')'
{
RemoveAggrStmt *n = makeNode(RemoveAggrStmt);
n->aggname = $3;
n->aggtype = (Node *) $5;
$$ = (Node *)n;
}
| DROP AGGREGATE func_name aggr_argtype
{
/* Obsolete syntax, but must support for awhile */
RemoveAggrStmt *n = makeNode(RemoveAggrStmt);
n->aggname = $3;
n->aggtype = (Node *) $4;