You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
(28) |
Jun
(12) |
Jul
(11) |
Aug
(12) |
Sep
(5) |
Oct
(19) |
Nov
(14) |
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(18) |
Feb
(30) |
Mar
(115) |
Apr
(89) |
May
(50) |
Jun
(44) |
Jul
(22) |
Aug
(13) |
Sep
(11) |
Oct
(30) |
Nov
(28) |
Dec
(39) |
2012 |
Jan
(38) |
Feb
(18) |
Mar
(43) |
Apr
(91) |
May
(108) |
Jun
(46) |
Jul
(37) |
Aug
(44) |
Sep
(33) |
Oct
(29) |
Nov
(36) |
Dec
(15) |
2013 |
Jan
(35) |
Feb
(611) |
Mar
(5) |
Apr
(55) |
May
(30) |
Jun
(28) |
Jul
(458) |
Aug
(34) |
Sep
(9) |
Oct
(39) |
Nov
(22) |
Dec
(32) |
2014 |
Jan
(16) |
Feb
(16) |
Mar
(42) |
Apr
(179) |
May
(7) |
Jun
(6) |
Jul
(9) |
Aug
|
Sep
(4) |
Oct
|
Nov
(3) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
|
1
(2) |
2
(3) |
3
|
4
(2) |
5
(3) |
6
(2) |
7
(8) |
8
(12) |
9
|
10
|
11
(17) |
12
(16) |
13
(4) |
14
(3) |
15
(5) |
16
|
17
|
18
(1) |
19
(3) |
20
(2) |
21
(1) |
22
(1) |
23
|
24
|
25
(3) |
26
(1) |
27
|
28
|
29
|
30
|
From: Abbas B. <ga...@us...> - 2011-04-25 17:45:23
|
Project "Postgres-XC". The branch, master has been updated via 7bbb6a36362ac0b9e92191bce988eeaa5dd5b118 (commit) from d7d1c15b38975aa6d88d70bf76c050a7fb887eb7 (commit) - Log ----------------------------------------------------------------- commit 7bbb6a36362ac0b9e92191bce988eeaa5dd5b118 Author: Abbas <abb...@en...> Date: Mon Apr 25 22:44:51 2011 +0500 A few more ORDER BY in portals test case diff --git a/src/test/regress/expected/portals_1.out b/src/test/regress/expected/portals_1.out index 3fa3c82..2fa80ec 100644 --- a/src/test/regress/expected/portals_1.out +++ b/src/test/regress/expected/portals_1.out @@ -978,7 +978,7 @@ FETCH c1; UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; ERROR: WHERE CURRENT OF clause not yet supported -SELECT f1,f2 FROM uctest; +SELECT f1,f2 FROM uctest ORDER BY 1; ERROR: current transaction is aborted, commands ignored until end of transaction block UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; ERROR: current transaction is aborted, commands ignored until end of transaction block @@ -1011,11 +1011,11 @@ SELECT f1,f2 FROM uctest ORDER BY f1; (3 rows) BEGIN; -DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest FOR UPDATE; +DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest ORDER BY 1 FOR UPDATE; FETCH c1; - f1 | f2 -----+------- - 3 | three + f1 | f2 +----+----- + 1 | one (1 row) UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; @@ -1064,7 +1064,7 @@ SELECT f1,f2 FROM uctest ORDER BY f1; (3 rows) BEGIN; -DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest FOR UPDATE; +DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest ORDER BY 1 FOR UPDATE; FETCH 1 FROM c1; f1 | f2 ----+------- @@ -1094,7 +1094,7 @@ SELECT f1,f2 FROM uctest ORDER BY f1; -- Can update from a self-join, but only if FOR UPDATE says which to use BEGIN; -DECLARE c1 CURSOR FOR SELECT a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5; +DECLARE c1 CURSOR FOR SELECT a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 ORDER BY 1; FETCH 1 FROM c1; f1 | f2 ----+----- @@ -1105,7 +1105,7 @@ 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 a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 FOR UPDATE; +DECLARE c1 CURSOR FOR SELECT a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 ORDER BY 1 FOR UPDATE; FETCH 1 FROM c1; f1 | f2 ----+----- @@ -1116,7 +1116,7 @@ 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 a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 FOR SHARE OF a; +DECLARE c1 CURSOR FOR SELECT a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 ORDER BY 1 FOR SHARE OF a; FETCH 1 FROM c1; f1 | f2 ----+----- @@ -1131,17 +1131,17 @@ ROLLBACK; -- Check various error cases DELETE FROM uctest WHERE CURRENT OF c1; -- fail, no such cursor ERROR: WHERE CURRENT OF clause not yet supported -DECLARE cx CURSOR WITH HOLD FOR SELECT f1,f2 FROM uctest; +DECLARE cx CURSOR WITH HOLD FOR SELECT f1,f2 FROM uctest ORDER BY 1; ERROR: portal "cx" does not exist DELETE FROM uctest WHERE CURRENT OF cx; -- fail, can't use held cursor ERROR: WHERE CURRENT OF clause not yet supported BEGIN; -DECLARE c CURSOR FOR SELECT * FROM tenk2; +DECLARE c CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DELETE FROM uctest WHERE CURRENT OF c; -- fail, cursor on wrong table ERROR: WHERE CURRENT OF clause not yet supported ROLLBACK; BEGIN; -DECLARE c CURSOR FOR SELECT * FROM tenk2 FOR SHARE; +DECLARE c CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2 FOR SHARE; DELETE FROM uctest WHERE CURRENT OF c; -- fail, cursor on wrong table ERROR: WHERE CURRENT OF clause not yet supported ROLLBACK; @@ -1163,7 +1163,7 @@ ERROR: WHERE CURRENT OF clause not yet supported ROLLBACK; -- WHERE CURRENT OF may someday work with views, but today is not that day. -- For now, just make sure it errors out cleanly. -CREATE VIEW ucview AS SELECT f1,f2 FROM uctest; +CREATE VIEW ucview AS SELECT f1,f2 FROM uctest ORDER BY 1; CREATE RULE ucrule AS ON DELETE TO ucview DO INSTEAD DELETE FROM uctest WHERE f1 = OLD.f1; BEGIN; diff --git a/src/test/regress/sql/portals.sql b/src/test/regress/sql/portals.sql index ff0d289..584e015 100644 --- a/src/test/regress/sql/portals.sql +++ b/src/test/regress/sql/portals.sql @@ -355,7 +355,7 @@ BEGIN; DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest; FETCH c1; UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -SELECT f1,f2 FROM uctest; +SELECT f1,f2 FROM uctest ORDER BY 1; UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; SELECT f1,f2 FROM uctest ORDER BY 1; -- insensitive cursor should not show effects of updates or deletes @@ -371,7 +371,7 @@ ROLLBACK; SELECT f1,f2 FROM uctest ORDER BY f1; BEGIN; -DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest FOR UPDATE; +DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest ORDER BY 1 FOR UPDATE; FETCH c1; UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; SELECT f1,f2 FROM uctest ORDER BY f1; @@ -395,7 +395,7 @@ INSERT INTO ucchild values(0, 100, 'hundred'); SELECT f1,f2 FROM uctest ORDER BY f1; BEGIN; -DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest FOR UPDATE; +DECLARE c1 CURSOR FOR SELECT f1,f2 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; @@ -408,17 +408,17 @@ SELECT f1,f2 FROM uctest ORDER BY f1; -- Can update from a self-join, but only if FOR UPDATE says which to use BEGIN; -DECLARE c1 CURSOR FOR SELECT a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5; +DECLARE c1 CURSOR FOR SELECT a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 ORDER BY 1; FETCH 1 FROM c1; UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -- fail ROLLBACK; BEGIN; -DECLARE c1 CURSOR FOR SELECT a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 FOR UPDATE; +DECLARE c1 CURSOR FOR SELECT a.f1,a.f2 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 a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 FOR SHARE OF a; +DECLARE c1 CURSOR FOR SELECT a.f1,a.f2 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 f1,f2 FROM uctest ORDER BY f1; @@ -427,14 +427,14 @@ ROLLBACK; -- Check various error cases DELETE FROM uctest WHERE CURRENT OF c1; -- fail, no such cursor -DECLARE cx CURSOR WITH HOLD FOR SELECT f1,f2 FROM uctest; +DECLARE cx CURSOR WITH HOLD FOR SELECT f1,f2 FROM uctest ORDER BY 1; DELETE FROM uctest WHERE CURRENT OF cx; -- fail, can't use held cursor BEGIN; -DECLARE c CURSOR FOR SELECT * FROM tenk2; +DECLARE c CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DELETE FROM uctest WHERE CURRENT OF c; -- fail, cursor on wrong table ROLLBACK; BEGIN; -DECLARE c CURSOR FOR SELECT * FROM tenk2 FOR SHARE; +DECLARE c CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2 FOR SHARE; DELETE FROM uctest WHERE CURRENT OF c; -- fail, cursor on wrong table ROLLBACK; BEGIN; @@ -452,7 +452,7 @@ ROLLBACK; -- WHERE CURRENT OF may someday work with views, but today is not that day. -- For now, just make sure it errors out cleanly. -CREATE VIEW ucview AS SELECT f1,f2 FROM uctest; +CREATE VIEW ucview AS SELECT f1,f2 FROM uctest ORDER BY 1; CREATE RULE ucrule AS ON DELETE TO ucview DO INSTEAD DELETE FROM uctest WHERE f1 = OLD.f1; BEGIN; ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/portals_1.out | 26 +++++++++++++------------- src/test/regress/sql/portals.sql | 20 ++++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-04-25 17:25:55
|
Project "Postgres-XC". The branch, master has been updated via d7d1c15b38975aa6d88d70bf76c050a7fb887eb7 (commit) from 32db0e37323690b45680e540302d9d8f91e6f102 (commit) - Log ----------------------------------------------------------------- commit d7d1c15b38975aa6d88d70bf76c050a7fb887eb7 Author: Abbas <abb...@en...> Date: Mon Apr 25 22:24:58 2011 +0500 Corrects minor error in expected output of create_misc diff --git a/src/test/regress/output/create_misc_1.source b/src/test/regress/output/create_misc_1.source index 75503b7..3e827fb 100644 --- a/src/test/regress/output/create_misc_1.source +++ b/src/test/regress/output/create_misc_1.source @@ -5,7 +5,7 @@ -- (any resemblance to real life is purely coincidental) -- INSERT INTO tenk2 SELECT * FROM tenk1; -COPY tenk1 FROM '@abs_srcdir@/data/tenk.data'; +COPY tenk2 FROM '@abs_srcdir@/data/tenk.data'; SELECT * INTO TABLE onek2 FROM onek; ERROR: INTO clause not yet supported CREATE TABLE onek2 ( ----------------------------------------------------------------------- Summary of changes: src/test/regress/output/create_misc_1.source | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-04-25 17:04:51
|
Project "Postgres-XC". The branch, master has been updated via 32db0e37323690b45680e540302d9d8f91e6f102 (commit) from 1c63e1870b95ddad3fdee284a0744f31add39919 (commit) - Log ----------------------------------------------------------------- commit 32db0e37323690b45680e540302d9d8f91e6f102 Author: Abbas <abb...@en...> Date: Mon Apr 25 22:01:54 2011 +0500 This patch fixes bug ID 3237776. Portals test case now passes after a) adding a few ORDER BY. b) adding data in tenk2 table. c) converting temp table and views to permanent ones d) Adding dummy columns to avoid updation to distribution column The output is consistent but is not correct because of the reasons explained in feature request 3291289: 1) WHERE CURRENT OF is not supported 2) XC does not evaluate query of the cursor when it is encountered. 3) Cursors created FOR UPDATE do not behave correctly. 4) Cursors created without specifying SCROLL option default to NO SCROLL. An alternate expected output file has been added. WHERE CURRENT OF is blocked with a decent message. diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index 2159a68..bd5e44d 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -1988,6 +1988,12 @@ transformCurrentOfExpr(ParseState *pstate, CurrentOfExpr *cexpr) { int sublevels_up; +#ifdef PGXC + ereport(ERROR, + (errcode(ERRCODE_STATEMENT_TOO_COMPLEX), + (errmsg("WHERE CURRENT OF clause not yet supported")))); +#endif + /* CURRENT OF can only appear at top level of UPDATE/DELETE */ Assert(pstate->p_target_rangetblentry != NULL); cexpr->cvarno = RTERangeTablePosn(pstate, diff --git a/src/test/regress/expected/portals.out b/src/test/regress/expected/portals.out index c837fed..be7348d 100644 --- a/src/test/regress/expected/portals.out +++ b/src/test/regress/expected/portals.out @@ -778,7 +778,7 @@ ERROR: cursor "foo26" does not exist BEGIN; CREATE FUNCTION declares_cursor(text) RETURNS void - AS 'DECLARE c CURSOR FOR SELECT stringu1 FROM tenk1 WHERE stringu1 LIKE $1 ORDER BY stringu1;' + AS 'DECLARE c CURSOR FOR SELECT stringu1 FROM tenk1 WHERE stringu1 LIKE $1;' LANGUAGE SQL; SELECT declares_cursor('AB%'); declares_cursor @@ -904,7 +904,7 @@ COMMIT; -- CREATE TEMP TABLE uctest(f1 int, f2 text); INSERT INTO uctest VALUES (1, 'one'), (2, 'two'), (3, 'three'); -SELECT * FROM uctest ORDER BY f1; +SELECT * FROM uctest; f1 | f2 ----+------- 1 | one @@ -914,7 +914,7 @@ SELECT * FROM uctest ORDER BY f1; -- Check DELETE WHERE CURRENT BEGIN; -DECLARE c1 CURSOR FOR SELECT * FROM uctest ORDER BY f1; +DECLARE c1 CURSOR FOR SELECT * FROM uctest; FETCH 2 FROM c1; f1 | f2 ----+----- @@ -923,21 +923,24 @@ FETCH 2 FROM c1; (2 rows) DELETE FROM uctest WHERE CURRENT OF c1; -ERROR: cursor "c1" is not a simply updatable scan of table "uctest" -- should show deletion -SELECT * FROM uctest ORDER BY f1; -ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT * FROM uctest; + f1 | f2 +----+------- + 1 | one + 3 | three +(2 rows) + -- cursor did not move FETCH ALL FROM c1; -ERROR: current transaction is aborted, commands ignored until end of transaction block + f1 | f2 +----+------- + 3 | three +(1 row) + -- cursor is insensitive MOVE BACKWARD ALL IN c1; -ERROR: current transaction is aborted, commands ignored until end of transaction block FETCH ALL FROM c1; -ERROR: current transaction is aborted, commands ignored until end of transaction block -COMMIT; --- should still see deletion -SELECT * FROM uctest ORDER BY f1; f1 | f2 ----+------- 1 | one @@ -945,6 +948,15 @@ SELECT * FROM uctest ORDER BY f1; 3 | three (3 rows) +COMMIT; +-- should still see deletion +SELECT * FROM uctest; + f1 | f2 +----+------- + 1 | one + 3 | three +(2 rows) + -- Check UPDATE WHERE CURRENT; this time use FOR UPDATE BEGIN; DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE; @@ -955,181 +967,159 @@ FETCH c1; (1 row) UPDATE uctest SET f1 = 8 WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; +SELECT * FROM uctest; f1 | f2 ----+------- - 2 | two 3 | three 8 | one -(3 rows) +(2 rows) COMMIT; -SELECT * FROM uctest ORDER BY f1; +SELECT * FROM uctest; f1 | f2 ----+------- - 2 | two 3 | three 8 | one -(3 rows) +(2 rows) -- Check repeated-update and update-then-delete cases BEGIN; DECLARE c1 CURSOR FOR SELECT * FROM uctest; FETCH c1; - f1 | f2 -----+----- - 2 | two + f1 | f2 +----+------- + 3 | three (1 row) UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; SELECT * FROM uctest; f1 | f2 ----+------- - 3 | three 8 | one - 12 | two -(3 rows) + 13 | three +(2 rows) UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY 1; +SELECT * FROM uctest; f1 | f2 ----+------- - 3 | three 8 | one - 22 | two -(3 rows) + 23 | three +(2 rows) -- insensitive cursor should not show effects of updates or deletes FETCH RELATIVE 0 FROM c1; - f1 | f2 -----+----- - 2 | two -(1 row) - -DELETE FROM uctest WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; f1 | f2 ----+------- 3 | three +(1 row) + +DELETE FROM uctest WHERE CURRENT OF c1; +SELECT * FROM uctest; + f1 | f2 +----+----- 8 | one -(2 rows) +(1 row) DELETE FROM uctest WHERE CURRENT OF c1; -- no-op -SELECT * FROM uctest ORDER BY f1; - f1 | f2 -----+------- - 3 | three +SELECT * FROM uctest; + f1 | f2 +----+----- 8 | one -(2 rows) +(1 row) UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -- no-op -SELECT * FROM uctest ORDER BY f1; - f1 | f2 -----+------- - 3 | three +SELECT * FROM uctest; + f1 | f2 +----+----- 8 | one -(2 rows) +(1 row) FETCH RELATIVE 0 FROM c1; - f1 | f2 -----+----- - 2 | two + f1 | f2 +----+------- + 3 | three (1 row) ROLLBACK; -SELECT * FROM uctest ORDER BY f1; +SELECT * FROM uctest; f1 | f2 ----+------- - 2 | two 3 | three 8 | one -(3 rows) +(2 rows) BEGIN; DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE; FETCH c1; - f1 | f2 -----+----- - 2 | two + f1 | f2 +----+------- + 3 | three (1 row) UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; +SELECT * FROM uctest; f1 | f2 ----+------- - 3 | three 8 | one - 12 | two -(3 rows) + 13 | three +(2 rows) UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; +SELECT * FROM uctest; f1 | f2 ----+------- - 3 | three 8 | one - 22 | two -(3 rows) + 23 | three +(2 rows) DELETE FROM uctest WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; - f1 | f2 -----+------- - 3 | three +SELECT * FROM uctest; + f1 | f2 +----+----- 8 | one -(2 rows) +(1 row) DELETE FROM uctest WHERE CURRENT OF c1; -- no-op -SELECT * FROM uctest ORDER BY f1; - f1 | f2 -----+------- - 3 | three +SELECT * FROM uctest; + f1 | f2 +----+----- 8 | one -(2 rows) +(1 row) UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -- no-op -SELECT * FROM uctest ORDER BY f1; - f1 | f2 -----+------- - 3 | three +SELECT * FROM uctest; + f1 | f2 +----+----- 8 | one -(2 rows) +(1 row) --- sensitive cursors can't currently scroll back, so this is an error: FETCH RELATIVE 0 FROM c1; ERROR: cursor can only scan forward HINT: Declare it with SCROLL option to enable backward scan. ROLLBACK; -SELECT * FROM uctest ORDER BY f1; +SELECT * FROM uctest; f1 | f2 ----+------- - 2 | two 3 | three 8 | one -(3 rows) +(2 rows) -- Check inheritance cases CREATE TEMP TABLE ucchild () inherits (uctest); INSERT INTO ucchild values(100, 'hundred'); -SELECT * FROM uctest ORDER BY f1; +SELECT * FROM uctest; f1 | f2 -----+--------- - 2 | two 3 | three 8 | one 100 | hundred -(4 rows) +(3 rows) BEGIN; DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE; FETCH 1 FROM c1; - f1 | f2 -----+----- - 2 | two -(1 row) - -UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -FETCH 1 FROM c1; f1 | f2 ----+------- 3 | three @@ -1149,15 +1139,20 @@ FETCH 1 FROM c1; 100 | hundred (1 row) +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; +FETCH 1 FROM c1; + f1 | f2 +----+---- +(0 rows) + COMMIT; -SELECT * FROM uctest ORDER BY f1; +SELECT * FROM uctest; f1 | f2 -----+--------- - 12 | two 13 | three 18 | one - 100 | hundred -(4 rows) + 110 | hundred +(3 rows) -- Can update from a self-join, but only if FOR UPDATE says which to use BEGIN; @@ -1191,14 +1186,13 @@ FETCH 1 FROM c1; (1 row) UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; +SELECT * FROM uctest; f1 | f2 -----+--------- - 12 | two 13 | three 28 | one - 100 | hundred -(4 rows) + 110 | hundred +(3 rows) ROLLBACK; -- Check various error cases @@ -1240,9 +1234,9 @@ CREATE RULE ucrule AS ON DELETE TO ucview DO INSTEAD BEGIN; DECLARE c1 CURSOR FOR SELECT * FROM ucview; FETCH FROM c1; - f1 | f2 -----+----- - 12 | two + f1 | f2 +----+------- + 13 | three (1 row) DELETE FROM ucview WHERE CURRENT OF c1; -- fail, views not supported diff --git a/src/test/regress/expected/portals.out b/src/test/regress/expected/portals_1.out similarity index 92% copy from src/test/regress/expected/portals.out copy to src/test/regress/expected/portals_1.out index c837fed..3fa3c82 100644 --- a/src/test/regress/expected/portals.out +++ b/src/test/regress/expected/portals_1.out @@ -3,27 +3,27 @@ -- BEGIN; DECLARE foo1 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo2 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo2 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo3 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo4 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo4 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo5 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo6 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo6 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo7 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo8 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo8 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo9 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo10 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo10 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo11 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo12 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo12 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo13 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo14 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo14 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo15 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo16 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo16 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo17 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo18 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo18 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo19 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo20 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo20 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo21 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo22 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo22 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo23 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; FETCH 1 in foo1; unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even | stringu1 | stringu2 | string4 @@ -682,15 +682,15 @@ SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors OR name | statement | is_holdable | is_binary | is_scrollable -------+-----------------------------------------------------------------------+-------------+-----------+--------------- foo13 | DECLARE foo13 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; | f | f | t - foo14 | DECLARE foo14 SCROLL CURSOR FOR SELECT * FROM tenk2; | f | f | t + foo14 | DECLARE foo14 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; | f | f | t foo15 | DECLARE foo15 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; | f | f | t - foo16 | DECLARE foo16 SCROLL CURSOR FOR SELECT * FROM tenk2; | f | f | t + foo16 | DECLARE foo16 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; | f | f | t foo17 | DECLARE foo17 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; | f | f | t - foo18 | DECLARE foo18 SCROLL CURSOR FOR SELECT * FROM tenk2; | f | f | t + foo18 | DECLARE foo18 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; | f | f | t foo19 | DECLARE foo19 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; | f | f | t - foo20 | DECLARE foo20 SCROLL CURSOR FOR SELECT * FROM tenk2; | f | f | t + foo20 | DECLARE foo20 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; | f | f | t foo21 | DECLARE foo21 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; | f | f | t - foo22 | DECLARE foo22 SCROLL CURSOR FOR SELECT * FROM tenk2; | f | f | t + foo22 | DECLARE foo22 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; | f | f | t foo23 | DECLARE foo23 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; | f | f | t (11 rows) @@ -724,7 +724,7 @@ SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors; (0 rows) BEGIN; -DECLARE foo25 SCROLL CURSOR WITH HOLD FOR SELECT * FROM tenk2; +DECLARE foo25 SCROLL CURSOR WITH HOLD FOR SELECT * FROM tenk2 ORDER BY unique2; FETCH FROM foo25; unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even | stringu1 | stringu2 | string4 ---------+---------+-----+------+-----+--------+---------+----------+-------------+-----------+----------+-----+------+----------+----------+--------- @@ -757,9 +757,9 @@ FETCH ABSOLUTE -1 FROM foo25; (1 row) SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors; - name | statement | is_holdable | is_binary | is_scrollable --------+----------------------------------------------------------------+-------------+-----------+--------------- - foo25 | DECLARE foo25 SCROLL CURSOR WITH HOLD FOR SELECT * FROM tenk2; | t | f | t + name | statement | is_holdable | is_binary | is_scrollable +-------+---------------------------------------------------------------------------------+-------------+-----------+--------------- + foo25 | DECLARE foo25 SCROLL CURSOR WITH HOLD FOR SELECT * FROM tenk2 ORDER BY unique2; | t | f | t (1 row) CLOSE foo25; @@ -812,7 +812,7 @@ ROLLBACK; -- in particular we want to see what happens during commit of a holdable -- cursor -- -create temp table tt1(f1 int); +create table tt1(f1 int); create function count_tt1_v() returns int8 as 'select count(*) from tt1' language sql volatile; create function count_tt1_s() returns int8 as @@ -824,7 +824,7 @@ insert into tt1 values(2); fetch all from c1; count_tt1_v | count_tt1_s -------------+------------- - 2 | 1 + 2 | 2 (1 row) rollback; @@ -837,11 +837,12 @@ delete from tt1; fetch all from c2; count_tt1_v | count_tt1_s -------------+------------- - 2 | 1 + | (1 row) drop function count_tt1_v(); drop function count_tt1_s(); +drop table tt1; -- Create a cursor with the BINARY option and check the pg_cursors view BEGIN; SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors; @@ -854,7 +855,7 @@ DECLARE bc BINARY CURSOR FOR SELECT * FROM tenk1; SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors ORDER BY 1; name | statement | is_holdable | is_binary | is_scrollable ------+----------------------------------------------------------------------+-------------+-----------+--------------- - bc | DECLARE bc BINARY CURSOR FOR SELECT * FROM tenk1; | f | t | t + bc | DECLARE bc BINARY CURSOR FOR SELECT * FROM tenk1; | f | t | f c2 | declare c2 cursor with hold for select count_tt1_v(), count_tt1_s(); | t | f | f (2 rows) @@ -863,12 +864,11 @@ ROLLBACK; -- implement EXECUTE in pg_cursors PREPARE cprep AS SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported EXECUTE cprep; - name | statement | is_holdable | is_binary | is_scrollable -------+----------------------------------------------------------------------+-------------+-----------+--------------- - c2 | declare c2 cursor with hold for select count_tt1_v(), count_tt1_s(); | t | f | f -(1 row) - +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported -- test CLOSE ALL; SELECT name FROM pg_cursors ORDER BY 1; name @@ -902,9 +902,9 @@ COMMIT; -- -- Tests for updatable cursors -- -CREATE TEMP TABLE uctest(f1 int, f2 text); -INSERT INTO uctest VALUES (1, 'one'), (2, 'two'), (3, 'three'); -SELECT * FROM uctest ORDER BY f1; +CREATE TABLE uctest(a int, f1 int, f2 text); +INSERT INTO uctest VALUES (11, 1, 'one'), (22, 2, 'two'), (33, 3, 'three'); +SELECT f1,f2 FROM uctest ORDER BY f1; f1 | f2 ----+------- 1 | one @@ -914,7 +914,7 @@ SELECT * FROM uctest ORDER BY f1; -- Check DELETE WHERE CURRENT BEGIN; -DECLARE c1 CURSOR FOR SELECT * FROM uctest ORDER BY f1; +DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest ORDER BY f1; FETCH 2 FROM c1; f1 | f2 ----+----- @@ -923,9 +923,9 @@ FETCH 2 FROM c1; (2 rows) DELETE FROM uctest WHERE CURRENT OF c1; -ERROR: cursor "c1" is not a simply updatable scan of table "uctest" +ERROR: WHERE CURRENT OF clause not yet supported -- should show deletion -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; ERROR: current transaction is aborted, commands ignored until end of transaction block -- cursor did not move FETCH ALL FROM c1; @@ -937,7 +937,7 @@ FETCH ALL FROM c1; ERROR: current transaction is aborted, commands ignored until end of transaction block COMMIT; -- should still see deletion -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; f1 | f2 ----+------- 1 | one @@ -947,188 +947,124 @@ 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; +DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest FOR UPDATE; FETCH c1; - f1 | f2 -----+----- - 1 | one -(1 row) - -UPDATE uctest SET f1 = 8 WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; f1 | f2 ----+------- - 2 | two 3 | three - 8 | one -(3 rows) +(1 row) +UPDATE uctest SET f1 = 8 WHERE CURRENT OF c1; +ERROR: WHERE CURRENT OF clause not yet supported +SELECT f1,f2 FROM uctest ORDER BY f1; +ERROR: current transaction is aborted, commands ignored until end of transaction block COMMIT; -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; f1 | f2 ----+------- + 1 | one 2 | two 3 | three - 8 | one (3 rows) -- Check repeated-update and update-then-delete cases BEGIN; -DECLARE c1 CURSOR FOR SELECT * FROM uctest; +DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest; FETCH c1; - f1 | f2 -----+----- - 2 | two -(1 row) - -UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -SELECT * FROM uctest; f1 | f2 ----+------- 3 | three - 8 | one - 12 | two -(3 rows) +(1 row) UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY 1; - f1 | f2 -----+------- - 3 | three - 8 | one - 22 | two -(3 rows) - +ERROR: WHERE CURRENT OF clause not yet supported +SELECT f1,f2 FROM uctest; +ERROR: current transaction is aborted, commands ignored until end of transaction block +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT f1,f2 FROM uctest ORDER BY 1; +ERROR: current transaction is aborted, commands ignored until end of transaction block -- insensitive cursor should not show effects of updates or deletes FETCH RELATIVE 0 FROM c1; - f1 | f2 -----+----- - 2 | two -(1 row) - +ERROR: current transaction is aborted, commands ignored until end of transaction block DELETE FROM uctest WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; - f1 | f2 -----+------- - 3 | three - 8 | one -(2 rows) - +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT f1,f2 FROM uctest ORDER BY f1; +ERROR: current transaction is aborted, commands ignored until end of transaction block DELETE FROM uctest WHERE CURRENT OF c1; -- no-op -SELECT * FROM uctest ORDER BY f1; - f1 | f2 -----+------- - 3 | three - 8 | one -(2 rows) - +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT f1,f2 FROM uctest ORDER BY f1; +ERROR: current transaction is aborted, commands ignored until end of transaction block UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -- no-op -SELECT * FROM uctest ORDER BY f1; - f1 | f2 -----+------- - 3 | three - 8 | one -(2 rows) - +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT f1,f2 FROM uctest ORDER BY f1; +ERROR: current transaction is aborted, commands ignored until end of transaction block FETCH RELATIVE 0 FROM c1; - f1 | f2 -----+----- - 2 | two -(1 row) - +ERROR: current transaction is aborted, commands ignored until end of transaction block ROLLBACK; -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; f1 | f2 ----+------- + 1 | one 2 | two 3 | three - 8 | one (3 rows) BEGIN; -DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE; +DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest FOR UPDATE; FETCH c1; - f1 | f2 -----+----- - 2 | two -(1 row) - -UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; f1 | f2 ----+------- 3 | three - 8 | one - 12 | two -(3 rows) +(1 row) UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; - f1 | f2 -----+------- - 3 | three - 8 | one - 22 | two -(3 rows) - +ERROR: WHERE CURRENT OF clause not yet supported +SELECT f1,f2 FROM uctest ORDER BY f1; +ERROR: current transaction is aborted, commands ignored until end of transaction block +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT f1,f2 FROM uctest ORDER BY f1; +ERROR: current transaction is aborted, commands ignored until end of transaction block DELETE FROM uctest WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; - f1 | f2 -----+------- - 3 | three - 8 | one -(2 rows) - +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT f1,f2 FROM uctest ORDER BY f1; +ERROR: current transaction is aborted, commands ignored until end of transaction block DELETE FROM uctest WHERE CURRENT OF c1; -- no-op -SELECT * FROM uctest ORDER BY f1; - f1 | f2 -----+------- - 3 | three - 8 | one -(2 rows) - +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT f1,f2 FROM uctest ORDER BY f1; +ERROR: current transaction is aborted, commands ignored until end of transaction block UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -- no-op -SELECT * FROM uctest ORDER BY f1; - f1 | f2 -----+------- - 3 | three - 8 | one -(2 rows) - +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT f1,f2 FROM uctest ORDER BY f1; +ERROR: current transaction is aborted, commands ignored until end of transaction block --- sensitive cursors can't currently scroll back, so this is an error: FETCH RELATIVE 0 FROM c1; -ERROR: cursor can only scan forward -HINT: Declare it with SCROLL option to enable backward scan. +ERROR: current transaction is aborted, commands ignored until end of transaction block ROLLBACK; -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; f1 | f2 ----+------- + 1 | one 2 | two 3 | three - 8 | one (3 rows) +DELETE FROM uctest WHERE f1 = 2; +UPDATE uctest SET f1 = 8 WHERE f1=1; -- Check inheritance cases -CREATE TEMP TABLE ucchild () inherits (uctest); -INSERT INTO ucchild values(100, 'hundred'); -SELECT * FROM uctest ORDER BY f1; +CREATE TABLE ucchild () inherits (uctest); +INSERT INTO ucchild values(0, 100, 'hundred'); +SELECT f1,f2 FROM uctest ORDER BY f1; f1 | f2 -----+--------- - 2 | two 3 | three 8 | one 100 | hundred -(4 rows) +(3 rows) BEGIN; -DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE; -FETCH 1 FROM c1; - f1 | f2 -----+----- - 2 | two -(1 row) - -UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; +DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest FOR UPDATE; FETCH 1 FROM c1; f1 | f2 ----+------- @@ -1136,130 +1072,127 @@ FETCH 1 FROM c1; (1 row) UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; +ERROR: WHERE CURRENT OF clause not yet supported FETCH 1 FROM c1; - f1 | f2 -----+----- - 8 | one -(1 row) - +ERROR: current transaction is aborted, commands ignored until end of transaction block UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; +ERROR: current transaction is aborted, commands ignored until end of transaction block FETCH 1 FROM c1; - f1 | f2 ------+--------- - 100 | hundred -(1 row) - +ERROR: current transaction is aborted, commands ignored until end of transaction block +UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; +ERROR: current transaction is aborted, commands ignored until end of transaction block +FETCH 1 FROM c1; +ERROR: current transaction is aborted, commands ignored until end of transaction block COMMIT; -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; f1 | f2 -----+--------- - 12 | two - 13 | three - 18 | one + 3 | three + 8 | one 100 | hundred -(4 rows) +(3 rows) -- Can update from a self-join, but only if FOR UPDATE says which to use BEGIN; -DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5; +DECLARE c1 CURSOR FOR SELECT a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5; FETCH 1 FROM c1; - f1 | f2 | f1 | f2 -----+-----+----+------- - 18 | one | 13 | three + f1 | f2 +----+----- + 8 | one (1 row) UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -- fail -ERROR: cursor "c1" is not a simply updatable scan of table "uctest" +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; +DECLARE c1 CURSOR FOR SELECT a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 FOR UPDATE; FETCH 1 FROM c1; - f1 | f2 | f1 | f2 -----+-----+----+------- - 18 | one | 13 | three + f1 | f2 +----+----- + 8 | one (1 row) UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -- fail -ERROR: cursor "c1" has multiple FOR UPDATE/SHARE references to table "uctest" +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; +DECLARE c1 CURSOR FOR SELECT a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 FOR SHARE OF a; FETCH 1 FROM c1; - f1 | f2 | f1 | f2 -----+-----+----+------- - 18 | one | 13 | three + f1 | f2 +----+----- + 8 | one (1 row) UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; - f1 | f2 ------+--------- - 12 | two - 13 | three - 28 | one - 100 | hundred -(4 rows) - +ERROR: WHERE CURRENT OF clause not yet supported +SELECT f1,f2 FROM uctest ORDER BY f1; +ERROR: current transaction is aborted, commands ignored until end of transaction block ROLLBACK; -- Check various error cases DELETE FROM uctest WHERE CURRENT OF c1; -- fail, no such cursor -ERROR: cursor "c1" does not exist -DECLARE cx CURSOR WITH HOLD FOR SELECT * FROM uctest; +ERROR: WHERE CURRENT OF clause not yet supported +DECLARE cx CURSOR WITH HOLD FOR SELECT f1,f2 FROM uctest; +ERROR: portal "cx" does not exist DELETE FROM uctest WHERE CURRENT OF cx; -- fail, can't use held cursor -ERROR: cursor "cx" is held from a previous transaction +ERROR: WHERE CURRENT OF clause not yet supported BEGIN; DECLARE c CURSOR FOR SELECT * FROM tenk2; DELETE FROM uctest WHERE CURRENT OF c; -- fail, cursor on wrong table -ERROR: cursor "c" is not a simply updatable scan of table "uctest" +ERROR: WHERE CURRENT OF clause not yet supported ROLLBACK; BEGIN; DECLARE c CURSOR FOR SELECT * FROM tenk2 FOR SHARE; DELETE FROM uctest WHERE CURRENT OF c; -- fail, cursor on wrong table -ERROR: cursor "c" does not have a FOR UPDATE/SHARE reference to table "uctest" +ERROR: WHERE CURRENT OF clause not yet supported ROLLBACK; BEGIN; DECLARE c CURSOR FOR SELECT * FROM tenk1 JOIN tenk2 USING (unique1); DELETE FROM tenk1 WHERE CURRENT OF c; -- fail, cursor is on a join -ERROR: cursor "c" is not a simply updatable scan of table "tenk1" +ERROR: WHERE CURRENT OF clause not yet supported ROLLBACK; BEGIN; DECLARE c CURSOR FOR SELECT f1,count(*) FROM uctest GROUP BY f1; +ERROR: GROUP BY clause is not yet supported DELETE FROM uctest WHERE CURRENT OF c; -- fail, cursor is on aggregation -ERROR: cursor "c" is not a simply updatable scan of table "uctest" +ERROR: current transaction is aborted, commands ignored until end of transaction block ROLLBACK; BEGIN; -DECLARE c1 CURSOR FOR SELECT * FROM uctest; +DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest; DELETE FROM uctest WHERE CURRENT OF c1; -- fail, no current row -ERROR: cursor "c1" is not positioned on a row +ERROR: WHERE CURRENT OF clause not yet supported ROLLBACK; -- WHERE CURRENT OF may someday work with views, but today is not that day. -- For now, just make sure it errors out cleanly. -CREATE TEMP VIEW ucview AS SELECT * FROM uctest; +CREATE VIEW ucview AS SELECT f1,f2 FROM uctest; CREATE RULE ucrule AS ON DELETE TO ucview DO INSTEAD DELETE FROM uctest WHERE f1 = OLD.f1; BEGIN; DECLARE c1 CURSOR FOR SELECT * FROM ucview; FETCH FROM c1; - f1 | f2 -----+----- - 12 | two + f1 | f2 +----+------- + 3 | three (1 row) DELETE FROM ucview WHERE CURRENT OF c1; -- fail, views not supported -ERROR: WHERE CURRENT OF on a view is not implemented +ERROR: WHERE CURRENT OF clause not yet supported ROLLBACK; -- Make sure snapshot management works okay, per bug report in -- 235...@ma... BEGIN; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; -CREATE TABLE cursor (a int); -INSERT INTO cursor VALUES (1); +CREATE TABLE cursor (a int, b int); +INSERT INTO cursor VALUES (1, 0); DECLARE c1 NO SCROLL CURSOR FOR SELECT * FROM cursor FOR UPDATE; -UPDATE cursor SET a = 2; +UPDATE cursor SET b = 2; FETCH ALL FROM c1; - a ---- -(0 rows) + a | b +---+--- + 1 | 2 +(1 row) COMMIT; DROP TABLE cursor; +DROP VIEW ucview; +DROP TABLE ucchild; +DROP TABLE uctest; diff --git a/src/test/regress/input/create_misc.source b/src/test/regress/input/create_misc.source index 30c5ade..882df6a 100644 --- a/src/test/regress/input/create_misc.source +++ b/src/test/regress/input/create_misc.source @@ -7,6 +7,7 @@ -- INSERT INTO tenk2 SELECT * FROM tenk1; +COPY tenk2 FROM '@abs_srcdir@/data/tenk.data'; SELECT * INTO TABLE onek2 FROM onek; diff --git a/src/test/regress/output/create_misc_1.source b/src/test/regress/output/create_misc_1.source index 53fbf2e..75503b7 100644 --- a/src/test/regress/output/create_misc_1.source +++ b/src/test/regress/output/create_misc_1.source @@ -5,6 +5,7 @@ -- (any resemblance to real life is purely coincidental) -- INSERT INTO tenk2 SELECT * FROM tenk1; +COPY tenk1 FROM '@abs_srcdir@/data/tenk.data'; SELECT * INTO TABLE onek2 FROM onek; ERROR: INTO clause not yet supported CREATE TABLE onek2 ( diff --git a/src/test/regress/sql/portals.sql b/src/test/regress/sql/portals.sql index a6c24f7..ff0d289 100644 --- a/src/test/regress/sql/portals.sql +++ b/src/test/regress/sql/portals.sql @@ -6,47 +6,47 @@ BEGIN; DECLARE foo1 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo2 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo2 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo3 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo4 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo4 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo5 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo6 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo6 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo7 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo8 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo8 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo9 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo10 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo10 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo11 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo12 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo12 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo13 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo14 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo14 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo15 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo16 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo16 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo17 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo18 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo18 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo19 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo20 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo20 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo21 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; -DECLARE foo22 SCROLL CURSOR FOR SELECT * FROM tenk2; +DECLARE foo22 SCROLL CURSOR FOR SELECT * FROM tenk2 ORDER BY unique2; DECLARE foo23 SCROLL CURSOR FOR SELECT * FROM tenk1 ORDER BY unique2; @@ -199,7 +199,7 @@ SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors; BEGIN; -DECLARE foo25 SCROLL CURSOR WITH HOLD FOR SELECT * FROM tenk2; +DECLARE foo25 SCROLL CURSOR WITH HOLD FOR SELECT * FROM tenk2 ORDER BY unique2; FETCH FROM foo25; @@ -253,7 +253,7 @@ ROLLBACK; -- cursor -- -create temp table tt1(f1 int); +create table tt1(f1 int); create function count_tt1_v() returns int8 as 'select count(*) from tt1' language sql volatile; @@ -290,6 +290,7 @@ fetch all from c2; drop function count_tt1_v(); drop function count_tt1_s(); +drop table tt1; -- Create a cursor with the BINARY option and check the pg_cursors view BEGIN; @@ -320,17 +321,17 @@ COMMIT; -- Tests for updatable cursors -- -CREATE TEMP TABLE uctest(f1 int, f2 text); -INSERT INTO uctest VALUES (1, 'one'), (2, 'two'), (3, 'three'); -SELECT * FROM uctest ORDER BY f1; +CREATE TABLE uctest(a int, f1 int, f2 text); +INSERT INTO uctest VALUES (11, 1, 'one'), (22, 2, 'two'), (33, 3, 'three'); +SELECT f1,f2 FROM uctest ORDER BY f1; -- Check DELETE WHERE CURRENT BEGIN; -DECLARE c1 CURSOR FOR SELECT * FROM uctest ORDER BY f1; +DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest ORDER BY f1; FETCH 2 FROM c1; DELETE FROM uctest WHERE CURRENT OF c1; -- should show deletion -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; -- cursor did not move FETCH ALL FROM c1; -- cursor is insensitive @@ -338,62 +339,63 @@ MOVE BACKWARD ALL IN c1; FETCH ALL FROM c1; COMMIT; -- should still see deletion -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; -- Check UPDATE WHERE CURRENT; this time use FOR UPDATE BEGIN; -DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE; +DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest FOR UPDATE; FETCH c1; UPDATE uctest SET f1 = 8 WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; COMMIT; -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; -- Check repeated-update and update-then-delete cases BEGIN; -DECLARE c1 CURSOR FOR SELECT * FROM uctest; +DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest; FETCH c1; UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -SELECT * FROM uctest; +SELECT f1,f2 FROM uctest; UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY 1; +SELECT f1,f2 FROM uctest ORDER BY 1; -- insensitive cursor should not show effects of updates or deletes FETCH RELATIVE 0 FROM c1; DELETE FROM uctest WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; DELETE FROM uctest WHERE CURRENT OF c1; -- no-op -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -- no-op -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; FETCH RELATIVE 0 FROM c1; ROLLBACK; -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; BEGIN; -DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE; +DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest FOR UPDATE; FETCH c1; UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; DELETE FROM uctest WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; DELETE FROM uctest WHERE CURRENT OF c1; -- no-op -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -- no-op -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; --- sensitive cursors can't currently scroll back, so this is an error: FETCH RELATIVE 0 FROM c1; ROLLBACK; -SELECT * FROM uctest ORDER BY f1; - +SELECT f1,f2 FROM uctest ORDER BY f1; +DELETE FROM uctest WHERE f1 = 2; +UPDATE uctest SET f1 = 8 WHERE f1=1; -- Check inheritance cases -CREATE TEMP TABLE ucchild () inherits (uctest); -INSERT INTO ucchild values(100, 'hundred'); -SELECT * FROM uctest ORDER BY f1; +CREATE TABLE ucchild () inherits (uctest); +INSERT INTO ucchild values(0, 100, 'hundred'); +SELECT f1,f2 FROM uctest ORDER BY f1; BEGIN; -DECLARE c1 CURSOR FOR SELECT * FROM uctest FOR UPDATE; +DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest FOR UPDATE; FETCH 1 FROM c1; UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; FETCH 1 FROM c1; @@ -402,30 +404,30 @@ FETCH 1 FROM c1; UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; FETCH 1 FROM c1; COMMIT; -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; -- Can update from a self-join, but only if FOR UPDATE says which to use BEGIN; -DECLARE c1 CURSOR FOR SELECT * FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5; +DECLARE c1 CURSOR FOR SELECT a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5; 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; +DECLARE c1 CURSOR FOR SELECT a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 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; +DECLARE c1 CURSOR FOR SELECT a.f1,a.f2 FROM uctest a, uctest b WHERE a.f1 = b.f1 + 5 FOR SHARE OF a; FETCH 1 FROM c1; UPDATE uctest SET f1 = f1 + 10 WHERE CURRENT OF c1; -SELECT * FROM uctest ORDER BY f1; +SELECT f1,f2 FROM uctest ORDER BY f1; ROLLBACK; -- Check various error cases DELETE FROM uctest WHERE CURRENT OF c1; -- fail, no such cursor -DECLARE cx CURSOR WITH HOLD FOR SELECT * FROM uctest; +DECLARE cx CURSOR WITH HOLD FOR SELECT f1,f2 FROM uctest; DELETE FROM uctest WHERE CURRENT OF cx; -- fail, can't use held cursor BEGIN; DECLARE c CURSOR FOR SELECT * FROM tenk2; @@ -444,13 +446,13 @@ DECLARE c CURSOR FOR SELECT f1,count(*) FROM uctest GROUP BY f1; DELETE FROM uctest WHERE CURRENT OF c; -- fail, cursor is on aggregation ROLLBACK; BEGIN; -DECLARE c1 CURSOR FOR SELECT * FROM uctest; +DECLARE c1 CURSOR FOR SELECT f1,f2 FROM uctest; DELETE FROM uctest WHERE CURRENT OF c1; -- fail, no current row ROLLBACK; -- WHERE CURRENT OF may someday work with views, but today is not that day. -- For now, just make sure it errors out cleanly. -CREATE TEMP VIEW ucview AS SELECT * FROM uctest; +CREATE VIEW ucview AS SELECT f1,f2 FROM uctest; CREATE RULE ucrule AS ON DELETE TO ucview DO INSTEAD DELETE FROM uctest WHERE f1 = OLD.f1; BEGIN; @@ -463,10 +465,15 @@ ROLLBACK; -- 235...@ma... BEGIN; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; -CREATE TABLE cursor (a int); -INSERT INTO cursor VALUES (1); +CREATE TABLE cursor (a int, b int); +INSERT INTO cursor VALUES (1, 0); DECLARE c1 NO SCROLL CURSOR FOR SELECT * FROM cursor FOR UPDATE; -UPDATE cursor SET a = 2; +UPDATE cursor SET b = 2; FETCH ALL FROM c1; COMMIT; DROP TABLE cursor; + +DROP VIEW ucview; +DROP TABLE ucchild; +DROP TABLE uctest; + ----------------------------------------------------------------------- Summary of changes: src/backend/parser/parse_expr.c | 6 + src/test/regress/expected/portals.out | 198 +++++------ .../expected/{portals.out => portals_1.out} | 365 ++++++++------------ src/test/regress/input/create_misc.source | 1 + src/test/regress/output/create_misc_1.source | 1 + src/test/regress/sql/portals.sql | 111 ++++--- 6 files changed, 312 insertions(+), 370 deletions(-) copy src/test/regress/expected/{portals.out => portals_1.out} (92%) hooks/post-receive -- Postgres-XC |