Re: pg_comments (was: Allow \dd to show constraint comments)

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Thom Brown <thom(at)linux(dot)com>
Cc: Josh Kupershmidt <schmiddy(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_comments (was: Allow \dd to show constraint comments)
Date: 2011-11-09 12:40:10
Message-ID: CA+TgmobCrznfpLzSW45SwedL9bpWcqvhVZ2FbDzBntwXkVXOXA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 9, 2011 at 3:38 AM, Thom Brown <thom(at)linux(dot)com> wrote:
> On 9 November 2011 02:42, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> On Tue, Nov 8, 2011 at 8:12 PM, Thom Brown <thom(at)linux(dot)com> wrote:
>>> Why is this marked as done on with Wiki's todo list?
>>
>> I assume you're referring to this item:
>>
>> --
>> \dd is missing comments for several types of objects.  Comments are
>> not handled at all for some object types, and are handled by both \dd
>> and the individual backslash command for others. Consider a system
>> view like pg_comments to manage this mess.
>> --
>>
>> What we did is modify psql so that all the backslash commands display
>> comments for their corresponding object types, at least when the +
>> modifier is used.  We then made \dd display comments for all object
>> types that lack their own backslash commands.  That seems like it
>> pretty much covers the todo item.
>>
>> I initially thought that pg_comments could be used *by psql*, which
>> seemed to me a good argument in favor of its general utility.  When we
>> didn't end up doing it that way, the view got less appealing to me.
>> I'm still willing to add it if enough people say they want it, but so
>> far I think we've gotten about three votes between +0.25 and +0.50 and
>> a -1 from Tom.  Which is not really enough for me to feel like pulling
>> the trigger.
>
> Okay, I've skim-read this topic too lightly.  I understand now.
>
> Can I ask, for which type of object are there comments for which we
> still can't easily find without this proposed view?

Well, the problem with our backslash commands in general is that they
work fine until they don't. For example, if you want to find a
function by name, \df is completely adequate. You can just type \df
foo* and away you go. But if you want to find a function that
*returns type foo*, it's useless. You've got to manually write a
query, and the level of effort is far higher than just typing a
backslash commands. Or if you want to add columns to or remove
columns from the output, you are out of luck. psql -E is a help, but
it's still kind of a pain.

Now, the problem is even worse than average when it comes to comments,
because extracting the comments typically involves a hairy left join
from whichever table contains the objects over to pg_description
and/or pg_shdescription, and the meanings of the columns in those
tables are not at all evident to the newcomer, who will probably
therefore screw it up. It seemed to me that, for those sorts of
situations, something like pg_comments might be useful.

I think the way that psql handles comments now is a big improvement
over previous releases, and I'm satisfied with it. But there are
certainly situations - especially, when you have a large number of
objects and want to filter them in some slightly unusual way - where
it - or our backslash commands more generally - might be judged
lacking.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Emanuel Calvo 2011-11-09 12:57:26 [Feature Request] \dx show "options"
Previous Message Albe Laurenz 2011-11-09 11:27:20 Re: Disable OpenSSL compression