pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14544: libpq: specifying 'target_session_attrs=read-write' prevents use of PQsendQuery
2+ messages / 2 participants
[nested] [flat]

* BUG #14544: libpq: specifying 'target_session_attrs=read-write' prevents use of PQsendQuery
@ 2017-02-13 19:43  jordal@amazon.com
  0 siblings, 1 reply; 2+ messages in thread

From: jordal@amazon.com @ 2017-02-13 19:43 UTC (permalink / raw)
  To: pgsql-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


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #14544: libpq: specifying 'target_session_attrs=read-write' prevents use of PQsendQuery
@ 2017-02-14 05:09  Michael Paquier <michael.paquier@gmail.com>
  parent: jordal@amazon.com
  0 siblings, 0 replies; 2+ messages in thread

From: Michael Paquier @ 2017-02-14 05:09 UTC (permalink / raw)
  To: jordal@amazon.com; +Cc: pgsql-bugs

On Tue, Feb 14, 2017 at 4:43 AM,  <jordal@amazon.com> wrote:
> 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.

That's a known problem, discussed here as well:
https://www.postgresql.org/message-id/flat/1803D792815FC24D871C00D17AE95905AC5FAE@g01jpexmbkw24#1803...
And there is a patch.
-- 
Michael


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2017-02-14 05:09 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-02-13 19:43 BUG #14544: libpq: specifying 'target_session_attrs=read-write' prevents use of PQsendQuery jordal@amazon.com
2017-02-14 05:09 ` Michael Paquier <michael.paquier@gmail.com>

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