Thread: Possible bug on update

Possible bug on update

From
"Jackson, DeJuan"
Date:
What should be the results of this little test:

drop table t1;
drop table t2;
create table t1 (a int, b int);
create table t2 (a int, c int);
insert into t1(a, b) VALUES (1, 1); 
insert into t1(a, b) VALUES (1, 2); 
insert into t1(a, b) VALUES (1, 3); 
insert into t1(a, b) VALUES (1, 4); 
insert into t1(a, b) VALUES (2, 1);   
insert into t1(a, b) VALUES (2, 2); 
insert into t1(a, b) VALUES (2, 3); 
insert into t1(a, b) VALUES (3, 1);  
insert into t1(a, b) VALUES (3, 2); 
select * from t1;
insert into t2 (a, c) select distinct a, 0 from t1;   
select * from t2;
update t2 set c = c+b from t1 where t1.a=t2.a;
select * from t2;

My guess would be:
a|c
-+--
1|10
2|6
3|3
(3 rows)
How does the standard address this?