]> granicus.if.org Git - postgresql/blob - src/include/postgres.h
Change my-function-name-- to my_function_name, and optimizer renames.
[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.20 1999/02/13 23:20:46 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 typedef struct nameData
96 {
97         char            data[NAMEDATALEN];
98 } NameData;
99 typedef NameData *Name;
100
101 /* ----------------------------------------------------------------
102  *                              Section 3: TransactionId and CommandId
103  * ----------------------------------------------------------------
104  */
105
106 typedef uint32 TransactionId;
107
108 #define InvalidTransactionId    0
109 typedef uint32 CommandId;
110
111 #define FirstCommandId  0
112
113 /* ----------------------------------------------------------------
114  *                              Section 4: genbki macros used by the
115  *                                                 catalog/pg_xxx.h files
116  * ----------------------------------------------------------------
117  */
118 #define CATALOG(x) \
119         typedef struct CppConcat(FormData_,x)
120
121 #define DATA(x) extern int errno
122 #define DESCR(x) extern int errno
123 #define DECLARE_INDEX(x) extern int errno
124
125 #define BUILD_INDICES
126 #define BOOTSTRAP
127
128 #define BKI_BEGIN
129 #define BKI_END
130
131 /* ----------------------------------------------------------------
132  *                              Section 5:      random stuff
133  *                                                      CSIGNBIT, MAXPGPATH, STATUS...
134  * ----------------------------------------------------------------
135  */
136
137 /* msb for int/unsigned */
138 #define ISIGNBIT (0x80000000)
139 #define WSIGNBIT (0x8000)
140
141 /* msb for char */
142 #define CSIGNBIT (0x80)
143
144 /* ----------------
145  *              global variables which should probably go someplace else.
146  * ----------------
147  */
148 #define MAXPGPATH               128
149
150 #define STATUS_OK                               (0)
151 #define STATUS_ERROR                    (-1)
152 #define STATUS_NOT_FOUND                (-2)
153 #define STATUS_INVALID                  (-3)
154 #define STATUS_UNCATALOGUED             (-4)
155 #define STATUS_REPLACED                 (-5)
156 #define STATUS_NOT_DONE                 (-6)
157 #define STATUS_BAD_PACKET               (-7)
158 #define STATUS_FOUND                    (1)
159
160 /* ---------------
161  * Cyrillic on the fly charsets recode
162  * ---------------
163  */
164 #ifdef CYR_RECODE
165 void            SetCharSet();
166
167 #endif   /* CYR_RECODE */
168
169 #endif   /* POSTGRES_H */