diff options
| author | Tom Lane | 2010-01-19 01:35:31 +0000 |
|---|---|---|
| committer | Tom Lane | 2010-01-19 01:35:31 +0000 |
| commit | 309cd7cf183d7e194205d8d97186c09ef67f83ae (patch) | |
| tree | 91c25a11865b718915fe1e2939299f9191c5016f /src/test | |
| parent | 8ab27affeaf5ebf9c735e87e0878c50a52eaf507 (diff) | |
Add "USING expressions" option to plpgsql's OPEN cursor FOR EXECUTE.
This is the last EXECUTE-like plpgsql statement that was missing
the capability of inserting parameter values via USING.
Pavel Stehule, reviewed by Itagaki Takahiro
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/plpgsql.out | 29 | ||||
| -rw-r--r-- | src/test/regress/sql/plpgsql.sql | 22 |
2 files changed, 51 insertions, 0 deletions
diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out index e126f616fe..c2bf41d6fc 100644 --- a/src/test/regress/expected/plpgsql.out +++ b/src/test/regress/expected/plpgsql.out @@ -3189,6 +3189,35 @@ NOTICE: 6 26 (1 row) +drop function exc_using(int, text); +create or replace function exc_using(int) returns void as $$ +declare + c refcursor; + i int; +begin + open c for execute 'select * from generate_series(1,$1)' using $1+1; + loop + fetch c into i; + exit when not found; + raise notice '%', i; + end loop; + close c; + return; +end; +$$ language plpgsql; +select exc_using(5); +NOTICE: 1 +NOTICE: 2 +NOTICE: 3 +NOTICE: 4 +NOTICE: 5 +NOTICE: 6 + exc_using +----------- + +(1 row) + +drop function exc_using(int); -- test FOR-over-cursor create or replace function forc01() returns void as $$ declare diff --git a/src/test/regress/sql/plpgsql.sql b/src/test/regress/sql/plpgsql.sql index 79756f6a01..3613194fd9 100644 --- a/src/test/regress/sql/plpgsql.sql +++ b/src/test/regress/sql/plpgsql.sql @@ -2629,6 +2629,28 @@ $$ language plpgsql; select exc_using(5, 'foobar'); +drop function exc_using(int, text); + +create or replace function exc_using(int) returns void as $$ +declare + c refcursor; + i int; +begin + open c for execute 'select * from generate_series(1,$1)' using $1+1; + loop + fetch c into i; + exit when not found; + raise notice '%', i; + end loop; + close c; + return; +end; +$$ language plpgsql; + +select exc_using(5); + +drop function exc_using(int); + -- test FOR-over-cursor create or replace function forc01() returns void as $$ |
