Permalink
Browse files

Enable FETCH statements in all queries involving FOR UPDATE in portal…

…s test case

After the fix for FOR UPDATE these statements work fine now.
  • Loading branch information...
1 parent 2e3a84e commit 9da4c2ebb0a209c3589f28a3f00254ad4c5f10aa @gabbasb gabbasb committed Apr 21, 2012
Showing with 43 additions and 30 deletions.
  1. +33 −15 src/test/regress/expected/portals_1.out
  2. +10 −15 src/test/regress/sql/portals.sql
@@ -948,9 +948,13 @@ SELECT * FROM uctest ORDER BY f1;
-- Check UPDATE WHERE CURRENT; this time use FOR UPDATE
BEGIN;
-DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE;
---PGXCTODO : Uncomment this fetch once we have implemented FOR UPDATE
---FETCH c1;
+DECLARE c1 CURSOR FOR SELECT * FROM uctest ORDER BY 1 FOR UPDATE;
+FETCH c1;
+ f1 | f2
+----+-----
+ 1 | one
+(1 row)
+
UPDATE uctest SET f1 = 8 WHERE CURRENT OF c1;
ERROR: WHERE CURRENT OF clause not yet supported
SELECT * FROM uctest ORDER BY f1;
@@ -1008,9 +1012,13 @@ SELECT * FROM uctest ORDER BY f1;
(3 rows)
BEGIN;
-DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE;
---PGXCTODO : Uncomment this fetch once we have implemented FOR UPDATE
---FETCH c1;
+DECLARE c1 CURSOR FOR SELECT * FROM uctest ORDER BY 1 FOR UPDATE;
+FETCH c1;
+ f1 | f2
+----+-----
+ 1 | one
+(1 row)
+
UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1;
ERROR: WHERE CURRENT OF clause not yet supported
SELECT * FROM uctest ORDER BY f1;
@@ -1056,9 +1064,13 @@ SELECT * FROM uctest ORDER BY f1;
(4 rows)
BEGIN;
-DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE;
---PGXCTODO : Uncomment this fetch once we have implemented FOR UPDATE
---FETCH 1 FROM c1;
+DECLARE c1 CURSOR FOR SELECT * FROM uctest ORDER BY 1 FOR UPDATE;
+FETCH 1 FROM c1;
+ f1 | f2
+----+-----
+ 1 | one
+(1 row)
+
UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1;
ERROR: WHERE CURRENT OF clause not yet supported
FETCH 1 FROM c1;
@@ -1093,16 +1105,22 @@ UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -- fail
ERROR: WHERE CURRENT OF clause not yet supported
ROLLBACK;
BEGIN;
-DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 FOR UPDATE;
---PGXCTODO : Uncomment this fetch once we have implemented FOR UPDATE
---FETCH 1 FROM c1;
+DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 ORDER BY 1 FOR UPDATE;
+FETCH 1 FROM c1;
+ f1 | f2 | f1 | f2
+----+----+----+----
+(0 rows)
+
UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -- fail
ERROR: WHERE CURRENT OF clause not yet supported
ROLLBACK;
BEGIN;
-DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 FOR SHARE OF a;
---PGXCTODO : Uncomment this fetch once we have implemented FOR UPDATE
---FETCH 1 FROM c1;
+DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 ORDER BY 1 FOR SHARE OF a;
+FETCH 1 FROM c1;
+ f1 | f2 | f1 | f2
+----+----+----+----
+(0 rows)
+
UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1;
ERROR: WHERE CURRENT OF clause not yet supported
SELECT * FROM uctest ORDER BY f1;
@@ -342,9 +342,8 @@ SELECT * FROM uctest ORDER BY f1;
-- Check UPDATE WHERE CURRENT; this time use FOR UPDATE
BEGIN;
-DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE;
---PGXCTODO : Uncomment this fetch once we have implemented FOR UPDATE
---FETCH c1;
+DECLARE c1 CURSOR FOR SELECT * FROM uctest ORDER BY 1 FOR UPDATE;
+FETCH c1;
UPDATE uctest SET f1 = 8 WHERE CURRENT OF c1;
SELECT * FROM uctest ORDER BY f1;
COMMIT;
@@ -371,9 +370,8 @@ ROLLBACK;
SELECT * FROM uctest ORDER BY f1;
BEGIN;
-DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE;
---PGXCTODO : Uncomment this fetch once we have implemented FOR UPDATE
---FETCH c1;
+DECLARE c1 CURSOR FOR SELECT * FROM uctest ORDER BY 1 FOR UPDATE;
+FETCH c1;
UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1;
SELECT * FROM uctest ORDER BY f1;
UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1;
@@ -395,9 +393,8 @@ INSERT INTO ucchild values(100, 'hundred');
SELECT * FROM uctest ORDER BY f1;
BEGIN;
-DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE;
---PGXCTODO : Uncomment this fetch once we have implemented FOR UPDATE
---FETCH 1 FROM c1;
+DECLARE c1 CURSOR FOR SELECT * FROM uctest ORDER BY 1 FOR UPDATE;
+FETCH 1 FROM c1;
UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1;
FETCH 1 FROM c1;
UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1;
@@ -414,15 +411,13 @@ FETCH 1 FROM c1;
UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -- fail
ROLLBACK;
BEGIN;
-DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 FOR UPDATE;
---PGXCTODO : Uncomment this fetch once we have implemented FOR UPDATE
---FETCH 1 FROM c1;
+DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 ORDER BY 1 FOR UPDATE;
+FETCH 1 FROM c1;
UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -- fail
ROLLBACK;
BEGIN;
-DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 FOR SHARE OF a;
---PGXCTODO : Uncomment this fetch once we have implemented FOR UPDATE
---FETCH 1 FROM c1;
+DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 ORDER BY 1 FOR SHARE OF a;
+FETCH 1 FROM c1;
UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1;
SELECT * FROM uctest ORDER BY f1;
ROLLBACK;

0 comments on commit 9da4c2e

Please sign in to comment.