Re: nested-xacts cursors (was Re: Performance with new nested-xacts code) - Mailing list pgsql-hackers

From Zeugswetter Andreas SB SD
Subject Re: nested-xacts cursors (was Re: Performance with new nested-xacts code)
Date
Msg-id 46C15C39FEB2C44BA555E356FBCD6FA40184D129@m0114.s-mxs.net
Whole thread Raw
In response to nested-xacts cursors (was Re: Performance with new nested-xacts code)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> begin;
>   declare cursor c ...;
>   fetch 1 from c;        -- returns tuple 1
>   begin;
>     fetch 1 from c;        -- returns tuple 2
>   rollback;
>   fetch 1 from c;        -- returns tuple 1 again
>
> This is mightly ugly but I think it's the most usable of the options
> seen so far.

Imho most usabel would be to handle the cursor like a hold corsor.

begin;  declare cursor c ...;  fetch 1 from c;        -- returns tuple 1  begin;    fetch 1 from c;        -- returns
tuple2  rollback;  fetch 1 from c;        -- returns tuple 3 

For me the reason is, that most likely you are not going to rollback
because the fetch did not work or returned something you don't like.
Most likely some consequent action did not work out, and the next step
will be to correct (or ignore) the problem. You can do that without an
extra fetch, because you still have the values in host variables.

resetting to "tuple 1" imho opens the door for endless loops.

Andreas


pgsql-hackers by date:

Previous
From: Andreas Pflug
Date:
Subject: Re: Adding column comment to information_schema.columns
Next
From: Oliver Jowett
Date:
Subject: Re: nested-xacts cursors (was Re: Performance with new