-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy PL/pgSQL regression tests in Makefile
- Loading branch information
Showing
10 changed files
with
338 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
-- directory paths are passed to us in environment variables | ||
\getenv abs_srcdir PG_ABS_SRCDIR | ||
\getenv abs_builddir PG_ABS_BUILDDIR | ||
|
||
-- set up file names to use | ||
\set srcfilename :abs_srcdir '/data/copy1.data' | ||
\set destfilename :abs_builddir '/results/copy1.data' | ||
|
||
CREATE TABLE copy1 (a int, b float); | ||
|
||
-- COPY TO/FROM not authorized from client. | ||
DO LANGUAGE plpgsql $$ | ||
BEGIN | ||
COPY copy1 TO stdout; | ||
END; | ||
$$; | ||
DO LANGUAGE plpgsql $$ | ||
BEGIN | ||
COPY copy1 FROM stdin; | ||
END; | ||
$$; | ||
DO LANGUAGE plpgsql $$ | ||
BEGIN | ||
EXECUTE 'COPY copy1 TO stdout'; | ||
END; | ||
$$; | ||
DO LANGUAGE plpgsql $$ | ||
BEGIN | ||
EXECUTE 'COPY copy1 FROM stdin'; | ||
END; | ||
$$; | ||
|
||
-- Valid cases | ||
-- COPY FROM | ||
\set dobody 'BEGIN COPY copy1 FROM ' :'srcfilename' '; END' | ||
DO LANGUAGE plpgsql :'dobody'; | ||
SELECT * FROM copy1 ORDER BY 1; | ||
TRUNCATE copy1; | ||
\set cmd 'COPY copy1 FROM ' :'srcfilename' | ||
\set dobody 'BEGIN EXECUTE ' :'cmd' '; END' | ||
DO LANGUAGE plpgsql :'dobody'; | ||
SELECT * FROM copy1 ORDER BY 1; | ||
|
||
-- COPY TO | ||
-- Copy the data externally once, then process it back to the table. | ||
\set dobody 'BEGIN COPY copy1 TO ' :'destfilename' '; END' | ||
DO LANGUAGE plpgsql :'dobody'; | ||
TRUNCATE copy1; | ||
\set dobody 'BEGIN COPY copy1 FROM ' :'destfilename' '; END' | ||
DO LANGUAGE plpgsql :'dobody'; | ||
|
||
\set cmd 'COPY copy1 FROM ' :'destfilename' | ||
\set dobody 'BEGIN EXECUTE ' :'cmd' '; END' | ||
DO LANGUAGE plpgsql :'dobody'; | ||
|
||
SELECT * FROM copy1 ORDER BY 1; | ||
|
||
DROP TABLE copy1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- | ||
-- Miscellaneous topics | ||
-- | ||
|
||
-- Verify that we can parse new-style CREATE FUNCTION/PROCEDURE | ||
do | ||
$$ | ||
declare procedure int; -- check we still recognize non-keywords as vars | ||
begin | ||
create function test1() returns int | ||
begin atomic | ||
select 2 + 2; | ||
end; | ||
create or replace procedure test2(x int) | ||
begin atomic | ||
select x + 2; | ||
end; | ||
end | ||
$$; | ||
|
||
\sf test1 | ||
\sf test2 | ||
|
||
-- Test %TYPE and %ROWTYPE error cases | ||
create table misc_table(f1 int); | ||
|
||
do $$ declare x foo%type; begin end $$; | ||
do $$ declare x notice%type; begin end $$; -- covers unreserved-keyword case | ||
do $$ declare x foo.bar%type; begin end $$; | ||
do $$ declare x foo.bar.baz%type; begin end $$; | ||
do $$ declare x public.foo.bar%type; begin end $$; | ||
do $$ declare x public.misc_table.zed%type; begin end $$; | ||
|
||
do $$ declare x foo%rowtype; begin end $$; | ||
do $$ declare x notice%rowtype; begin end $$; -- covers unreserved-keyword case | ||
do $$ declare x foo.bar%rowtype; begin end $$; | ||
do $$ declare x foo.bar.baz%rowtype; begin end $$; | ||
do $$ declare x public.foo%rowtype; begin end $$; | ||
do $$ declare x public.misc_table%rowtype; begin end $$; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.