I would like to fix psql's incomplete and inconsistent handling of
object comments. I think this subject can be handled separately from
the pg_comments discussion, and we can focus on the
appearance/behavior of psql commands here.
First, As brought up recently , comments for the following object
types are not currently displayed by any psql backslash command:
FOREIGN DATA WRAPPER
In the case of PROCEDURAL LANGUAGE, it was mere oversight that \dL did
not display comments, and I'm not aware of any reason why we're not
doing so for the other objects above. I'd like to propose adding an
additional column to the respective psql backslash commands for the
above object types which will display any comment associated with the
Second, comments of the following object types would IMO be better
displayed in the object's individual backslash command, and not in \dd
as they are now:
Third, comments for the following objects are displayed by both \dd
and the object's individual backslash command:
FOREIGN TABLE (via \d+)
Seems like there's no need to add more noise to \dd for these cases.
Fourth, there is a bug in at least the display of comments for indexes
using \d+ (the "Description" is empty when it shouldn't be).
As a summary, here is how I am proposing we display object comments :
1.) Object comments displayed by \dd:
2.) Object comments displayed in the backslash commands for the object:
COLUMN \d+ tablename
DOMAIN \dD and \dT+
FOREIGN DATA WRAPPER \dew
FOREIGN TABLE \det and \d+
INDEX \di+ and \d+
LARGE OBJECT \dl
PROCEDURAL LANGUAGE \dL
SEQUENCE \ds+ and \d+
TABLE \dt+ and \d+
TEXT SEARCH CONFIGURATION \dF
TEXT SEARCH DICTIONARY \dFd
TEXT SEARCH PARSER \dFp
TEXT SEARCH TEMPLATE \dFt
A few notes:
a.) As you can see, there's not much consistency in whether we
display object comments only in verbose mode or not. I'm open to
suggestions on how to tweak/standardize this.
b.) I'd rather not have any overlap between groups 1.) and 2.).
c.) \dd doesn't yet display all the object types it should (operator
class & family are missing); that's slated to be fixed with the
pg_comments patch though.
Patch attached and comments welcome; will add to next CF barring
objections. I've also attached a test .sql file I was using to make up
a bunch of comments, it might save you some time if you're interested
in trying the patch out.
 The object types broken down here should cover all comment-able
types on http://www.postgresql.org/docs/9.1/static/sql-comment.html
pgsql-hackers by date
|Next:||From: Peter Eisentraut||Date: 2011-07-09 18:45:23|
|Subject: Re: cataloguing NOT NULL constraints|
|Previous:||From: Yeb Havinga||Date: 2011-07-09 15:45:34|
|Subject: Re: Parameterized aggregate subquery (was: Pull up aggregate