Re: Quoting of psql \d output

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Quoting of psql \d output
Date: 2003-12-23 22:07:24
Message-ID: 200312232207.hBNM7OT09388@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> "Peter Eisentraut" <peter_e(at)gmx(dot)net> writes:
> > While I don't really agree that this is a problem, better solutions would
> > be to not quote the thing at all or write something like Table "%s"
> > (Schema "%s"). However, the message style guidelines are very clear on
> > this point, and before we deviate I'd like to see an adjusted proposal.
>
> As Bruce pointed out, this isn't really a message; it's just a column
> heading, and so it's not clear that the message style guidelines apply.
>
> I kinda like the idea of not quoting it at all, actually, since that is
> a far simpler solution.

I looked into doing no quotes at all. Look at this. I have a table "xx y":

test=> \d
List of relations
Schema | Name | Type | Owner
--------+------+-------+----------
public | test | table | postgres
public | xx | table | postgres
public | xx y | table | postgres
(3 rows)

test=> \d xx y
Table public.xx <-- wrong table
Column | Type | Modifiers
--------+---------+-----------
y | integer |
Indexes:
ii btree (y)

\d: extra argument "y" ignored <-- fails without quotes

test=> \d "xx y"
Table public."xx y"
Column | Type | Modifiers
--------+---------+-----------
y | integer |
Indexes:
vv btree (y)

test=> create table "Xa" (y int);
CREATE TABLE

test=> \d Xa
Did not find any relation named "Xa". <-- again, requires quotes
test=> \d "Xa"
Table public."Xa"
Column | Type | Modifiers
--------+---------+-----------
y | integer |

Because the backslash commands require quotes to access specific tables,
and because queries will require quotes, I thought displaying quotes
when appropriate was a good idea and a good reminder to users. I also
thought that spaces in names could lead to confusing displays where the
spaces don't clearly identify where the object name begins and ends in
the display --- something Peter was concerned about.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-12-23 22:08:05 Re: Bug in new buffer freelist code
Previous Message Tom Lane 2003-12-23 22:03:34 Re: Bug in new buffer freelist code

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2003-12-23 22:13:29 Re: Quoting of psql \d output
Previous Message Tom Lane 2003-12-23 17:20:16 Re: Quoting of psql \d output