Re: Quoting of psql \d output - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: Quoting of psql \d output
Date
Msg-id 200312232207.hBNM7OT09388@candle.pha.pa.us
Whole thread Raw
In response to Re: Quoting of psql \d output  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
Tom Lane wrote:
> "Peter Eisentraut" <peter_e@gmx.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@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: Quoting of psql \d output
Next
From: Bruce Momjian
Date:
Subject: Re: Quoting of psql \d output