Server.cs never did anything at all.
[versaplex.git] / vxodbc / psqlodbc.h
blob4be195926734349a6870b12700009012bf6f9a01
1 /* File: psqlodbc.h
3 * Description: This file contains defines and declarations that are related to
4 * the entire driver.
6 * Comments: See "notice.txt" for copyright and license information.
8 * $Id: psqlodbc.h,v 1.118 2007/04/11 16:36:47 h-saito Exp $
12 #ifndef __PSQLODBC_H__
13 #define __PSQLODBC_H__
15 /* #define __MS_REPORTS_ANSI_CHAR__ */
17 #ifdef __cplusplus
18 #define EXTERN_C extern "C"
19 #else
20 #define EXTERN_C
21 #endif
23 #ifndef WIN32
24 #include "config.h"
25 #else
26 #define WIN32_LEAN_AND_MEAN
27 #include <windows.h>
28 #endif
30 #include <stdio.h> /* for FILE* pointers: see GLOBAL_VALUES */
31 #ifdef POSIX_MULTITHREAD_SUPPORT
32 #include <pthread.h>
33 #endif
34 #include "version.h"
36 #ifdef WIN32
37 #ifdef _DEBUG
38 #ifndef _MEMORY_DEBUG_
39 #include <stdlib.h>
40 #include <malloc.h>
41 #define _CRTDBG_MAP_ALLOC
42 #include <crtdbg.h>
43 #endif /* _MEMORY_DEBUG_ */
44 #endif /* _DEBUG */
45 #endif /* WIN32 */
47 #ifdef WIN32
48 //#include <delayimp.h>
49 #endif /* WIN32 */
50 /* Must come before sql.h */
51 #ifndef ODBCVER
52 #define ODBCVER 0x0351
53 #endif /* ODBCVER_REP */
55 #define NAMEDATALEN_V72 32
56 #define NAMEDATALEN_V73 64
57 #ifndef NAMESTORAGELEN
58 #define NAMESTORAGELEN 64
59 #endif /* NAMESTORAGELEN */
62 #ifndef WIN32
63 #undef WIN_MULTITHREAD_SUPPORT
64 #endif
65 #if defined(WIN32) || defined(WITH_UNIXODBC) || defined(WITH_IODBC)
66 #include <sql.h>
67 #include <sqlext.h>
68 #include <sqlucode.h>
69 #if defined(WIN32) && (_MSC_VER < 1300) /* in case of VC6 or under */
70 #define SQLLEN SQLINTEGER
71 #define SQLULEN SQLUINTEGER
72 #define SQLSETPOSIROW SQLUSMALLINT
73 /* VC6 bypasses 64bit mode. */
74 #define DWLP_USER DWL_USER
75 #define ULONG_PTR ULONG
76 #define LONG_PTR LONG
77 #define SetWindowLongPtr(hdlg, DWLP_USER, lParam) SetWindowLong(hdlg, DWLP_USER, lParam)
78 #define GetWindowLongPtr(hdlg, DWLP_USER) GetWindowLong(hdlg, DWLP_USER);
79 #endif
80 #else
81 #include "iodbc.h"
82 #include "isql.h"
83 #include "isqlext.h"
84 #endif /* WIN32 */
86 #if defined(WIN32)
87 #include <odbcinst.h>
88 #elif defined(WITH_UNIXODBC)
89 #include <odbcinst.h>
90 #elif defined(WITH_IODBC)
91 #include <iodbcinst.h>
92 #else
93 #include "gpps.h"
94 #endif
96 #ifdef __cplusplus
97 extern "C" {
98 #endif
100 #define Int4 int
101 #define UInt4 unsigned int
102 #define Int2 short
103 #define UInt2 unsigned short
104 typedef UInt4 OID;
106 #ifdef WIN32
107 #define ssize_t SSIZE_T
108 #define FORMAT_SIZE_T "%Iu" /* size_t */
109 #define FORMAT_SSIZE_T "%Id" /* ssize_t */
110 #define FORMAT_INTEGER "%ld" /* SQLINTEGER */
111 #define FORMAT_UINTEGER "%lu" /* SQLUINTEGER */
112 #ifdef _WIN64
113 #define FORMAT_LEN "%I64d" /* SQLLEN */
114 #define FORMAT_ULEN "%I64u" /* SQLULEN */
115 #define FORMAT_LPTR "%I64d" /* LONG_PTR */
116 #define FORMAT_ULPTR "%I64u" /* ULONG_PTR */
117 #else
118 #define FORMAT_LEN "%ld" /* SQLLEN */
119 #define FORMAT_ULEN "%lu" /* SQLULEN */
120 #define FORMAT_LPTR "%ld" /* LONG_PTR */
121 #define FORMAT_ULPTR "%lu" /* ULONG_PTR */
122 #endif /* _WIN64 */
123 #else
124 #define FORMAT_SIZE_T "%xu" /* size_t */
125 #define FORMAT_SSIZE_T "%xd" /* ssize_t */
126 #ifndef HAVE_SSIZE_T
127 typedef long ssize_t
128 #endif /* HAVE_SSIZE_T */
129 #if (SIZEOF_VOID_P == SIZEOF_LONG)
130 typedef long LONG_PTR;
131 typedef unsigned long ULONG_PTR;
132 #define FORMAT_LPTR "%ld" /* LONG_PTR */
133 #define FORMAT_ULPTR "%lu" /* ULONG_PTR */
134 #elif defined (HAVE_LONG_LONG)
135 typedef long long LONG_PTR;
136 typedef unsigned long long ULONG_PTR;
137 #define FORMAT_LPTR "%lld" /* LONG_PTR */
138 #define FORMAT_ULPTR "%llu" /* ULONG_PTR */
139 #else
140 #error appropriate long pointer type not found
141 #endif /* SIZEOF_VOID_P */
142 #if (SIZEOF_VOID_P == 8)
143 #define FORMAT_INTEGER "%d" /* SQLINTEGER */
144 #define FORMAT_UINTEGER "%u" /* SQLUINTEGER */
145 #if defined(WITH_UNIXODBC) && !defined(BUILD_REAL_64_BIT_MODE)
146 #define FORMAT_LEN "%d" /* SQLLEN */
147 #define FORMAT_ULEN "%u" /* SQLULEN */
148 #else
149 #define FORMAT_LEN "%ld" /* SQLLEN */
150 #define FORMAT_ULEN "%lu" /* SQLULEN */
151 #endif /* WITH_UNIXODBC */
152 #else
153 #define FORMAT_LEN "%ld" /* SQLLEN */
154 #define FORMAT_ULEN "%lu" /* SQLULEN */
155 #define FORMAT_INTEGER "%ld" /* SQLINTEGER */
156 #define FORMAT_UINTEGER "%lu" /* SQLUINTEGER */
157 #endif /* SIZEOF_VOID_P */
158 #endif /* WIN32 */
159 #define CAST_PTR(type, ptr) (type)((LONG_PTR)(ptr))
160 #define CAST_UPTR(type, ptr) (type)((ULONG_PTR)(ptr))
161 #ifndef SQL_IS_LEN
162 #define SQL_IS_LEN (-1000)
163 #endif /* SQL_IS_LEN */
165 #ifndef WIN32
166 #if !defined(WITH_UNIXODBC) && !defined(WITH_IODBC)
167 typedef float SFLOAT;
168 typedef double SDOUBLE;
169 #endif /* WITH_UNIXODBC */
171 #ifndef CALLBACK
172 #define CALLBACK
173 #endif /* CALLBACK */
174 #endif /* WIN32 */
176 #ifndef WIN32
177 #define stricmp strcasecmp
178 #define strnicmp strncasecmp
179 #ifndef TRUE
180 #define TRUE (BOOL)1
181 #endif /* TRUE */
182 #ifndef FALSE
183 #define FALSE (BOOL)0
184 #endif /* FALSE */
185 #else
186 #define snprintf _snprintf
187 #define strdup _strdup
188 #define strnicmp _strnicmp
189 #define stricmp _stricmp
190 #define vsnprintf _vsnprintf
191 #endif /* WIN32 */
193 #ifndef SQL_ATTR_APP_ROW_DESC
194 #define SQL_ATTR_APP_ROW_DESC 10010
195 #endif
196 #ifndef SQL_ATTR_APP_PARAM_DESC
197 #define SQL_ATTR_APP_PARAM_DESC 10011
198 #endif
199 #ifndef SQL_ATTR_IMP_ROW_DESC
200 #define SQL_ATTR_IMP_ROW_DESC 10012
201 #endif
202 #ifndef SQL_ATTR_IMP_PARAM_DESC
203 #define SQL_ATTR_IMP_PARAM_DESC 10013
204 #endif
206 /* Driver stuff */
208 #define DRIVERNAME "Versaplex ODBC"
209 #define DRIVER_ODBC_VER "03.51"
210 #define DBMS_NAME "Versaplex"
212 #ifdef WIN32
213 #define DRIVER_FILE_NAME "VXODBC.DLL"
214 #else
215 #define DRIVER_FILE_NAME "vxodbc.so"
216 #endif /* WIN32 */
218 #define NULL_CATALOG_NAME ""
220 /* ESCAPEs */
221 #define ESCAPE_IN_LITERAL '\\'
222 #define BYTEA_ESCAPE_CHAR '\\'
223 #define SEARCH_PATTERN_ESCAPE '\\'
224 #define LITERAL_QUOTE '\''
225 #define IDENTIFIER_QUOTE '\"'
226 #define DOLLAR_QUOTE '$'
227 #define LITERAL_EXT 'E'
228 #define PG_CARRIAGE_RETURN '\r'
229 #define PG_LINEFEED '\n'
231 /* Limits */
232 #define BLCKSZ 4096
233 #define MAXPGPATH 1024
235 #define MAX_MESSAGE_LEN 65536 /* This puts a limit on
236 * query size but I don't */
237 /* see an easy way round this - DJP 24-1-2001 */
238 #define MAX_CONNECT_STRING 4096
239 #define ERROR_MSG_LENGTH 4096
240 #define FETCH_MAX 100 /* default number of rows to cache
241 * for declare/fetch */
242 #define TUPLE_MALLOC_INC 100
243 #define SOCK_BUFFER_SIZE 4096 /* default socket buffer
244 * size */
245 #define MAX_CONNECTIONS 128 /* conns per environment
246 * (arbitrary) */
247 #define MAX_FIELDS 512
248 #define BYTELEN 8
249 #define VARHDRSZ sizeof(Int4)
251 #ifdef NAMEDATALEN
252 #define MAX_SCHEMA_LEN NAMEDATALEN
253 #define MAX_TABLE_LEN NAMEDATALEN
254 #define MAX_COLUMN_LEN NAMEDATALEN
255 #define NAME_FIELD_SIZE NAMEDATALEN /* size of name fields */
256 #if (NAMEDATALEN > NAMESTORAGELEN)
257 #undef NAMESTORAGELEN
258 #define NAMESTORAGELEN NAMEDATALEN
259 #endif
260 #endif /* NAMEDATALEN */
261 #define MAX_CURSOR_LEN 32
263 #define SCHEMA_NAME_STORAGE_LEN NAMESTORAGELEN
264 #define TABLE_NAME_STORAGE_LEN NAMESTORAGELEN
265 #define COLUMN_NAME_STORAGE_LEN NAMESTORAGELEN
266 #define INDEX_KEYS_STORAGE_COUNT 32
268 /* Registry length limits */
269 #define LARGE_REGISTRY_LEN 4096 /* used for special cases */
270 #define MEDIUM_REGISTRY_LEN 256 /* normal size for
271 * user,database,etc. */
272 #define SMALL_REGISTRY_LEN 10 /* for 1/0 settings */
275 /* These prefixes denote system tables */
276 #define POSTGRES_SYS_PREFIX "pg_"
277 #define KEYS_TABLE "dd_fkey"
279 /* Info limits */
280 #define MAX_INFO_STRING 128
281 #define MAX_KEYPARTS 20
282 #define MAX_KEYLEN 512 /* max key of the form
284 * "date+outlet+invoice" */
285 /* POSIX defines a PATH_MAX.( wondows is _MAX_PATH ..) */
286 #ifndef PATH_MAX
287 #define PATH_MAX 1024
288 #endif
290 #define MAX_ROW_SIZE 0 /* Unlimited rowsize with the
291 * Tuple Toaster */
292 #define MAX_STATEMENT_LEN 0 /* Unlimited statement size with
293 * 7.0 */
295 /* Previously, numerous query strings were defined of length MAX_STATEMENT_LEN */
296 /* Now that's 0, lets use this instead. DJP 24-1-2001 */
297 #define STD_STATEMENT_LEN MAX_MESSAGE_LEN
299 #define PG62 "6.2" /* "Protocol" key setting
300 * to force Postgres 6.2 */
301 #define PG63 "6.3" /* "Protocol" key setting
302 * to force postgres 6.3 */
303 #define PG64 "6.4"
304 #define PG74REJECTED "reject7.4"
305 #define PG74 "7.4"
307 typedef int (*PQFUNC)();
309 typedef struct ConnectionClass_ ConnectionClass;
310 typedef struct StatementClass_ StatementClass;
311 typedef struct QResultClass_ QResultClass;
312 typedef struct BindInfoClass_ BindInfoClass;
313 typedef struct ParameterInfoClass_ ParameterInfoClass;
314 typedef struct ParameterImplClass_ ParameterImplClass;
315 typedef struct ColumnInfoClass_ ColumnInfoClass;
316 typedef struct EnvironmentClass_ EnvironmentClass;
317 typedef struct TupleField_ TupleField;
318 typedef struct KeySet_ KeySet;
319 typedef struct Rollback_ Rollback;
320 typedef struct ARDFields_ ARDFields;
321 typedef struct APDFields_ APDFields;
322 typedef struct IRDFields_ IRDFields;
323 typedef struct IPDFields_ IPDFields;
325 typedef struct col_info COL_INFO;
327 typedef struct GlobalValues_
329 char onlyread; /* readonly is reserved on Digital C++
330 * compiler */
331 } GLOBAL_VALUES;
333 typedef struct StatementOptions_
335 SQLLEN maxRows;
336 SQLLEN maxLength;
337 SQLLEN keyset_size;
338 SQLUINTEGER cursor_type;
339 SQLUINTEGER scroll_concurrency;
340 SQLUINTEGER retrieve_data;
341 SQLUINTEGER use_bookmarks;
342 void *bookmark_ptr;
343 SQLUINTEGER metadata_id;
344 } StatementOptions;
346 /* Used to pass extra query info to send_query */
347 typedef struct QueryInfo_
349 SQLLEN row_size;
350 QResultClass *result_in;
351 const char *cursor;
352 } QueryInfo;
354 /* Used to save the error information */
355 typedef struct
357 UInt4 status;
358 Int4 errorsize;
359 Int2 recsize;
360 Int2 errorpos;
361 char sqlstate[8];
362 SQLLEN diag_row_count;
363 char __error_message[1];
364 } PG_ErrorInfo;
365 PG_ErrorInfo *ER_Constructor(SDWORD errornumber, const char *errormsg);
366 PG_ErrorInfo *ER_Dup(const PG_ErrorInfo *from);
367 void ER_Destructor(PG_ErrorInfo *);
368 RETCODE SQL_API ER_ReturnError(PG_ErrorInfo **, SQLSMALLINT, UCHAR FAR *,
369 SQLINTEGER FAR *, UCHAR FAR *, SQLSMALLINT, SQLSMALLINT FAR *, UWORD);
371 void logs_on_off(int cnopen, int, int);
373 #define PG_TYPE_LO_UNDEFINED (-999) /* hack until permanent
374 * type available */
375 #define PG_TYPE_LO_NAME "lo"
376 #define CTID_ATTNUM (-1) /* the attnum of ctid */
377 #define OID_ATTNUM (-2) /* the attnum of oid */
378 #define XMIN_ATTNUM (-3) /* the attnum of xmin */
380 /* sizes */
381 #define TEXT_FIELD_SIZE 8190 /* size of default text fields
382 * (not including null term) */
383 #define MAX_VARCHAR_SIZE 255 /* default maximum size of
384 * varchar fields (not including null term) */
385 #define INFO_VARCHAR_SIZE 254 /* varchar field size
386 * used in info.c */
388 #define PG_NUMERIC_MAX_PRECISION 1000
389 #define PG_NUMERIC_MAX_SCALE 1000
391 #define INFO_INQUIRY_LEN 8192 /* this seems sufficiently big for
392 * queries used in info.c inoue
393 * 2001/05/17 */
395 #define LENADDR_SHIFT(x, sft) ((x) ? (SQLLEN *)((char *)(x) + (sft)) : NULL)
397 int initialize_global_cs(void);
398 #ifdef POSIX_MULTITHREAD_SUPPORT
399 #if !defined(HAVE_ECO_THREAD_LOCKS)
400 #define POSIX_THREADMUTEX_SUPPORT
401 #endif /* HAVE_ECO_THREAD_LOCKS */
402 #endif /* POSIX_MULTITHREAD_SUPPORT */
404 #ifdef POSIX_THREADMUTEX_SUPPORT
405 const pthread_mutexattr_t *getMutexAttr(void);
406 #endif /* POSIX_THREADMUTEX_SUPPORT */
407 #ifdef UNICODE_SUPPORT
408 #define WCLEN sizeof(SQLWCHAR)
409 SQLULEN ucs2strlen(const SQLWCHAR *ucs2str);
410 char *ucs2_to_utf8(const SQLWCHAR *ucs2str, SQLLEN ilen, SQLLEN *olen, BOOL tolower);
411 SQLULEN utf8_to_ucs2_lf(const char * utf8str, SQLLEN ilen, BOOL lfconv, SQLWCHAR *ucs2str, SQLULEN buflen);
412 #define utf8_to_ucs2(utf8str, ilen, ucs2str, buflen) utf8_to_ucs2_lf(utf8str, ilen, FALSE, ucs2str, buflen)
413 #endif /* UNICODE_SUPPORT */
415 #ifdef _MEMORY_DEBUG_
416 void *debug_alloc(size_t);
417 void *debug_calloc(size_t, size_t);
418 void *debug_realloc(void *, size_t);
419 char *debug_strdup(const char *);
420 void *debug_memcpy(void *, const void *, size_t);
421 void *debug_memset(void *, int c, size_t);
422 char *debug_strcpy(char *, const char *);
423 char *debug_strncpy(char *, const char *, size_t);
424 char *debug_strncpy_null(char *, const char *, size_t);
425 void debug_free(void *);
426 void debug_memory_check(void);
428 #ifdef WIN32
429 #undef strdup
430 #undef strnicmp
431 #undef stricmp
432 #endif /* WIN32 */
433 #define malloc debug_alloc
434 #define realloc debug_realloc
435 #define calloc debug_calloc
436 #define strdup debug_strdup
437 #define free debug_free
438 #define strcpy debug_strcpy
439 #define strncpy debug_strncpy
440 /* #define strncpy_null debug_strncpy_null */
441 #define memcpy debug_memcpy
442 #define memset debug_memset
443 #endif /* _MEMORY_DEBUG_ */
445 #ifdef __cplusplus
447 #endif
449 #include "misc.h"
451 CSTR NULL_STRING = "";
452 CSTR PRINT_NULL = "(null)";
453 CSTR OID_NAME = "oid";
454 #endif /* __PSQLODBC_H__ */