From: | Oleksandr Shulgin <oleksandr(dot)shulgin(at)zalando(dot)de> |
---|---|
To: | Jobin Augustine <jobinau(at)gmail(dot)com> |
Cc: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: libpq parameter parsing problem |
Date: | 2020-01-07 14:23:41 |
Message-ID: | CACACo5Qf4xBbs=8s4sYxZiQEYzfKM3JY3uCDrtZYu3CpOcP5xA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Tue, Jan 7, 2020 at 2:17 PM Jobin Augustine <jobinau(at)gmail(dot)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(at)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(at)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(at)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(at)localhost:5432/postgres?application_name=hello&options=-c
synchronous_commit%3Doff'
Cheers,
--
Alex
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2020-01-07 15:08:07 | Re: BUG #16122: segfault pg_detoast_datum (datum=0x0) at fmgr.c:1833 numrange query |
Previous Message | Heikki Linnakangas | 2020-01-07 13:27:08 | Re: libpq parameter parsing problem |