pgsql: This makes all the \dX commands (most importantly to most: \df)

Started by Bruce Momjianover 17 years ago18 messageshackers
Jump to latest
#1Bruce Momjian
bruce@momjian.us

Log Message:
-----------
This makes all the \dX commands (most importantly to most: \df) work
like \dt does, in that it requires a \dXS to see system items.

Greg Sabino Mullane

Modified Files:
--------------
pgsql/src/bin/psql:
command.c (r1.200 -> r1.201)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/bin/psql/command.c?r1=1.200&r2=1.201)
describe.c (r1.193 -> r1.194)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/bin/psql/describe.c?r1=1.193&r2=1.194)
describe.h (r1.37 -> r1.38)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/bin/psql/describe.h?r1=1.37&r2=1.38)
help.c (r1.133 -> r1.134)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/bin/psql/help.c?r1=1.133&r2=1.134)

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#1)
Re: pgsql: This makes all the \dX commands (most importantly to most: \df)

momjian@postgresql.org (Bruce Momjian) writes:

This makes all the \dX commands (most importantly to most: \df) work
like \dt does, in that it requires a \dXS to see system items.

The lack of any documentation change is glaring.

regards, tom lane

#3Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#2)
Re: pgsql: This makes all the \dX commands (most importantly to most: \df)

Tom Lane wrote:

momjian@postgresql.org (Bruce Momjian) writes:

This makes all the \dX commands (most importantly to most: \df) work
like \dt does, in that it requires a \dXS to see system items.

The lack of any documentation change is glaring.

Oh, it sure does. I will work on that.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#4Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#3)
Re: [COMMITTERS] pgsql: This makes all the \dX commands (most importantly to most: \df)

Bruce Momjian wrote:

Tom Lane wrote:

momjian@postgresql.org (Bruce Momjian) writes:

This makes all the \dX commands (most importantly to most: \df) work
like \dt does, in that it requires a \dXS to see system items.

The lack of any documentation change is glaring.

Oh, it sure does. I will work on that.

OK, documentation added with the attached patch, applied. The
documentation needed quite a bit of cleanup, independent of this patch,
which I did.

I also found a bug that \do didn't work because the AND system table
check was being added to the LEFT JOIN and not to the WHERE clause
(trigger display was also a problem).

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

Attachments:

/rtmp/difftext/x-diffDownload+139-118
#5Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#4)
Re: Re: [COMMITTERS] pgsql: This makes all the \dX commands (most importantly to most: \df)

Bruce Momjian wrote:

Bruce Momjian wrote:

Tom Lane wrote:

momjian@postgresql.org (Bruce Momjian) writes:

This makes all the \dX commands (most importantly to most: \df) work
like \dt does, in that it requires a \dXS to see system items.

The lack of any documentation change is glaring.

Oh, it sure does. I will work on that.

OK, documentation added with the attached patch, applied. The
documentation needed quite a bit of cleanup, independent of this patch,
which I did.

I also found a bug that \do didn't work because the AND system table
check was being added to the LEFT JOIN and not to the WHERE clause
(trigger display was also a problem).

Let me also say that that \d* display is ready to fall over from its own
weight:

