drop database if exists dbtest;
create database dbtest;
\c dbtest

begin;
create table test (c1 int, c2 int);
insert into test select col1, col1 + 10 
                   from (select col1 from generate_series(1, 15000) col1) as foo;
alter table test add primary key(c1);
commit;

analyze;

begin;
update test set c2 = c2 + 15 where c1 = 100;
declare q1 cursor for select * from test where c1 = 100;
fetch q1;
update test set c2 = c2 -15 where current of q1; 
update test set c2 = c2 + 15 where c1 = 100;
select * from test where c1 = 100;
commit;
select * from test where c1 = 100;
