Re: [SQL] Savepoints and SELECT FOR UPDATE in 8.2

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "EXT-Rothermel, Peter M" <Peter(dot)M(dot)Rothermel(at)boeing(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] Savepoints and SELECT FOR UPDATE in 8.2
Date: 2008-08-02 01:07:08
Message-ID: dcc563d10808011807l3100f873vc2e1806ddea4c642@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-interfaces pgsql-sql

On Fri, Aug 1, 2008 at 11:02 AM, EXT-Rothermel, Peter M
<Peter(dot)M(dot)Rothermel(at)boeing(dot)com> wrote:
>
> I was thinking of something like this:
>
> connect to DB
>
> BEGIN
>
> SELECT * FROM table_foo where foo_state = 'queued' FOR UPDATE;
> for each row
> do [
>
> SAVEPOINT s;
> UPDATE foo_resource SET in_use = 1 WHERE ...;
>
> status = application_logic_code(foo_column1, foo_column2);
>
> IF status OK
> THEN
> ROLLBACK TO SAVEPOINT s;
> ELSE
> RELEASE SAVEPOINT s;
> ENDIF
> ]
>
>
> COMMIT;
>
> I found a caution in the documentation that says that SELECT FOR UPDATE
> and SAVEPOINTS is not implemented correctly in version 8.2:
>
> http://www.postgresql.org/docs/8.2/interactive/sql-select.html#SQL-FOR-U
> PDATE-SHARE
>
> Any suggestions?

Why not plain rollback?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew 2008-08-02 04:08:26 Re: hibernate nativequery and uuid
Previous Message Linos 2008-08-01 22:38:25 Re: savepoint problems

Browse pgsql-interfaces by date

  From Date Subject
Next Message Vincent Predoehl 2008-08-05 01:20:38 Running a Script
Previous Message EXT-Rothermel, Peter M 2008-08-01 17:02:04 Savepoints and SELECT FOR UPDATE in 8.2

Browse pgsql-sql by date

  From Date Subject
Next Message Marcin Krawczyk 2008-08-04 09:53:21 return setof record - strange behavior
Previous Message maria s 2008-08-01 17:29:36 Re: column names with - and (