Hello Hackers,

Attached is a work-in-progress patch for URI connection string syntax support 
in libpq.  The recent discussion (also pointing to the original one) is here: 

  http://archives.postgresql.org/message-id/1321899990-sup-1235@moon

The patch adds support for the following syntax in psql, by adding special 
handling of dbname parameter, when it starts with "postgresql://", e.g:

  psql -d postgresql://user@pw:host:port/dbname?param1=value1&param2=value2...

Virtually every component of the above syntax is optional, ultimately allowing 
for, e.g:

  psql -d postgresql:///

to specify local connection via Unix socket, with default port, user name, 
dbname, etc.

URI percent-encoding is handled, in particular, allowing to include special 
symbols in the embedded password string, or to specify non-standard Unix socket 
location, like the following:

  psql -d postgresql://%2Fvar%2Fpgsql%2Ftmp/mydb

The patch applies cleanly against the master branch and compiles w/o errors or 
warnings.  No tests were broken by this patch on my box, as far as I can tell.

The patch follows design initially proposed and tries to address feedback 
gathered from the recent discussion.  Special provision was made to improve 
compatibility with JDBC's connection URIs, by treating "ssl=true" parameter as 
equivalent of "sslmode=require".

The patch intentionally omits documentation changes, to focus on the desired 
behavior and new code design.

I've put reasonable effort into testing the new code by feeding various 
parameters to "psql -d".  However, if there's a facility for writing formal 
regression tests against psql, I'd be happy to use that.

I'm also adding this to the next open CommitFest: 2012-01.

--
Regards,
Alex

Attachment: libpq-uri-v3.patch
Description: Binary data

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to