Re: Odd query execution behavior with extended protocol - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Odd query execution behavior with extended protocol
Date
Msg-id 21640.1443969901@sss.pgh.pa.us
Whole thread Raw
In response to Odd query execution behavior with extended protocol  (Shay Rojansky <roji@roji.org>)
Responses Re: Odd query execution behavior with extended protocol  (Shay Rojansky <roji@roji.org>)
List pgsql-hackers
Shay Rojansky <roji@roji.org> writes:
> Npgsql supports sending multiple SQL statements in a single packet via the
> extended protocol. This works fine, but when the second query SELECTs a
> value modified by the first's UPDATE, I'm getting a result as if the UPDATE
> hasn't yet occurred.

> The exact messages send by Npgsql are:

> Parse (UPDATE data SET name='foo' WHERE id=1), statement=unnamed
> Describe (statement=unnamed)
> Bind (statement=unnamed, portal=MQ0)
> Parse (SELECT * FROM data WHERE id=1), statement=unnamed
> Describe (statement=unnamed)
> Bind (statement=unnamed, portal=MQ1)
> Execute (portal=MQ0)
> Close (portal=MQ0)
> Execute (portal=MQ1)
> Close (portal=MQ1)
> Sync

I'm fairly sure that the query snapshot is established at Bind time,
which means that this SELECT will run with a snapshot that indeed
does not see the effects of the UPDATE.

To my mind there is not a lot of value in performing Bind until you
are ready to do Execute.  The only reason the operations are separated
in the protocol is so that you can do multiple Executes with a row limit
on each one, to retrieve a large query result in chunks.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: check fails on Fedora 23
Next
From: Pavel Stehule
Date:
Subject: Re: check fails on Fedora 23