Re: \d+ for long view definitions?

Lists: pgsql-hackers
From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: \d+ for long view definitions?
Date: 2009-08-30 21:02:41
Message-ID: 1251666161.22097.6.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Using \d on, say, information schema views is completely hilarious
because the column name/data type information is usually scrolled off
the screen by the immense view definition.

Could we change this perhaps so that the full view definition is only
shown with \d+ when the view definition is longer than N characters or N
lines or some other suitable cutoff. Ideas?


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: \d+ for long view definitions?
Date: 2009-08-30 22:43:51
Message-ID: 2170.1251672231@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> Using \d on, say, information schema views is completely hilarious
> because the column name/data type information is usually scrolled off
> the screen by the immense view definition.

> Could we change this perhaps so that the full view definition is only
> shown with \d+ when the view definition is longer than N characters or N
> lines or some other suitable cutoff. Ideas?

The same complaint could be made for any table with more than
twenty-some columns. Seems like a more general answer would be
for \d output to go through the pager ...

regards, tom lane


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: \d+ for long view definitions?
Date: 2009-08-31 00:04:39
Message-ID: 20090831000439.GB18965@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > Using \d on, say, information schema views is completely hilarious
> > because the column name/data type information is usually scrolled off
> > the screen by the immense view definition.
>
> > Could we change this perhaps so that the full view definition is only
> > shown with \d+ when the view definition is longer than N characters or N
> > lines or some other suitable cutoff. Ideas?
>
> The same complaint could be made for any table with more than
> twenty-some columns. Seems like a more general answer would be
> for \d output to go through the pager ...

I think the fix is to have psql add the number of lines in headers and
footers to the calculation that decides whether to use the pager or not.
Right now I think it only considers data rows.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: \d+ for long view definitions?
Date: 2009-08-31 20:13:11
Message-ID: 1251749591.20938.6.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On sön, 2009-08-30 at 18:43 -0400, Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > Using \d on, say, information schema views is completely hilarious
> > because the column name/data type information is usually scrolled off
> > the screen by the immense view definition.
>
> > Could we change this perhaps so that the full view definition is only
> > shown with \d+ when the view definition is longer than N characters or N
> > lines or some other suitable cutoff. Ideas?
>
> The same complaint could be made for any table with more than
> twenty-some columns.

I guess my premise is that if I use \d, I'm primarily interested in the
column names and types. The view definition is secondary. If the view
definition is a single line or uses a single table, it's interesting
because it might describe something about the schema design, but if it's
20 lines it's an implementation detail.

I think this is quite similar to showing the function definition only
with \df+. If I'm looking at the function, I'm usually only looking for
name and parameter information, not the full source code.

> Seems like a more general answer would be
> for \d output to go through the pager ...

That should also be fixed, but I'm not sure if it really does it for me.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: \d+ for long view definitions?
Date: 2009-08-31 20:20:59
Message-ID: 1626.1251750059@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> On sn, 2009-08-30 at 18:43 -0400, Tom Lane wrote:
>> Seems like a more general answer would be
>> for \d output to go through the pager ...

> That should also be fixed, but I'm not sure if it really does it for me.

Why not? Just quit out of the pager when you've seen enough.

If the view definition precedes other data that is deemed more
important, then we'd need to adjust the ordering, but I'm not
entirely seeing the point of having to suppress the definition.

I especially don't like the thought of making it depend on the length
of the definition. I would prefer \d not showing it at all.

regards, tom lane


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: \d+ for long view definitions?
Date: 2009-09-01 17:31:21
Message-ID: 4A9D5A69.8090007@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 8/31/09 1:13 PM, Peter Eisentraut wrote:
> I guess my premise is that if I use \d, I'm primarily interested in the
> column names and types. The view definition is secondary. If the view
> definition is a single line or uses a single table, it's interesting
> because it might describe something about the schema design, but if it's
> 20 lines it's an implementation detail.

I agree with Peter here.

--
Josh Berkus
PostgreSQL Experts Inc.
www.pgexperts.com


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: \d+ for long view definitions?
Date: 2009-09-01 18:17:31
Message-ID: 603c8f070909011117x166004a1j65c2dcea8709c849@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Sep 1, 2009 at 1:31 PM, Josh Berkus<josh(at)agliodbs(dot)com> wrote:
> On 8/31/09 1:13 PM, Peter Eisentraut wrote:
>> I guess my premise is that if I use \d, I'm primarily interested in the
>> column names and types.  The view definition is secondary.  If the view
>> definition is a single line or uses a single table, it's interesting
>> because it might describe something about the schema design, but if it's
>> 20 lines it's an implementation detail.
>
> I agree with Peter here.