Informational
Modifiers: S = show system objects + = Additional detail
\l[+] list all databases
\d[S+] list tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] list aggregate functions
\db[+] [PATTERN] list tablespaces
\dc[S] [PATTERN] list conversions
\dC [PATTERN] list casts
\dd [PATTERN] show comment for object
\dd[S] [PATTERN] list comments on objects
\dD[S] [PATTERN] list domains
\des[+] [PATTERN] list foreign servers
\deu[+] [PATTERN] list user mappings
\dew[+] [PATTERN] list foreign-data wrappers
\df[S+] [PATTERN] list functions
\dF[+] [PATTERN] list text search configurations
\dFd[+] [PATTERN] list text search dictionaries
\dFp[+] [PATTERN] list text search parsers
\dFt[+] [PATTERN] list text search templates
\dg [PATTERN] list roles (groups)
\di[S+] [PATTERN] list indexes
\dl list large objects, same as \lo_list
\dn[+] [PATTERN] list schemas
\do[S] [PATTERN] list operators
\dp [PATTERN] list table, view, and sequence access privileges
\z [PATTERN] same as \dp
\ds[S+] [PATTERN] list sequences
\dt[S+] [PATTERN] list tables
\dT[S+] [PATTERN] list data types
\du [PATTERN] list roles (users)
\dv[S+] [PATTERN] list views

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#6Joshua D. Drake
jd@commandprompt.com
In reply to: Bruce Momjian (#5)
Re: Re: [COMMITTERS] pgsql: This makes all the \dX commands (most importantly to most: \df)

On Tue, 2009-01-06 at 18:08 -0500, Bruce Momjian wrote:

Bruce Momjian wrote:

I also found a bug that \do didn't work because the AND system table
check was being added to the LEFT JOIN and not to the WHERE clause
(trigger display was also a problem).

Let me also say that that \d* display is ready to fall over from its own
weight:

Informational
Modifiers: S = show system objects + = Additional detail
\l[+] list all databases
\d[S+] list tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] list aggregate functions
\db[+] [PATTERN] list tablespaces
\dc[S] [PATTERN] list conversions

Hmmm, I wonder if it makes sense to make it four column instead of two
column.

Joshua D. Drake

--
PostgreSQL
Consulting, Development, Support, Training
503-667-4564 - http://www.commandprompt.com/
The PostgreSQL Company, serving since 1997

#7Bruce Momjian
bruce@momjian.us
In reply to: Joshua D. Drake (#6)
Re: Re: [COMMITTERS] pgsql: This makes all the \dX commands (most importantly to most: \df)

Joshua D. Drake wrote:

On Tue, 2009-01-06 at 18:08 -0500, Bruce Momjian wrote:

Bruce Momjian wrote:

I also found a bug that \do didn't work because the AND system table
check was being added to the LEFT JOIN and not to the WHERE clause
(trigger display was also a problem).

Let me also say that that \d* display is ready to fall over from its own
weight:

Informational
Modifiers: S = show system objects + = Additional detail
\l[+] list all databases
\d[S+] list tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] list aggregate functions
\db[+] [PATTERN] list tablespaces
\dc[S] [PATTERN] list conversions

Hmmm, I wonder if it makes sense to make it four column instead of two
column.

You mean like this?

fprintf(output, _("Informational\n"));
fprintf(output, _(" Modifiers: S = show system objects + = Additional detail\n"));
fprintf(output, _(" \\l[+] list all databases\n"));
fprintf(output, _(" \\d[S+] list tables, views, and sequences\n"));
fprintf(output, _(" \\d[S+] NAME describe table, view, sequence, or index\n"));
fprintf(output, _(" \\da[S] [PATTERN] list aggregate functions\n"));
fprintf(output, _(" \\db[+] [PATTERN] list tablespaces\n"));
fprintf(output, _(" \\dc[S] [PATTERN] list conversions\n"));
fprintf(output, _(" \\dC [PATTERN] list casts\n"));
fprintf(output, _(" \\dd [PATTERN] show comment for object\n"));
fprintf(output, _(" \\dd[S] [PATTERN] list comments on objects\n"));
fprintf(output, _(" \\dD[S] [PATTERN] list domains\n"));
fprintf(output, _(" \\des[+] [PATTERN] list foreign servers\n"));
fprintf(output, _(" \\deu[+] [PATTERN] list user mappings\n"));
fprintf(output, _(" \\dew[+] [PATTERN] list foreign-data wrappers\n"));
fprintf(output, _(" \\df[S+] [PATTERN] list functions\n"));
fprintf(output, _(" \\dF[+] [PATTERN] list text search configurations\n"));
fprintf(output, _(" \\dFd[+] [PATTERN] list text search dictionaries\n"));
fprintf(output, _(" \\dFp[+] [PATTERN] list text search parsers\n"));
fprintf(output, _(" \\dFt[+] [PATTERN] list text search templates\n"));
fprintf(output, _(" \\dg [PATTERN] list roles (groups)\n"));
fprintf(output, _(" \\di[S+] [PATTERN] list indexes\n"));
fprintf(output, _(" \\dl list large objects, same as \\lo_list\n"));
fprintf(output, _(" \\dn[+] [PATTERN] list schemas\n"));
fprintf(output, _(" \\do[S] [PATTERN] list operators\n"));
fprintf(output, _(" \\dp [PATTERN] list table, view, and sequence access privileges\n"));
fprintf(output, _(" \\z [PATTERN] same as \\dp\n"));
fprintf(output, _(" \\ds[S+] [PATTERN] list sequences\n"));
fprintf(output, _(" \\dt[S+] [PATTERN] list tables\n"));
fprintf(output, _(" \\dT[S+] [PATTERN] list data types\n"));
fprintf(output, _(" \\du [PATTERN] list roles (users)\n"));
fprintf(output, _(" \\dv[S+] [PATTERN] list views\n"));
fprintf(output, "\n");

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#8Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#7)
Re: Re: [COMMITTERS] pgsql: This makes all the \dX commands (most importantly to most: \df)

Bruce Momjian wrote:

Joshua D. Drake wrote:

On Tue, 2009-01-06 at 18:08 -0500, Bruce Momjian wrote:

Bruce Momjian wrote:

I also found a bug that \do didn't work because the AND system table
check was being added to the LEFT JOIN and not to the WHERE clause
(trigger display was also a problem).

Let me also say that that \d* display is ready to fall over from its own
weight:

Informational
Modifiers: S = show system objects + = Additional detail
\l[+] list all databases
\d[S+] list tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] list aggregate functions
\db[+] [PATTERN] list tablespaces
\dc[S] [PATTERN] list conversions

Hmmm, I wonder if it makes sense to make it four column instead of two
column.

OK, done (below). 'list' seems kind of redundant. Can we factor that
out somehow?

Informational
Modifiers: S = show system objects + = Additional detail
\l[+] list all databases
\d[S+] list tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] list aggregate functions
\db[+] [PATTERN] list tablespaces
\dc[S] [PATTERN] list conversions
\dC [PATTERN] list casts
\dd [PATTERN] show comment for object
\dd[S] [PATTERN] list comments on objects
\dD[S] [PATTERN] list domains
\des[+] [PATTERN] list foreign servers
\deu[+] [PATTERN] list user mappings
\dew[+] [PATTERN] list foreign-data wrappers
\df[S+] [PATTERN] list functions
\dF[+] [PATTERN] list text search configurations
\dFd[+] [PATTERN] list text search dictionaries
\dFp[+] [PATTERN] list text search parsers
\dFt[+] [PATTERN] list text search templates
\dg [PATTERN] list roles (groups)
\di[S+] [PATTERN] list indexes
\dl list large objects, same as \lo_list
\dn[+] [PATTERN] list schemas
\do[S] [PATTERN] list operators
\dp [PATTERN] list table, view, and sequence access privileges
\z [PATTERN] same as \dp
\ds[S+] [PATTERN] list sequences
\dt[S+] [PATTERN] list tables
\dT[S+] [PATTERN] list data types
\du [PATTERN] list roles (users)
\dv[S+] [PATTERN] list views

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#9Joshua D. Drake
jd@commandprompt.com
In reply to: Bruce Momjian (#8)
Re: Re: [COMMITTERS] pgsql: This makes all the \dX commands (most importantly to most: \df)

On Tue, 2009-01-06 at 19:06 -0500, Bruce Momjian wrote:

Bruce Momjian wrote:

OK, done (below). 'list' seems kind of redundant. Can we factor that
out somehow?

Informational
Modifiers: S = show system objects + = Additional detail
\l[+] list all databases
\d[S+] list tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] list aggregate functions
\db[+] [PATTERN] list tablespaces
\dc[S] [PATTERN] list conversions
\dC [PATTERN] list casts
\dd [PATTERN] show comment for object

Per offline comments my thoughts were something like:

