Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
8.21. Pseudo-Types
Prev UpChapter 8. Data TypesHome Next

8.21. Pseudo-Types#

ThePostgreSQL type system contains a number of special-purpose entries that are collectively calledpseudo-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 specificSQL data type.Table 8.27 lists the existing pseudo-types.

Table 8.27. Pseudo-Types

NameDescription
anyIndicates that a function accepts any input data type.
anyelementIndicates that a function accepts any data type (seeSection 36.2.5).
anyarrayIndicates that a function accepts any array data type (seeSection 36.2.5).
anynonarrayIndicates that a function accepts any non-array data type (seeSection 36.2.5).
anyenumIndicates that a function accepts any enum data type (seeSection 36.2.5 andSection 8.7).
anyrangeIndicates that a function accepts any range data type (seeSection 36.2.5 andSection 8.17).
anymultirangeIndicates that a function accepts any multirange data type (seeSection 36.2.5 andSection 8.17).
anycompatibleIndicates that a function accepts any data type, with automatic promotion of multiple arguments to a common data type (seeSection 36.2.5).
anycompatiblearrayIndicates that a function accepts any array data type, with automatic promotion of multiple arguments to a common data type (seeSection 36.2.5).
anycompatiblenonarrayIndicates that a function accepts any non-array data type, with automatic promotion of multiple arguments to a common data type (seeSection 36.2.5).
anycompatiblerangeIndicates that a function accepts any range data type, with automatic promotion of multiple arguments to a common data type (seeSection 36.2.5 andSection 8.17).
anycompatiblemultirangeIndicates that a function accepts any multirange data type, with automatic promotion of multiple arguments to a common data type (seeSection 36.2.5 andSection 8.17).
cstringIndicates that a function accepts or returns a null-terminated C string.
internalIndicates that a function accepts or returns a server-internal data type.
language_handlerA procedural language call handler is declared to returnlanguage_handler.
fdw_handlerA foreign-data wrapper handler is declared to returnfdw_handler.
table_am_handlerA table access method handler is declared to returntable_am_handler.
index_am_handlerAn index access method handler is declared to returnindex_am_handler.
tsm_handlerA tablesample method handler is declared to returntsm_handler.
recordIdentifies a function taking or returning an unspecified row type.
triggerA trigger function is declared to returntrigger.
event_triggerAn event trigger function is declared to returnevent_trigger.
pg_ddl_commandIdentifies a representation of DDL commands that is available to event triggers.
voidIndicates that a function returns no value.
unknownIdentifies a not-yet-resolved type, e.g., of an undecorated string literal.

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.

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 onlyvoid andrecord as a result type (plustrigger orevent_trigger 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 inSection 36.2.5.

Theinternal 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 anSQL query. If a function has at least oneinternal-type argument then it cannot be called fromSQL. 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 returninternal unless it has at least oneinternal argument.


Prev Up Next
8.20. pg_lsn Type Home Chapter 9. Functions and Operators
pdfepub
Go to PostgreSQL 17
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp