pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jobin Augustine <jobinau@gmail.com>
To: Oleksandr Shulgin <oleksandr.shulgin@zalando.de>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: libpq parameter parsing problem
Date: Wed, 8 Jan 2020 14:18:12 +0530
Message-ID: <CANaTPsrgsrVK2nb6bPym-fZcQvL7aJErMCXek7LBp-QFDQt-RQ@mail.gmail.com> (raw)
In-Reply-To: <CACACo5Qf4xBbs=8s4sYxZiQEYzfKM3JY3uCDrtZYu3CpOcP5xA@mail.gmail.com>
References: <CANaTPsrYgSgE2fuj3=4x=Jmx1c+NgkEDzftNknZbrMuqL+aBhQ@mail.gmail.com>
	<CACACo5Qf4xBbs=8s4sYxZiQEYzfKM3JY3uCDrtZYu3CpOcP5xA@mail.gmail.com>

Thanks Alex and Heikki,

Encoding works and it solved the problem. I find the documentation is not
very clear about it.
Heikki's single line comment was more clear to me than documentation :)
A statement like  "PostgreSQL URI string need to be encoded with
Percent-encoding <https://en.wikipedia.org/wiki/Percent-encoding; " would
have been much better


On Tue, Jan 7, 2020 at 7:54 PM Oleksandr Shulgin <
oleksandr.shulgin@zalando.de> wrote:

> On Tue, Jan 7, 2020 at 2:17 PM Jobin Augustine <jobinau@gmail.com> wrote:
>
>> Hello hackers,
>> User can pass session-level settings as a parameter in the connection
>> string like:
>> psql "host=localhost user=postgres options='-c synchronous_commit=off'"
>> Which sets the synchronous_commit off for the session.
>>
>> However, URI spec is not allowing it,
>> psql postgresql://postgres@localhost:5432/postgres?options="-c
>> synchronous_commit=off"
>> psql: error: could not connect to server: extra key/value separator "="
>> in URI query parameter: "options"
>>
>> psql postgresql://postgres@localhost:5432/postgres?options="-c
>> synchronous_commit off"
>> psql: error: could not connect to server: FATAL:  -c synchronous_commit
>> requires a value
>>
>
> Jobin,
>
> As already pointed out by Heikki, and per documentation:
>
> > Percent-encoding may be used to include symbols with special meaning in
> any of the URI parts, e.g. replace = with %3D.
> https://www.postgresql.org/docs/current/libpq-connect.html
>
> Moreover session just hangs forever:
>> psql postgresql://postgres@localhost:5432/postgres?application_name=hello&options='-c
>> synchronous_commit=off'
>> provided that the connection works without the 'options' parameter
>> specification
>>
>
> What you observe here is most likely the result of your shell interpreting
> the ampersand sign (&) in the middle of the URI and triggering asynchronous
> execution of the command before the sign.  Please try escaping the sign or
> using appropriate quoting, e.g. extend the single quote to start before the
> URI:
>
> psql 'postgresql://postgres@localhost:5432/postgres?application_name=hello&options=-c
> synchronous_commit%3Doff'
>

Yes, That was too silly. my bad

>
> Cheers,
> --
> Alex
>

Thanks and Regards,
Jobin

view thread (22+ messages)  latest in thread

Message-ID: <CANaTPsrgsrVK2nb6bPym-fZcQvL7aJErMCXek7LBp-QFDQt-RQ@mail.gmail.com>
Permalink:  ../CANaTPsrgsrVK2nb6bPym-fZcQvL7aJErMCXek7LBp-QFDQt-RQ@mail.gmail.com/
Also on:    postgresql.org/message-id/CANaTPsrgsrVK2nb6bPym-fZcQvL7aJErMCXek7LBp-QFDQt-RQ@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: jobinau@gmail.com, oleksandr.shulgin@zalando.de
  Subject: Re: libpq parameter parsing problem
  In-Reply-To: <CANaTPsrgsrVK2nb6bPym-fZcQvL7aJErMCXek7LBp-QFDQt-RQ@mail.gmail.com>
  References: <CANaTPsrYgSgE2fuj3=4x=Jmx1c+NgkEDzftNknZbrMuqL+aBhQ@mail.gmail.com> <CACACo5Qf4xBbs=8s4sYxZiQEYzfKM3JY3uCDrtZYu3CpOcP5xA@mail.gmail.com> <CANaTPsrgsrVK2nb6bPym-fZcQvL7aJErMCXek7LBp-QFDQt-RQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox