From 577e21b34f8629ce76651a6388298891f81be99a Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 26 Oct 1999 03:12:39 +0000 Subject: Hello. The following patch extends the COMMENT ON functionality to the rest of the database objects beyond just tables, columns, and views. The grammer of the COMMENT ON statement now looks like: COMMENT ON [ [ DATABASE | INDEX | RULE | SEQUENCE | TABLE | TYPE | VIEW ] | COLUMN . | AGGREGATE | FUNCTION (arg1, arg2, ...) | OPERATOR (leftoperand_typ rightoperand_typ) | TRIGGER ON relname> Mike Mascari (mascarim@yahoo.com) --- src/backend/parser/gram.y | 100 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 87 insertions(+), 13 deletions(-) (limited to 'src/backend/parser') diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index 16a4efa2baa..a4a0c721ea3 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.109 1999/10/15 01:49:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.110 1999/10/26 03:12:34 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -196,7 +196,8 @@ Oid param_type(int t); /* used in parse_expr.c */ %type opt_cursor %type copy_dirn, def_type, opt_direction, remove_type, - opt_column, event + opt_column, event, comment_type, comment_cl, + comment_ag, comment_fn, comment_op, comment_tg %type fetch_how_many @@ -1542,28 +1543,101 @@ TruncateStmt: TRUNCATE TABLE relation_name /***************************************************************************** * - * QUERY: - * comment on [ table | column . ] - * is 'text' + * The COMMENT ON statement can take different forms based upon the type of + * the object associated with the comment. The form of the statement is: + * + * COMMENT ON [ [ DATABASE | INDEX | RULE | SEQUENCE | TABLE | TYPE | VIEW ] + * | AGGREGATE | FUNCTION + * (arg1, arg2, ...) | OPERATOR + * (leftoperand_typ rightoperand_typ) | TRIGGER ON + * ] IS 'text' * *****************************************************************************/ -CommentStmt: COMMENT ON COLUMN relation_name '.' attr_name IS Sconst +CommentStmt: COMMENT ON comment_type name IS Sconst + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = $3; + n->objname = $4; + n->objproperty = NULL; + n->objlist = NULL; + n->comment = $6; + $$ = (Node *) n; + } + | COMMENT ON comment_cl relation_name '.' attr_name IS Sconst { CommentStmt *n = makeNode(CommentStmt); - n->relname = $4; - n->attrname = $6; + n->objtype = $3; + n->objname = $4; + n->objproperty = $6; + n->objlist = NULL; n->comment = $8; $$ = (Node *) n; } - | COMMENT ON TABLE relation_name IS Sconst - { + | COMMENT ON comment_ag name aggr_argtype IS Sconst + { CommentStmt *n = makeNode(CommentStmt); - n->relname = $4; - n->attrname = NULL; - n->comment = $6; + n->objtype = $3; + n->objname = $4; + n->objproperty = $5; + n->objlist = NULL; + n->comment = $7; + $$ = (Node *) n; + } + | COMMENT ON comment_fn func_name func_args IS Sconst + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = $3; + n->objname = $4; + n->objproperty = NULL; + n->objlist = $5; + n->comment = $7; + $$ = (Node *) n; + } + | COMMENT ON comment_op all_Op '(' oper_argtypes ')' IS Sconst + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = $3; + n->objname = $4; + n->objproperty = NULL; + n->objlist = $6; + n->comment = $9; $$ = (Node *) n; } + | COMMENT ON comment_tg name ON relation_name IS Sconst + { + CommentStmt *n = makeNode(CommentStmt); + n->objtype = $3; + n->objname = $4; + n->objproperty = $6; + n->objlist = NULL; + n->comment = $8; + $$ = (Node *) n; + } + ; + +comment_type: DATABASE { $$ = DATABASE; } + | INDEX { $$ = INDEX; } + | RULE { $$ = RULE; } + | SEQUENCE { $$ = SEQUENCE; } + | TABLE { $$ = TABLE; } + | TYPE_P { $$ = TYPE_P; } + | VIEW { $$ = VIEW; } + ; + +comment_cl: COLUMN { $$ = COLUMN; } + ; + +comment_ag: AGGREGATE { $$ = AGGREGATE; } + ; + +comment_fn: FUNCTION { $$ = FUNCTION; } + ; + +comment_op: OPERATOR { $$ = OPERATOR; } + ; + +comment_tg: TRIGGER { $$ = TRIGGER; } ; /***************************************************************************** -- cgit v1.2.3