Informational: S = show system objects + = Additional detail
Display:
\l[+] all databases
\d[S+] tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] aggregate functions
\db[+] [PATTERN] tablespaces
\dc[S] [PATTERN] conversions
\dC [PATTERN] casts
\dd [PATTERN] show comment for object
\dd[S] [PATTERN] comments on objects

But I am not putting up any sandbags :)

Joshua D. Drake

--
PostgreSQL
Consulting, Development, Support, Training
503-667-4564 - http://www.commandprompt.com/
The PostgreSQL Company, serving since 1997

#10Bruce Momjian
bruce@momjian.us
In reply to: Joshua D. Drake (#9)
Re: Re: [COMMITTERS] pgsql: This makes all the \dX commands (most importantly to most: \df)

Joshua D. Drake wrote:

On Tue, 2009-01-06 at 19:06 -0500, Bruce Momjian wrote:

Bruce Momjian wrote:

OK, done (below). 'list' seems kind of redundant. Can we factor that
out somehow?

Informational
Modifiers: S = show system objects + = Additional detail
\l[+] list all databases
\d[S+] list tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] list aggregate functions
\db[+] [PATTERN] list tablespaces
\dc[S] [PATTERN] list conversions
\dC [PATTERN] list casts
\dd [PATTERN] show comment for object

Per offline comments my thoughts were something like:

Informational: S = show system objects + = Additional detail
Display:

I don't like the "Display:" here because it mimicks the heading above
it.

\l[+] all databases
\d[S+] tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] aggregate functions
\db[+] [PATTERN] tablespaces
\dc[S] [PATTERN] conversions
\dC [PATTERN] casts
\dd [PATTERN] show comment for object
\dd[S] [PATTERN] comments on objects

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#11Joshua D. Drake
jd@commandprompt.com
In reply to: Bruce Momjian (#10)
Re: Re: [COMMITTERS] pgsql: This makes all the \dX commands (most importantly to most: \df)

On Tue, 2009-01-06 at 19:13 -0500, Bruce Momjian wrote:

Joshua D. Drake wrote:

Per offline comments my thoughts were something like:

Informational: S = show system objects + = Additional detail
Display:

I don't like the "Display:" here because it mimicks the heading above
it.

Fair enough. I would be fine without it.

Joshua D. Drake

--
PostgreSQL
Consulting, Development, Support, Training
503-667-4564 - http://www.commandprompt.com/
The PostgreSQL Company, serving since 1997

#12Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Bruce Momjian (#8)
Re: Re: [COMMITTERS] pgsql: This makes all the \dX commands (most importantly to most: \df)

Bruce Momjian wrote:

Informational
Modifiers: S = show system objects + = Additional detail
\l[+] list all databases
\d[S+] list tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] list aggregate functions

If we do this, is there a way to abstract the translation marker _()
from the alignment whitespace?

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#13Joshua D. Drake
jd@commandprompt.com
In reply to: Alvaro Herrera (#12)
Re: Re: [COMMITTERS] pgsql: This makes all the \dX commands (most importantly to most: \df)

On Tue, 2009-01-06 at 21:58 -0300, Alvaro Herrera wrote:

Bruce Momjian wrote:

Informational
Modifiers: S = show system objects + = Additional detail
\l[+] list all databases
\d[S+] list tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] list aggregate functions

If we do this, is there a way to abstract the translation marker _()
from the alignment whitespace?

O.k. I might just be stupid here but can we just seek until we hit a non
space or \t?

Joshua D. Drake

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

--
PostgreSQL
Consulting, Development, Support, Training
503-667-4564 - http://www.commandprompt.com/
The PostgreSQL Company, serving since 1997

#14Bruce Momjian
bruce@momjian.us
In reply to: Alvaro Herrera (#12)
Re: Re: [COMMITTERS] pgsql: This makes all the \dX commands (most importantly to most: \df)

Alvaro Herrera wrote:

Bruce Momjian wrote:

Informational
Modifiers: S = show system objects + = Additional detail
\l[+] list all databases
\d[S+] list tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] list aggregate functions

If we do this, is there a way to abstract the translation marker _()
from the alignment whitespace?

