1 /*-------------------------------------------------------------------------
4 * definition of the system "type" relation (pg_type)
5 * along with the relation's initial contents.
8 * Copyright (c) 1994, Regents of the University of California
10 * $Id: pg_type.h,v 1.63 1999/07/09 03:28:52 momjian Exp $
13 * the genbki.sh script reads this file and generates .bki
14 * information from the DATA() statements.
16 *-------------------------------------------------------------------------
21 #include <utils/rel.h>
24 * postgres.h contains the system type definitions and the
25 * CATALOG(), BOOTSTRAP and DATA() sugar words so this file
26 * can be read by both genbki.sh and the C compiler.
31 * pg_type definition. cpp turns this into
32 * typedef struct FormData_pg_type
34 * Some of the values in a pg_type instance are copied into
35 * pg_attribute instances. Some parts of Postgres use the pg_type copy,
36 * while others use the pg_attribute copy, so they must match.
37 * See struct FormData_pg_attribute for details.
40 CATALOG(pg_type) BOOTSTRAP
47 * typlen is the number of bytes we use to represent a value of this
48 * type, e.g. 4 for an int4. But for a variable length type, typlen
55 * typbyval determines whether internal Postgres routines pass a value
56 * of this type by value or by reference. Only char, short, and int-
57 * equivalent items can be passed by value, so if the type is not 1,
58 * 2, or 4 bytes long, Postgres does not have the option of passing by
59 * value and so typbyval had better be FALSE. Variable-length types
60 * are always passed by reference. Note that typbyval can be false
61 * even if the length would allow pass-by-value; this is currently
62 * true for type float4, for example.
67 * typtype is 'b' for a basic type and 'c' for a catalog type (ie a
68 * class). If typtype is 'c', typrelid is the OID of the class' entry
69 * in pg_class. (Why do we need an entry in pg_type for classes,
74 Oid typrelid; /* 0 if not a class type */
78 * typelem is 0 if this is not an array type. If this is an array
79 * type, typelem is the OID of the type of the elements of the array
80 * (it identifies another row in Table pg_type).
89 * typalign is the alignment required when storing a value of this
90 * type. It applies to storage on disk as well as most
91 * representations of the value inside Postgres. When multiple values
92 * are stored consecutively, such as in the representation of a
93 * complete row on disk, padding is inserted before a datum of this
94 * type so that it begins on the specified boundary. The alignment
95 * reference is the beginning of the first datum in the sequence.
97 * 'c' = CHAR alignment, ie no alignment needed.
98 * 's' = SHORT alignment (2 bytes on most machines).
99 * 'i' = INT alignment (4 bytes on most machines).
100 * 'd' = DOUBLE alignment (8 bytes on many machines, but by no means all).
102 * See include/utils/memutils.h for the macros that compute these
103 * alignment requirements.
105 * NOTE: for types used in system tables, it is critical that the
106 * size and alignment defined in pg_type agree with the way that the
107 * compiler will lay out the field in a struct representing a table row.
110 text typdefault; /* VARIABLE LENGTH FIELD */
114 * Form_pg_type corresponds to a pointer to a row with
115 * the format of pg_type relation.
118 typedef FormData_pg_type *Form_pg_type;
121 * compiler constants for pg_type
124 #define Natts_pg_type 16
125 #define Anum_pg_type_typname 1
126 #define Anum_pg_type_typowner 2
127 #define Anum_pg_type_typlen 3
128 #define Anum_pg_type_typprtlen 4
129 #define Anum_pg_type_typbyval 5
130 #define Anum_pg_type_typtype 6
131 #define Anum_pg_type_typisdefined 7
132 #define Anum_pg_type_typdelim 8
133 #define Anum_pg_type_typrelid 9
134 #define Anum_pg_type_typelem 10
135 #define Anum_pg_type_typinput 11
136 #define Anum_pg_type_typoutput 12
137 #define Anum_pg_type_typreceive 13
138 #define Anum_pg_type_typsend 14
139 #define Anum_pg_type_typalign 15
140 #define Anum_pg_type_typdefault 16
143 * initial contents of pg_type
147 /* keep the following ordered by OID so that later changes can be made easier*/
149 /* Make sure the typlen, typbyval, and typalign values here match the initial
150 values for attlen, attbyval, and attalign in both places in pg_attribute.h
155 DATA(insert OID = 16 ( bool PGUID 1 1 t b t \054 0 0 boolin boolout boolin boolout c _null_ ));
156 DESCR("boolean 'true'/'false'");
159 DATA(insert OID = 17 ( bytea PGUID -1 -1 f b t \054 0 18 byteain byteaout byteain byteaout i _null_ ));
160 DESCR("variable length array of bytes");
163 DATA(insert OID = 18 ( char PGUID 1 1 t b t \054 0 0 charin charout charin charout c _null_ ));
164 DESCR("single character");
167 DATA(insert OID = 19 ( name PGUID NAMEDATALEN NAMEDATALEN f b t \054 0 18 namein nameout namein nameout i _null_ ));
168 DESCR("31-character type for storing system identifiers");
171 DATA(insert OID = 20 ( int8 PGUID 8 20 f b t \054 0 0 int8in int8out int8in int8out d _null_ ));
172 DESCR("eight-byte integer, >18 digits");
175 DATA(insert OID = 21 ( int2 PGUID 2 5 t b t \054 0 0 int2in int2out int2in int2out s _null_ ));
176 DESCR("two-byte integer, -32k to 32k");
179 DATA(insert OID = 22 ( int28 PGUID 16 50 f b t \054 0 21 int28in int28out int28in int28out i _null_ ));
180 DESCR("8 2-byte integers, used internally");
182 * XXX -- the implementation of int28's in postgres is a hack, and will
183 * go away someday. until that happens, there is a case (in the
184 * catalog cache management code) where we need to step gingerly
185 * over piles of int28's on the sidewalk. in order to do so, we
186 * need the OID of the int28 row from pg_type.
190 DATA(insert OID = 23 ( int4 PGUID 4 10 t b t \054 0 0 int4in int4out int4in int4out i _null_ ));
191 DESCR("4-byte integer, -2B to 2B");
194 DATA(insert OID = 24 ( regproc PGUID 4 16 t b t \054 0 0 regprocin regprocout regprocin regprocout i _null_ ));
195 DESCR("registered procedure");
196 #define REGPROCOID 24
198 DATA(insert OID = 25 ( text PGUID -1 -1 f b t \054 0 18 textin textout textin textout i _null_ ));
199 DESCR("native variable-length string");
202 DATA(insert OID = 26 ( oid PGUID 4 10 t b t \054 0 0 int4in int4out int4in int4out i _null_ ));
203 DESCR("object identifier type");
206 DATA(insert OID = 27 ( tid PGUID 6 19 f b t \054 0 0 tidin tidout tidin tidout i _null_ ));
207 DESCR("tuple identifier type, physical location of tuple");
210 DATA(insert OID = 28 ( xid PGUID 4 12 t b t \054 0 0 xidin xidout xidin xidout i _null_ ));
211 DESCR("transaction id");
214 DATA(insert OID = 29 ( cid PGUID 4 10 t b t \054 0 0 cidin cidout cidin cidout i _null_ ));
215 DESCR("command identifier type, sequence in transaction id");
218 DATA(insert OID = 30 ( oid8 PGUID 32 89 f b t \054 0 26 oid8in oid8out oid8in oid8out i _null_ ));
219 DESCR("array of 8 oid, used in system tables");
220 DATA(insert OID = 32 ( SET PGUID -1 -1 f b t \054 0 0 textin textout textin textout i _null_ ));
221 DESCR("set of tuples");
223 DATA(insert OID = 71 ( pg_type PGUID 4 4 t c t \054 1247 0 foo bar foo bar i _null_));
224 DATA(insert OID = 75 ( pg_attribute PGUID 4 4 t c t \054 1249 0 foo bar foo bar i _null_));
225 DATA(insert OID = 81 ( pg_proc PGUID 4 4 t c t \054 1255 0 foo bar foo bar i _null_));
226 DATA(insert OID = 83 ( pg_class PGUID 4 4 t c t \054 1259 0 foo bar foo bar i _null_));
227 DATA(insert OID = 86 ( pg_shadow PGUID 4 4 t c t \054 1260 0 foo bar foo bar i _null_));
228 DATA(insert OID = 87 ( pg_group PGUID 4 4 t c t \054 1261 0 foo bar foo bar i _null_));
229 DATA(insert OID = 88 ( pg_database PGUID 4 4 t c t \054 1262 0 foo bar foo bar i _null_));
230 DATA(insert OID = 90 ( pg_variable PGUID 4 4 t c t \054 1264 0 foo bar foo bar i _null_));
231 DATA(insert OID = 99 ( pg_log PGUID 4 4 t c t \054 1269 0 foo bar foo bar i _null_));
235 DATA(insert OID = 109 ( pg_attrdef PGUID 4 4 t c t \054 1215 0 foo bar foo bar i _null_));
236 DATA(insert OID = 110 ( pg_relcheck PGUID 4 4 t c t \054 1216 0 foo bar foo bar i _null_));
237 DATA(insert OID = 111 ( pg_trigger PGUID 4 4 t c t \054 1219 0 foo bar foo bar i _null_));
241 DATA(insert OID = 210 ( smgr PGUID 2 12 t b t \054 0 0 smgrin smgrout smgrin smgrout s _null_ ));
242 DESCR("storage manager");
251 DATA(insert OID = 600 ( point PGUID 16 24 f b t \054 0 701 point_in point_out point_in point_out d _null_ ));
252 DESCR("geometric point '(x, y)'");
254 DATA(insert OID = 601 ( lseg PGUID 32 48 f b t \054 0 600 lseg_in lseg_out lseg_in lseg_out d _null_ ));
255 DESCR("geometric line segment '(pt1,pt2)'");
257 DATA(insert OID = 602 ( path PGUID -1 -1 f b t \054 0 600 path_in path_out path_in path_out d _null_ ));
258 DESCR("geometric path '(pt1,...)'");
260 DATA(insert OID = 603 ( box PGUID 32 100 f b t \073 0 600 box_in box_out box_in box_out d _null_ ));
261 DESCR("geometric box '(lower left,upper right)'");
263 DATA(insert OID = 604 ( polygon PGUID -1 -1 f b t \054 0 0 poly_in poly_out poly_in poly_out d _null_ ));
264 DESCR("geometric polygon '(pt1,...)'");
265 #define POLYGONOID 604
266 DATA(insert OID = 605 ( filename PGUID 256 -1 f b t \054 0 18 filename_in filename_out filename_in filename_out i _null_ ));
267 DESCR("filename used in system tables");
269 DATA(insert OID = 628 ( line PGUID 32 48 f b t \054 0 701 line_in line_out line_in line_out d _null_ ));
270 DESCR("geometric line '(pt1,pt2)'");
272 DATA(insert OID = 629 ( _line PGUID -1 -1 f b t \054 0 628 array_in array_out array_in array_out d _null_ ));
277 DATA(insert OID = 700 ( float4 PGUID 4 12 f b t \054 0 0 float4in float4out float4in float4out i _null_ ));
278 DESCR("single-precision floating point number, 4-byte");
279 #define FLOAT4OID 700
280 DATA(insert OID = 701 ( float8 PGUID 8 24 f b t \054 0 0 float8in float8out float8in float8out d _null_ ));
281 DESCR("double-precision floating point number, 8-byte");
282 #define FLOAT8OID 701
283 DATA(insert OID = 702 ( abstime PGUID 4 20 t b t \054 0 0 nabstimein nabstimeout nabstimein nabstimeout i _null_ ));
284 DESCR("absolute, limited-range date and time (Unix system time)");
285 #define ABSTIMEOID 702
286 DATA(insert OID = 703 ( reltime PGUID 4 20 t b t \054 0 0 reltimein reltimeout reltimein reltimeout i _null_ ));
287 DESCR("relative, limited-range time interval (Unix delta time)");
288 #define RELTIMEOID 703
289 DATA(insert OID = 704 ( tinterval PGUID 12 47 f b t \054 0 0 tintervalin tintervalout tintervalin tintervalout i _null_ ));
290 DESCR("time interval '(abstime,abstime)'");
291 DATA(insert OID = 705 ( unknown PGUID -1 -1 f b t \054 0 18 textin textout textin textout i _null_ ));
293 #define UNKNOWNOID 705
295 DATA(insert OID = 718 ( circle PGUID 24 47 f b t \054 0 0 circle_in circle_out circle_in circle_out d _null_ ));
296 DESCR("geometric circle '(center,radius)'");
297 #define CIRCLEOID 718
298 DATA(insert OID = 719 ( _circle PGUID -1 -1 f b t \054 0 718 array_in array_out array_in array_out d _null_ ));
299 DATA(insert OID = 790 ( money PGUID 4 24 f b t \054 0 0 cash_in cash_out cash_in cash_out i _null_ ));
300 DESCR("money '$d,ddd.cc'");
302 DATA(insert OID = 791 ( _money PGUID -1 -1 f b t \054 0 790 array_in array_out array_in array_out i _null_ ));
305 DATA(insert OID = 829 ( macaddr PGUID 6 -1 f b t \054 0 0 macaddr_in macaddr_out macaddr_in macaddr_out i _null_ ));
306 DESCR("MAC address");
307 DATA(insert OID = 869 ( inet PGUID -1 -1 f b t \054 0 0 inet_in inet_out inet_in inet_out i _null_ ));
308 DESCR("Host address");
310 DATA(insert OID = 650 ( cidr PGUID -1 -1 f b t \054 0 0 cidr_in cidr_out cidr_in cidr_out i _null_ ));
311 DESCR("Network address");
316 /* OIDS 1000 - 1099 */
317 DATA(insert OID = 1000 ( _bool PGUID -1 -1 f b t \054 0 16 array_in array_out array_in array_out i _null_ ));
318 DATA(insert OID = 1001 ( _bytea PGUID -1 -1 f b t \054 0 17 array_in array_out array_in array_out i _null_ ));
319 DATA(insert OID = 1002 ( _char PGUID -1 -1 f b t \054 0 18 array_in array_out array_in array_out i _null_ ));
320 DATA(insert OID = 1003 ( _name PGUID -1 -1 f b t \054 0 19 array_in array_out array_in array_out i _null_ ));
321 DATA(insert OID = 1005 ( _int2 PGUID -1 -1 f b t \054 0 21 array_in array_out array_in array_out i _null_ ));
322 DATA(insert OID = 1006 ( _int28 PGUID -1 -1 f b t \054 0 22 array_in array_out array_in array_out i _null_ ));
323 DATA(insert OID = 1007 ( _int4 PGUID -1 -1 f b t \054 0 23 array_in array_out array_in array_out i _null_ ));
324 DATA(insert OID = 1008 ( _regproc PGUID -1 -1 f b t \054 0 24 array_in array_out array_in array_out i _null_ ));
325 DATA(insert OID = 1009 ( _text PGUID -1 -1 f b t \054 0 25 array_in array_out array_in array_out i _null_ ));
326 DATA(insert OID = 1028 ( _oid PGUID -1 -1 f b t \054 0 26 array_in array_out array_in array_out i _null_ ));
327 DATA(insert OID = 1010 ( _tid PGUID -1 -1 f b t \054 0 27 array_in array_out array_in array_out i _null_ ));
328 DATA(insert OID = 1011 ( _xid PGUID -1 -1 f b t \054 0 28 array_in array_out array_in array_out i _null_ ));
329 DATA(insert OID = 1012 ( _cid PGUID -1 -1 f b t \054 0 29 array_in array_out array_in array_out i _null_ ));
330 DATA(insert OID = 1013 ( _oid8 PGUID -1 -1 f b t \054 0 30 array_in array_out array_in array_out i _null_ ));
331 DATA(insert OID = 1014 ( _bpchar PGUID -1 -1 f b t \054 0 1042 array_in array_out array_in array_out i _null_ ));
332 DATA(insert OID = 1015 ( _varchar PGUID -1 -1 f b t \054 0 1043 array_in array_out array_in array_out i _null_ ));
333 DATA(insert OID = 1017 ( _point PGUID -1 -1 f b t \054 0 600 array_in array_out array_in array_out d _null_ ));
334 DATA(insert OID = 1018 ( _lseg PGUID -1 -1 f b t \054 0 601 array_in array_out array_in array_out d _null_ ));
335 DATA(insert OID = 1019 ( _path PGUID -1 -1 f b t \054 0 602 array_in array_out array_in array_out d _null_ ));
336 DATA(insert OID = 1020 ( _box PGUID -1 -1 f b t \073 0 603 array_in array_out array_in array_out d _null_ ));
337 DATA(insert OID = 1021 ( _float4 PGUID -1 -1 f b t \054 0 700 array_in array_out array_in array_out i _null_ ));
338 DATA(insert OID = 1022 ( _float8 PGUID -1 -1 f b t \054 0 701 array_in array_out array_in array_out d _null_ ));
339 DATA(insert OID = 1023 ( _abstime PGUID -1 -1 f b t \054 0 702 array_in array_out array_in array_out i _null_ ));
340 DATA(insert OID = 1024 ( _reltime PGUID -1 -1 f b t \054 0 703 array_in array_out array_in array_out i _null_ ));
341 DATA(insert OID = 1025 ( _tinterval PGUID -1 -1 f b t \054 0 704 array_in array_out array_in array_out i _null_ ));
342 DATA(insert OID = 1026 ( _filename PGUID -1 -1 f b t \054 0 605 array_in array_out array_in array_out i _null_ ));
343 DATA(insert OID = 1027 ( _polygon PGUID -1 -1 f b t \054 0 604 array_in array_out array_in array_out d _null_ ));
345 * Note: the size of aclitem needs to match sizeof(AclItem) in acl.h.
346 * Thanks to some padding, this will be 8 on all platforms.
347 * We also have an Assert to make sure.
349 #define ACLITEMSIZE 8
350 DATA(insert OID = 1033 ( aclitem PGUID 8 -1 f b t \054 0 0 aclitemin aclitemout aclitemin aclitemout i _null_ ));
351 DESCR("access control list");
352 DATA(insert OID = 1034 ( _aclitem PGUID -1 -1 f b t \054 0 1033 array_in array_out array_in array_out i _null_ ));
353 DATA(insert OID = 1040 ( _macaddr PGUID -1 -1 f b t \054 0 829 array_in array_out array_in array_out i _null_ ));
354 DATA(insert OID = 1041 ( _inet PGUID -1 -1 f b t \054 0 869 array_in array_out array_in array_out i _null_ ));
355 DATA(insert OID = 651 ( _cidr PGUID -1 -1 f b t \054 0 650 array_in array_out array_in array_out i _null_ ));
356 DATA(insert OID = 1042 ( bpchar PGUID -1 -1 f b t \054 0 18 bpcharin bpcharout bpcharin bpcharout i _null_ ));
357 DESCR("blank-padded characters, length specifed when created");
358 #define BPCHAROID 1042
359 DATA(insert OID = 1043 ( varchar PGUID -1 -1 f b t \054 0 18 varcharin varcharout varcharin varcharout i _null_ ));
360 DESCR("non-blank-padded-length string, length specified when created");
361 #define VARCHAROID 1043
363 DATA(insert OID = 1082 ( date PGUID 4 10 t b t \054 0 0 date_in date_out date_in date_out i _null_ ));
364 DESCR("ANSI SQL date 'yyyy-mm-dd'");
366 DATA(insert OID = 1083 ( time PGUID 8 16 f b t \054 0 0 time_in time_out time_in time_out d _null_ ));
367 DESCR("ANSI SQL time 'hh:mm:ss'");
370 /* OIDS 1100 - 1199 */
371 DATA(insert OID = 1182 ( _date PGUID -1 -1 f b t \054 0 1082 array_in array_out array_in array_out i _null_ ));
372 DATA(insert OID = 1183 ( _time PGUID -1 -1 f b t \054 0 1083 array_in array_out array_in array_out d _null_ ));
373 DATA(insert OID = 1184 ( datetime PGUID 8 47 f b t \054 0 0 datetime_in datetime_out datetime_in datetime_out d _null_ ));
374 DESCR("date and time 'yyyy-mm-dd hh:mm:ss'");
375 #define DATETIMEOID 1184
376 DATA(insert OID = 1185 ( _datetime PGUID -1 -1 f b t \054 0 1184 array_in array_out array_in array_out d _null_ ));
377 DATA(insert OID = 1186 ( timespan PGUID 12 47 f b t \054 0 0 timespan_in timespan_out timespan_in timespan_out d _null_ ));
378 DESCR("time interval '@ <number> <units>'");
379 #define TIMESPANOID 1186
380 DATA(insert OID = 1187 ( _timespan PGUID -1 -1 f b t \054 0 1186 array_in array_out array_in array_out d _null_ ));
382 /* OIDS 1200 - 1299 */
383 DATA(insert OID = 1296 ( timestamp PGUID 4 19 t b t \054 0 0 timestamp_in timestamp_out timestamp_in timestamp_out i _null_ ));
384 DESCR("limited-range ISO-format date and time");
385 #define TIMESTAMPOID 1296
387 /* OIDS 1700 - 1799 */
388 DATA(insert OID = 1700 ( numeric PGUID -1 -1 f b t \054 0 0 numeric_in numeric_out numeric_in numeric_out i _null_ ));
389 DESCR("arbitrary precision exact numeric data type");
390 #define NUMERICOID 1700
393 #define VARLENA_FIXED_SIZE(attr) ((attr)->atttypid == BPCHAROID && (attr)->atttypmod > 0)
396 * prototypes for functions in pg_type.c
398 extern Oid TypeGet(char *typeName, bool *defined);
399 extern Oid TypeShellMake(char *typeName);
400 extern Oid TypeCreate(char *typeName,
406 char *inputProcedure,
407 char *outputProcedure,
408 char *receiveProcedure,
410 char *elementTypeName,
411 char *defaultTypeValue,
412 bool passedByValue, char alignment);
413 extern void TypeRename(char *oldTypeName, char *newTypeName);
414 extern char *makeArrayTypeName(char *typeName);
417 #endif /* PG_TYPE_H */