Skip site navigation (1) Skip section navigation (2)

Re: BUG #6360: with hold cursor, cause function executed twice and wrong results

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: wcting163(at)163(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6360: with hold cursor, cause function executed twice and wrong results
Date: 2011-12-27 17:47:20
Message-ID: 11717.1325008040@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
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.

			regards, tom lane

In response to

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2011-12-27 18:00:42
Subject: Re: converting between infinity timestamp and float8 (epoch)
Previous:From: Phil SorberDate: 2011-12-27 16:38:27
Subject: Re: converting between infinity timestamp and float8 (epoch)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group