Home Explore Blog CI



postgresql

66th chunk of `doc/src/sgml/datatype.sgml`
a6fb4f3ae968e18e11f5f1e81a5c0484da8661c2c24f41460000000100000da4
     <row>
        <entry><type>language_handler</type></entry>
        <entry>A procedural language call handler is declared to return <type>language_handler</type>.</entry>
       </row>

       <row>
        <entry><type>fdw_handler</type></entry>
        <entry>A foreign-data wrapper handler is declared to return <type>fdw_handler</type>.</entry>
       </row>

       <row>
        <entry><type>table_am_handler</type></entry>
        <entry>A table access method handler is declared to return <type>table_am_handler</type>.</entry>
       </row>

       <row>
        <entry><type>index_am_handler</type></entry>
        <entry>An index access method handler is declared to return <type>index_am_handler</type>.</entry>
       </row>

       <row>
        <entry><type>tsm_handler</type></entry>
        <entry>A tablesample method handler is declared to return <type>tsm_handler</type>.</entry>
       </row>

       <row>
        <entry><type>record</type></entry>
        <entry>Identifies a function taking or returning an unspecified row type.</entry>
       </row>

       <row>
        <entry><type>trigger</type></entry>
        <entry>A trigger function is declared to return <type>trigger.</type></entry>
       </row>

       <row>
        <entry><type>event_trigger</type></entry>
        <entry>An event trigger function is declared to return <type>event_trigger.</type></entry>
       </row>

       <row>
        <entry><type>pg_ddl_command</type></entry>
        <entry>Identifies a representation of DDL commands that is available to event triggers.</entry>
       </row>

       <row>
        <entry><type>void</type></entry>
        <entry>Indicates that a function returns no value.</entry>
       </row>

       <row>
        <entry><type>unknown</type></entry>
        <entry>Identifies a not-yet-resolved type, e.g., of an undecorated
         string literal.</entry>
       </row>
      </tbody>
     </tgroup>
    </table>

   <para>
    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.
   </para>

   <para>
    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 <type>void</type> and <type>record</type> as a result type (plus
    <type>trigger</type> or <type>event_trigger</type> 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 <xref linkend="extend-types-polymorphic"/>.
   </para>

   <para>
    The <type>internal</type> 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>SQL</acronym>
    query.  If a function has at least one <type>internal</type>-type
    argument then it cannot be called from <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 <type>internal</type> unless it has at least one
    <type>internal</type> argument.
   </para>

  </sect1>

 </chapter>

Title: PostgreSQL Pseudo-Types and Function Declarations
Summary
The section describes PostgreSQL pseudo-types, including language_handler, fdw_handler, and others, which are used to declare function argument or result types, and discusses the rules and restrictions for using these pseudo-types in functions coded in C or procedural languages, including type safety and invocation restrictions.