Re: Using PQexecQuery in pipeline mode produces unexpected Close messages
Kyotaro Horiguchi <horikyota.ntt@gmail.com>
From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
To: alvherre@alvh.no-ip.org
Cc: daniele.varrazzo@gmail.com, pgsql-hackers@lists.postgresql.org
Date: 2022-06-10T06:25:44Z
Lists: pgsql-bugs, pgsql-hackers
Attachments
(Moved to -hackers) At Wed, 8 Jun 2022 17:08:47 +0200, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote in > What that Close message is doing is closing the unnamed portal, which > is otherwise closed implicitly when the next one is opened. That's how > single-query mode works: if you run a single portal, it'll be kept open. > > I believe that the right fix is to not send that Close message in > PQsendQuery. Agreed. At least Close message in that context is useless and PQsendQueryGuts doesn't send it. And removes the Close message surely fixes the issue. The doc [1] says: [1] https://www.postgresql.org/docs/14/protocol-flow.html > The simple Query message is approximately equivalent to the series > Parse, Bind, portal Describe, Execute, Close, Sync, using the > unnamed prepared statement and portal objects and no parameters. One The current implement of PQsendQueryInternal looks like the result of a misunderstanding of the doc. In the regression tests, that path is excercised only for an error case, where no CloseComplete comes. The attached adds a test for the normal-path of pipelined PQsendQuery() to simple_pipeline test then modifies that function not to send Close message. Without the fix, the test fails by "unexpected notice" even if the trace matches the "expected" content. regards. -- Kyotaro Horiguchi NTT Open Source Software Center
Commits
-
001_libpq_pipeline.pl: use Test::Differences if available
- 87e4f24d8293 16.0 landed
-
libpq: Improve idle state handling in pipeline mode
- 93cf9233cd54 15.0 landed
- 7c1f42612384 14.5 landed
- 054325c5eeb3 16.0 landed