Skip to content

Commit 11b80d9

Browse files
committed
Extend SQL function tests lightly
The basic tests that defined SQL functions didn't actually run the functions to see if they worked. Add that, and also fix a minor mistake in a function that was revealed by this. (This is not a question of test coverage, since there are other places where SQL functions are run, but it is a bit of a silly test design.) Discussion: https://www.postgresql.org/message-id/flat/[email protected]
1 parent 556cbdf commit 11b80d9

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/test/regress/expected/create_function_3.out

+19-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ SET search_path TO temp_func_test, public;
1717
CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sql'
1818
AS 'SELECT $1 = ''abcd'' AND $2 > ''2001-01-01''';
1919
CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sql'
20-
AS 'SELECT $1[0]::int';
20+
AS 'SELECT $1[1]::int';
2121
CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sql'
2222
AS 'SELECT false';
2323
SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc
@@ -31,6 +31,24 @@ SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc
3131
functest_a_3 | boolean | {}
3232
(3 rows)
3333

34+
SELECT functest_A_1('abcd', '2020-01-01');
35+
functest_a_1
36+
--------------
37+
t
38+
(1 row)
39+
40+
SELECT functest_A_2(ARRAY['1', '2', '3']);
41+
functest_a_2
42+
--------------
43+
1
44+
(1 row)
45+
46+
SELECT functest_A_3();
47+
functest_a_3
48+
--------------
49+
f
50+
(1 row)
51+
3452
--
3553
-- IMMUTABLE | STABLE | VOLATILE
3654
--

src/test/regress/sql/create_function_3.sql

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@ SET search_path TO temp_func_test, public;
2323
CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sql'
2424
AS 'SELECT $1 = ''abcd'' AND $2 > ''2001-01-01''';
2525
CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sql'
26-
AS 'SELECT $1[0]::int';
26+
AS 'SELECT $1[1]::int';
2727
CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sql'
2828
AS 'SELECT false';
2929
SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc
3030
WHERE oid in ('functest_A_1'::regproc,
3131
'functest_A_2'::regproc,
3232
'functest_A_3'::regproc) ORDER BY proname;
3333

34+
SELECT functest_A_1('abcd', '2020-01-01');
35+
SELECT functest_A_2(ARRAY['1', '2', '3']);
36+
SELECT functest_A_3();
37+
3438
--
3539
-- IMMUTABLE | STABLE | VOLATILE
3640
--

0 commit comments

Comments
 (0)