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/1c11f1eb-f00c-43b7-799d-2d44132c02d7@2ndquadrant.com
This commit is contained in:
parent
556cbdfce4
commit
11b80d900f
@ -17,7 +17,7 @@ SET search_path TO temp_func_test, public;
|
||||
CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sql'
|
||||
AS 'SELECT $1 = ''abcd'' AND $2 > ''2001-01-01''';
|
||||
CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sql'
|
||||
AS 'SELECT $1[0]::int';
|
||||
AS 'SELECT $1[1]::int';
|
||||
CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sql'
|
||||
AS 'SELECT false';
|
||||
SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc
|
||||
@ -31,6 +31,24 @@ SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc
|
||||
functest_a_3 | boolean | {}
|
||||
(3 rows)
|
||||
|
||||
SELECT functest_A_1('abcd', '2020-01-01');
|
||||
functest_a_1
|
||||
--------------
|
||||
t
|
||||
(1 row)
|
||||
|
||||
SELECT functest_A_2(ARRAY['1', '2', '3']);
|
||||
functest_a_2
|
||||
--------------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT functest_A_3();
|
||||
functest_a_3
|
||||
--------------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
--
|
||||
-- IMMUTABLE | STABLE | VOLATILE
|
||||
--
|
||||
|
@ -23,7 +23,7 @@ SET search_path TO temp_func_test, public;
|
||||
CREATE FUNCTION functest_A_1(text, date) RETURNS bool LANGUAGE 'sql'
|
||||
AS 'SELECT $1 = ''abcd'' AND $2 > ''2001-01-01''';
|
||||
CREATE FUNCTION functest_A_2(text[]) RETURNS int LANGUAGE 'sql'
|
||||
AS 'SELECT $1[0]::int';
|
||||
AS 'SELECT $1[1]::int';
|
||||
CREATE FUNCTION functest_A_3() RETURNS bool LANGUAGE 'sql'
|
||||
AS 'SELECT false';
|
||||
SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc
|
||||
@ -31,6 +31,10 @@ SELECT proname, prorettype::regtype, proargtypes::regtype[] FROM pg_proc
|
||||
'functest_A_2'::regproc,
|
||||
'functest_A_3'::regproc) ORDER BY proname;
|
||||
|
||||
SELECT functest_A_1('abcd', '2020-01-01');
|
||||
SELECT functest_A_2(ARRAY['1', '2', '3']);
|
||||
SELECT functest_A_3();
|
||||
|
||||
--
|
||||
-- IMMUTABLE | STABLE | VOLATILE
|
||||
--
|
||||
|
Loading…
x
Reference in New Issue
Block a user