From: wcting163 <wcting163@163.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6360: with hold cursor, cause function executed twice and wrong results
Date: Wed, 28 Dec 2011 10:44:39 +0800 (CST)
Message-ID: <765ac25d.11190.134828e204f.Coremail.wcting163@163.com> (raw)
In-Reply-To: <11717.1325008040@sss.pgh.pa.us>
References: <11717.1325008040@sss.pgh.pa.us>
<E1RfTzu-00024G-Dv@wrigleys.postgresql.org>
At 2011-12-28 01:47:20,"Tom Lane" tgl@sss.pgh.pa.us> wrote:
Yup. I don't particularly see this as a bug. If you were to manually
>rewind and rescan the cursor (ie, MOVE BACKWARD ALL and re-fetch),
>the function would be executed multiple times too. If you don't want
>that to happen, the best way would be to commit the transaction
>immediately, not fetch some rows and then commit.
>
> regards, tom lane
Why *with hold cursor* acts as *MOVE BACKWARD ALL & FETCH*?
Is this right or necessary? maybe they are not comparable, i doubt this analogy.
MOVE BACKWARD ALL & FETCH will cause cursor re-fetch?
Maybe pepole have different opinions for MOVE BACKWARD ALL & FETCH:
1. fetch from the old result-sets, not rescan(re-execute);
2. re-fetch and generate the new result-sets, cause plan re-execute again;
Now, pg acts as the second;
*Move* is not SQL standard, and does not clearly documented in pg document,
If we create *DestTuplestore* when first fetch, not in commit transaction, then:
1. we always fetch results from *DestTuplestore*;
2. if *DestTuplestore* is empty, we execute-plan and fill the results into *DestTuplestore*;
3. when rewind, just rewind *DestTuplestore*, not executor;
then we can implement the first action?
So, there are two questions here:
1. the Standard action of *MOVE BACKWARD ALL & FETCH*;
2. *with hold cursor* acts as *MOVE BACKWARD ALL & FETCH*, is this right(necessary)?
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: wcting163@163.com, tgl@sss.pgh.pa.us
Subject: Re: BUG #6360: with hold cursor, cause function executed twice and wrong results
In-Reply-To: <765ac25d.11190.134828e204f.Coremail.wcting163@163.com>
References: <11717.1325008040@sss.pgh.pa.us> <E1RfTzu-00024G-Dv@wrigleys.postgresql.org> <765ac25d.11190.134828e204f.Coremail.wcting163@163.com>
* 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