From 5a8bda19066586a5ff0aa1d7b1cb31d839886728 Mon Sep 17 00:00:00 2001 From: Christian Winter Date: Thu, 20 Aug 2026 15:18:34 +0200 Subject: [PATCH] Update function docs to reflect the now PostgreSQL compatible syntax --- content/references/objects/functions.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/content/references/objects/functions.md b/content/references/objects/functions.md index ebdc6e0a..7b881bd7 100644 --- a/content/references/objects/functions.md +++ b/content/references/objects/functions.md @@ -7,12 +7,15 @@ weight: 70 Create function allows creating user-defined functions. Functions can help you to encapsulate common logic that can be reused. +The body of a SQL function is a `select` statement of the form `select `, matching PostgreSQL's syntax for SQL-language functions. +SQL functions must return the result of one scalar expression and cannot reference tables or subqueries. + ```sql create function times_two(x int) returns int language sql as - 'x * 2'; + 'select x * 2'; create function cowsay(t text) returns text language sql as $$ - ' ' || repeat('_', length(t) + 2) || E'\n' || + select ' ' || repeat('_', length(t) + 2) || E'\n' || '< ' || t || E' >\n' || ' ' || repeat('-', length(t) + 2) || E'\n' || E' \\ ^__^\n' ||