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

Commit11b80d9

Browse files
committed
Extend SQL function tests lightly
The basic tests that defined SQL functions didn't actually run thefunctions to see if they worked. Add that, and also fix a minormistake in a function that was revealed by this. (This is not aquestion of test coverage, since there are other places where SQLfunctions 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
1 parent556cbdf commit11b80d9

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

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

Lines changed: 19 additions & 1 deletion
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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@ SET search_path TO temp_func_test, public;
2323
CREATEFUNCTIONfunctest_A_1(text,date) RETURNS bool LANGUAGE'sql'
2424
AS'SELECT $1 =''abcd'' AND $2 >''2001-01-01''';
2525
CREATEFUNCTIONfunctest_A_2(text[]) RETURNSint LANGUAGE'sql'
26-
AS'SELECT $1[0]::int';
26+
AS'SELECT $1[1]::int';
2727
CREATEFUNCTIONfunctest_A_3() RETURNS bool LANGUAGE'sql'
2828
AS'SELECT false';
2929
SELECT proname, prorettype::regtype, proargtypes::regtype[]FROM pg_proc
3030
WHEREoidin ('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)

[8]ページ先頭

©2009-2025 Movatter.jp