3 * Description: This file contains defines and declarations that are related to
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__ */
18 #define EXTERN_C extern "C"
26 #define WIN32_LEAN_AND_MEAN
30 #include <stdio.h> /* for FILE* pointers: see GLOBAL_VALUES */
31 #ifdef POSIX_MULTITHREAD_SUPPORT
38 #ifndef _MEMORY_DEBUG_
41 #define _CRTDBG_MAP_ALLOC
43 #endif /* _MEMORY_DEBUG_ */
48 //#include <delayimp.h>
50 /* Must come before sql.h */
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 */
63 #undef WIN_MULTITHREAD_SUPPORT
65 #if defined(WIN32) || defined(WITH_UNIXODBC) || defined(WITH_IODBC)
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
77 #define SetWindowLongPtr(hdlg, DWLP_USER, lParam) SetWindowLong(hdlg, DWLP_USER, lParam)
78 #define GetWindowLongPtr(hdlg, DWLP_USER) GetWindowLong(hdlg, DWLP_USER);
88 #elif defined(WITH_UNIXODBC)
90 #elif defined(WITH_IODBC)
91 #include <iodbcinst.h>
101 #define UInt4 unsigned int
103 #define UInt2 unsigned short
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 */
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 */
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 */
124 #define FORMAT_SIZE_T "%xu" /* size_t */
125 #define FORMAT_SSIZE_T "%xd" /* 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 */
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 */
149 #define FORMAT_LEN "%ld" /* SQLLEN */
150 #define FORMAT_ULEN "%lu" /* SQLULEN */
151 #endif /* WITH_UNIXODBC */
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 */
159 #define CAST_PTR(type, ptr) (type)((LONG_PTR)(ptr))
160 #define CAST_UPTR(type, ptr) (type)((ULONG_PTR)(ptr))
162 #define SQL_IS_LEN (-1000)
163 #endif /* SQL_IS_LEN */
166 #if !defined(WITH_UNIXODBC) && !defined(WITH_IODBC)
167 typedef float SFLOAT
;
168 typedef double SDOUBLE
;
169 #endif /* WITH_UNIXODBC */
173 #endif /* CALLBACK */
177 #define stricmp strcasecmp
178 #define strnicmp strncasecmp
183 #define FALSE (BOOL)0
186 #define snprintf _snprintf
187 #define strdup _strdup
188 #define strnicmp _strnicmp
189 #define stricmp _stricmp
190 #define vsnprintf _vsnprintf
193 #ifndef SQL_ATTR_APP_ROW_DESC
194 #define SQL_ATTR_APP_ROW_DESC 10010
196 #ifndef SQL_ATTR_APP_PARAM_DESC
197 #define SQL_ATTR_APP_PARAM_DESC 10011
199 #ifndef SQL_ATTR_IMP_ROW_DESC
200 #define SQL_ATTR_IMP_ROW_DESC 10012
202 #ifndef SQL_ATTR_IMP_PARAM_DESC
203 #define SQL_ATTR_IMP_PARAM_DESC 10013
208 #define DRIVERNAME "Versaplex ODBC"
209 #define DRIVER_ODBC_VER "03.51"
210 #define DBMS_NAME "Versaplex"
213 #define DRIVER_FILE_NAME "VXODBC.DLL"
215 #define DRIVER_FILE_NAME "vxodbc.so"
218 #define NULL_CATALOG_NAME ""
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'
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
245 #define MAX_CONNECTIONS 128 /* conns per environment
247 #define MAX_FIELDS 512
249 #define VARHDRSZ sizeof(Int4)
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
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"
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 ..) */
287 #define PATH_MAX 1024
290 #define MAX_ROW_SIZE 0 /* Unlimited rowsize with the
292 #define MAX_STATEMENT_LEN 0 /* Unlimited statement size with
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 */
304 #define PG74REJECTED "reject7.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++
333 typedef struct StatementOptions_
338 SQLUINTEGER cursor_type
;
339 SQLUINTEGER scroll_concurrency
;
340 SQLUINTEGER retrieve_data
;
341 SQLUINTEGER use_bookmarks
;
343 SQLUINTEGER metadata_id
;
346 /* Used to pass extra query info to send_query */
347 typedef struct QueryInfo_
350 QResultClass
*result_in
;
354 /* Used to save the error information */
362 SQLLEN diag_row_count
;
363 char __error_message
[1];
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
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 */
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
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
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);
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_ */
451 CSTR NULL_STRING
= "";
452 CSTR PRINT_NULL
= "(null)";
453 CSTR OID_NAME
= "oid";
454 #endif /* __PSQLODBC_H__ */