Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit632b03d

Browse files
committed
Start a separate test suite for plpgsql
The plpgsql.sql test file in the main regression tests is now by far thelargest after numeric_big, making editing and managing the test casesvery cumbersome. The other PLs have their own test suites split up intosmaller files by topic. It would be nice to have that for plpgsql aswell. So, to get that started, set up test infrastructure insrc/pl/plpgsql/src/ and split out the recently added procedure testcases into a new file there. That file now mirrors the test cases addedto the other PLs, making managing those matching tests a bit easier too.msvc build system changes with help from Michael Paquier
1 parent3d88742 commit632b03d

File tree

7 files changed

+125
-101
lines changed

7 files changed

+125
-101
lines changed

‎src/pl/plpgsql/src/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
/pl_gram.c
22
/pl_gram.h
33
/plerrcodes.h
4+
/log/
5+
/results/
6+
/tmp_check/

‎src/pl/plpgsql/src/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ OBJS = pl_gram.o pl_handler.o pl_comp.o pl_exec.o \
2424

2525
DATA = plpgsql.control plpgsql--1.0.sql plpgsql--unpackaged--1.0.sql
2626

27+
REGRESS = plpgsql_call
28+
2729
all: all-lib
2830

2931
# Shared library stuff
@@ -65,6 +67,18 @@ pl_gram.c: BISONFLAGS += -d
6567
plerrcodes.h:$(top_srcdir)/src/backend/utils/errcodes.txt generate-plerrcodes.pl
6668
$(PERL)$(srcdir)/generate-plerrcodes.pl$<>$@
6769

70+
71+
check: submake
72+
$(pg_regress_check)$(REGRESS_OPTS)$(REGRESS)
73+
74+
installcheck: submake
75+
$(pg_regress_installcheck)$(REGRESS_OPTS)$(REGRESS)
76+
77+
.PHONY: submake
78+
submake:
79+
$(MAKE) -C$(top_builddir)/src/test/regress pg_regress$(X)
80+
81+
6882
distprep: pl_gram.h pl_gram.c plerrcodes.h
6983

7084
# pl_gram.c, pl_gram.h and plerrcodes.h are in the distribution tarball,
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--
2+
-- Tests for procedures / CALL syntax
3+
--
4+
CREATE PROCEDURE test_proc1()
5+
LANGUAGE plpgsql
6+
AS $$
7+
BEGIN
8+
NULL;
9+
END;
10+
$$;
11+
CALL test_proc1();
12+
-- error: can't return non-NULL
13+
CREATE PROCEDURE test_proc2()
14+
LANGUAGE plpgsql
15+
AS $$
16+
BEGIN
17+
RETURN 5;
18+
END;
19+
$$;
20+
CALL test_proc2();
21+
ERROR: cannot return a value from a procedure
22+
CONTEXT: PL/pgSQL function test_proc2() while casting return value to function's return type
23+
CREATE TABLE test1 (a int);
24+
CREATE PROCEDURE test_proc3(x int)
25+
LANGUAGE plpgsql
26+
AS $$
27+
BEGIN
28+
INSERT INTO test1 VALUES (x);
29+
END;
30+
$$;
31+
CALL test_proc3(55);
32+
SELECT * FROM test1;
33+
a
34+
----
35+
55
36+
(1 row)
37+
38+
DROP PROCEDURE test_proc1;
39+
DROP PROCEDURE test_proc2;
40+
DROP PROCEDURE test_proc3;
41+
DROP TABLE test1;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
--
2+
-- Tests for procedures / CALL syntax
3+
--
4+
5+
CREATE PROCEDURE test_proc1()
6+
LANGUAGE plpgsql
7+
AS $$
8+
BEGIN
9+
NULL;
10+
END;
11+
$$;
12+
13+
CALL test_proc1();
14+
15+
16+
-- error: can't return non-NULL
17+
CREATE PROCEDURE test_proc2()
18+
LANGUAGE plpgsql
19+
AS $$
20+
BEGIN
21+
RETURN5;
22+
END;
23+
$$;
24+
25+
CALL test_proc2();
26+
27+
28+
CREATETABLEtest1 (aint);
29+
30+
CREATE PROCEDURE test_proc3(xint)
31+
LANGUAGE plpgsql
32+
AS $$
33+
BEGIN
34+
INSERT INTO test1VALUES (x);
35+
END;
36+
$$;
37+
38+
CALL test_proc3(55);
39+
40+
SELECT*FROM test1;
41+
42+
43+
DROP PROCEDURE test_proc1;
44+
DROP PROCEDURE test_proc2;
45+
DROP PROCEDURE test_proc3;
46+
47+
DROPTABLE test1;

