From: jordal@amazon.com
To: pgsql-bugs@postgresql.org
Subject: BUG #14544: libpq: specifying 'target_session_attrs=read-write' prevents use of PQsendQuery
Date: Mon, 13 Feb 2017 19:43:55 +0000
Message-ID: <20170213194355.6101.10039@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
The following bug has been logged on the website:
Bug reference: 14544
Logged by: Jordan Lange
Email address: jordal@amazon.com
PostgreSQL version: Unsupported/Unknown
Operating system: Linux
Description:
As a part of the commit that adds support for specifying multiple hosts in
libpq
(https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=721f7bd3cbccaf8c07cad2707826b83f84694...),
I believe there's a small bug in the code that checks a connection to see if
it's writable in PQconnectPoll.
There's a switch statement that consumes the input of 'show
transaction_read_only', but this code doesn't loop on PQgetResult until it
returns NULL which leaves the connection in a state where the application
would need to call PQgetResult once more before being able to submit
queries.
A simple fix would be to call PQgetResult once more after the processing is
done (and before erroring out), perhaps with some simple sanity check that
it then returns NULL.
Repro steps:
1. Establish a connection with PQconnectdb and ensure you add
“target_session_attrs=read-write” to the connection string
2. Try to submit a query using PQsendQuery on the returned connection
object
3. PQsendQuery fails, and the error message gets set to “another command is
already in progress”
Reference libpq doc that says PQgetResult must be called until it returns
NULL: https://www.postgresql.org/docs/current/static/libpq-async.html.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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: jordal@amazon.com
Subject: Re: BUG #14544: libpq: specifying 'target_session_attrs=read-write' prevents use of PQsendQuery
In-Reply-To: <20170213194355.6101.10039@wrigleys.postgresql.org>
References: <20170213194355.6101.10039@wrigleys.postgresql.org>
* 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