I think we should always or never show the view definition, not sometimes.

And I also agree with Tom's point that we should fix the pager. The
way that it works now is really annoying.

...Robert


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: \d+ for long view definitions?
Date: 2009-09-01 18:29:12
Message-ID: 27417.1251829752@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> I think we should always or never show the view definition, not sometimes.

Yeah. I can live with \d not showing it and \d+ showing it --- as Peter
already mentioned, that would be consistent with \df behavior. Making
it depend on the length is just weird.

regards, tom lane


From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Josh Berkus" <josh(at)agliodbs(dot)com>, "Robert Haas" <robertmhaas(at)gmail(dot)com>
Cc: "Peter Eisentraut" <peter_e(at)gmx(dot)net>, <pgsql-hackers(at)postgresql(dot)org>,"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: \d+ for long view definitions?
Date: 2009-09-01 18:39:07
Message-ID: 4A9D23FB020000250002A7AC@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> I think we should always or never show the view definition, not
> sometimes.

+1

> And I also agree with Tom's point that we should fix the pager. The
> way that it works now is really annoying.

+1

-Kevin


From: David Fetter <david(at)fetter(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: \d+ for long view definitions?
Date: 2009-09-01 19:01:10
Message-ID: 20090901190109.GV20482@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Sep 01, 2009 at 02:29:12PM -0400, Tom Lane wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> > I think we should always or never show the view definition, not
> > sometimes.
>
> Yeah. I can live with \d not showing it and \d+ showing it --- as
> Peter already mentioned, that would be consistent with \df behavior.
> Making it depend on the length is just weird.

As I see it, there are two independent issues here:

* "Smart" display based on number of columns in the query and the psql window
* Whether to display the view definition.

I'm thinking on the second, \d should not display the definition, and
\d+ should.

On the first...could we go to \x-type display if the columns will
overflow the terminal?

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Josh Berkus <josh(at)agliodbs(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: \d+ for long view definitions?
Date: 2009-09-01 19:11:45
Message-ID: 603c8f070909011211v6272ecffvd402a3a5b0d549c5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Sep 1, 2009 at 3:01 PM, David Fetter<david(at)fetter(dot)org> wrote:
> On Tue, Sep 01, 2009 at 02:29:12PM -0400, Tom Lane wrote:
>> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> > I think we should always or never show the view definition, not
>> > sometimes.
>>
>> Yeah.  I can live with \d not showing it and \d+ showing it --- as
>> Peter already mentioned, that would be consistent with \df behavior.
>> Making it depend on the length is just weird.
>
> As I see it, there are two independent issues here:
>
> * "Smart" display based on number of columns in the query and the psql window
> * Whether to display the view definition.
>
> I'm thinking on the second, \d should not display the definition, and
> \d+ should.
>
> On the first...could we go to \x-type display if the columns will
> overflow the terminal?

I don't understand exactly what you're proposing, but I don't think
flipping into \x mode based on the window size is ever a good idea.

...Robert


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: \d+ for long view definitions?
Date: 2009-10-29 22:41:26
Message-ID: 1256856086.9673.2.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On tis, 2009-09-01 at 14:29 -0400, Tom Lane wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> > I think we should always or never show the view definition, not sometimes.
>
> Yeah. I can live with \d not showing it and \d+ showing it --- as Peter
> already mentioned, that would be consistent with \df behavior. Making
> it depend on the length is just weird.

The patch for this endeavor is:

diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -1306,7 +1306,7 @@ describeOneTableDetails(const char *schemaname,
printTableAddHeader(&cont, headers[i], true, 'l');

/* Check if table is a view */
- if (tableinfo.relkind == 'v')
+ if (tableinfo.relkind == 'v' && verbose)
{
PGresult *result;

Any final words?


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: \d+ for long view definitions?
Date: 2009-10-31 17:37:24
Message-ID: 4AEC75D4.1010605@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
> --- a/src/bin/psql/describe.c
> +++ b/src/bin/psql/describe.c
> @@ -1306,7 +1306,7 @@ describeOneTableDetails(const char *schemaname,
> printTableAddHeader(&cont, headers[i], true, 'l');
>
> /* Check if table is a view */
> - if (tableinfo.relkind == 'v')
> + if (tableinfo.relkind == 'v' && verbose)
> {
> PGresult *result;
>
> Any final words?

Thanks?

--Josh Berkus