blob: 4c94a24baf83291e1500399f91c60e4462a5f7fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<?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>38.3. User-Defined Functions</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="extend-type-system.html" title="38.2. The PostgreSQL Type System" /><link rel="next" href="xproc.html" title="38.4. User-Defined Procedures" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">38.3. User-Defined Functions</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="extend-type-system.html" title="38.2. The PostgreSQL Type System">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="extend.html" title="Chapter 38. Extending SQL">Up</a></td><th width="60%" align="center">Chapter 38. Extending <acronym class="acronym">SQL</acronym></th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="xproc.html" title="38.4. User-Defined Procedures">Next</a></td></tr></table><hr /></div><div class="sect1" id="XFUNC"><div class="titlepage"><div><div><h2 class="title" style="clear: both">38.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="38.5. Query Language (SQL) Functions">Section 38.5</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="38.8. Procedural Language Functions">Section 38.8</a>)
</p></li><li class="listitem"><p>
internal functions (<a class="xref" href="xfunc-internal.html" title="38.9. Internal Functions">Section 38.9</a>)
</p></li><li class="listitem"><p>
C-language functions (<a class="xref" href="xfunc-c.html" title="38.10. C-Language Functions">Section 38.10</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="link" href="sql-createfunction.html" title="CREATE FUNCTION"><code class="command">CREATE
FUNCTION</code></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 class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="extend-type-system.html" title="38.2. The PostgreSQL Type System">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="extend.html" title="Chapter 38. Extending SQL">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="xproc.html" title="38.4. User-Defined Procedures">Next</a></td></tr><tr><td width="40%" align="left" valign="top">38.2. The <span class="productname">PostgreSQL</span> Type System </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 38.4. User-Defined Procedures</td></tr></table></div></body></html>
|