]> granicus.if.org Git - postgresql/blob - src/include/postgres.h
More config.h cleanups.
[postgresql] / src / include / postgres.h
1 /*-------------------------------------------------------------------------
2  *
3  * postgres.h
4  *        definition of (and support for) postgres system types.
5  * this file is included by almost every .c in the system
6  *
7  * Copyright (c) 1995, Regents of the University of California
8  *
9  * $Id: postgres.h,v 1.26 1999/07/17 04:12:10 momjian Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 /*
14  *       NOTES
15  *              this file will eventually contain the definitions for the
16  *              following (and perhaps other) system types:
17  *
18  *                              int2       int4           float4           float8
19  *                              Oid                regproc        RegProcedure
20  *                              aclitem
21  *                              struct varlena
22  *                              int28     oid8
23  *                              bytea      text
24  *                              NameData   Name
25  *
26  *       TABLE OF CONTENTS
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
31  *              5)              random CSIGNBIT, MAXPGPATH, STATUS macros
32  *
33  * ----------------------------------------------------------------
34  */
35 #ifndef POSTGRES_H
36 #define POSTGRES_H
37
38 #include "postgres_ext.h"
39 #include "c.h"
40 #include "utils/elog.h"
41 #include "utils/mcxt.h"
42 #include "utils/palloc.h"
43
44 /* ----------------------------------------------------------------
45  *                              Section 1:      simple type definitions
46  * ----------------------------------------------------------------
47  */
48
49 typedef int16 int2;
50 typedef int32 int4;
51 typedef float float4;
52 typedef double float8;
53
54 typedef int4 aclitem;
55
56 #define InvalidOid              0
57 #define OidIsValid(objectId)  ((bool) (objectId != InvalidOid))
58
59 /* unfortunately, both regproc and RegProcedure are used */
60 typedef Oid regproc;
61 typedef Oid RegProcedure;
62
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...
74  */
75 typedef int32 ((*func_ptr) ());
76 #else 
77 typedef char *((*func_ptr) ());
78 #endif
79
80
81 #define RegProcedureIsValid(p)  OidIsValid(p)
82
83 /* ----------------------------------------------------------------
84  *                              Section 2:      variable length and array types
85  * ----------------------------------------------------------------
86  */
87 /* ----------------
88  *              struct varlena
89  * ----------------
90  */
91 struct varlena
92 {
93         int32           vl_len;
94         char            vl_dat[1];
95 };
96
97 #define VARSIZE(PTR)    (((struct varlena *)(PTR))->vl_len)
98 #define VARDATA(PTR)    (((struct varlena *)(PTR))->vl_dat)
99 #define VARHDRSZ                sizeof(int32)
100
101 typedef struct varlena bytea;
102 typedef struct varlena text;
103
104 typedef int2 int28[8];
105 typedef Oid oid8[8];
106
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.
110  */
111 typedef union nameData
112 {
113         char            data[NAMEDATALEN];
114         int                     alignmentDummy;
115 } NameData;
116 typedef NameData *Name;
117
118 /* ----------------------------------------------------------------
119  *                              Section 3: TransactionId and CommandId
120  * ----------------------------------------------------------------
121  */
122
123 typedef uint32 TransactionId;
124
125 #define InvalidTransactionId    0
126 typedef uint32 CommandId;
127
128 #define FirstCommandId  0
129
130 /* ----------------------------------------------------------------
131  *                              Section 4: genbki macros used by the
132  *                                                 catalog/pg_xxx.h files
133  * ----------------------------------------------------------------
134  */
135 #define CATALOG(x) \
136         typedef struct CppConcat(FormData_,x)
137
138 #define DATA(x) extern int errno
139 #define DESCR(x) extern int errno
140 #define DECLARE_INDEX(x) extern int errno
141
142 #define BUILD_INDICES
143 #define BOOTSTRAP
144
145 #define BKI_BEGIN
146 #define BKI_END
147
148 /* ----------------------------------------------------------------
149  *                              Section 5:      random stuff
150  *                                                      CSIGNBIT, MAXPGPATH, STATUS...
151  * ----------------------------------------------------------------
152  */
153
154 /* msb for int/unsigned */
155 #define ISIGNBIT (0x80000000)
156 #define WSIGNBIT (0x8000)
157
158 /* msb for char */
159 #define CSIGNBIT (0x80)
160
161 /* ----------------
162  *              global variables which should probably go someplace else.
163  * ----------------
164  */
165 #define MAXPGPATH               128
166 #define MAX_QUERY_SIZE  (BLCKSZ*2)
167
168 #define STATUS_OK                               (0)
169 #define STATUS_ERROR                    (-1)
170 #define STATUS_NOT_FOUND                (-2)
171 #define STATUS_INVALID                  (-3)
172 #define STATUS_UNCATALOGUED             (-4)
173 #define STATUS_REPLACED                 (-5)
174 #define STATUS_NOT_DONE                 (-6)
175 #define STATUS_BAD_PACKET               (-7)
176 #define STATUS_FOUND                    (1)
177
178 /* ---------------
179  * Cyrillic on the fly charsets recode
180  * ---------------
181  */
182 #ifdef CYR_RECODE
183 void            SetCharSet();
184
185 #endif   /* CYR_RECODE */
186
187 #endif   /* POSTGRES_H */