BEGIN;
CREATE TABLE c_test (a int) distributed randomly;
INSERT into c_test values (1), (2);
SAVEPOINT s;
SELECT c_test.a/0 from c_test;
ROLLBACK TO SAVEPOINT s;
SELECT c_test.a/0 from c_test where c_test.a > 2;
ROLLBACK TO SAVEPOINT s;
DECLARE c CURSOR for SELECT c_test.a/0 from c_test;
FETCH 1 from c;
ROLLBACK TO SAVEPOINT s;
DECLARE c CURSOR for SELECT c_test.a/0 from c_test where c_test.a > 2;
FETCH 1 from c;
ABORT;

BEGIN;
CREATE TABLE c_test (a int, b int) distributed randomly;
INSERT into c_test values (1, 2), (2, 3), (3, 4);
SAVEPOINT s;
SELECT * from c_test;
SELECT a/b from c_test;
UPDATE c_test set b = 0 where b = 4;
SAVEPOINT s;
SELECT a/b from c_test where c_test.a < 3;
SELECT a/b from c_test;
ROLLBACK TO SAVEPOINT s;
DECLARE c CURSOR for SELECT a/b from c_test;
FETCH 1 from c;
FETCH 1 from c;
FETCH 1 from c;
ROLLBACK TO SAVEPOINT s;
DECLARE c CURSOR for SELECT c_test.a/0 from c_test where c_test.a > 1;
FETCH 1 from c;
ABORT;

BEGIN;
CREATE TABLE c_test (a int, b int) distributed randomly;
INSERT into c_test select 1, generate_series(1, 2000);
UPDATE c_test set a = b where b = 1995;
SAVEPOINT s;
SELECT * from c_test order by b limit 5;
SELECT a/b from c_test order by b desc limit 10;
SAVEPOINT s;
SELECT b/(b - a) from c_test;
ROLLBACK TO SAVEPOINT s;
DECLARE c CURSOR for SELECT b/(b - a) from c_test order by b desc limit 10;
FETCH 1 from c;
FETCH 1 from c;
FETCH 1 from c;
ROLLBACK TO SAVEPOINT s;
DECLARE c CURSOR for SELECT c_test.a/0 from c_test where c_test.a > 1;
FETCH 1 from c;
ABORT;