Re: libpq parameter parsing problem - Mailing list pgsql-bugs

From Heikki Linnakangas
Subject Re: libpq parameter parsing problem
Date
Msg-id 38896fd5-afe9-6922-0034-63d32a04cbcf@iki.fi
Whole thread Raw
In response to libpq parameter parsing problem  (Jobin Augustine <jobinau@gmail.com>)
List pgsql-bugs
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



pgsql-bugs by date:

Previous
From: Jobin Augustine
Date:
Subject: libpq parameter parsing problem
Next
From: Oleksandr Shulgin
Date:
Subject: Re: libpq parameter parsing problem