77 *
88 * Copyright (c) 1994, Regents of the University of California
99 *
10- * $Id: pg_type.h,v 1.55 1999/03/10 05:02:34 tgl Exp $
10+ * $Id: pg_type.h,v 1.56 1999/03/25 03:49:25 tgl Exp $
1111 *
1212 * NOTES
1313 * the genbki.sh script reads this file and generates .bki
2121#include <utils/rel.h>
2222
2323/* ----------------
24- *postgres.h contains the system typedefinintions and the
24+ *postgres.h contains the system typedefinitions and the
2525 *CATALOG(), BOOTSTRAP and DATA() sugar words so this file
2626 *can be read by both genbki.sh and the C compiler.
2727 * ----------------
@@ -53,44 +53,38 @@ CATALOG(pg_type) BOOTSTRAP
5353
5454/*
5555 * typbyval determines whether internal Postgres routines pass a value
56- * of this type by value or by reference. Postgres uses a 4 byte area
57- * for passing a field value info, so if the value is not 1, 2, or 4
58- * bytes long, Postgres does not have the option of passing by value
59- * and ignores typbyval.
60- *
61- * (I don't understand why this column exists. The above description may
62- * be an oversimplification. Also, there appear to be bugs in which
63- * Postgres doesn't ignore typbyval when it should, but I'm afraid to
64- * change them until I see proof of damage. -BRYANH 96.08).
65- *
66- * (Postgres crashes if typbyval is true, the declared length is 8, and
67- * the I/O routines are written to expect pass by reference. Note that
68- * float4 is written for pass by reference and has a declared length
69- * of 4 bytes, so it looks like pass by reference must be consistant
70- * with the declared length, and typbyval is used somewhere. - tgl
71- * 1997-03-20).
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
58+ * 1, 2, or 4 bytes long, Postgres does not have the option of passing
59+ * by value and so typbyval had better be FALSE. Variable-length types
60+ * are always passed by reference.
61+ * Note that typbyval can be false even if the length would allow
62+ * pass-by-value; this is currently true for type float4, for example.
7263 */
7364char typtype ;
65+
66+ /*
67+ * typtype is 'b' for a basic type and 'c' for a catalog type (ie a class).
68+ * If typtype is 'c', typrelid is the OID of the class' entry in pg_class.
69+ * (Why do we need an entry in pg_type for classes, anyway?)
70+ */
7471bool typisdefined ;
7572char typdelim ;
76- Oid typrelid ;
73+ Oid typrelid ;/* 0 if not a class type */
7774Oid typelem ;
7875
7976/*
80- * typelem isNULL if this is not an array type. If this is an array
77+ * typelem is0 if this is not an array type. If this is an array
8178 * type, typelem is the OID of the type of the elements of the array
8279 * (it identifies another row in Table pg_type).
83- *
84- * (Note that zero ("0") rather than _null_ is used in the declarations.
85- * - tgl 97/03/20)
8680 */
8781regproc typinput ;
8882regproc typoutput ;
8983regproc typreceive ;
9084regproc typsend ;
9185char typalign ;
9286
93- /*
87+ /* ----------------
9488 * typalign is the alignment required when storing a value of this
9589 * type. It applies to storage on disk as well as most
9690 * representations of the value inside Postgres. When multiple values
@@ -99,11 +93,18 @@ CATALOG(pg_type) BOOTSTRAP
9993 * type so that it begins on the specified boundary. The alignment
10094 * reference is the beginning of the first datum in the sequence.
10195 *
102- * 'c' = 1 byte alignment. 's' = 2 byte alignment. 'i' = 4 byte
103- * alignment. 'd' = 8 byte alignment.
96+ * 'c' = CHAR alignment, ie no alignment needed.
97+ * 's' = SHORT alignment (2 bytes on most machines).
98+ * 'i' = INT alignment (4 bytes on most machines).
99+ * 'd' = DOUBLE alignment (8 bytes on many machines, but by no means all).
100+ *
101+ * See include/utils/memutils.h for the macros that compute these
102+ * alignment requirements.
104103 *
105- * (This might actually be flexible depending on machine architecture,
106- * but I doubt it - BRYANH 96.08).
104+ * NOTE: for types used in system tables, it is critical that the
105+ * size and alignment defined in pg_type agree with the way that the
106+ * compiler will lay out the field in a struct representing a table row.
107+ * ----------------
107108 */
108109text typdefault ;/* VARIABLE LENGTH FIELD */
109110}FormData_pg_type ;
@@ -218,21 +219,21 @@ DESCR("array of 8 oid, used in system tables");
218219DATA (insert OID = 32 (SET PGUID - 1 - 1 f r t \054 0 - 1 textin textout textin textout i _null_ ));
219220DESCR ("set of tuples" );
220221
221- DATA (insert OID = 71 (pg_type PGUID - 1 - 1 t b t \054 1247 0 foo bar foo bar c _null_ ));
222- DATA (insert OID = 75 (pg_attribute PGUID - 1 - 1 t b t \054 1249 0 foo bar foo bar c _null_ ));
223- DATA (insert OID = 81 (pg_proc PGUID - 1 - 1 t b t \054 1255 0 foo bar foo bar c _null_ ));
224- DATA (insert OID = 83 (pg_class PGUID - 1 - 1 t b t \054 1259 0 foo bar foo bar c _null_ ));
225- DATA (insert OID = 86 (pg_shadow PGUID - 1 - 1 t b t \054 1260 0 foo bar foo bar c _null_ ));
226- DATA (insert OID = 87 (pg_group PGUID - 1 - 1 t b t \054 1261 0 foo bar foo bar c _null_ ));
227- DATA (insert OID = 88 (pg_database PGUID - 1 - 1 t b t \054 1262 0 foo bar foo bar c _null_ ));
228- DATA (insert OID = 90 (pg_variable PGUID - 1 - 1 t b t \054 1264 0 foo bar foo bar c _null_ ));
229- DATA (insert OID = 99 (pg_log PGUID - 1 - 1 t b t \054 1269 0 foo bar foo bar c _null_ ));
222+ DATA (insert OID = 71 (pg_type PGUID 4 4 t c t \054 1247 0 foo bar foo bar i _null_ ));
223+ DATA (insert OID = 75 (pg_attribute PGUID 4 4 t c t \054 1249 0 foo bar foo bar i _null_ ));
224+ DATA (insert OID = 81 (pg_proc PGUID 4 4 t c t \054 1255 0 foo bar foo bar i _null_ ));
225+ DATA (insert OID = 83 (pg_class PGUID 4 4 t c t \054 1259 0 foo bar foo bar i _null_ ));
226+ DATA (insert OID = 86 (pg_shadow PGUID 4 4 t c t \054 1260 0 foo bar foo bar i _null_ ));
227+ DATA (insert OID = 87 (pg_group PGUID 4 4 t c t \054 1261 0 foo bar foo bar i _null_ ));
228+ DATA (insert OID = 88 (pg_database PGUID 4 4 t c t \054 1262 0 foo bar foo bar i _null_ ));
229+ DATA (insert OID = 90 (pg_variable PGUID 4 4 t c t \054 1264 0 foo bar foo bar i _null_ ));
230+ DATA (insert OID = 99 (pg_log PGUID 4 4 t c t \054 1269 0 foo bar foo bar i _null_ ));
230231
231232/* OIDS 100 - 199 */
232233
233- DATA (insert OID = 109 (pg_attrdef PGUID - 1 - 1 t b t \054 1215 0 foo bar foo bar c _null_ ));
234- DATA (insert OID = 110 (pg_relcheck PGUID - 1 - 1 t b t \054 1216 0 foo bar foo bar c _null_ ));
235- DATA (insert OID = 111 (pg_trigger PGUID - 1 - 1 t b t \054 1219 0 foo bar foo bar c _null_ ));
234+ DATA (insert OID = 109 (pg_attrdef PGUID 4 4 t c t \054 1215 0 foo bar foo bar i _null_ ));
235+ DATA (insert OID = 110 (pg_relcheck PGUID 4 4 t c t \054 1216 0 foo bar foo bar i _null_ ));
236+ DATA (insert OID = 111 (pg_trigger PGUID 4 4 t c t \054 1219 0 foo bar foo bar i _null_ ));
236237
237238/* OIDS 200 - 299 */
238239