‎src/test/regress/expected/plpgsql.out

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6067,44 +6067,3 @@ END; $$ LANGUAGE plpgsql;
60676067
ERROR: "x" is not a scalar variable
60686068
LINE 3: GET DIAGNOSTICS x = ROW_COUNT;
60696069
^
6070-
--
6071-
-- Procedures
6072-
--
6073-
CREATE PROCEDURE test_proc1()
6074-
LANGUAGE plpgsql
6075-
AS $$
6076-
BEGIN
6077-
NULL;
6078-
END;
6079-
$$;
6080-
CALL test_proc1();
6081-
-- error: can't return non-NULL
6082-
CREATE PROCEDURE test_proc2()
6083-
LANGUAGE plpgsql
6084-
AS $$
6085-
BEGIN
6086-
RETURN 5;
6087-
END;
6088-
$$;
6089-
CALL test_proc2();
6090-
ERROR: cannot return a value from a procedure
6091-
CONTEXT: PL/pgSQL function test_proc2() while casting return value to function's return type
6092-
CREATE TABLE proc_test1 (a int);
6093-
CREATE PROCEDURE test_proc3(x int)
6094-
LANGUAGE plpgsql
6095-
AS $$
6096-
BEGIN
6097-
INSERT INTO proc_test1 VALUES (x);
6098-
END;
6099-
$$;
6100-
CALL test_proc3(55);
6101-
SELECT * FROM proc_test1;
6102-
a
6103-
----
6104-
55
6105-
(1 row)
6106-
6107-
DROP PROCEDURE test_proc1;
6108-
DROP PROCEDURE test_proc2;
6109-
DROP PROCEDURE test_proc3;
6110-
DROP TABLE proc_test1;

‎src/test/regress/sql/plpgsql.sql

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4843,52 +4843,3 @@ BEGIN
48434843
GET DIAGNOSTICS x= ROW_COUNT;
48444844
RETURN;
48454845
END; $$ LANGUAGE plpgsql;
4846-
4847-
4848-
--
4849-
-- Procedures
4850-
--
4851-
4852-
CREATE PROCEDURE test_proc1()
4853-
LANGUAGE plpgsql
4854-
AS $$
4855-
BEGIN
4856-
NULL;
4857-
END;
4858-
$$;
4859-
4860-
CALL test_proc1();
4861-
4862-
4863-
-- error: can't return non-NULL
4864-
CREATE PROCEDURE test_proc2()
4865-
LANGUAGE plpgsql
4866-
AS $$
4867-
BEGIN
4868-
RETURN5;
4869-
END;
4870-
$$;
4871-
4872-
CALL test_proc2();
4873-
4874-
4875-
CREATETABLEproc_test1 (aint);
4876-
4877-
CREATE PROCEDURE test_proc3(xint)
4878-
LANGUAGE plpgsql
4879-
AS $$
4880-
BEGIN
4881-
INSERT INTO proc_test1VALUES (x);
4882-
END;
4883-
$$;
4884-
4885-
CALL test_proc3(55);
4886-
4887-
SELECT*FROM proc_test1;
4888-
4889-
4890-
DROP PROCEDURE test_proc1;
4891-
DROP PROCEDURE test_proc2;
4892-
DROP PROCEDURE test_proc3;
4893-
4894-
DROPTABLE proc_test1;

‎src/tools/msvc/vcregress.pl

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,23 +248,32 @@ sub taptest
248248

249249
subplcheck
250250
{
251-
chdir"../../pl";
251+
chdir"$topdir/src/pl";
252252

253-
foreachmy$pl (glob("*"))
253+
foreachmy$dir (glob("*/src*"))
254254
{
255-
nextunless-d"$pl/sql" &&-d"$pl/expected";
256-
my$lang =$pleq'tcl' ?'pltcl' :$pl;
255+
nextunless-d"$dir/sql" &&-d"$dir/expected";
256+
my$lang;
257+
if ($direq'plpgsql/src') {
258+
$lang ='plpgsql';
259+
}
260+
elsif ($direq'tcl') {
261+
$lang ='pltcl';
262+
}
263+
else {
264+
$lang =$dir;
265+
}
257266
if ($langeq'plpython')
258267
{
259-
nextunless-d"../../$Config/plpython2";
268+
nextunless-d"$topdir/$Config/plpython2";
260269
$lang ='plpythonu';
261270
}
262271
else
263272
{
264-
nextunless-d"../../$Config/$lang";
273+
nextunless-d"$topdir/$Config/$lang";
265274
}
266275
my@lang_args = ("--load-extension=$lang");
267-
chdir$pl;
276+
chdir$dir;
268277
my@tests = fetchTests();
269278
if ($langeq'plperl')
270279
{
@@ -285,16 +294,16 @@ sub plcheck
285294
"============================================================\n";
286295
print"Checking$lang\n";
287296
my@args = (
288-
"../../../$Config/pg_regress/pg_regress",
289-
"--bindir=../../../$Config/psql",
297+
"$topdir/$Config/pg_regress/pg_regress",
298+
"--bindir=$topdir/$Config/psql",
290299
"--dbname=pl_regression",@lang_args,@tests);
291300
system(@args);
292301
my$status =$? >> 8;
293302
exit$statusif$status;
294-
chdir"..";
303+
chdir"$topdir/src/pl";
295304
}
296305

297-
chdir"../../..";
306+
chdir"$topdir";
298307
}
299308

300309
subsubdircheck

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp