summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/datatype-pseudo.html
blob: 6c24833f5b770d0abf6d8dec0e7d1dbbab474a3a (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?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>8.21. Pseudo-Types</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="datatype-pg-lsn.html" title="8.20. pg_lsn Type" /><link rel="next" href="functions.html" title="Chapter 9. Functions and Operators" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">8.21. Pseudo-Types</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="datatype-pg-lsn.html" title="8.20. pg_lsn Type">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="datatype.html" title="Chapter 8. Data Types">Up</a></td><th width="60%" align="center">Chapter 8. Data Types</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.5 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="functions.html" title="Chapter 9. Functions and Operators">Next</a></td></tr></table><hr /></div><div class="sect1" id="DATATYPE-PSEUDO"><div class="titlepage"><div><div><h2 class="title" style="clear: both">8.21. Pseudo-Types</h2></div></div></div><a id="id-1.5.7.29.2" class="indexterm"></a><a id="id-1.5.7.29.3" class="indexterm"></a><a id="id-1.5.7.29.4" class="indexterm"></a><a id="id-1.5.7.29.5" class="indexterm"></a><a id="id-1.5.7.29.6" class="indexterm"></a><a id="id-1.5.7.29.7" class="indexterm"></a><a id="id-1.5.7.29.8" class="indexterm"></a><a id="id-1.5.7.29.9" class="indexterm"></a><a id="id-1.5.7.29.10" class="indexterm"></a><a id="id-1.5.7.29.11" class="indexterm"></a><a id="id-1.5.7.29.12" class="indexterm"></a><a id="id-1.5.7.29.13" class="indexterm"></a><a id="id-1.5.7.29.14" class="indexterm"></a><a id="id-1.5.7.29.15" class="indexterm"></a><a id="id-1.5.7.29.16" class="indexterm"></a><a id="id-1.5.7.29.17" class="indexterm"></a><a id="id-1.5.7.29.18" class="indexterm"></a><a id="id-1.5.7.29.19" class="indexterm"></a><a id="id-1.5.7.29.20" class="indexterm"></a><a id="id-1.5.7.29.21" class="indexterm"></a><a id="id-1.5.7.29.22" class="indexterm"></a><a id="id-1.5.7.29.23" class="indexterm"></a><a id="id-1.5.7.29.24" class="indexterm"></a><a id="id-1.5.7.29.25" class="indexterm"></a><a id="id-1.5.7.29.26" class="indexterm"></a><p>
    The <span class="productname">PostgreSQL</span> type system contains a
    number of special-purpose entries that are collectively called
    <em class="firstterm">pseudo-types</em>.  A pseudo-type cannot be used as a
    column data type, but it can be used to declare a function's
    argument or result type.  Each of the available pseudo-types is
    useful in situations where a function's behavior does not
    correspond to simply taking or returning a value of a specific
    <acronym class="acronym">SQL</acronym> data type.  <a class="xref" href="datatype-pseudo.html#DATATYPE-PSEUDOTYPES-TABLE" title="Table 8.27. Pseudo-Types">Table 8.27</a> lists the existing
    pseudo-types.
   </p><div class="table" id="DATATYPE-PSEUDOTYPES-TABLE"><p class="title"><strong>Table 8.27. Pseudo-Types</strong></p><div class="table-contents"><table class="table" summary="Pseudo-Types" border="1"><colgroup><col class="col1" /><col class="col2" /></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><code class="type">any</code></td><td>Indicates that a function accepts any input data type.</td></tr><tr><td><code class="type">anyelement</code></td><td>Indicates that a function accepts any data type
        (see <a class="xref" href="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC" title="38.2.5. Polymorphic Types">Section 38.2.5</a>).</td></tr><tr><td><code class="type">anyarray</code></td><td>Indicates that a function accepts any array data type
        (see <a class="xref" href="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC" title="38.2.5. Polymorphic Types">Section 38.2.5</a>).</td></tr><tr><td><code class="type">anynonarray</code></td><td>Indicates that a function accepts any non-array data type
        (see <a class="xref" href="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC" title="38.2.5. Polymorphic Types">Section 38.2.5</a>).</td></tr><tr><td><code class="type">anyenum</code></td><td>Indicates that a function accepts any enum data type
        (see <a class="xref" href="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC" title="38.2.5. Polymorphic Types">Section 38.2.5</a> and
        <a class="xref" href="datatype-enum.html" title="8.7. Enumerated Types">Section 8.7</a>).</td></tr><tr><td><code class="type">anyrange</code></td><td>Indicates that a function accepts any range data type
        (see <a class="xref" href="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC" title="38.2.5. Polymorphic Types">Section 38.2.5</a> and
        <a class="xref" href="rangetypes.html" title="8.17. Range Types">Section 8.17</a>).</td></tr><tr><td><code class="type">anymultirange</code></td><td>Indicates that a function accepts any multirange data type
        (see <a class="xref" href="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC" title="38.2.5. Polymorphic Types">Section 38.2.5</a> and
        <a class="xref" href="rangetypes.html" title="8.17. Range Types">Section 8.17</a>).</td></tr><tr><td><code class="type">anycompatible</code></td><td>Indicates that a function accepts any data type,
        with automatic promotion of multiple arguments to a common data type
        (see <a class="xref" href="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC" title="38.2.5. Polymorphic Types">Section 38.2.5</a>).</td></tr><tr><td><code class="type">anycompatiblearray</code></td><td>Indicates that a function accepts any array data type,
        with automatic promotion of multiple arguments to a common data type
        (see <a class="xref" href="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC" title="38.2.5. Polymorphic Types">Section 38.2.5</a>).</td></tr><tr><td><code class="type">anycompatiblenonarray</code></td><td>Indicates that a function accepts any non-array data type,
        with automatic promotion of multiple arguments to a common data type
        (see <a class="xref" href="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC" title="38.2.5. Polymorphic Types">Section 38.2.5</a>).</td></tr><tr><td><code class="type">anycompatiblerange</code></td><td>Indicates that a function accepts any range data type,
        with automatic promotion of multiple arguments to a common data type
        (see <a class="xref" href="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC" title="38.2.5. Polymorphic Types">Section 38.2.5</a> and
        <a class="xref" href="rangetypes.html" title="8.17. Range Types">Section 8.17</a>).</td></tr><tr><td><code class="type">anycompatiblemultirange</code></td><td>Indicates that a function accepts any multirange data type,
        with automatic promotion of multiple arguments to a common data type
        (see <a class="xref" href="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC" title="38.2.5. Polymorphic Types">Section 38.2.5</a> and
        <a class="xref" href="rangetypes.html" title="8.17. Range Types">Section 8.17</a>).</td></tr><tr><td><code class="type">cstring</code></td><td>Indicates that a function accepts or returns a null-terminated C string.</td></tr><tr><td><code class="type">internal</code></td><td>Indicates that a function accepts or returns a server-internal
        data type.</td></tr><tr><td><code class="type">language_handler</code></td><td>A procedural language call handler is declared to return <code class="type">language_handler</code>.</td></tr><tr><td><code class="type">fdw_handler</code></td><td>A foreign-data wrapper handler is declared to return <code class="type">fdw_handler</code>.</td></tr><tr><td><code class="type">table_am_handler</code></td><td>A table access method handler is declared to return <code class="type">table_am_handler</code>.</td></tr><tr><td><code class="type">index_am_handler</code></td><td>An index access method handler is declared to return <code class="type">index_am_handler</code>.</td></tr><tr><td><code class="type">tsm_handler</code></td><td>A tablesample method handler is declared to return <code class="type">tsm_handler</code>.</td></tr><tr><td><code class="type">record</code></td><td>Identifies a function taking or returning an unspecified row type.</td></tr><tr><td><code class="type">trigger</code></td><td>A trigger function is declared to return <code class="type">trigger.</code></td></tr><tr><td><code class="type">event_trigger</code></td><td>An event trigger function is declared to return <code class="type">event_trigger.</code></td></tr><tr><td><code class="type">pg_ddl_command</code></td><td>Identifies a representation of DDL commands that is available to event triggers.</td></tr><tr><td><code class="type">void</code></td><td>Indicates that a function returns no value.</td></tr><tr><td><code class="type">unknown</code></td><td>Identifies a not-yet-resolved type, e.g., of an undecorated
         string literal.</td></tr></tbody></table></div></div><br class="table-break" /><p>
    Functions coded in C (whether built-in or dynamically loaded) can be
    declared to accept or return any of these pseudo-types.  It is up to
    the function author to ensure that the function will behave safely
    when a pseudo-type is used as an argument type.
   </p><p>
    Functions coded in procedural languages can use pseudo-types only as
    allowed by their implementation languages.  At present most procedural
    languages forbid use of a pseudo-type as an argument type, and allow
    only <code class="type">void</code> and <code class="type">record</code> as a result type (plus
    <code class="type">trigger</code> or <code class="type">event_trigger</code> when the function is used
    as a trigger or event trigger).  Some also support polymorphic functions
    using the polymorphic pseudo-types, which are shown above and discussed
    in detail in <a class="xref" href="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC" title="38.2.5. Polymorphic Types">Section 38.2.5</a>.
   </p><p>
    The <code class="type">internal</code> pseudo-type is used to declare functions
    that are meant only to be called internally by the database
    system, and not by direct invocation in an <acronym class="acronym">SQL</acronym>
    query.  If a function has at least one <code class="type">internal</code>-type
    argument then it cannot be called from <acronym class="acronym">SQL</acronym>.  To
    preserve the type safety of this restriction it is important to
    follow this coding rule: do not create any function that is
    declared to return <code class="type">internal</code> unless it has at least one
    <code class="type">internal</code> argument.
   </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="datatype-pg-lsn.html" title="8.20. pg_lsn Type">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="datatype.html" title="Chapter 8. Data Types">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="functions.html" title="Chapter 9. Functions and Operators">Next</a></td></tr><tr><td width="40%" align="left" valign="top">8.20. <code class="type">pg_lsn</code> Type </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.5 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Chapter 9. Functions and Operators</td></tr></table></div></body></html>