Pseudo-Types

5.11. Pseudo-Types

The PostgreSQL type system contains a number of special-purpose entries that are collectively called pseudo-types. 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 SQL data type. Table 5-21 lists the existing pseudo-types.

Table 5-21. Pseudo-Types

Type nameDescription
recordIdentifies a function returning an unspecified row type
anyIndicates that a function accepts any input data type whatever
anyarrayIndicates that a function accepts any array data type
voidIndicates that a function returns no value
triggerA trigger function is declared to return trigger
language_handlerA procedural language call handler is declared to return language_handler
cstringIndicates that a function accepts or returns a null-terminated C string
internalIndicates that a function accepts or returns a server-internal data type
opaqueAn obsolete type name that formerly served all the above purposes

Functions coded in C (whether built-in or dynamically loaded) may be declared to accept or return any of these pseudo data 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.

Functions coded in procedural languages may use pseudo-types only as allowed by their implementation languages. At present the procedural languages all forbid use of a pseudo-type as argument type, and allow only void as a result type (plus trigger when the function is used as a trigger).

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

Home
Online Resources
General
Beginner Tutorials
MySQL
PostgreSQL
Oracle
mSQL
Microsoft SQL
Contact Us
Random quote of the moment:
kernel panic: write-only-memory (/dev/wom0) capacity exceeded.
 
http://www.sql.org/
 
Proudly designed and hosted by OmegaSphere, providers of all your Web Hosting, SSL Certificate, and Domain Name needs!