mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
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 ] <objname> | COLUMN <relation>.<attribute> | AGGREGATE <aggname> <aggtype> | FUNCTION <funcname> (arg1, arg2, ...) | OPERATOR <op> (leftoperand_typ rightoperand_typ) | TRIGGER <triggername> ON relname> Mike Mascari (mascarim@yahoo.com)
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.49 1999/10/15 01:49:39 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.50 1999/10/26 03:12:34 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -234,52 +234,6 @@ TruncateRelation(char *name)
|
||||
heap_truncate(name);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------
|
||||
* CommentRelation --
|
||||
* Adds a comment to pg_description for the associated
|
||||
* relation or relation attribute.
|
||||
*
|
||||
* Note:
|
||||
* The comment is dropped on the relation or attribute if
|
||||
* the comment is an empty string.
|
||||
*------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
CommentRelation(char *relname, char *attrname, char *comments)
|
||||
{
|
||||
|
||||
Relation relation;
|
||||
HeapTuple attrtuple;
|
||||
Oid oid;
|
||||
|
||||
/*** First ensure relname is valid ***/
|
||||
|
||||
relation = heap_openr(relname, AccessShareLock);
|
||||
|
||||
/*** Now, if an attribute was specified, fetch its oid, else use relation's oid ***/
|
||||
|
||||
if (attrname != NULL) {
|
||||
attrtuple = SearchSysCacheTuple(ATTNAME, ObjectIdGetDatum(relation->rd_id),
|
||||
PointerGetDatum(attrname), 0, 0);
|
||||
if (!HeapTupleIsValid(attrtuple)) {
|
||||
elog(ERROR, "CommentRelation: attribute \"%s\" is not an attribute of relation \"%s\"",
|
||||
attrname, relname);
|
||||
}
|
||||
oid = attrtuple->t_data->t_oid;
|
||||
} else {
|
||||
oid = RelationGetRelid(relation);
|
||||
}
|
||||
|
||||
/*** Call CreateComments() to create/drop the comments ***/
|
||||
|
||||
CreateComments(oid, comments);
|
||||
|
||||
/*** Now, close the heap relation ***/
|
||||
|
||||
heap_close(relation, AccessShareLock);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* MergeAttributes
|
||||
* Returns new schema given initial schema and supers.
|
||||
|
Reference in New Issue
Block a user