Pseudo-types v15
Data type | Native | Alias | Description |
---|---|---|---|
any | ✅ | Indicates that a function accepts any input data type. | |
anyelement | ✅ | Indicates that a function accepts any data type. For more information, see Polymorphic types in the PostgreSQL documentation. | |
anyarray | ✅ | Indicates that a function accepts any array data type. For more information, see Polymorphic types in the PostgreSQL documentation. | |
anynonarray | ✅ | Indicates that a function accepts any non-array data type. For more information, see Polymorphic types in the PostgreSQL documentation. | |
anyenum | ✅ | Indicates that a function accepts any enum data type. For more information, see Polymorphic types and Enumerated types in the PostgreSQL documentation. | |
anyrange | ✅ | Indicates that a function accepts any range data type. For more information, see Polymorphic types and Range types in the PostgreSQL documentation. | |
cstring | ✅ | Indicates that a function accepts or returns a null-terminated C string. | |
internal | ✅ | Indicates that a function accepts or returns a server-internal data type. | |
language_handler | ✅ | A procedural language call handler is declared to return language_handler . | |
fdw_handler | ✅ | A foreign-data wrapper handler is declared to return fdw_handler . | |
record | ✅ | Identifies a function taking or returning an unspecified row type. | |
trigger | ✅ | A trigger function is declared to return trigger. | |
event_trigger | ✅ | An event trigger function is declared to return event_trigger . | |
void | ✅ | Indicates that a function returns no value. | |
opaque | ✅ | An obsolete type name that formerly served all the above purposes. |
Overview
The PostgreSQL type system contains a number of special-purpose entries that are collectively called pseudo-types. A pseudo-type can't 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 doesn't correspond to taking or returning a value of a specific SQL data type.
Functions coded in C (whether built-in or dynamically loaded) can be declared to accept or return any of these pseudo data types. It's up to the function author to ensure that the function behaves safely when a pseudo-type is used as an argument type.
Functions coded in procedural languages can use pseudo-types only as allowed by their implementation languages. At present, most procedural languages forbid the use of a pseudo-type as an argument type. They allow only void
and record
as a result type (plus trigger
or event_trigger
when the function is used as a trigger or event trigger). Some also support polymorphic functions using the types anyelement
, anyarray
, anynonarray
, anyenum
, and anyrange
.
The internal
pseudo-type is used to declare functions that are meant to be called only internally by the database system and not by direct invocation in an SQL query. If a function has at least one internal-type argument, then it can't be called from SQL. To preserve the type safety of this restriction, it's important to follow this coding rule: don't create any function that's declared to return internal
unless it has at least one internal argument.
- On this page
- Overview