BUG #4547: sort columns in \d

Lists: pgsql-bugs
From: "Ferdinand Gassauer" <gassauer(at)kde(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #4547: sort columns in \d
Date: 2008-11-23 16:19:38
Message-ID: 200811231619.mANGJciW041976@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 4547
Logged by: Ferdinand Gassauer
Email address: gassauer(at)kde(dot)org
PostgreSQL version: 8.3.5
Operating system: any
Description: sort columns in \d
Details:

currently the columns are sorted by attnum (not very userfriendly) instead
of attname (userfriendly)

this patch fixes this and makes the output of \d much more usable.

thank you for listening

--- describe.c.dist 2008-11-23 16:59:07.000000000 +0100
+++ describe.c 2008-11-23 16:59:28.000000000 +0100
@@ -867,7 +867,7 @@ describeOneTableDetails(const char *sche
appendPQExpBuffer(&buf, "\nWHERE a.attrelid = '%s' AND a.attnum > 0
AND NOT a.attisdropped", oid);
if (tableinfo.relkind == 'i')
appendPQExpBuffer(&buf, " AND a.attrelid = i.indexrelid");
- appendPQExpBuffer(&buf, "\nORDER BY a.attnum");
+ appendPQExpBuffer(&buf, "\nORDER BY a.attname");

res = PSQLexec(buf.data, false);
if (!res)


From: toruvinn <toruvinn(at)lain(dot)pl>
To: "Ferdinand Gassauer" <gassauer(at)kde(dot)org>
Subject: Re: BUG #4547: sort columns in \d
Date: 2008-11-23 16:36:13
Message-ID: op.uk2y2nm233x80h@insanity.lain.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Sun, 23 Nov 2008 17:19:38 +0100, Ferdinand Gassauer <gassauer(at)kde(dot)org>
wrote:
> currently the columns are sorted by attnum (not very userfriendly)
> instead
> of attname (userfriendly)
Actually, I prefer it the old way. I just like to know the column order
`SELECT *' would return (though I never use `SELECT *' myself). Not to
mention - the column order in my tables usually has some logical meaning
(result of relation design, you yourself probably don't just `throw some
columns in there' too) which would be lost otherwise.

Regards,
--
ru


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Ferdinand Gassauer" <gassauer(at)kde(dot)org>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4547: sort columns in \d
Date: 2008-11-23 17:40:38
Message-ID: 25646.1227462038@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

"Ferdinand Gassauer" <gassauer(at)kde(dot)org> writes:
> currently the columns are sorted by attnum (not very userfriendly) instead
> of attname (userfriendly)

This is intentional.

> this patch fixes this and makes the output of \d much more usable.

Calling this a "bug" isn't a good way to start a discussion about it.

regards, tom lane


From: "Jaime Casanova" <jcasanov(at)systemguards(dot)com(dot)ec>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Ferdinand Gassauer" <gassauer(at)kde(dot)org>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4547: sort columns in \d
Date: 2008-11-23 18:53:27
Message-ID: 3073cc9b0811231053i181d852fyacf684846d3b08d1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Sun, Nov 23, 2008 at 12:40 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>> this patch fixes this and makes the output of \d much more usable.
>
> Calling this a "bug" isn't a good way to start a discussion about it.
>

specially because this *fix* will lead to confusions about the order
of columns in INSERT statements, eventually you will be forced to put
column names in every INSERT statement (ie: if you start to work in an
enterprise with an already implemented postgres database)

--
Atentamente,
Jaime Casanova
Soporte y capacitación de PostgreSQL
Asesoría y desarrollo de sistemas
Guayaquil - Ecuador
Cel. +59387171157


From: Ferdinand Gassauer <gassauer(at)kde(dot)org>
To: "Undisclosed(dot)Recipients": ;
Cc: "Jaime Casanova" <jcasanov(at)systemguards(dot)com(dot)ec>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org, toruvinn <toruvinn(at)lain(dot)pl>
Subject: Re: BUG #4547: sort columns in \d
Date: 2008-11-23 19:10:35
Message-ID: 200811232010.36459.gassauer@kde.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

>Calling this a "bug" isn't a good way to start a discussion about it.
sorry, didn't want to insult anyone

All your comments are certainly valid.

I had to inspect and maintain a database which was not designed by me and has
tables with some 20-30 columns - no way to understand which columns are in a
table with the actual \d
OK other way is to use a graphical client...

may be a \D which sorts alphabetically ?

thanks for listening
--
cu
ferdinand


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Jaime Casanova" <jcasanov(at)systemguards(dot)com(dot)ec>
Cc: "Ferdinand Gassauer" <gassauer(at)kde(dot)org>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4547: sort columns in \d
Date: 2008-11-23 19:11:44
Message-ID: 26502.1227467504@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

"Jaime Casanova" <jcasanov(at)systemguards(dot)com(dot)ec> writes:
> On Sun, Nov 23, 2008 at 12:40 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> this patch fixes this and makes the output of \d much more usable.
>>
>> Calling this a "bug" isn't a good way to start a discussion about it.

> specially because this *fix* will lead to confusions about the order
> of columns in INSERT statements,

And "SELECT *" statements. I don't necessarily object to having some
way to list the columns alphabetically, but it shouldn't be the only
way, and probably not even the default.

regards, tom lane


From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4547: sort columns in \d
Date: 2008-11-24 06:39:48
Message-ID: 20081124063948.GA22704@shinkuro.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Sun, Nov 23, 2008 at 05:36:13PM +0100, toruvinn wrote:

> Actually, I prefer it the old way. I just like to know the column order
> `SELECT *' would return (though I never use `SELECT *' myself). Not to

You can't know that, as a matter of SQL semantics.

A

--
Andrew Sullivan
ajs(at)crankycanuck(dot)ca


From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4547: sort columns in \d
Date: 2008-11-24 06:41:41
Message-ID: 20081124064141.GB22704@shinkuro.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Mon, Nov 24, 2008 at 01:39:48AM -0500, Andrew Sullivan wrote:
>
> You can't know that, as a matter of SQL semantics.

I shouldn't reply to listmail when bone tired. I was thinking of
rows. Sorry.

A

--
Andrew Sullivan
ajs(at)crankycanuck(dot)ca