So they don't have to re-translate?

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#15Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Bruce Momjian (#14)
Re: Re: [COMMITTERS] pgsql: This makes all the \dX commands (most importantly to most: \df)

Bruce Momjian wrote:

Alvaro Herrera wrote:

Bruce Momjian wrote:

Informational
Modifiers: S = show system objects + = Additional detail
\l[+] list all databases
\d[S+] list tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] list aggregate functions

If we do this, is there a way to abstract the translation marker _()
from the alignment whitespace?

So they don't have to re-translate?

No, so that the translators don't have to worry about getting alignment
right; and also so that they don't have to translate \\d[S+] etc which
obviously doesn't need any translation.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#16Bruce Momjian
bruce@momjian.us
In reply to: Alvaro Herrera (#15)
Re: Re: [COMMITTERS] pgsql: This makes all the \dX commands (most importantly to most: \df)

Alvaro Herrera wrote:

Bruce Momjian wrote:

Alvaro Herrera wrote:

Bruce Momjian wrote:

Informational
Modifiers: S = show system objects + = Additional detail
\l[+] list all databases
\d[S+] list tables, views, and sequences
\d[S+] NAME describe table, view, sequence, or index
\da[S] [PATTERN] list aggregate functions

If we do this, is there a way to abstract the translation marker _()
from the alignment whitespace?

So they don't have to re-translate?

No, so that the translators don't have to worry about getting alignment
right; and also so that they don't have to translate \\d[S+] etc which
obviously doesn't need any translation.

I am thinking we can do:

fprintf(output, " \\da[S] %.9s %s\n", _("[PATTERN]"),
_("list aggregate"));

What do you think?

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#17Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Bruce Momjian (#16)
Re: Re: [COMMITTERS] pgsql: This makes all the \dX commands (most importantly to most: \df)

Bruce Momjian wrote:

Alvaro Herrera wrote:

No, so that the translators don't have to worry about getting alignment
right; and also so that they don't have to translate \\d[S+] etc which
obviously doesn't need any translation.

I am thinking we can do:

fprintf(output, " \\da[S] %.9s %s\n", _("[PATTERN]"),
_("list aggregate"));

What do you think?

Right, something like that ... I'm wondering, though, if there are any
translations where [PATTERN] ends up longer than 9 chars. At least none
of the existing translations has that problem, so it seems we're good ...

Hmm, what's the difference here:

\dd [PATTERN] show comment for object
\dd[S] [PATTERN] list comments on objects
?

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

#18Bruce Momjian
bruce@momjian.us
In reply to: Alvaro Herrera (#17)
Re: Re: [COMMITTERS] pgsql: This makes all the \dX commands (most importantly to most: \df)

Alvaro Herrera wrote:

Bruce Momjian wrote:

Alvaro Herrera wrote:

No, so that the translators don't have to worry about getting alignment
right; and also so that they don't have to translate \\d[S+] etc which
obviously doesn't need any translation.

I am thinking we can do:

fprintf(output, " \\da[S] %.9s %s\n", _("[PATTERN]"),
_("list aggregate"));

What do you think?

Right, something like that ... I'm wondering, though, if there are any
translations where [PATTERN] ends up longer than 9 chars. At least none
of the existing translations has that problem, so it seems we're good ...

I probably should have suggested:

fprintf(output, " \\da[S] %-12s %s\n", _("[PATTERN]"),
_("list aggregate"));

I am hesistant to use -12.12 because that might cut off a long word, or
a bracket.

The larger question is how does printf(3) handle width, as bytes or
characters. My Ubuntu says:

If the converted value has fewer characters than the
field width, it will be padded with spaces on the left
(or right, if the left-adjustment flag has been given).

This talks about characters, but is it really multibyte characters?
Alvaro says we have to use %ls, but he says that is wchar_t, which we
don't use.

Hmm, what's the difference here:

\dd [PATTERN] show comment for object
\dd[S] [PATTERN] list comments on objects

I don't know what you're talking about --- LOOK THERE! (removes duplicate
line while no one is looking)

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +