Re: How to use read uncommitted transaction level and set update order

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: Andrus <kobruleht2(at)hot(dot)ee>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to use read uncommitted transaction level and set update order
Date: 2009-12-19 21:53:08
Message-ID: F0F70752-EE6B-47E3-A4B0-0B65A5B594EE@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)thebuild(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-12-19 22:02:03 Re: How to use read uncommitted transaction level and set update order
Previous Message Jaime Casanova 2009-12-19 21:35:27 Re: How to use read uncommitted transaction level and set update order