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; 63-- Things that shouldn't work: 64CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL 65 AS 'SELECT ''not an integer'';'; 66ERROR: return type mismatch in function declared to return integer 67DETAIL: Actual return type is text. 68CONTEXT: SQL function "test1" 69CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL 70 AS 'not even SQL'; 71ERROR: syntax error at or near "not" 72LINE 2: AS 'not even SQL'; 73 ^ 74CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL 75 AS 'SELECT 1, 2, 3;'; 76ERROR: return type mismatch in function declared to return integer 77DETAIL: Final statement must return exactly one column. 78CONTEXT: SQL function "test1" 79CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL 80 AS 'SELECT $2;'; 81ERROR: there is no parameter $2 82LINE 2: AS 'SELECT $2;'; 83 ^ 84CREATE FUNCTION test1 (int) RETURNS int LANGUAGE SQL 85 AS 'a', 'b'; 86ERROR: only one AS item needed for language "sql" 87CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C 88 AS 'nosuchfile'; 89ERROR: could not access file "nosuchfile": No such file or directory 90CREATE FUNCTION test1 (int) RETURNS int LANGUAGE C 91 AS '@libdir@/regress@DLSUFFIX@', 'nosuchsymbol'; 92ERROR: could not find function "nosuchsymbol" in file "@libdir@/regress@DLSUFFIX@" 93CREATE FUNCTION test1 (int) RETURNS int LANGUAGE internal 94 AS 'nosuch'; 95ERROR: there is no built-in function named "nosuch" 96