1-- 2-- CREATE_FUNCTION_1 3-- 4CREATE FUNCTION widget_in(cstring) 5 RETURNS widget 6 AS '@libdir@/regress@DLSUFFIX@' 7 LANGUAGE C STRICT IMMUTABLE; 8NOTICE: type "widget" is not yet defined 9DETAIL: Creating a shell type definition. 10CREATE FUNCTION widget_out(widget) 11 RETURNS cstring 12 AS '@libdir@/regress@DLSUFFIX@' 13 LANGUAGE C STRICT IMMUTABLE; 14NOTICE: argument type widget is only a shell 15CREATE FUNCTION int44in(cstring) 16 RETURNS city_budget 17 AS '@libdir@/regress@DLSUFFIX@' 18 LANGUAGE C STRICT IMMUTABLE; 19NOTICE: type "city_budget" is not yet defined 20DETAIL: Creating a shell type definition. 21CREATE FUNCTION int44out(city_budget) 22 RETURNS cstring 23 AS '@libdir@/regress@DLSUFFIX@' 24 LANGUAGE C STRICT IMMUTABLE; 25NOTICE: argument type city_budget is only a shell 26CREATE FUNCTION check_primary_key () 27 RETURNS trigger 28 AS '@libdir@/refint@DLSUFFIX@' 29 LANGUAGE C; 30CREATE FUNCTION check_foreign_key () 31 RETURNS trigger 32 AS '@libdir@/refint@DLSUFFIX@' 33 LANGUAGE C; 34CREATE FUNCTION autoinc () 35 RETURNS trigger 36 AS '@libdir@/autoinc@DLSUFFIX@' 37 LANGUAGE C; 38CREATE FUNCTION trigger_return_old () 39 RETURNS trigger 40 AS '@libdir@/regress@DLSUFFIX@' 41 LANGUAGE C; 42CREATE FUNCTION ttdummy () 43 RETURNS trigger 44 AS '@libdir@/regress@DLSUFFIX@' 45 LANGUAGE C; 46CREATE FUNCTION set_ttdummy (int4) 47 RETURNS int4 48 AS '@libdir@/regress@DLSUFFIX@' 49 LANGUAGE C STRICT; 50CREATE FUNCTION make_tuple_indirect (record) 51 RETURNS record 52 AS '@libdir@/regress@DLSUFFIX@' 53 LANGUAGE C STRICT; 54CREATE FUNCTION test_atomic_ops() 55 RETURNS bool 56 AS '@libdir@/regress@DLSUFFIX@' 57 LANGUAGE C; 58-- Tests creating a FDW handler 59CREATE FUNCTION test_fdw_handler() 60 RETURNS fdw_handler 61 AS '@libdir@/regress@DLSUFFIX@', 'test_fdw_handler' 62 LANGUAGE C; 63CREATE FUNCTION test_support_func(internal) 64 RETURNS internal 65 AS '@libdir@/regress@DLSUFFIX@', 'test_support_func' 66 LANGUAGE C STRICT; 67-- Things that shouldn't work: 68CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL 69 AS 'SELECT ''not an integer'';'; 70ERROR: return type mismatch in function declared to return integer 71DETAIL: Actual return type is text. 72CONTEXT: SQL function "test1" 73CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL 74 AS 'not even SQL'; 75ERROR: syntax error at or near "not" 76LINE 2: AS 'not even SQL'; 77 ^ 78CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL 79 AS 'SELECT 1, 2, 3;'; 80ERROR: return type mismatch in function declared to return integer 81DETAIL: Final statement must return exactly one column. 82CONTEXT: SQL function "test1" 83CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL 84 AS 'SELECT $2;'; 85ERROR: there is no parameter $2 86LINE 2: AS 'SELECT $2;'; 87 ^ 88CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL 89 AS 'a', 'b'; 90ERROR: only one AS item needed for language "sql" 91CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C 92 AS 'nosuchfile'; 93ERROR: could not access file "nosuchfile": No such file or directory 94CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C 95 AS '@libdir@/regress@DLSUFFIX@', 'nosuchsymbol'; 96ERROR: could not find function "nosuchsymbol" in file "@libdir@/regress@DLSUFFIX@" 97CREATE FUNCTION test1 (int) RETURNS int LANGUAGE internal 98 AS 'nosuch'; 99ERROR: there is no built-in function named "nosuch" 100