Re: psql - better support pipe line

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: "Shulgin, Oleksandr" <oleksandr(dot)shulgin(at)zalando(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql - better support pipe line
Date: 2015-08-27 13:37:54
Message-ID: CAFj8pRDYZsjXqwARUvPdOVL_k3VoThuzQxRUw8xw5grUFni5Qg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2015-08-27 11:54 GMT+02:00 Shulgin, Oleksandr <oleksandr(dot)shulgin(at)zalando(dot)de>
:

>
>
> On Wed, Aug 26, 2015 at 5:44 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote:
>
>> Hi
>>
>> 2015-08-25 17:21 GMT+02:00 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>>
>>> Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)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?
>

This is pretty difficult - any parameter can be important, and hard to
identify default values on client side without connect to server side. I
don't see any other way, than hold bitmap for identification entered values
and default values from the input.

Pavel

>
> --
> Alex
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-08-27 13:43:09 Re: What does RIR as in fireRIRrules stand for?
Previous Message David G. Johnston 2015-08-27 13:27:34 Re: What does RIR as in fireRIRrules stand for?