Loading topic
lower() or now(). This chapter covers the basic shape of CREATE FUNCTION, how to call the result, and the first decisions you make wh6 min readCREATE FUNCTION for a simple SQL function, and that you know what a schema and the search_path setting are. It covers the two ways to write a SQL function body and the practical differences between them.6 min readCREATE FUNCTION ... LANGUAGE sql statement and know how SELECT and INSERT work. You should also be comfortable with common PostgreSQL types and with running statements in psql. Here you will learn how to declare the inputs a function takes and the c5 min readCREATE FUNCTION ... LANGUAGE sql statement and know the difference between a scalar value, a row and a set of rows. It covers how PostgreSQL decides what a SQL function hands back to the caller, and the errors you get when the body and the declared type d5 min readSTRICT marker, which changes that behavior, and the problems it can cause. It assumes you can write a basic CREATE FUNCTION ... LANGUAGE sql statement, you know that NULL means "unknown or mis6 min readCREATE FUNCTION ... LANGUAGE sql statement, know that a SQL function returns the result of its last statement, and can read SELECT ... FROM ... JOIN queries. The examples 5 min readCREATE FUNCTION ... LANGUAGE sql and read an EXPLAIN plan.6 min readCREATE FUNCTION ... LANGUAGE sql and know what a return type is. It also assumes you know what VOLATILE, STABLE and IMMUTABLE mean. You should be comfortable with RETURNING on plain DML st5 min readCALL instead of SELECT. It is meant for actions, such as archiving rows or recording an event, and not for computing a value inside a query. This chapter assumes you can write a basic SQL function (the earlier chapters on CREATE FUNCTION, par5 min readCREATE OR REPLACE FUNCTION may and may not change, how overloads are chosen at call time, and how to remove functions safely. It assumes you can write a basic SQL function (the first chapters of this tutorial), know what a schema and a5 min readCREATE FUNCTION. You should also know how parameters and return types work, and how to ref4 min readCREATE FUNCTION, you know the three volatility categories, and you can read EXPLAIN output. You should also have a table with an index to experiment on.6 min readGRANT and REVOKE work. By the end you will know how to create a SECURITY DEFINER function that does not hand its owner's privileges to anyone who calls it.5 min readCOST, ROWS and PARALLEL. They never change what a function returns. They change the query plan, and a wrong PARALLEL label can change results or cause errors.5 min readCREATE FUNCTION. It also assumes you know the volatility categories and STRICT, and have read the earlier chapter on planner inlining. It helps you choose between LANGUAGE sql and LANGUAGE plpgsql for a given task.5 min read