Skip site navigation (1) Skip section navigation (2)

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(at)postgresql(dot)org
Subject: Re: Patch: psql \whoami option
Date: 2010-07-18 17:17:44
Message-ID: 0B812EBB-531C-45C8-8671-49E974BE0F03@endpoint.com (view raw or flat)
Thread:
Lists: pgsql-hackers
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.

Regards,

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





In response to

Responses

pgsql-hackers by date

Next:From: Kevin GrittnerDate: 2010-07-18 17:18:06
Subject: Re: Review: Row-level Locks & SERIALIZABLE transactions, postgres vs. Oracle
Previous:From: Tom LaneDate: 2010-07-18 17:16:59
Subject: Re: standard_conforming_strings

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group