1--
2-- CREATE_FUNCTION_0
3--
4-- Create a bunch of C functions that will be used by later tests:
5CREATE FUNCTION check_primary_key ()
6	RETURNS trigger
7	AS '@libdir@/refint@DLSUFFIX@'
8	LANGUAGE C;
9CREATE FUNCTION check_foreign_key ()
10	RETURNS trigger
11	AS '@libdir@/refint@DLSUFFIX@'
12	LANGUAGE C;
13CREATE FUNCTION autoinc ()
14	RETURNS trigger
15	AS '@libdir@/autoinc@DLSUFFIX@'
16	LANGUAGE C;
17CREATE FUNCTION trigger_return_old ()
18        RETURNS trigger
19        AS '@libdir@/regress@DLSUFFIX@'
20        LANGUAGE C;
21CREATE FUNCTION ttdummy ()
22        RETURNS trigger
23        AS '@libdir@/regress@DLSUFFIX@'
24        LANGUAGE C;
25CREATE FUNCTION set_ttdummy (int4)
26        RETURNS int4
27        AS '@libdir@/regress@DLSUFFIX@'
28        LANGUAGE C STRICT;
29CREATE FUNCTION make_tuple_indirect (record)
30        RETURNS record
31        AS '@libdir@/regress@DLSUFFIX@'
32        LANGUAGE C STRICT;
33CREATE FUNCTION test_atomic_ops()
34    RETURNS bool
35    AS '@libdir@/regress@DLSUFFIX@'
36    LANGUAGE C;
37CREATE FUNCTION test_fdw_handler()
38    RETURNS fdw_handler
39    AS '@libdir@/regress@DLSUFFIX@', 'test_fdw_handler'
40    LANGUAGE C;
41CREATE FUNCTION test_support_func(internal)
42    RETURNS internal
43    AS '@libdir@/regress@DLSUFFIX@', 'test_support_func'
44    LANGUAGE C STRICT;
45CREATE FUNCTION test_opclass_options_func(internal)
46    RETURNS void
47    AS '@libdir@/regress@DLSUFFIX@', 'test_opclass_options_func'
48    LANGUAGE C;
49CREATE FUNCTION test_enc_conversion(bytea, name, name, bool, validlen OUT int, result OUT bytea)
50    AS '@libdir@/regress@DLSUFFIX@', 'test_enc_conversion'
51    LANGUAGE C STRICT;
52CREATE FUNCTION binary_coercible(oid, oid)
53    RETURNS bool
54    AS '@libdir@/regress@DLSUFFIX@', 'binary_coercible'
55    LANGUAGE C STRICT STABLE PARALLEL SAFE;
56-- Things that shouldn't work:
57CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
58    AS 'SELECT ''not an integer'';';
59ERROR:  return type mismatch in function declared to return integer
60DETAIL:  Actual return type is text.
61CONTEXT:  SQL function "test1"
62CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
63    AS 'not even SQL';
64ERROR:  syntax error at or near "not"
65LINE 2:     AS 'not even SQL';
66                ^
67CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
68    AS 'SELECT 1, 2, 3;';
69ERROR:  return type mismatch in function declared to return integer
70DETAIL:  Final statement must return exactly one column.
71CONTEXT:  SQL function "test1"
72CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
73    AS 'SELECT $2;';
74ERROR:  there is no parameter $2
75LINE 2:     AS 'SELECT $2;';
76                       ^
77CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL
78    AS 'a', 'b';
79ERROR:  only one AS item needed for language "sql"
80CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C
81    AS 'nosuchfile';
82ERROR:  could not access file "nosuchfile": No such file or directory
83CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C
84    AS '@libdir@/regress@DLSUFFIX@', 'nosuchsymbol';
85ERROR:  could not find function "nosuchsymbol" in file "@libdir@/regress@DLSUFFIX@"
86CREATE FUNCTION test1 (int) RETURNS int LANGUAGE internal
87    AS 'nosuch';
88ERROR:  there is no built-in function named "nosuch"
89