]> granicus.if.org Git - postgresql/blob - src/include/postgres.h
here are some patches for 6.5.0 which I already submitted but have never
[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.22 1999/05/03 19:10:14 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 #ifndef WIN32
40 #include "config.h"
41 #endif
42 #include "c.h"
43 #include "utils/elog.h"
44 #include "utils/palloc.h"
45
46 /* ----------------------------------------------------------------
47  *                              Section 1:      simple type definitions
48  * ----------------------------------------------------------------
49  */
50
51 typedef int16 int2;
52 typedef int32 int4;
53 typedef float float4;
54 typedef double float8;
55
56 typedef int4 aclitem;
57
58 #define InvalidOid              0
59 #define OidIsValid(objectId)  ((bool) (objectId != InvalidOid))
60
61 /* unfortunately, both regproc and RegProcedure are used */
62 typedef Oid regproc;
63 typedef Oid RegProcedure;
64
65 /* ptr to func returning (char *) */
66 typedef char *((*func_ptr) ());
67
68
69 #define RegProcedureIsValid(p)  OidIsValid(p)
70
71 /* ----------------------------------------------------------------
72  *                              Section 2:      variable length and array types
73  * ----------------------------------------------------------------
74  */
75 /* ----------------
76  *              struct varlena
77  * ----------------
78  */
79 struct varlena
80 {
81         int32           vl_len;
82         char            vl_dat[1];
83 };
84
85 #define VARSIZE(PTR)    (((struct varlena *)(PTR))->vl_len)
86 #define VARDATA(PTR)    (((struct varlena *)(PTR))->vl_dat)
87 #define VARHDRSZ                sizeof(int32)
88
89 typedef struct varlena bytea;
90 typedef struct varlena text;
91
92 typedef int2 int28[8];
93 typedef Oid oid8[8];
94
95 /* We want NameData to have length NAMEDATALEN and int alignment,
96  * because that's how the data type 'name' is defined in pg_type.
97  * Use a union to make sure the compiler agrees.
98  */
99 typedef union nameData
100 {
101         char            data[NAMEDATALEN];
102         int                     alignmentDummy;
103 } NameData;
104 typedef NameData *Name;
105
106 /* ----------------------------------------------------------------
107  *                              Section 3: TransactionId and CommandId
108  * ----------------------------------------------------------------
109  */
110
111 typedef uint32 TransactionId;
112
113 #define InvalidTransactionId    0
114 typedef uint32 CommandId;
115
116 #define FirstCommandId  0
117
118 /* ----------------------------------------------------------------
119  *                              Section 4: genbki macros used by the
120  *                                                 catalog/pg_xxx.h files
121  * ----------------------------------------------------------------
122  */
123 #define CATALOG(x) \
124         typedef struct CppConcat(FormData_,x)
125
126 #define DATA(x) extern int errno
127 #define DESCR(x) extern int errno
128 #define DECLARE_INDEX(x) extern int errno
129
130 #define BUILD_INDICES
131 #define BOOTSTRAP
132
133 #define BKI_BEGIN
134 #define BKI_END
135
136 /* ----------------------------------------------------------------
137  *                              Section 5:      random stuff
138  *                                                      CSIGNBIT, MAXPGPATH, STATUS...
139  * ----------------------------------------------------------------
140  */
141
142 /* msb for int/unsigned */
143 #define ISIGNBIT (0x80000000)
144 #define WSIGNBIT (0x8000)
145
146 /* msb for char */
147 #define CSIGNBIT (0x80)
148
149 /* ----------------
150  *              global variables which should probably go someplace else.
151  * ----------------
152  */
153 #define MAXPGPATH               128
154 #define MAX_QUERY_SIZE  (BLCKSZ*2)
155
156 #define STATUS_OK                               (0)
157 #define STATUS_ERROR                    (-1)
158 #define STATUS_NOT_FOUND                (-2)
159 #define STATUS_INVALID                  (-3)
160 #define STATUS_UNCATALOGUED             (-4)
161 #define STATUS_REPLACED                 (-5)
162 #define STATUS_NOT_DONE                 (-6)
163 #define STATUS_BAD_PACKET               (-7)
164 #define STATUS_FOUND                    (1)
165
166 /* ---------------
167  * Cyrillic on the fly charsets recode
168  * ---------------
169  */
170 #ifdef CYR_RECODE
171 void            SetCharSet();
172
173 #endif   /* CYR_RECODE */
174
175 #endif   /* POSTGRES_H */