/pl_gram.c
/pl_gram.h
/plerrcodes.h
+/log/
+/results/
+/tmp_check/
DATA = plpgsql.control plpgsql--1.0.sql plpgsql--unpackaged--1.0.sql
+REGRESS = plpgsql_call
+
all: all-lib
# Shared library stuff
plerrcodes.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-plerrcodes.pl
$(PERL) $(srcdir)/generate-plerrcodes.pl $< > $@
+
+check: submake
+ $(pg_regress_check) $(REGRESS_OPTS) $(REGRESS)
+
+installcheck: submake
+ $(pg_regress_installcheck) $(REGRESS_OPTS) $(REGRESS)
+
+.PHONY: submake
+submake:
+ $(MAKE) -C $(top_builddir)/src/test/regress pg_regress$(X)
+
+
distprep: pl_gram.h pl_gram.c plerrcodes.h
# pl_gram.c, pl_gram.h and plerrcodes.h are in the distribution tarball,
--- /dev/null
+--
+-- Tests for procedures / CALL syntax
+--
+CREATE PROCEDURE test_proc1()
+LANGUAGE plpgsql
+AS $$
+BEGIN
+ NULL;
+END;
+$$;
+CALL test_proc1();
+-- error: can't return non-NULL
+CREATE PROCEDURE test_proc2()
+LANGUAGE plpgsql
+AS $$
+BEGIN
+ RETURN 5;
+END;
+$$;
+CALL test_proc2();
+ERROR: cannot return a value from a procedure
+CONTEXT: PL/pgSQL function test_proc2() while casting return value to function's return type
+CREATE TABLE test1 (a int);
+CREATE PROCEDURE test_proc3(x int)
+LANGUAGE plpgsql
+AS $$
+BEGIN
+ INSERT INTO test1 VALUES (x);
+END;
+$$;
+CALL test_proc3(55);
+SELECT * FROM test1;
+ a
+----
+ 55
+(1 row)
+
+DROP PROCEDURE test_proc1;
+DROP PROCEDURE test_proc2;
+DROP PROCEDURE test_proc3;
+DROP TABLE test1;
--- /dev/null
+--
+-- Tests for procedures / CALL syntax
+--
+
+CREATE PROCEDURE test_proc1()
+LANGUAGE plpgsql
+AS $$
+BEGIN
+ NULL;
+END;
+$$;
+
+CALL test_proc1();
+
+
+-- error: can't return non-NULL
+CREATE PROCEDURE test_proc2()
+LANGUAGE plpgsql
+AS $$
+BEGIN
+ RETURN 5;
+END;
+$$;
+
+CALL test_proc2();
+
+
+CREATE TABLE test1 (a int);
+
+CREATE PROCEDURE test_proc3(x int)
+LANGUAGE plpgsql
+AS $$
+BEGIN
+ INSERT INTO test1 VALUES (x);
+END;
+$$;
+
+CALL test_proc3(55);
+
+SELECT * FROM test1;
+
+
+DROP PROCEDURE test_proc1;
+DROP PROCEDURE test_proc2;
+DROP PROCEDURE test_proc3;
+
+DROP TABLE test1;
ERROR: "x" is not a scalar variable
LINE 3: GET DIAGNOSTICS x = ROW_COUNT;
^
---
--- Procedures
---
-CREATE PROCEDURE test_proc1()
-LANGUAGE plpgsql
-AS $$
-BEGIN
- NULL;
-END;
-$$;
-CALL test_proc1();
--- error: can't return non-NULL
-CREATE PROCEDURE test_proc2()
-LANGUAGE plpgsql
-AS $$
-BEGIN
- RETURN 5;
-END;
-$$;
-CALL test_proc2();
-ERROR: cannot return a value from a procedure
-CONTEXT: PL/pgSQL function test_proc2() while casting return value to function's return type
-CREATE TABLE proc_test1 (a int);
-CREATE PROCEDURE test_proc3(x int)
-LANGUAGE plpgsql
-AS $$
-BEGIN
- INSERT INTO proc_test1 VALUES (x);
-END;
-$$;
-CALL test_proc3(55);
-SELECT * FROM proc_test1;
- a
-----
- 55
-(1 row)
-
-DROP PROCEDURE test_proc1;
-DROP PROCEDURE test_proc2;
-DROP PROCEDURE test_proc3;
-DROP TABLE proc_test1;
GET DIAGNOSTICS x = ROW_COUNT;
RETURN;
END; $$ LANGUAGE plpgsql;
-
-
---
--- Procedures
---
-
-CREATE PROCEDURE test_proc1()
-LANGUAGE plpgsql
-AS $$
-BEGIN
- NULL;
-END;
-$$;
-
-CALL test_proc1();
-
-
--- error: can't return non-NULL
-CREATE PROCEDURE test_proc2()
-LANGUAGE plpgsql
-AS $$
-BEGIN
- RETURN 5;
-END;
-$$;
-
-CALL test_proc2();
-
-
-CREATE TABLE proc_test1 (a int);
-
-CREATE PROCEDURE test_proc3(x int)
-LANGUAGE plpgsql
-AS $$
-BEGIN
- INSERT INTO proc_test1 VALUES (x);
-END;
-$$;
-
-CALL test_proc3(55);
-
-SELECT * FROM proc_test1;
-
-
-DROP PROCEDURE test_proc1;
-DROP PROCEDURE test_proc2;
-DROP PROCEDURE test_proc3;
-
-DROP TABLE proc_test1;
sub plcheck
{
- chdir "../../pl";
+ chdir "$topdir/src/pl";
- foreach my $pl (glob("*"))
+ foreach my $dir (glob("*/src *"))
{
- next unless -d "$pl/sql" && -d "$pl/expected";
- my $lang = $pl eq 'tcl' ? 'pltcl' : $pl;
+ next unless -d "$dir/sql" && -d "$dir/expected";
+ my $lang;
+ if ($dir eq 'plpgsql/src') {
+ $lang = 'plpgsql';
+ }
+ elsif ($dir eq 'tcl') {
+ $lang = 'pltcl';
+ }
+ else {
+ $lang = $dir;
+ }
if ($lang eq 'plpython')
{
- next unless -d "../../$Config/plpython2";
+ next unless -d "$topdir/$Config/plpython2";
$lang = 'plpythonu';
}
else
{
- next unless -d "../../$Config/$lang";
+ next unless -d "$topdir/$Config/$lang";
}
my @lang_args = ("--load-extension=$lang");
- chdir $pl;
+ chdir $dir;
my @tests = fetchTests();
if ($lang eq 'plperl')
{
"============================================================\n";
print "Checking $lang\n";
my @args = (
- "../../../$Config/pg_regress/pg_regress",
- "--bindir=../../../$Config/psql",
+ "$topdir/$Config/pg_regress/pg_regress",
+ "--bindir=$topdir/$Config/psql",
"--dbname=pl_regression", @lang_args, @tests);
system(@args);
my $status = $? >> 8;
exit $status if $status;
- chdir "..";
+ chdir "$topdir/src/pl";
}
- chdir "../../..";
+ chdir "$topdir";
}
sub subdircheck