WIP: URI connection string support for libpq

From: Alexander Shulgin <ash(at)commandprompt(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: WIP: URI connection string support for libpq
Date: 2011-12-12 22:06:31
Message-ID: 1323723673-sup-8978@moon
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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(at)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 Content-Type Size
libpq-uri-v3.patch application/octet-stream 18.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Smith 2011-12-12 22:08:51 Re: [REVIEW] pg_last_xact_insert_timestamp
Previous Message Andrew Dunstan 2011-12-12 21:47:08 Re: includeifexists in configuration file