update the same tuple in one command twice

From: "terry" <94487509(at)qq(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: update the same tuple in one command twice
Date: 2010-03-16 07:15:29
Message-ID: hnnb78$2svu$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

In one command, why can we update the same tuple for twice?
And the result is not predicated!!

Welcome to psql 8.3.3, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

TEST=# CREATE TABLE t1(a INT, b INT);
CREATE TABLE
TEST=# CREATE TABLE t2(c INT, d INT, e INT);
CREATE TABLE
TEST=# INSERT INTO t1 VALUES(1, 1);
INSERT 0 1
TEST=# INSERT INTO t1 VALUES(2, 3);
INSERT 0 1
TEST=# INSERT INTO t2 VALUES(2, 203, 212);
INSERT 0 1
TEST=# INSERT INTO t2 VALUES(2, 324, 1342);
INSERT 0 1
TEST=# INSERT INTO t2 VALUES(3, 342, 214);
INSERT 0 1
TEST=# update t1 set a = t2.d from t2 where a=t2.c;
UPDATE 1
TEST=# select * from t1;
a | b
-----+---
1 | 1
203 | 3
(2 rows)

why not is:
a | b
-----+---
1 | 1
324 | 3
(2 rows)

TEST=# select * from t2;
c | d | e
---+-----+------
2 | 203 | 212
2 | 324 | 1342
3 | 342 | 214
(3 rows)

TEST=#

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Eisentraut 2010-03-16 11:02:08 Re: Error when lock conflict on REPLACE function
Previous Message beulah prasanthi 2010-03-16 07:06:10 could not load library