Re: Patch: psql \whoami option

From: David Christensen <david(at)endpoint(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Steve Singer <ssinger_pg(at)sympatico(dot)ca>, pgsql-hackers Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Patch: psql \whoami option
Date: 2010-07-18 17:29:22
Message-ID: D4C0B645-B42C-4C8F-8084-114BC8910A9D@endpoint.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Jul 18, 2010, at 12:17 PM, David Christensen wrote:

>
> On Jun 21, 2010, at 9:00 AM, Tom Lane wrote:
>
>> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>>> On Sun, Jun 20, 2010 at 10:51 PM, Steve Singer <ssinger_pg(at)sympatico(dot)ca> wrote:
>>>> One comment I have on the output format is that values (ie the database
>>>> name) are enclosed in double quotes but the values being quoted can contain
>>>> double quotes that are not being escaped.
>>
>> This is the same as standard practice in just about every other
>> message...
>>
>>> It seems like for user and database it might be sensible to apply
>>> PQescapeIdentifier to the value before printing it.
>>
>> I think this would actually be a remarkably bad idea in this particular
>> instance, because in the majority of cases psql does not apply
>> identifier dequoting rules to user and database names. What is printed
>> should be the same as what you'd need to give to \connect, for example.
>
>
> So I'm not quite sure how the above two paragraphs resolve? Should the user/database names be quoted or not? I have a new version of this patch available which has incorporated the feedback to this point?
>
> As an example of the current behavior, consider:
>
> machack:machack:5432=# create database "foo""bar"
> machack-# ;
> CREATE DATABASE
>
> [Sun Jul 18 12:14:49 CDT 2010]
> machack:machack:5432=# \c foo"bar
> unterminated quoted string
> You are now connected to database "machack".
>
> [Sun Jul 18 12:14:53 CDT 2010]
> machack:machack:5432=# \c "foo"bar"
> unterminated quoted string
> You are now connected to database "machack".
>
> [Sun Jul 18 12:14:59 CDT 2010]
> machack:machack:5432=# \c "foo""bar"
> You are now connected to database "foo"bar".
>
> As you can see, the value passed to connect differs from the output in the "connected to database" string.

It's helpful when you attach said patch. This has been rebased to current HEAD.

Regards,

David
--
David Christensen
End Point Corporation
david(at)endpoint(dot)com

Attachment Content-Type Size
psql-conninfo-v2.patch application/octet-stream 3.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-07-18 17:30:00 Re: Patch: psql \whoami option
Previous Message Andrew Dunstan 2010-07-18 17:23:44 Re: Review: Row-level Locks & SERIALIZABLE transactions, postgres vs. Oracle