check_function_bodies
A configuration parameter controlling the validation of the function body string on creation
check_function_bodies
is a configuration parameter controlling the validation of the function body string when CREATE FUNCTION
is executed.
check_function_bodies
was added in PostgreSQL 7.4.
Default value
The default value for check_function_bodies
is: on
.
Change history
- PostgreSQL 7.4
- added (commit 15c194c1)
Examples
Normally the body of a function being created is validated:
postgres=# CREATE FUNCTION foo() RETURNS INT LANGUAGE SQL AS 'SELECT * FROM bar()'; ERROR: function bar() does not exist LINE 4: AS 'SELECT * FROM bar()'; ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.
However, if check_function_bodies
is set to off
, the function can be created:
postgres=# SHOW check_function_bodies; check_function_bodies ----------------------- off (1 row) postgres=# \df List of functions Schema | Name | Result data type | Argument data types | Type --------+------+------------------+---------------------+------ (0 rows) postgres=# CREATE FUNCTION foo() RETURNS INT LANGUAGE SQL AS 'SELECT * FROM bar()'; CREATE FUNCTION
Until the missing function is added, the function will of coursel fail with an ERROR
:
postgres=# SELECT * FROM foo(); ERROR: function bar() does not exist LINE 1: SELECT * FROM bar() ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. QUERY: SELECT * FROM bar() CONTEXT: SQL function "foo" during inlining
References
- PostgreSQL documentation: check_function_bodies