1 /*-------------------------------------------------------------------------
4 * definition of (and support for) postgres system types.
5 * this file is included by almost every .c in the system
7 * Copyright (c) 1995, Regents of the University of California
9 * $Id: postgres.h,v 1.29 1999/11/04 08:01:07 inoue Exp $
11 *-------------------------------------------------------------------------
15 * this file will eventually contain the definitions for the
16 * following (and perhaps other) system types:
18 * int2 int4 float4 float8
19 * Oid regproc RegProcedure
27 * 1) simple type definitions
28 * 2) varlena and array types
29 * 3) TransactionId and CommandId
30 * 4) genbki macros used by catalog/pg_xxx.h files
33 * ----------------------------------------------------------------
38 #include "postgres_ext.h"
40 #include "utils/elog.h"
41 #include "utils/mcxt.h"
42 #include "utils/palloc.h"
44 /* ----------------------------------------------------------------
45 * Section 1: simple type definitions
46 * ----------------------------------------------------------------
52 typedef double float8;
57 #define OidIsValid(objectId) ((bool) ((objectId) != InvalidOid))
59 /* unfortunately, both regproc and RegProcedure are used */
61 typedef Oid RegProcedure;
63 /* ptr to func returning (char *) */
64 #if defined(__mc68000__) && defined(__ELF__)
65 /* The m68k SVR4 ABI defines that pointers are returned in %a0 instead of
66 * %d0. So if a function pointer is declared to return a pointer, the
67 * compiler may look only into %a0, but if the called function was declared
68 * to return return an integer type, it puts its value only into %d0. So the
69 * caller doesn't pink up the correct return value. The solution is to
70 * declare the function pointer to return int, so the compiler picks up the
71 * return value from %d0. (Functions returning pointers put their value
72 * *additionally* into %d0 for compability.) The price is that there are
73 * some warnings about int->pointer conversions...
75 typedef int32 ((*func_ptr) ());
77 typedef char *((*func_ptr) ());
81 #define RegProcedureIsValid(p) OidIsValid(p)
83 /* ----------------------------------------------------------------
84 * Section 2: variable length and array types
85 * ----------------------------------------------------------------
97 #define VARSIZE(PTR) (((struct varlena *)(PTR))->vl_len)
98 #define VARDATA(PTR) (((struct varlena *)(PTR))->vl_dat)
99 #define VARHDRSZ sizeof(int32)
101 typedef struct varlena bytea;
102 typedef struct varlena text;
104 typedef int2 int28[8];
107 /* We want NameData to have length NAMEDATALEN and int alignment,
108 * because that's how the data type 'name' is defined in pg_type.
109 * Use a union to make sure the compiler agrees.
111 typedef union nameData
113 char data[NAMEDATALEN];
116 typedef NameData *Name;
118 /* ----------------------------------------------------------------
119 * Section 3: TransactionId and CommandId
120 * ----------------------------------------------------------------
123 typedef uint32 TransactionId;
125 #define InvalidTransactionId 0
126 typedef uint32 CommandId;
128 #define FirstCommandId 0
130 /* ----------------------------------------------------------------
131 * Section 4: genbki macros used by the
132 * catalog/pg_xxx.h files
133 * ----------------------------------------------------------------
136 typedef struct CppConcat(FormData_,x)
138 #define DATA(x) extern int errno
139 #define DESCR(x) extern int errno
140 #define DECLARE_INDEX(x) extern int errno
141 #define DECLARE_UNIQUE_INDEX(x) extern int errno
143 #define BUILD_INDICES
149 /* ----------------------------------------------------------------
150 * Section 5: random stuff
151 * CSIGNBIT, STATUS...
152 * ----------------------------------------------------------------
155 /* msb for int/unsigned */
156 #define ISIGNBIT (0x80000000)
157 #define WSIGNBIT (0x8000)
160 #define CSIGNBIT (0x80)
162 #define STATUS_OK (0)
163 #define STATUS_ERROR (-1)
164 #define STATUS_NOT_FOUND (-2)
165 #define STATUS_INVALID (-3)
166 #define STATUS_UNCATALOGUED (-4)
167 #define STATUS_REPLACED (-5)
168 #define STATUS_NOT_DONE (-6)
169 #define STATUS_BAD_PACKET (-7)
170 #define STATUS_FOUND (1)
173 * Cyrillic on the fly charsets recode
177 extern void SetCharSet();
178 #endif /* CYR_RECODE */
180 #endif /* POSTGRES_H */