From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | wcting163(at)163(dot)com, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #6360: with hold cursor, cause function executed twice and wrong results |
Date: | 2012-01-09 18:01:10 |
Message-ID: | CA+TgmoYDQbUGou7HgWRQXji7Sk5uT8dmaQy3VEvzFbSuXLNYCg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Tue, Dec 27, 2011 at 12:47 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> wcting163(at)163(dot)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.
Is that even per spec? I would not expect the results, or the
side-effects, of a query to depend on the method used to retrieve its
results.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2012-01-09 18:03:45 | Re: BUG #6364: The URL for the page listing user groups is unresponsive. |
Previous Message | Robert Haas | 2012-01-09 17:59:00 | Re: BUG #6359: excessively inlining subquery leads to slow queries |