Re: How to use read uncommitted transaction level and set update order - Mailing list pgsql-general

From Christophe Pettus
Subject Re: How to use read uncommitted transaction level and set update order
Date
Msg-id F0F70752-EE6B-47E3-A4B0-0B65A5B594EE@thebuild.com
Whole thread Raw
In response to How to use read uncommitted transaction level and set update order  ("Andrus" <kobruleht2@hot.ee>)
Responses Re: How to use read uncommitted transaction level and set update order  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: How to use read uncommitted transaction level and set update order  ("Andrus" <kobruleht2@hot.ee>)
List pgsql-general
On Dec 19, 2009, at 11:24 AM, Andrus wrote:
> set transaction isolation level read uncommitted;
> create temp table test1 ( a int, b int) on commit drop;
> insert into test1 values(1,2);
> update test1 set a=4, b=a ;
> select * from test1
>
> b value is 1 but must be 4.
> How to use updated value ?

The problem here isn't the transaction isolation level.  The order of
evaluation in an UPDATE statement is (for practical purposes):
Evaluate all of the right-hand side expressions, and then assign them
all to the left-hand side fields.

It's not clear why you need to do it this way, though.  Presumably,
since you did some kind of computation that came up with the number
'4', you can assign that value instead of using the field a:

UPDATE test1 set a=4, b=4;

--
-- Christophe Pettus
    xof@thebuild.com


pgsql-general by date:

Previous
From: Jaime Casanova
Date:
Subject: Re: How to use read uncommitted transaction level and set update order
Next
From: Tom Lane
Date:
Subject: Re: How to use read uncommitted transaction level and set update order