Pseudo-types are special type identifiers in the PolarDB for Oracle type system. They can appear as function argument or return types to express behaviors that ordinary type declarations cannot capture.
Polymorphic pseudo-types
Polymorphic pseudo-types let a single function definition work across multiple data types. They come in two families with different type-matching rules:
| Name | Family | Description |
|---|---|---|
anyelement | Simple | Accepts any data type. |
anyarray | Simple | Accepts any array data type. |
anynonarray | Simple | Accepts any non-array data type. |
anyenum | Simple | Accepts any enum data type. |
anyrange | Simple | Accepts any range data type. |
anymultirange | Simple | Accepts any multirange data type. |
anycompatible | Common | Accepts any data type, with automatic promotion of multiple arguments to a common data type. |
anycompatiblearray | Common | Accepts any array data type, with automatic promotion to a common data type. |
anycompatiblenonarray | Common | Accepts any non-array data type, with automatic promotion to a common data type. |
anycompatiblerange | Common | Accepts any range data type, with automatic promotion to a common data type. |
anycompatiblemultirange | Common | Accepts any multirange data type, with automatic promotion to a common data type. |
Other pseudo-types
| Name | Description |
|---|---|
any | Accepts any input data type. |
cstring | Accepts or returns a null-terminated C string. |
internal | Accepts or returns a server-internal data type. See Security restrictions on internal for details. |
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. |
table_am_handler | A table access method handler is declared to return table_am_handler. |
index_am_handler | An index access method handler is declared to return index_am_handler. |
tsm_handler | A tablesample method handler is declared to return tsm_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. |
pg_ddl_command | Identifies a representation of DDL commands available to event triggers. |
void | Indicates that a function returns no value. |
unknown | Identifies a not-yet-resolved type, such as an undecorated string literal. |
Usage notes
C functions
Functions written in C — whether built-in or dynamically loaded — can be declared to accept or return any pseudo-type. The function author is responsible for ensuring the function behaves safely when a pseudo-type is used as an argument type.
Procedural language functions
Functions written in procedural languages can use pseudo-types only as permitted by their implementation language. Currently, most procedural languages forbid pseudo-types as argument types and allow only void and record as return types (plus trigger or event_trigger when the function is used as a trigger or event trigger).
Security restrictions on internal
internal is reserved for functions meant to be called only by the database system, not directly from SQL. A function with at least one internal-type argument cannot be called from SQL.
To maintain type safety, never declare a function as returning internal unless it has at least one internal argument.