Postgres-XC 1.2devel Documentation | ||||
---|---|---|---|---|
Prev | Fast Backward | Chapter 34. Extending SQL | Fast Forward | Next |
Note: The following description applies both to Postgres-XC and PostgreSQL if not described explicitly. You can read PostgreSQL as Postgres-XC except for version number, which is specific to each product.
PostgreSQL provides four kinds of functions:
query language functions (functions written in SQL) (Section 34.4)
procedural language functions (functions written in, for example, PL/pgSQL or PL/Tcl) (Section 34.7)
internal functions (Section 34.8)
C-language functions (Section 34.9)
Every kind of function can take base types, composite types, or combinations of these as arguments (parameters). In addition, every kind of function can return a base type or a composite type. Functions can also be defined to return sets of base or composite values.
Many kinds of functions can take or return certain pseudo-types (such as polymorphic types), but the available facilities vary. Consult the description of each kind of function for more details.
It's easiest to define SQL functions, so we'll start by discussing those. Most of the concepts presented for SQL functions will carry over to the other types of functions.
Throughout this chapter, it can be useful to look at the reference page of the CREATE FUNCTION command to understand the examples better. Some examples from this chapter can be found in funcs.sql and funcs.c in the src/tutorial directory in the PostgreSQL source distribution.
Note: XCONLY: The following description applies only to Postgres-XC.
Postgres-XC allow only one SQL statement embedded in each function. This restriction will be removed in the future releases.