Unix Technical Forum

Re: [PATCHES] psql commandline conninfo

This is a discussion on Re: [PATCHES] psql commandline conninfo within the pgsql Hackers forums, part of the PostgreSQL category; --> I assume this patch will still allow a database name with an equals sign, right? psql "dbname='a=b'" The libpq ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 07:00 AM
Bruce Momjian
 
Posts: n/a
Default Re: [PATCHES] psql commandline conninfo


I assume this patch will still allow a database name with an equals
sign, right?


psql "dbname='a=b'"


The libpq documentation isn't clear that single-quotes also escape
equals, but I assume that is true looking at the code:

http://www.postgresql.org/docs/8.2/s...q-connect.html

The passed string can be empty to use all default parameters, or it can
contain one or more parameter settings separated by whitespace. Each
parameter setting is in the form keyword = value. Spaces around the
equal sign are optional. To write an empty value or a value containing
spaces, surround it with single quotes, e.g., keyword = 'a value'.
Single quotes and backslashes within the value must be escaped with a
backslash, i.e., \' and \\.


---------------------------------------------------------------------------

Andrew Dunstan wrote:
> Andrew Dunstan wrote:
> > Tom Lane wrote:
> >> "Andrew Dunstan" <andrew@dunslane.net> writes:
> >>
> >>> We change libpq from time to time. Besides, how many DBs are there that
> >>> match the name pattern /^conn:.*=/ ? My guess is mighty few. So I don't
> >>> expect lots of surprise.
> >>>
> >>
> >> Um, but how many DB names have an "=" in them at all?
> >>
> >> Basically what this proposal is about is migrating from separated
> >> dbname/user/host/port/etc parameters to a unified conninfo parameter.
> >> That seems to me like a good long-term objective, and so I'm willing
> >> to break a few eggs on the way to the omelet, as long as we're not
> >> breaking any very likely usages.
> >>
> >> So: who here has a database with "=" in the name? And hands up if
> >> you've got a database whose name begins with "conn:"?
> >>
> >> I'm betting zero response rate on both of those, so see no reason to
> >> contort the long-term definition for a very marginal difference in
> >> the extent of backwards compatibility ...
> >>
> >>
> >>

> >
> > I'm not sure -hackers is the most representative group to poll regarding
> > dbnames in use ...
> >
> > Anyway, if I understand your current position, the only change needed to
> > my current patch would be that if we fail to parse a dbname parameter
> > that contains an = we simply fail at that point, rather than retrying it
> > as a straight database name.
> >
> > I'm OK with that.
> >

>
>
> Here's the patch for what I think is the consensus position. If there's no
> objection I will apply this and document it.
>
> cheers
>
> andrew


[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match


--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-12-2008, 07:00 AM
Andrew Dunstan
 
Posts: n/a
Default Re: [PATCHES] psql commandline conninfo

Bruce Momjian wrote:
>
> I assume this patch will still allow a database name with an equals
> sign, right?
>
>
> psql "dbname='a=b'"



Yes. In fact, reading the code it looks like the quotes are not necessary
in this case.

cheers

andrew


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-12-2008, 07:00 AM
Bruce Momjian
 
Posts: n/a
Default Re: [PATCHES] psql commandline conninfo

Andrew Dunstan wrote:
> Bruce Momjian wrote:
> >
> > I assume this patch will still allow a database name with an equals
> > sign, right?
> >
> >
> > psql "dbname='a=b'"

>
>
> Yes. In fact, reading the code it looks like the quotes are not necessary
> in this case.


OK, good to know. Does the patch need documentation too? Are we
deprecating the psql options now duplicated by the new functionality,
like host/port/username/password?

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-12-2008, 07:00 AM
Tom Lane
 
Posts: n/a
Default Re: [PATCHES] psql commandline conninfo

Bruce Momjian <bruce@momjian.us> writes:
> OK, good to know. Does the patch need documentation too?


Certainly.

> Are we
> deprecating the psql options now duplicated by the new functionality,
> like host/port/username/password?


I'd vote not. This is just another way to do it.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-12-2008, 07:00 AM
Andrew Dunstan
 
Posts: n/a
Default Re: [PATCHES] psql commandline conninfo



Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
>
>> OK, good to know. Does the patch need documentation too?
>>

>
> Certainly.
>



That's why I haven't committed it yet. I intend to put info in the psql
manual as well as in the libpq reference.
>
>> Are we
>> deprecating the psql options now duplicated by the new functionality,
>> like host/port/username/password?
>>

>
> I'd vote not. This is just another way to do it.
>
>
>


I entirely agree. It lets you do some nice things that aren't obvious
now, like:

psql 'service=foo sslmode=require'

cheers

andrew

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:48 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com