Skip to main content

Module enums

Module enums 

Source
Expand description

Enum label input and output, ordered label functions and I/O casts through the statement’s catalog.

Values carry an immutable label key; the catalog supplies the current label text, so ALTER TYPE ... RENAME VALUE never rewrites stored values. Comparisons use the key order and need no catalog access.

Structs§

EnumTypeLabel
One label of an enum type.
EnumTypeLabels
The labels of one enum type in ascending key order, which is declaration order.

Traits§

EnumLabelCatalog
Catalog access for enum label input and output, supplied by the statement’s execution context and by catalog-aware binding.

Functions§

call_applies_output_functions
Whether a built-in call converts its arguments with their types’ output functions, so enum arguments contribute their current labels. || concatenates text only when neither operand is an array; with an array operand it appends or prepends the enum value itself.
cast_to_enum
Cast a value to an enum type: identity for the same type, enum_in for unknown literals and string-category sources, and 42846 otherwise. Returns None when the target is not an enum.
contains_enum_carrier
Whether a value contains an enum carrier anywhere.
enum_endpoint
enum_first and enum_last read only the argument’s type; the returned label must be usable.
enum_function_value
Evaluate one bound enum support function. Strict operations return NULL for any NULL argument before reading the catalog.
enum_label_oid
Catalog OID of an enum value’s label, the datum PostgreSQL stores for the value.
enum_label_text
enum_out: the current label of a value.
enum_output_for_cast
Cast an enum value to a string-category type through its label; any other target has no cast.
enum_range
enum_range(lower, upper): labels from lower through upper inclusive, where a missing bound is open. A lower bound after the upper bound yields an empty array. Every returned label must be usable.
enum_value_from_text
enum_in: the label with exactly this text. Case and surrounding spaces are significant.
fold_unknown_literal
Convert an unknown literal to an enum or enum-array type with the type’s input function, as PostgreSQL does when it coerces an untyped constant during parse analysis. Returns None for any other target.
is_enum_bearing
Whether a declared type is an enum or an array whose leaf is an enum.
render_call_arguments
Render the enum carriers of an output-function call’s arguments as their labels.
render_enum_labels
Replace every enum carrier inside a value by its label text, as the output functions of containers do.
render_host_arguments
Arguments handed to host-registered functions: enum values become their labels, as procedural languages receive them through the type’s output function.