Re: psql - better support pipe line - Mailing list pgsql-hackers

From Shulgin, Oleksandr
Subject Re: psql - better support pipe line
Date
Msg-id CACACo5TmOn4=DJujnVPfcHWi23h4XqSnpmkdzB-qy99c10RPRA@mail.gmail.com
Whole thread Raw
In response to Re: psql - better support pipe line  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: psql - better support pipe line
Re: psql - better support pipe line
List pgsql-hackers


On Wed, Aug 26, 2015 at 5:44 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hi

2015-08-25 17:21 GMT+02:00 Tom Lane <tgl@sss.pgh.pa.us>:
Jim Nasby <Jim.Nasby@bluetreble.com> writes:
> What I've had problems with is trying to correlate psql specified
> connection attributes with things like DBI. It would be nice if there
> was a way to get a fully formed connection URI for the current connection.

Yeah, although I'd think the capability to create such a URI is libpq's
province not psql's.  Maybe a PQgetConnectionURI(PGConn) function in
libpq, and some psql backslash command to access that?  Or maybe a nicer
API would be that there's a magic psql variable containing the URI; not
sure.

proof concept of PQGetConnectionUri and \uri command.

I like the idea, thanks!
 
missing:

connection options
uri encoding

Attached adds implementation of both.  Still missing:

- documentation

Maybe we should provide a bool parameter to this new function so that additional parameters could be ignored.  Right now it will print a few default values, that are of no great use anyway:

$ ./bin/psql -c '\uri' 'postgresql://username@/postgres'
postgresql:/username@:5432/postgres?client_encoding=UTF8&fallback_application_name=psql&sslmode=disable

I don't think we can detect and remove the default values from this output in a reliable way?

--
Alex

Attachment

pgsql-hackers by date:

Previous
From: Etsuro Fujita
Date:
Subject: Re: Foreign join pushdown vs EvalPlanQual
Next
From: Andres Freund
Date:
Subject: Re: Custom Scans and private data