Pseudo-types

更新时间:
复制 MD 格式

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:

NameFamilyDescription
anyelementSimpleAccepts any data type.
anyarraySimpleAccepts any array data type.
anynonarraySimpleAccepts any non-array data type.
anyenumSimpleAccepts any enum data type.
anyrangeSimpleAccepts any range data type.
anymultirangeSimpleAccepts any multirange data type.
anycompatibleCommonAccepts any data type, with automatic promotion of multiple arguments to a common data type.
anycompatiblearrayCommonAccepts any array data type, with automatic promotion to a common data type.
anycompatiblenonarrayCommonAccepts any non-array data type, with automatic promotion to a common data type.
anycompatiblerangeCommonAccepts any range data type, with automatic promotion to a common data type.
anycompatiblemultirangeCommonAccepts any multirange data type, with automatic promotion to a common data type.

Other pseudo-types

NameDescription
anyAccepts any input data type.
cstringAccepts or returns a null-terminated C string.
internalAccepts or returns a server-internal data type. See Security restrictions on internal for details.
language_handlerA procedural language call handler is declared to return language_handler.
fdw_handlerA foreign-data wrapper handler is declared to return fdw_handler.
table_am_handlerA table access method handler is declared to return table_am_handler.
index_am_handlerAn index access method handler is declared to return index_am_handler.
tsm_handlerA tablesample method handler is declared to return tsm_handler.
recordIdentifies a function taking or returning an unspecified row type.
triggerA trigger function is declared to return trigger.
event_triggerAn event trigger function is declared to return event_trigger.
pg_ddl_commandIdentifies a representation of DDL commands available to event triggers.
voidIndicates that a function returns no value.
unknownIdentifies 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.