From: Tom Lane <tgl@sss.pgh.pa.us>
To: wcting163@163.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6360: with hold cursor, cause function executed twice and wrong results
Date: Tue, 27 Dec 2011 12:47:20 -0500
Message-ID: <11717.1325008040@sss.pgh.pa.us> (raw)
In-Reply-To: <E1RfTzu-00024G-Dv@wrigleys.postgresql.org>
References: <E1RfTzu-00024G-Dv@wrigleys.postgresql.org>
wcting163@163.com writes:
> The reason is that the function p_test_execute is executed twice, when
> *fetch*, it is first executed, and when transaction commit, because the
> cursor is a *holdable* cursor, it is executed again.
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
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: tgl@sss.pgh.pa.us, wcting163@163.com
Subject: Re: BUG #6360: with hold cursor, cause function executed twice and wrong results
In-Reply-To: <11717.1325008040@sss.pgh.pa.us>
References: <E1RfTzu-00024G-Dv@wrigleys.postgresql.org> <11717.1325008040@sss.pgh.pa.us>
* 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