OSDN Git Service

Another pgindent run. Fixes enum indenting, and improves #endif
[pg-rex/syncrep.git] / src / interfaces / odbc / psqlodbc.h
1 /* File:                        psqlodbc.h
2  *
3  * Description:         This file contains defines and declarations that are related to
4  *                                      the entire driver.
5  *
6  * Comments:            See "notice.txt" for copyright and license information.
7  *
8  * $Id: psqlodbc.h,v 1.53 2001/10/28 06:26:14 momjian Exp $
9  *
10  */
11
12 #ifndef __PSQLODBC_H__
13 #define __PSQLODBC_H__
14
15 #ifndef WIN32
16 #include "pg_config.h"
17 #else
18 #include <windows.h>
19 #endif
20
21 #include <stdio.h>                              /* for FILE* pointers: see GLOBAL_VALUES */
22
23 /* Must come before sql.h */
24 #ifdef  ODBCVER_REP
25 #define ODBCVER                                         ODBCVER_REP
26 #else
27 #define ODBCVER                                         0x0250
28 #endif   /* ODBCVER_REP */
29
30
31 #if defined(WIN32) || defined(WITH_UNIXODBC) || defined(WITH_IODBC)
32 #include <sql.h>
33 #include <sqlext.h>
34 #else
35 #include "iodbc.h"
36 #include "isql.h"
37 #include "isqlext.h"
38 #endif
39
40 #if defined(WIN32)
41 #include <odbcinst.h>
42 #elif defined(WITH_UNIXODBC)
43 #include <odbcinst.h>
44 #elif defined(WITH_IODBC)
45 #include <iodbcinst.h>
46 #else
47 #include "gpps.h"
48 #endif
49
50 #ifndef WIN32
51 #define Int4 long int
52 #define UInt4 unsigned int
53 #define Int2 short
54 #define UInt2 unsigned short
55
56 #if !defined(WITH_UNIXODBC) && !defined(WITH_IODBC)
57 typedef float SFLOAT;
58 typedef double SDOUBLE;
59 #endif
60
61 #ifndef CALLBACK
62 #define CALLBACK
63 #endif
64
65 #else
66 #define Int4 int
67 #define UInt4 unsigned int
68 #define Int2 short
69 #define UInt2 unsigned short
70 #endif
71
72 typedef UInt4 Oid;
73
74 #ifndef WIN32
75 #define stricmp strcasecmp
76 #define strnicmp strncasecmp
77 #endif
78
79 /* Driver stuff */
80 #define DRIVER_ODBC_VER                         "02.50"
81
82 #define DRIVERNAME                                      "PostgreSQL ODBC"
83 #define DBMS_NAME                                       "PostgreSQL"
84
85 #define POSTGRESDRIVERVERSION           "07.01.0008"
86
87 #ifdef WIN32
88 #define DRIVER_FILE_NAME                        "PSQLODBC.DLL"
89 #else
90 #define DRIVER_FILE_NAME                        "libpsqlodbc.so"
91 #endif
92
93 /* Limits */
94 #ifdef WIN32
95 #define BLCKSZ                                          4096
96 #endif
97
98 #define MAX_MESSAGE_LEN                         65536           /* This puts a limit on
99                                                                                                  * query size but I don't */
100  /* see an easy way round this - DJP 24-1-2001 */
101 #define MAX_CONNECT_STRING                      4096
102 #define ERROR_MSG_LENGTH                        4096
103 #define FETCH_MAX                                       100 /* default number of rows to cache
104                                                                                  * for declare/fetch */
105 #define TUPLE_MALLOC_INC                        100
106 #define SOCK_BUFFER_SIZE                        4096            /* default socket buffer
107                                                                                                  * size */
108 #define MAX_CONNECTIONS                         128 /* conns per environment
109                                                                                  * (arbitrary)  */
110 #define MAX_FIELDS                                      512
111 #define BYTELEN                                         8
112 #define VARHDRSZ                                        sizeof(Int4)
113
114 #define MAX_TABLE_LEN                           32
115 #define MAX_COLUMN_LEN                          32
116 #define MAX_CURSOR_LEN                          32
117
118 /*      Registry length limits */
119 #define LARGE_REGISTRY_LEN                      4096            /* used for special cases */
120 #define MEDIUM_REGISTRY_LEN                     256 /* normal size for
121                                                                                  * user,database,etc. */
122 #define SMALL_REGISTRY_LEN                      10      /* for 1/0 settings */
123
124
125 /*      These prefixes denote system tables */
126 #define POSTGRES_SYS_PREFIX                     "pg_"
127 #define KEYS_TABLE                                      "dd_fkey"
128
129 /*      Info limits */
130 #define MAX_INFO_STRING                         128
131 #define MAX_KEYPARTS                            20
132 #define MAX_KEYLEN                                      512 /* max key of the form
133                                                                                  * "date+outlet+invoice" */
134 #define MAX_ROW_SIZE                            0       /* Unlimited rowsize with the
135                                                                                  * Tuple Toaster */
136 #define MAX_STATEMENT_LEN                       0       /* Unlimited statement size with
137                                                                                  * 7.0 */
138
139 /* Previously, numerous query strings were defined of length MAX_STATEMENT_LEN */
140 /* Now that's 0, lets use this instead. DJP 24-1-2001 */
141 #define STD_STATEMENT_LEN                       MAX_MESSAGE_LEN
142
143 #define PG62                                            "6.2"           /* "Protocol" key setting
144                                                                                                  * to force Postgres 6.2 */
145 #define PG63                                            "6.3"           /* "Protocol" key setting
146                                                                                                  * to force postgres 6.3 */
147 #define PG64                                            "6.4"
148
149 typedef struct ConnectionClass_ ConnectionClass;
150 typedef struct StatementClass_ StatementClass;
151 typedef struct QResultClass_ QResultClass;
152 typedef struct SocketClass_ SocketClass;
153 typedef struct BindInfoClass_ BindInfoClass;
154 typedef struct ParameterInfoClass_ ParameterInfoClass;
155 typedef struct ColumnInfoClass_ ColumnInfoClass;
156 typedef struct TupleListClass_ TupleListClass;
157 typedef struct EnvironmentClass_ EnvironmentClass;
158 typedef struct TupleNode_ TupleNode;
159 typedef struct TupleField_ TupleField;
160
161 typedef struct col_info COL_INFO;
162 typedef struct lo_arg LO_ARG;
163
164 typedef struct GlobalValues_
165 {
166         int                     fetch_max;
167         int                     socket_buffersize;
168         int                     unknown_sizes;
169         int                     max_varchar_size;
170         int                     max_longvarchar_size;
171         char            debug;
172         char            commlog;
173         char            disable_optimizer;
174         char            ksqo;
175         char            unique_index;
176         char            onlyread;               /* readonly is reserved on Digital C++
177                                                                  * compiler */
178         char            use_declarefetch;
179         char            text_as_longvarchar;
180         char            unknowns_as_longvarchar;
181         char            bools_as_char;
182         char            lie;
183         char            parse;
184         char            cancel_as_freestmt;
185         char            extra_systable_prefixes[MEDIUM_REGISTRY_LEN];
186         char            conn_settings[LARGE_REGISTRY_LEN];
187         char            protocol[SMALL_REGISTRY_LEN];
188 } GLOBAL_VALUES;
189
190 typedef struct StatementOptions_
191 {
192         int                     maxRows;
193         int                     maxLength;
194         int                     rowset_size;
195         int                     keyset_size;
196         int                     cursor_type;
197         int                     scroll_concurrency;
198         int                     retrieve_data;
199         int                     bind_size;              /* size of each structure if using Row
200                                                                  * Binding */
201         int                     use_bookmarks;
202         UInt4      *rowsFetched;
203         UInt2      *rowStatusArray;
204         void       *bookmark_ptr;
205 } StatementOptions;
206
207 /*      Used to pass extra query info to send_query */
208 typedef struct QueryInfo_
209 {
210         int                     row_size;
211         QResultClass *result_in;
212         char       *cursor;
213 } QueryInfo;
214
215 void            logs_on_off(int cnopen, int, int);
216
217 #define PG_TYPE_LO                                      (-999)          /* hack until permanent
218                                                                                                  * type available */
219 #define PG_TYPE_LO_NAME                         "lo"
220 #define OID_ATTNUM                                      (-2)            /* the attnum in pg_index
221                                                                                                  * of the oid */
222
223 /* sizes */
224 #define TEXT_FIELD_SIZE                         8190            /* size of text fields
225                                                                                                  * (not including null
226                                                                                                  * term) */
227 #define NAME_FIELD_SIZE                         32      /* size of name fields */
228 #define MAX_VARCHAR_SIZE                        254 /* maximum size of a varchar (not
229                                                                                  * including null term) */
230
231 #define PG_NUMERIC_MAX_PRECISION        1000
232 #define PG_NUMERIC_MAX_SCALE            1000
233
234 #define INFO_INQUIRY_LEN                8192    /* this seems sufficiently big for
235                                                                                  * queries used in info.c inoue
236                                                                                  * 2001/05/17 */
237
238 #include "misc.h"
239
240 #ifdef  _MEMORY_DEBUG_
241 void       *debug_alloc(size_t);
242 void       *debug_realloc(void *, size_t);
243 char       *debug_strdup(const char *);
244 void            debug_free(void *);
245 void            debug_memory_check(void);
246
247 #define malloc  debug_alloc
248 #define realloc debug_realloc
249 #define strdup  debug_strdup
250 #define free    debug_free
251 #endif   /* _MEMORY_DEBUG_ */
252
253 #endif