]> begriffs open source - ai-pg/blob - full-docs/txt/catalog-pg-type.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / catalog-pg-type.txt
1
2 52.64. pg_type #
3
4    The catalog pg_type stores information about data types. Base types and
5    enum types (scalar types) are created with CREATE TYPE, and domains
6    with CREATE DOMAIN. A composite type is automatically created for each
7    table in the database, to represent the row structure of the table. It
8    is also possible to create composite types with CREATE TYPE AS.
9
10    Table 52.64. pg_type Columns
11
12    Column Type
13
14    Description
15
16    oid oid
17
18    Row identifier
19
20    typname name
21
22    Data type name
23
24    typnamespace oid (references pg_namespace.oid)
25
26    The OID of the namespace that contains this type
27
28    typowner oid (references pg_authid.oid)
29
30    Owner of the type
31
32    typlen int2
33
34    For a fixed-size type, typlen is the number of bytes in the internal
35    representation of the type. But for a variable-length type, typlen is
36    negative. -1 indicates a “varlena” type (one that has a length word),
37    -2 indicates a null-terminated C string.
38
39    typbyval bool
40
41    typbyval determines whether internal routines pass a value of this type
42    by value or by reference. typbyval had better be false if typlen is not
43    1, 2, or 4 (or 8 on machines where Datum is 8 bytes). Variable-length
44    types are always passed by reference. Note that typbyval can be false
45    even if the length would allow pass-by-value.
46
47    typtype char
48
49    typtype is b for a base type, c for a composite type (e.g., a table's
50    row type), d for a domain, e for an enum type, p for a pseudo-type, r
51    for a range type, or m for a multirange type. See also typrelid and
52    typbasetype.
53
54    typcategory char
55
56    typcategory is an arbitrary classification of data types that is used
57    by the parser to determine which implicit casts should be “preferred”.
58    See Table 52.65.
59
60    typispreferred bool
61
62    True if the type is a preferred cast target within its typcategory
63
64    typisdefined bool
65
66    True if the type is defined, false if this is a placeholder entry for a
67    not-yet-defined type. When typisdefined is false, nothing except the
68    type name, namespace, and OID can be relied on.
69
70    typdelim char
71
72    Character that separates two values of this type when parsing array
73    input. Note that the delimiter is associated with the array element
74    data type, not the array data type.
75
76    typrelid oid (references pg_class.oid)
77
78    If this is a composite type (see typtype), then this column points to
79    the pg_class entry that defines the corresponding table. (For a
80    free-standing composite type, the pg_class entry doesn't really
81    represent a table, but it is needed anyway for the type's pg_attribute
82    entries to link to.) Zero for non-composite types.
83
84    typsubscript regproc (references pg_proc.oid)
85
86    Subscripting handler function's OID, or zero if this type doesn't
87    support subscripting. Types that are “true” array types have
88    typsubscript = array_subscript_handler, but other types may have other
89    handler functions to implement specialized subscripting behavior.
90
91    typelem oid (references pg_type.oid)
92
93    If typelem is not zero then it identifies another row in pg_type,
94    defining the type yielded by subscripting. This should be zero if
95    typsubscript is zero. However, it can be zero when typsubscript isn't
96    zero, if the handler doesn't need typelem to determine the subscripting
97    result type. Note that a typelem dependency is considered to imply
98    physical containment of the element type in this type; so DDL changes
99    on the element type might be restricted by the presence of this type.
100
101    typarray oid (references pg_type.oid)
102
103    If typarray is not zero then it identifies another row in pg_type,
104    which is the “true” array type having this type as element
105
106    typinput regproc (references pg_proc.oid)
107
108    Input conversion function (text format)
109
110    typoutput regproc (references pg_proc.oid)
111
112    Output conversion function (text format)
113
114    typreceive regproc (references pg_proc.oid)
115
116    Input conversion function (binary format), or zero if none
117
118    typsend regproc (references pg_proc.oid)
119
120    Output conversion function (binary format), or zero if none
121
122    typmodin regproc (references pg_proc.oid)
123
124    Type modifier input function, or zero if type does not support
125    modifiers
126
127    typmodout regproc (references pg_proc.oid)
128
129    Type modifier output function, or zero to use the standard format
130
131    typanalyze regproc (references pg_proc.oid)
132
133    Custom ANALYZE function, or zero to use the standard function
134
135    typalign char
136
137    typalign is the alignment required when storing a value of this type.
138    It applies to storage on disk as well as most representations of the
139    value inside PostgreSQL. When multiple values are stored consecutively,
140    such as in the representation of a complete row on disk, padding is
141    inserted before a datum of this type so that it begins on the specified
142    boundary. The alignment reference is the beginning of the first datum
143    in the sequence. Possible values are:
144      * c = char alignment, i.e., no alignment needed.
145      * s = short alignment (2 bytes on most machines).
146      * i = int alignment (4 bytes on most machines).
147      * d = double alignment (8 bytes on many machines, but by no means
148        all).
149
150    typstorage char
151
152    typstorage tells for varlena types (those with typlen = -1) if the type
153    is prepared for toasting and what the default strategy for attributes
154    of this type should be. Possible values are:
155      * p (plain): Values must always be stored plain (non-varlena types
156        always use this value).
157      * e (external): Values can be stored in a secondary “TOAST” relation
158        (if relation has one, see pg_class.reltoastrelid).
159      * m (main): Values can be compressed and stored inline.
160      * x (extended): Values can be compressed and/or moved to a secondary
161        relation.
162
163    x is the usual choice for toast-able types. Note that m values can also
164    be moved out to secondary storage, but only as a last resort (e and x
165    values are moved first).
166
167    typnotnull bool
168
169    typnotnull represents a not-null constraint on a type. Used for domains
170    only.
171
172    typbasetype oid (references pg_type.oid)
173
174    If this is a domain (see typtype), then typbasetype identifies the type
175    that this one is based on. Zero if this type is not a domain.
176
177    typtypmod int4
178
179    Domains use typtypmod to record the typmod to be applied to their base
180    type (-1 if base type does not use a typmod). -1 if this type is not a
181    domain.
182
183    typndims int4
184
185    typndims is the number of array dimensions for a domain over an array
186    (that is, typbasetype is an array type). Zero for types other than
187    domains over array types.
188
189    typcollation oid (references pg_collation.oid)
190
191    typcollation specifies the collation of the type. If the type does not
192    support collations, this will be zero. A base type that supports
193    collations will have a nonzero value here, typically
194    DEFAULT_COLLATION_OID. A domain over a collatable type can have a
195    collation OID different from its base type's, if one was specified for
196    the domain.
197
198    typdefaultbin pg_node_tree
199
200    If typdefaultbin is not null, it is the nodeToString() representation
201    of a default expression for the type. This is only used for domains.
202
203    typdefault text
204
205    typdefault is null if the type has no associated default value. If
206    typdefaultbin is not null, typdefault must contain a human-readable
207    version of the default expression represented by typdefaultbin. If
208    typdefaultbin is null and typdefault is not, then typdefault is the
209    external representation of the type's default value, which can be fed
210    to the type's input converter to produce a constant.
211
212    typacl aclitem[]
213
214    Access privileges; see Section 5.8 for details
215
216 Note
217
218    For fixed-width types used in system tables, it is critical that the
219    size and alignment defined in pg_type agree with the way that the
220    compiler will lay out the column in a structure representing a table
221    row.
222
223    Table 52.65 lists the system-defined values of typcategory. Any future
224    additions to this list will also be upper-case ASCII letters. All other
225    ASCII characters are reserved for user-defined categories.
226
227    Table 52.65. typcategory Codes
228    Code       Category
229    A    Array types
230    B    Boolean types
231    C    Composite types
232    D    Date/time types
233    E    Enum types
234    G    Geometric types
235    I    Network address types
236    N    Numeric types
237    P    Pseudo-types
238    R    Range types
239    S    String types
240    T    Timespan types
241    U    User-defined types
242    V    Bit-string types
243    X    unknown type
244    Z    Internal-use types