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.23 1999/06/10 22:59:22 momjian 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
31 * 5) random CSIGNBIT, MAXPGPATH, STATUS macros
33 * ----------------------------------------------------------------
38 #include "postgres_ext.h"
43 #include "utils/elog.h"
44 #include "utils/palloc.h"
46 /* ----------------------------------------------------------------
47 * Section 1: simple type definitions
48 * ----------------------------------------------------------------
54 typedef double float8;
59 #define OidIsValid(objectId) ((bool) (objectId != InvalidOid))
61 /* unfortunately, both regproc and RegProcedure are used */
63 typedef Oid RegProcedure;
65 /* ptr to func returning (char *) */
66 #if defined(__mc68000__) && defined(__ELF__)
67 /* The m68k SVR4 ABI defines that pointers are returned in %a0 instead of
68 * %d0. So if a function pointer is declared to return a pointer, the
69 * compiler may look only into %a0, but if the called function was declared
70 * to return return an integer type, it puts its value only into %d0. So the
71 * caller doesn't pink up the correct return value. The solution is to
72 * declare the function pointer to return int, so the compiler picks up the
73 * return value from %d0. (Functions returning pointers put their value
74 * *additionally* into %d0 for compability.) The price is that there are
75 * some warnings about int->pointer conversions...
77 typedef int32 ((*func_ptr) ());
79 typedef char *((*func_ptr) ());
83 #define RegProcedureIsValid(p) OidIsValid(p)
85 /* ----------------------------------------------------------------
86 * Section 2: variable length and array types
87 * ----------------------------------------------------------------
99 #define VARSIZE(PTR) (((struct varlena *)(PTR))->vl_len)
100 #define VARDATA(PTR) (((struct varlena *)(PTR))->vl_dat)
101 #define VARHDRSZ sizeof(int32)
103 typedef struct varlena bytea;
104 typedef struct varlena text;
106 typedef int2 int28[8];
109 /* We want NameData to have length NAMEDATALEN and int alignment,
110 * because that's how the data type 'name' is defined in pg_type.
111 * Use a union to make sure the compiler agrees.
113 typedef union nameData
115 char data[NAMEDATALEN];
118 typedef NameData *Name;
120 /* ----------------------------------------------------------------
121 * Section 3: TransactionId and CommandId
122 * ----------------------------------------------------------------
125 typedef uint32 TransactionId;
127 #define InvalidTransactionId 0
128 typedef uint32 CommandId;
130 #define FirstCommandId 0
132 /* ----------------------------------------------------------------
133 * Section 4: genbki macros used by the
134 * catalog/pg_xxx.h files
135 * ----------------------------------------------------------------
138 typedef struct CppConcat(FormData_,x)
140 #define DATA(x) extern int errno
141 #define DESCR(x) extern int errno
142 #define DECLARE_INDEX(x) extern int errno
144 #define BUILD_INDICES
150 /* ----------------------------------------------------------------
151 * Section 5: random stuff
152 * CSIGNBIT, MAXPGPATH, STATUS...
153 * ----------------------------------------------------------------
156 /* msb for int/unsigned */
157 #define ISIGNBIT (0x80000000)
158 #define WSIGNBIT (0x8000)
161 #define CSIGNBIT (0x80)
164 * global variables which should probably go someplace else.
167 #define MAXPGPATH 128
168 #define MAX_QUERY_SIZE (BLCKSZ*2)
170 #define STATUS_OK (0)
171 #define STATUS_ERROR (-1)
172 #define STATUS_NOT_FOUND (-2)
173 #define STATUS_INVALID (-3)
174 #define STATUS_UNCATALOGUED (-4)
175 #define STATUS_REPLACED (-5)
176 #define STATUS_NOT_DONE (-6)
177 #define STATUS_BAD_PACKET (-7)
178 #define STATUS_FOUND (1)
181 * Cyrillic on the fly charsets recode
187 #endif /* CYR_RECODE */
189 #endif /* POSTGRES_H */