mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
This patch implements ORACLE's COMMENT SQL command.
>From the ORACLE 7 SQL Language Reference Manual:
-----------------------------------------------------
COMMENT
Purpose:
To add a comment about a table, view, snapshot, or
column into the data dictionary.
Prerequisites:
The table, view, or snapshot must be in your own
schema
or you must have COMMENT ANY TABLE system privilege.
Syntax:
COMMENT ON [ TABLE table ] |
[ COLUMN table.column] IS 'text'
You can effectively drop a comment from the database
by setting it to the empty string ''.
-----------------------------------------------------
Example:
COMMENT ON TABLE workorders IS
'Maintains base records for workorder information';
COMMENT ON COLUMN workorders.hours IS
'Number of hours the engineer worked on the task';
to drop a comment:
COMMENT ON COLUMN workorders.hours IS '';
The current patch will simply perform the insert into
pg_description, as per the TODO. And, of course, when
the table is dropped, any comments relating to it
or any of its attributes are also dropped. I haven't
looked at the ODBC source yet, but I do know from
an ODBC client standpoint that the standard does
support the notion of table and column comments.
Hopefully the ODBC driver is already fetching these
values from pg_description, but if not, it should be
trivial.
Hope this makes the grade,
Mike Mascari
(mascarim@yahoo.com)
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.108 1999/10/07 04:23:12 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.109 1999/10/15 01:49:41 momjian Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@@ -118,7 +118,7 @@ Oid param_type(int t); /* used in parse_expr.c */
|
||||
%type <node> stmt,
|
||||
AddAttrStmt, ClosePortalStmt,
|
||||
CopyStmt, CreateStmt, CreateAsStmt, CreateSeqStmt, DefineStmt, DestroyStmt,
|
||||
TruncateStmt,
|
||||
TruncateStmt, CommentStmt,
|
||||
ExtendStmt, FetchStmt, GrantStmt, CreateTrigStmt, DropTrigStmt,
|
||||
CreatePLangStmt, DropPLangStmt,
|
||||
IndexStmt, ListenStmt, UnlistenStmt, LockStmt, OptimizableStmt,
|
||||
@@ -314,7 +314,7 @@ Oid param_type(int t); /* used in parse_expr.c */
|
||||
*/
|
||||
%token ABORT_TRANS, ACCESS, AFTER, AGGREGATE, ANALYZE,
|
||||
BACKWARD, BEFORE, BINARY,
|
||||
CACHE, CLUSTER, COPY, CREATEDB, CREATEUSER, CYCLE,
|
||||
CACHE, CLUSTER, COMMENT, COPY, CREATEDB, CREATEUSER, CYCLE,
|
||||
DATABASE, DELIMITERS, DO,
|
||||
EACH, ENCODING, EXCLUSIVE, EXPLAIN, EXTEND,
|
||||
FORWARD, FUNCTION, HANDLER,
|
||||
@@ -402,6 +402,7 @@ stmt : AddAttrStmt
|
||||
| DefineStmt
|
||||
| DestroyStmt
|
||||
| TruncateStmt
|
||||
| CommentStmt
|
||||
| DropPLangStmt
|
||||
| DropTrigStmt
|
||||
| DropUserStmt
|
||||
@@ -1539,6 +1540,32 @@ TruncateStmt: TRUNCATE TABLE relation_name
|
||||
}
|
||||
;
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* QUERY:
|
||||
* comment on [ table <relname> | column <relname>.<attribute> ]
|
||||
* is 'text'
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
CommentStmt: COMMENT ON COLUMN relation_name '.' attr_name IS Sconst
|
||||
{
|
||||
CommentStmt *n = makeNode(CommentStmt);
|
||||
n->relname = $4;
|
||||
n->attrname = $6;
|
||||
n->comment = $8;
|
||||
$$ = (Node *) n;
|
||||
}
|
||||
| COMMENT ON TABLE relation_name IS Sconst
|
||||
{
|
||||
CommentStmt *n = makeNode(CommentStmt);
|
||||
n->relname = $4;
|
||||
n->attrname = NULL;
|
||||
n->comment = $6;
|
||||
$$ = (Node *) n;
|
||||
}
|
||||
;
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* QUERY:
|
||||
@@ -5011,6 +5038,7 @@ ColId: IDENT { $$ = $1; }
|
||||
| BACKWARD { $$ = "backward"; }
|
||||
| BEFORE { $$ = "before"; }
|
||||
| CACHE { $$ = "cache"; }
|
||||
| COMMENT { $$ = "comment"; }
|
||||
| COMMITTED { $$ = "committed"; }
|
||||
| CONSTRAINTS { $$ = "constraints"; }
|
||||
| CREATEDB { $$ = "createdb"; }
|
||||
@@ -5081,6 +5109,7 @@ ColId: IDENT { $$ = $1; }
|
||||
| TIMEZONE_HOUR { $$ = "timezone_hour"; }
|
||||
| TIMEZONE_MINUTE { $$ = "timezone_minute"; }
|
||||
| TRIGGER { $$ = "trigger"; }
|
||||
| TRUNCATE { $$ = "truncate"; }
|
||||
| TRUSTED { $$ = "trusted"; }
|
||||
| TYPE_P { $$ = "type"; }
|
||||
| VALID { $$ = "valid"; }
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.62 1999/09/29 16:06:08 wieck Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.63 1999/10/15 01:49:41 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -60,6 +60,7 @@ static ScanKeyword ScanKeywords[] = {
|
||||
{"coalesce", COALESCE},
|
||||
{"collate", COLLATE},
|
||||
{"column", COLUMN},
|
||||
{"comment", COMMENT},
|
||||
{"commit", COMMIT},
|
||||
{"committed", COMMITTED},
|
||||
{"constraint", CONSTRAINT},
|
||||
|
||||
Reference in New Issue
Block a user