Re: Improving psql \ds

Lists: pgsql-hackers
From: Julien Tachoires <julmon(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Improving psql \ds
Date: 2012-10-07 21:06:56
Message-ID: CAFEQCbEtA5QSXOyr16cz3K-ydQ1Zj8p6yVLkHptK1d4aDjdYjA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

I would like to work on psql \ds improvements. Here's my idea :
- in src/bin/psql/describe.c, add a new function :
listSequences(*pattern, verbose) wich will list sequences and remove
code related to sequences from listTables()
- in src/bin/psql/command.c, call listSequences() on \ds
- about listSequences() implementation :
- get list from pg_catalog.pg_class WHERE relkind = 'S'
- for each seq. name, get details using : SELECT * FROM <seqname>;
(is there an other way to do that ?)

About \ds behaviour, I think to add 2 columns :
- 'LastValue'
- 'Increment'

for \ds+ :
- all extras informations available from the sequence table.

BTW, why don't we get last_value value with
pg_catalog.pg_sequence_parameters(oid) ? I guess this is because
last_value is not a parameter... Perhaps, having a
pg_sequence_all(oid) or something like that, giving all informations
from the seq. table could be usefull.

Thought ?

Cheers,


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Julien Tachoires <julmon(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improving psql \ds
Date: 2012-10-07 22:20:38
Message-ID: 19080.1349648438@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Julien Tachoires <julmon(at)gmail(dot)com> writes:
> About \ds behaviour, I think to add 2 columns :
> - 'LastValue'
> - 'Increment'

That would make the command a great deal slower, since it would have to
access each sequence to get that info. I don't object to adding such
columns to \ds+, but I don't think it's a good idea to put them in the
basic command.

The other problem you're going to have here is that there is in fact no
such command as "\ds" (nor "\ds+"); rather, it's a special case of
\dtsvi. As such, putting any relkind-specific info into the result is
problematic. I think you're going to have to invent a different command
if you want there to be sequence-specific columns.

regards, tom lane


From: Julien Tachoires <julmon(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improving psql \ds
Date: 2012-10-08 07:49:27
Message-ID: CAFEQCbEPjfgOvD9jQFih86uOoH1ZAGLfLCn+CjaP90oQOLS2NQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2012/10/8 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Julien Tachoires <julmon(at)gmail(dot)com> writes:
>> About \ds behaviour, I think to add 2 columns :
>> - 'LastValue'
>> - 'Increment'
>
> That would make the command a great deal slower, since it would have to
> access each sequence to get that info. I don't object to adding such
> columns to \ds+, but I don't think it's a good idea to put them in the
> basic command.

Ok.

> The other problem you're going to have here is that there is in fact no
> such command as "\ds" (nor "\ds+"); rather, it's a special case of
> \dtsvi. As such, putting any relkind-specific info into the result is
> problematic. I think you're going to have to invent a different command
> if you want there to be sequence-specific columns.

Yes, that's why I plan to create a new function listSequences() and
call it from src/bin/psql/command.c :
+ /* \d* commands */
+ else if (cmd[0] == 'd')
+ {
...
+ case 's':
+ success = listSequences(pattern, show_verbose);
+ break;

Cheers,


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Julien Tachoires <julmon(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improving psql \ds
Date: 2012-10-08 14:53:03
Message-ID: CA+Tgmob1DLjV_yWZ02p_Wt=9LgHRKaDywyWX6T2uJvux3u+MYQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Oct 8, 2012 at 3:49 AM, Julien Tachoires <julmon(at)gmail(dot)com> wrote:
> 2012/10/8 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>> Julien Tachoires <julmon(at)gmail(dot)com> writes:
>>> About \ds behaviour, I think to add 2 columns :
>>> - 'LastValue'
>>> - 'Increment'
>>
>> That would make the command a great deal slower, since it would have to
>> access each sequence to get that info. I don't object to adding such
>> columns to \ds+, but I don't think it's a good idea to put them in the
>> basic command.
>
> Ok.
>
>> The other problem you're going to have here is that there is in fact no
>> such command as "\ds" (nor "\ds+"); rather, it's a special case of
>> \dtsvi. As such, putting any relkind-specific info into the result is
>> problematic. I think you're going to have to invent a different command
>> if you want there to be sequence-specific columns.
>
> Yes, that's why I plan to create a new function listSequences() and
> call it from src/bin/psql/command.c :
> + /* \d* commands */
> + else if (cmd[0] == 'd')
> + {
> ...
> + case 's':
> + success = listSequences(pattern, show_verbose);
> + break;

What happens if the user does this:

\dis

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


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Julien Tachoires <julmon(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improving psql \ds
Date: 2012-10-08 14:59:59
Message-ID: 1263.1349708399@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Julien Tachoires <julmon(at)gmail(dot)com> writes:
> 2012/10/8 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>> The other problem you're going to have here is that there is in fact no
>> such command as "\ds" (nor "\ds+"); rather, it's a special case of
>> \dtsvi. As such, putting any relkind-specific info into the result is
>> problematic. I think you're going to have to invent a different command
>> if you want there to be sequence-specific columns.

> Yes, that's why I plan to create a new function listSequences() and
> call it from src/bin/psql/command.c :
> + /* \d* commands */
> + else if (cmd[0] == 'd')
> + {
> ...
> + case 's':
> + success = listSequences(pattern, show_verbose);
> + break;

No, that's not acceptable, because it will break cases such as "\dstv".

The \dxxx command namespace is already direly overloaded; I'm not sure
cramming more behaviors into it is a good idea anyway. Perhaps
something along the line of "\seqs" would be a usable substitute.

regards, tom lane


From: Julien Tachoires <julmon(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improving psql \ds
Date: 2012-10-08 15:02:48
Message-ID: CAFEQCbFydwvg6xnis3UJS6oxdU=gSizq4g3RJ5=oeH-ktRXkyA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2012/10/8 Robert Haas <robertmhaas(at)gmail(dot)com>:
> On Mon, Oct 8, 2012 at 3:49 AM, Julien Tachoires <julmon(at)gmail(dot)com> wrote:
>> 2012/10/8 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>>> Julien Tachoires <julmon(at)gmail(dot)com> writes:
>>>> About \ds behaviour, I think to add 2 columns :
>>>> - 'LastValue'
>>>> - 'Increment'
>>>
>>> That would make the command a great deal slower, since it would have to
>>> access each sequence to get that info. I don't object to adding such
>>> columns to \ds+, but I don't think it's a good idea to put them in the
>>> basic command.
>>
>> Ok.
>>
>>> The other problem you're going to have here is that there is in fact no
>>> such command as "\ds" (nor "\ds+"); rather, it's a special case of
>>> \dtsvi. As such, putting any relkind-specific info into the result is
>>> problematic. I think you're going to have to invent a different command
>>> if you want there to be sequence-specific columns.
>>
>> Yes, that's why I plan to create a new function listSequences() and
>> call it from src/bin/psql/command.c :
>> + /* \d* commands */
>> + else if (cmd[0] == 'd')
>> + {
>> ...
>> + case 's':
>> + success = listSequences(pattern, show_verbose);
>> + break;
>
> What happens if the user does this:
>
> \dis

hmm, you're right, this is not a good idea.


From: Julien Tachoires <julmon(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improving psql \ds
Date: 2012-10-08 15:10:38
Message-ID: CAFEQCbFPxa=ZhztjYLZwKd-v3HkBgfdT3XqrTURjs=J1OGw1-g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2012/10/8 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Julien Tachoires <julmon(at)gmail(dot)com> writes:
>> 2012/10/8 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>>> The other problem you're going to have here is that there is in fact no
>>> such command as "\ds" (nor "\ds+"); rather, it's a special case of
>>> \dtsvi. As such, putting any relkind-specific info into the result is
>>> problematic. I think you're going to have to invent a different command
>>> if you want there to be sequence-specific columns.
>
>> Yes, that's why I plan to create a new function listSequences() and
>> call it from src/bin/psql/command.c :
>> + /* \d* commands */
>> + else if (cmd[0] == 'd')
>> + {
>> ...
>> + case 's':
>> + success = listSequences(pattern, show_verbose);
>> + break;
>
> No, that's not acceptable, because it will break cases such as "\dstv".
>
> The \dxxx command namespace is already direly overloaded; I'm not sure
> cramming more behaviors into it is a good idea anyway. Perhaps
> something along the line of "\seqs" would be a usable substitute.

Ok. Does having both '\ds' and , let's call it '\seqs', won't be
source of confusion for the user ?


From: Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Julien Tachoires <julmon(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Improving psql \ds
Date: 2012-10-08 18:57:38
Message-ID: 50732222.8020200@archidevsys.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 09/10/12 03:53, Robert Haas wrote:
> On Mon, Oct 8, 2012 at 3:49 AM, Julien Tachoires <julmon(at)gmail(dot)com> wrote:
>> 2012/10/8 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>>> Julien Tachoires <julmon(at)gmail(dot)com> writes:
>>>> About \ds behaviour, I think to add 2 columns :
>>>> - 'LastValue'
>>>> - 'Increment'
>>> That would make the command a great deal slower, since it would have to
>>> access each sequence to get that info. I don't object to adding such
>>> columns to \ds+, but I don't think it's a good idea to put them in the
>>> basic command.
>> Ok.
>>
>>> The other problem you're going to have here is that there is in fact no
>>> such command as "\ds" (nor "\ds+"); rather, it's a special case of
>>> \dtsvi. As such, putting any relkind-specific info into the result is
>>> problematic. I think you're going to have to invent a different command
>>> if you want there to be sequence-specific columns.
>> Yes, that's why I plan to create a new function listSequences() and
>> call it from src/bin/psql/command.c :
>> + /* \d* commands */
>> + else if (cmd[0] == 'd')
>> + {
>> ...
>> + case 's':
>> + success = listSequences(pattern, show_verbose);
>> + break;
> What happens if the user does this:
>
> \dis
>
Hmm...

'According' to Terry Prachett,that is probably short hand for telling
the backend to go to Hell = 'dis' is apparently another name for 'Hell'!
(In his book 'Truth', commander Vimes has a personal dis-organiser - as
the 'dis-organiser' is run by a demon from Hell.)

Now back to more appropriate comments...