Re: Using PQexecQuery in pipeline mode produces unexpected Close messages - Mailing list pgsql-hackers

From Kyotaro Horiguchi
Subject Re: Using PQexecQuery in pipeline mode produces unexpected Close messages
Date
Msg-id 20220610.152544.1597540405935332165.horikyota.ntt@gmail.com
Whole thread Raw
Responses Re: Using PQexecQuery in pipeline mode produces unexpected Close messages
Re: Using PQexecQuery in pipeline mode produces unexpected Close messages
Re: Using PQexecQuery in pipeline mode produces unexpected Close messages
List pgsql-hackers
(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

Attachment

pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: Collation version tracking for macOS
Next
From: Amit Kapila
Date:
Subject: Re: Support logical replication of DDLs