1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +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:
Bruce Momjian
1999-10-15 01:49:49 +00:00
parent 55fa71a9e9
commit 7acc237744
12 changed files with 287 additions and 21 deletions

View File

@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: parsenodes.h,v 1.84 1999/10/07 04:23:17 tgl Exp $
* $Id: parsenodes.h,v 1.85 1999/10/15 01:49:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -309,6 +309,18 @@ typedef struct TruncateStmt
NodeTag type;
char *relName; /* relation to be truncated */
} TruncateStmt;
/* ----------------------
* Comment On Statement
* ----------------------
*/
typedef struct CommentStmt
{
NodeTag type;
char *relname; /* relation to create/drop comment */
char *attrname; /* attribute to comment on */
char *comment; /* the actual comment */
} CommentStmt;
/* ----------------------
* Extend Index Statement