Re: libpq parameter parsing problem

Heikki Linnakangas <[email protected]> Tue, 7 Jan 2020 15:27:08 +0200
Newsgroups gmane.comp.db.postgresql.bugs
Message-ID <[email protected]>
On 07/01/2020 15:17, Jobin Augustine 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"

The "-c synchronous_commit=off" string is part of the value for the 
"options" keyword. So it needs to be URI encoded:

psql 
"postgresql://postgres@localhost:5432/postgres?options=-c%20synchronous_commit%3Doff"

- Heikki