Thread: psql: Add setting to make '+' on \d implicit

psql: Add setting to make '+' on \d implicit

From
Terry Brown
Date:
I asked on IRC if there was any way to make \d behave like \d+ by default, and davidfetter said no but suggest it
here.

endpoint_david pointed out you could use \d- to get the old behavior if you wanted to temporarily negate the setting.

So the proposal would be:

\d+ does as it has always done, no change
\d- (new) always behaves like 'old' \d
\d  acts as 'old' \d or as \d+, depending on the setting of 'verbose_describe', set via \pset.

Default setting of verbose_describe would presumably yield 'old' behavior.

Motivation is that I like to see comments when they exist.  Probably useful for other reasons too.

Cheers -Terry


Re: psql: Add setting to make '+' on \d implicit

From
"Ross J. Reedstrom"
Date:
On Fri, Apr 23, 2010 at 10:58:40AM -0500, Terry Brown wrote:
> I asked on IRC if there was any way to make \d behave like \d+ by default, and davidfetter said no but suggest it
here.
> 
> endpoint_david pointed out you could use \d- to get the old behavior if you wanted to temporarily negate the
setting.
> 
> So the proposal would be:
> 
> \d+ does as it has always done, no change
> \d- (new) always behaves like 'old' \d
> \d  acts as 'old' \d or as \d+, depending on the setting of 'verbose_describe', set via \pset.
> 
> Default setting of verbose_describe would presumably yield 'old' behavior.
> 
> Motivation is that I like to see comments when they exist.  Probably useful for other reasons too.

Hmm, what about all the other + variants? Would this setting affect
them? I'd suggest perhaps it should.

Ross
-- 
Ross Reedstrom, Ph.D.                                 reedstrm@rice.edu
Systems Engineer & Admin, Research Scientist        phone: 713-348-6166
The Connexions Project      http://cnx.org            fax: 713-348-3665
Rice University MS-375, Houston, TX 77005
GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E  F888 D3AE 810E 88F0 BEDE


Re: psql: Add setting to make '+' on \d implicit

From
Tom Lane
Date:
"Ross J. Reedstrom" <reedstrm@rice.edu> writes:
> On Fri, Apr 23, 2010 at 10:58:40AM -0500, Terry Brown wrote:
>> So the proposal would be:
>> 
>> \d+ does as it has always done, no change
>> \d- (new) always behaves like 'old' \d
>> \d  acts as 'old' \d or as \d+, depending on the setting of 'verbose_describe', set via \pset.

> Hmm, what about all the other + variants? Would this setting affect
> them? I'd suggest perhaps it should.

If we were to do something like that, it would certainly have to affect
every \d variant that has a + option.  Which is probably not a very good
idea --- in many cases that's a very expensive/verbose option.  I can't
get excited about this proposal, personally.

What the OP actually seemed to care about was database object comments.
I could see somebody who relied heavily on comments wanting his comments
to be included in all display commands, even without the + option.
Maybe a configuration variable along the lines of 'always_show_comments'
would be a better design.

BTW, \pset seems like the wrong place for this.  That's for formatting
table output, not for controlling what specific \d commands show.
        regards, tom lane


Re: psql: Add setting to make '+' on \d implicit

From
Steve Atkins
Date:
On Apr 23, 2010, at 11:28 AM, Tom Lane wrote:

> "Ross J. Reedstrom" <reedstrm@rice.edu> writes:
>> On Fri, Apr 23, 2010 at 10:58:40AM -0500, Terry Brown wrote:
>>> So the proposal would be:
>>>
>>> \d+ does as it has always done, no change
>>> \d- (new) always behaves like 'old' \d
>>> \d  acts as 'old' \d or as \d+, depending on the setting of 'verbose_describe', set via \pset.
>
>> Hmm, what about all the other + variants? Would this setting affect
>> them? I'd suggest perhaps it should.
>
> If we were to do something like that, it would certainly have to affect
> every \d variant that has a + option.  Which is probably not a very good
> idea --- in many cases that's a very expensive/verbose option.  I can't
> get excited about this proposal, personally.
>
> What the OP actually seemed to care about was database object comments.
> I could see somebody who relied heavily on comments wanting his comments
> to be included in all display commands, even without the + option.
> Maybe a configuration variable along the lines of 'always_show_comments'
> would be a better design.

Or more generally an ability to set aliases via .psqlrc similar to \set, maybe?

\alias "\d-" = "\d"
\alias "\d" = "\d+"

Cheers, Steve

Re: psql: Add setting to make '+' on \d implicit

From
Terry Brown
Date:
On Fri, 23 Apr 2010 14:28:38 -0400
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> If we were to do something like that, it would certainly have to affect
> every \d variant that has a + option.  Which is probably not a very good
> idea --- in many cases that's a very expensive/verbose option.  I can't
> get excited about this proposal, personally.

I was thinking of affecting all \d* commands, didn't know some were expensive though.

> What the OP actually seemed to care about was database object comments.
> I could see somebody who relied heavily on comments wanting his comments
> to be included in all display commands, even without the + option.
> Maybe a configuration variable along the lines of 'always_show_comments'
> would be a better design.

Sounds good, comment visibility is my goal.  I know full metadata should be handled in other ways, but I like to do
mostprocessing in psql sessions for the self documenting effect, and seeing comments helps in that context.  If \pset's
notthe right place anywhere else would be fine.
 

Thanks for considering,
Cheers -Terry


Re: psql: Add setting to make '+' on \d implicit

From
Terry Brown
Date:
On Fri, 23 Apr 2010 14:34:45 -0700
Steve Atkins <steve@blighty.com> wrote:

> > Maybe a configuration variable along the lines of 'always_show_comments'
> > would be a better design.  
> 
> Or more generally an ability to set aliases via .psqlrc similar to \set, maybe?
> 
> \alias "\d-" = "\d"
> \alias "\d" = "\d+"

Sounds harder but better because of the generality.

Cheers -Terry



Re: psql: Add setting to make '+' on \d implicit

From
Bernd Helmle
Date:

--On 23. April 2010 14:34:45 -0700 Steve Atkins <steve@blighty.com> wrote:

> Or more generally an ability to set aliases via .psqlrc similar to \set,
> maybe?
>
> \alias "\d-" = "\d"
> \alias "\d" = "\d+"

You mean something like this?

<http://archives.postgresql.org/pgsql-patches/2008-04/msg00005.php>

-- 
Thanks
Bernd