~ubuntu-branches/ubuntu/lucid/psqlodbc/lucid

« back to all changes in this revision

Viewing changes to psqlodbc.h

  • Committer: Bazaar Package Importer
  • Author(s): Peter Eisentraut
  • Date: 2008-05-09 10:40:32 UTC
  • mfrom: (1.1.5 upstream) (4.1.1 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080509104032-brus47zgn7ak380w
Tags: 1:08.03.0200-1
* New upstream release
  - Disables some broken code (closes: #396218)
  - Obsoletes psqlodbc-413534.diff and most of psqlodbc-358949.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *
6
6
 * Comments:            See "notice.txt" for copyright and license information.
7
7
 *
8
 
 * $Id: psqlodbc.h,v 1.94 2006/01/26 18:44:28 luf Exp $
 
8
 * $Id: psqlodbc.h,v 1.122 2008/05/03 05:57:42 hinoue Exp $
9
9
 *
10
10
 */
11
11
 
12
12
#ifndef __PSQLODBC_H__
13
13
#define __PSQLODBC_H__
14
14
 
 
15
/* #define      __MS_REPORTS_ANSI_CHAR__ */
 
16
 
15
17
#ifndef WIN32
16
18
#include "config.h"
17
19
#else
 
20
#define WIN32_LEAN_AND_MEAN
18
21
#include <windows.h>
19
22
#endif
20
23
 
21
24
#include <stdio.h>                              /* for FILE* pointers: see GLOBAL_VALUES */
22
25
#ifdef POSIX_MULTITHREAD_SUPPORT
23
 
#define _XOPEN_SOURCE
24
26
#include <pthread.h>
25
27
#endif
26
28
#include "version.h"
27
29
 
 
30
#ifdef  WIN32
 
31
#ifdef  _DEBUG
 
32
#ifndef _MEMORY_DEBUG_
 
33
#include <stdlib.h>
 
34
#if (_MSC_VER < 1400) /* in case of VC7 or under */
 
35
#include <malloc.h>
 
36
#endif /* _MSC_VER */
 
37
#define _CRTDBG_MAP_ALLOC
 
38
#include <crtdbg.h>
 
39
#endif /* _MEMORY_DEBUG_ */
 
40
#endif /* _DEBUG */
 
41
#endif /* WIN32 */
 
42
 
 
43
#ifdef  WIN32
 
44
#include <delayimp.h>
 
45
#endif /* WIN32 */
28
46
/* Must come before sql.h */
29
47
#ifndef ODBCVER
30
 
#define ODBCVER                                         0x0300
31
 
#endif   /* ODBCVER */
 
48
#define ODBCVER                                         0x0250
 
49
#endif   /* ODBCVER_REP */
32
50
 
33
51
#define NAMEDATALEN_V72                                 32
34
52
#define NAMEDATALEN_V73                                 64
40
58
#ifndef WIN32
41
59
#undef  WIN_MULTITHREAD_SUPPORT
42
60
#endif
43
 
 
 
61
#if defined(WIN32) || defined(WITH_UNIXODBC) || defined(WITH_IODBC)
44
62
#include <sql.h>
45
63
#include <sqlext.h>
46
 
#if defined(UNICODE_SUPPORT) && !defined(WIN32)
47
 
# include <sqlucode.h>
 
64
#if defined(WIN32) && (_MSC_VER < 1300) /* in case of VC6 or under */
 
65
#define SQLLEN SQLINTEGER
 
66
#define SQLULEN SQLUINTEGER
 
67
#define SQLSETPOSIROW SQLUSMALLINT
 
68
/* VC6 bypasses 64bit mode. */
 
69
#define DWLP_USER DWL_USER
 
70
#define ULONG_PTR ULONG
 
71
#define LONG_PTR LONG
 
72
#define SetWindowLongPtr(hdlg, DWLP_USER, lParam) SetWindowLong(hdlg, DWLP_USER, lParam)
 
73
#define GetWindowLongPtr(hdlg, DWLP_USER) GetWindowLong(hdlg, DWLP_USER);
48
74
#endif
 
75
#else
 
76
#include "iodbc.h"
 
77
#include "isql.h"
 
78
#include "isqlext.h"
 
79
#endif /* WIN32 */
49
80
 
50
81
#if defined(WIN32)
51
82
#include <odbcinst.h>
54
85
#elif defined(WITH_IODBC)
55
86
#include <iodbcinst.h>
56
87
#else
57
 
#error "don't know where to get odbcinst.h"
58
 
#endif
59
 
 
 
88
#include "gpps.h"
 
89
#endif
 
90
 
 
91
#ifdef  __cplusplus
 
92
extern "C" {
 
93
#endif
 
94
 
 
95
#define Int4 int
 
96
#define UInt4 unsigned int
 
97
#define Int2 short
 
98
#define UInt2 unsigned short
 
99
typedef UInt4   OID;
 
100
 
 
101
#ifdef  WIN32
 
102
#define ssize_t SSIZE_T
 
103
#define FORMAT_SIZE_T   "%Iu"   /* size_t */
 
104
#define FORMAT_SSIZE_T  "%Id"   /* ssize_t */
 
105
#define FORMAT_INTEGER  "%ld"   /* SQLINTEGER */
 
106
#define FORMAT_UINTEGER "%lu"   /* SQLUINTEGER */
 
107
#ifdef  _WIN64
 
108
#define FORMAT_LEN      "%I64d" /* SQLLEN */
 
109
#define FORMAT_ULEN     "%I64u" /* SQLULEN */
 
110
#define FORMAT_LPTR     "%I64d" /* LONG_PTR */
 
111
#define FORMAT_ULPTR    "%I64u" /* ULONG_PTR */
 
112
#else
 
113
#define FORMAT_LEN      "%ld"   /* SQLLEN */
 
114
#define FORMAT_ULEN     "%lu"   /* SQLULEN */
 
115
#define FORMAT_LPTR     "%ld"   /* LONG_PTR */
 
116
#define FORMAT_ULPTR    "%lu"   /* ULONG_PTR */
 
117
#endif /* _WIN64 */
 
118
#else
 
119
#define FORMAT_SIZE_T   "%xu"   /* size_t */    
 
120
#define FORMAT_SSIZE_T  "%xd"   /* ssize_t */
 
121
#ifndef HAVE_SSIZE_T
 
122
typedef long    ssize_t
 
123
#endif /* HAVE_SSIZE_T */
 
124
#if (SIZEOF_VOID_P == SIZEOF_LONG)
 
125
typedef long    LONG_PTR;
 
126
typedef unsigned long   ULONG_PTR;
 
127
#define FORMAT_LPTR     "%ld"   /* LONG_PTR */
 
128
#define FORMAT_ULPTR    "%lu"   /* ULONG_PTR */
 
129
#elif defined (HAVE_LONG_LONG)
 
130
typedef long long LONG_PTR;
 
131
typedef unsigned long long ULONG_PTR;
 
132
#define FORMAT_LPTR     "%lld"  /* LONG_PTR */
 
133
#define FORMAT_ULPTR    "%llu"  /* ULONG_PTR */
 
134
#else
 
135
#error appropriate long pointer type not found 
 
136
#endif /* SIZEOF_VOID_P */
 
137
#if (SIZEOF_VOID_P == 8)
 
138
#define FORMAT_INTEGER  "%d"    /* SQLINTEGER */
 
139
#define FORMAT_UINTEGER "%u"    /* SQLUINTEGER */
 
140
#if defined(WITH_UNIXODBC) && !defined(BUILD_REAL_64_BIT_MODE)
 
141
#define FORMAT_LEN      "%d"    /* SQLLEN */
 
142
#define FORMAT_ULEN     "%u"    /* SQLULEN */
 
143
#else
 
144
#define FORMAT_LEN      "%ld"   /* SQLLEN */
 
145
#define FORMAT_ULEN     "%lu"   /* SQLULEN */
 
146
#endif /* WITH_UNIXODBC */
 
147
#else
 
148
#define FORMAT_LEN      "%ld"   /* SQLLEN */
 
149
#define FORMAT_ULEN     "%lu"   /* SQLULEN */
 
150
#define FORMAT_INTEGER  "%ld"   /* SQLINTEGER */
 
151
#define FORMAT_UINTEGER "%lu"   /* SQLUINTEGER */
 
152
#endif /* SIZEOF_VOID_P */
 
153
#endif /* WIN32 */
 
154
#define CAST_PTR(type, ptr)     (type)((LONG_PTR)(ptr))
 
155
#define CAST_UPTR(type, ptr)    (type)((ULONG_PTR)(ptr))
 
156
#ifndef SQL_IS_LEN
 
157
#define SQL_IS_LEN      (-1000)
 
158
#endif /* SQL_IS_LEN */
60
159
 
61
160
#ifndef WIN32
62
 
 
63
 
# if defined(HAVE_INTTYPES_H)
64
 
#  include <inttypes.h>
65
 
# else
66
 
#  if defined(HAVE_STDINT_H)
67
 
#   include <stdint.h>
68
 
#  endif
69
 
# endif
70
 
 
71
 
# define Int4 int32_t
72
 
# define UInt4 uint32_t
73
 
# define Int2 int16_t
74
 
# define UInt2 uint16_t
75
 
 
76
 
# if !defined(WITH_UNIXODBC) && !defined(WITH_IODBC)
 
161
#if !defined(WITH_UNIXODBC) && !defined(WITH_IODBC)
77
162
typedef float SFLOAT;
78
163
typedef double SDOUBLE;
79
 
# endif
80
 
 
81
 
# ifndef CALLBACK
82
 
#  define CALLBACK
83
 
# endif
84
 
 
85
 
#else /* WIN32 */
86
 
 
87
 
# define Int4 int
88
 
# define UInt4 unsigned int
89
 
# define Int2 short
90
 
# define UInt2 unsigned short
91
 
 
92
 
#endif
93
 
 
94
 
#ifndef FALSE
95
 
#define FALSE   (BOOL)0
96
 
#endif
97
 
#ifndef TRUE
98
 
#define TRUE    (BOOL)1
99
 
#endif
100
 
 
 
164
#endif /* WITH_UNIXODBC */
 
165
 
 
166
#ifndef CALLBACK
 
167
#define CALLBACK
 
168
#endif /* CALLBACK */
 
169
#endif /* WIN32 */
101
170
 
102
171
#ifndef WIN32
103
172
#define stricmp strcasecmp
104
173
#define strnicmp strncasecmp
 
174
#ifndef TRUE
 
175
#define TRUE    (BOOL)1
 
176
#endif /* TRUE */
 
177
#ifndef FALSE
 
178
#define FALSE   (BOOL)0
 
179
#endif /* FALSE */
105
180
#else
106
181
#define snprintf _snprintf
107
 
#endif
 
182
#ifndef strdup
 
183
#define strdup _strdup
 
184
#endif /* strdup */
 
185
#define strnicmp _strnicmp
 
186
#define stricmp _stricmp
 
187
#define vsnprintf _vsnprintf
 
188
#endif /* WIN32 */
108
189
 
109
190
#ifndef SQL_ATTR_APP_ROW_DESC
110
191
#define SQL_ATTR_APP_ROW_DESC   10010
120
201
#endif
121
202
 
122
203
/* Driver stuff */
123
 
#define DBMS_NAME                               "PostgreSQL"
 
204
 
 
205
#define DRIVERNAME                              "PostgreSQL ODBC"
 
206
#if (ODBCVER >= 0x0300)
 
207
#if (ODBCVER >= 0x0351)
 
208
#define DRIVER_ODBC_VER                         "03.51"
 
209
#else
124
210
#define DRIVER_ODBC_VER                         "03.00"
125
 
 
126
 
#ifdef  UNICODE_SUPPORT          
127
 
#define DRIVERNAME                              "PostgreSQL Unicode"     
 
211
#endif /* ODBCVER 0x0351 */
 
212
#ifndef DBMS_NAME
 
213
#ifdef  UNICODE_SUPPORT
 
214
#define DBMS_NAME                               "PostgreSQL Unicode"
128
215
#else
129
 
#define DRIVERNAME                              "PostgreSQL ANSI"
 
216
#define DBMS_NAME                               "PostgreSQL ANSI"
130
217
#endif /* UNICODE_SUPPORT */
 
218
#endif /* DBMS_NAME */
 
219
#else
 
220
#define DRIVER_ODBC_VER                         "02.50"
 
221
#define DBMS_NAME                               "PostgreSQL Legacy"
 
222
#endif   /* ODBCVER */
131
223
 
132
224
#ifdef WIN32
 
225
#if (ODBCVER >= 0x0300)
 
226
#ifdef  UNICODE_SUPPORT
 
227
#if (ODBCVER >= 0x0350)
 
228
#define DRIVER_FILE_NAME                        "PSQLODBC35W.DLL"
 
229
#else
 
230
#define DRIVER_FILE_NAME                        "PSQLODBC30W.DLL"
 
231
#endif /* ODBCVER 0x0350 */
 
232
#else
 
233
#define DRIVER_FILE_NAME                        "PSQLODBC.DLL"
 
234
#endif   /* UNICODE_SUPPORT */
 
235
#else
 
236
#define DRIVER_FILE_NAME                        "PSQLODBC25.DLL"
 
237
#endif   /* ODBCVER 0x0300 */
 
238
BOOL isMsAccess();
 
239
BOOL isMsQuery();
 
240
BOOL isSqlServr();
 
241
#else
133
242
#ifdef  UNICODE_SUPPORT
134
 
#define DRIVER_FILE_NAME                        "PSQLODBCW.DLL"
 
243
#define DRIVER_FILE_NAME                        "psqlodbcw.so"
135
244
#else
136
 
#define DRIVER_FILE_NAME                        "PSQLODBCA.DLL"
 
245
#define DRIVER_FILE_NAME                        "psqlodbca.so"
137
246
#endif
138
 
#else
139
 
#define DRIVER_FILE_NAME                        "libpsqlodbc.so"
140
247
#endif   /* WIN32 */
141
248
 
 
249
#define NULL_CATALOG_NAME                               ""
 
250
 
 
251
/* ESCAPEs */
 
252
#define ESCAPE_IN_LITERAL                               '\\'
 
253
#define BYTEA_ESCAPE_CHAR                               '\\'
 
254
#define SEARCH_PATTERN_ESCAPE                           '\\'
 
255
#define LITERAL_QUOTE                                   '\''
 
256
#define IDENTIFIER_QUOTE                                '\"'
 
257
#define DOLLAR_QUOTE                                    '$'
 
258
#define LITERAL_EXT                                     'E'
 
259
#define PG_CARRIAGE_RETURN                              '\r'
 
260
#define PG_LINEFEED                                     '\n'
 
261
 
142
262
/* Limits */
143
263
#define BLCKSZ                                          4096
144
264
#define MAXPGPATH                                       1024
145
265
 
146
 
#define MAX_MESSAGE_LEN                         65536   /* This puts a limit on
147
 
                                                         * query size but I don't */
148
 
                                                         /* see an easy way round this - DJP 24-1-2001 */
 
266
#define MAX_MESSAGE_LEN                         65536           /* This puts a limit on
 
267
                                                                                                 * query size but I don't */
 
268
 /* see an easy way round this - DJP 24-1-2001 */
149
269
#define MAX_CONNECT_STRING                      4096
150
270
#define ERROR_MSG_LENGTH                        4096
151
 
#define SQLSTATE_LENGTH                         8
152
 
#define FETCH_MAX                                       100     /* default number of rows to cache
153
 
                                                         * for declare/fetch */
 
271
#define FETCH_MAX                                       100 /* default number of rows to cache
 
272
                                                                                 * for declare/fetch */
154
273
#define TUPLE_MALLOC_INC                        100
155
 
#define SOCK_BUFFER_SIZE                        8192    /* default socket buffer
156
 
                                                         * size */
157
 
#define MAX_CONNECTIONS                         128     /* conns per environment
158
 
                                                         * (arbitrary)  */
 
274
#define SOCK_BUFFER_SIZE                        4096            /* default socket buffer
 
275
                                                                                                 * size */
 
276
#define MAX_CONNECTIONS                         128 /* conns per environment
 
277
                                                                                 * (arbitrary)  */
159
278
#define MAX_FIELDS                                      512
160
279
#define BYTELEN                                         8
161
280
#define VARHDRSZ                                        sizeof(Int4)
178
297
#define INDEX_KEYS_STORAGE_COUNT                32
179
298
 
180
299
/*      Registry length limits */
181
 
#define LARGE_REGISTRY_LEN                      4096    /* used for special cases */
182
 
#define MEDIUM_REGISTRY_LEN                     256     /* normal size for
183
 
                                                         * user,database,etc. */
 
300
#define LARGE_REGISTRY_LEN                      4096            /* used for special cases */
 
301
#define MEDIUM_REGISTRY_LEN                     256 /* normal size for
 
302
                                                                                 * user,database,etc. */
184
303
#define SMALL_REGISTRY_LEN                      10      /* for 1/0 settings */
185
304
 
186
305
 
187
306
/*      These prefixes denote system tables */
188
307
#define POSTGRES_SYS_PREFIX                     "pg_"
189
 
#define KEYS_TABLE                              "dd_fkey"
 
308
#define KEYS_TABLE                                      "dd_fkey"
190
309
 
191
310
/*      Info limits */
192
311
#define MAX_INFO_STRING                         128
193
312
#define MAX_KEYPARTS                            20
194
 
#define MAX_KEYLEN                              512             /* max key of the form
195
 
                                                                 * "date+outlet+invoice" */
196
 
#define MAX_ROW_SIZE                            0               /* Unlimited rowsize with the
197
 
                                                                 * Tuple Toaster */
198
 
#define MAX_STATEMENT_LEN                       0               /* Unlimited statement size with
199
 
                                                                 * 7.0 */
 
313
#define MAX_KEYLEN                              512     /* max key of the form
 
314
 
 
315
                                                                                 * "date+outlet+invoice" */
 
316
/* POSIX defines a PATH_MAX.( wondows is _MAX_PATH ..) */
 
317
#ifndef PATH_MAX
 
318
#ifdef _MAX_PATH
 
319
#define PATH_MAX        _MAX_PATH
 
320
#else
 
321
#define PATH_MAX       1024
 
322
#endif /* _MAX_PATH */
 
323
#endif /* PATH_MAX */
 
324
 
 
325
#define MAX_ROW_SIZE                            0       /* Unlimited rowsize with the
 
326
                                                                                 * Tuple Toaster */
 
327
#define MAX_STATEMENT_LEN                       0       /* Unlimited statement size with
 
328
                                                                                 * 7.0 */
200
329
 
201
330
/* Previously, numerous query strings were defined of length MAX_STATEMENT_LEN */
202
331
/* Now that's 0, lets use this instead. DJP 24-1-2001 */
203
332
#define STD_STATEMENT_LEN                       MAX_MESSAGE_LEN
204
333
 
 
334
#define PG62                                            "6.2"           /* "Protocol" key setting
 
335
                                                                                                 * to force Postgres 6.2 */
 
336
#define PG63                                            "6.3"           /* "Protocol" key setting
 
337
                                                                                                 * to force postgres 6.3 */
 
338
#define PG64                                            "6.4"
 
339
#define PG74REJECTED                                    "reject7.4"
 
340
#define PG74                                            "7.4"
 
341
 
 
342
typedef int     (*PQFUNC)();
 
343
 
205
344
typedef struct ConnectionClass_ ConnectionClass;
206
345
typedef struct StatementClass_ StatementClass;
207
346
typedef struct QResultClass_ QResultClass;
 
347
typedef struct SocketClass_ SocketClass;
208
348
typedef struct BindInfoClass_ BindInfoClass;
209
349
typedef struct ParameterInfoClass_ ParameterInfoClass;
210
350
typedef struct ParameterImplClass_ ParameterImplClass;
211
351
typedef struct ColumnInfoClass_ ColumnInfoClass;
212
 
typedef struct TupleListClass_ TupleListClass;
213
352
typedef struct EnvironmentClass_ EnvironmentClass;
214
 
typedef struct TupleNode_ TupleNode;
215
353
typedef struct TupleField_ TupleField;
216
354
typedef struct KeySet_ KeySet;
217
355
typedef struct Rollback_ Rollback;
236
374
        char            ksqo;
237
375
        char            unique_index;
238
376
        char            onlyread;               /* readonly is reserved on Digital C++
239
 
                                                 * compiler */
 
377
                                                                 * compiler */
240
378
        char            use_declarefetch;
241
379
        char            text_as_longvarchar;
242
380
        char            unknowns_as_longvarchar;
246
384
        char            cancel_as_freestmt;
247
385
        char            extra_systable_prefixes[MEDIUM_REGISTRY_LEN];
248
386
        char            conn_settings[LARGE_REGISTRY_LEN];
 
387
        char            protocol[SMALL_REGISTRY_LEN];
249
388
} GLOBAL_VALUES;
250
389
 
251
390
typedef struct StatementOptions_
252
391
{
253
 
        int                     maxRows;
254
 
        int                     maxLength;
255
 
        int                     keyset_size;
256
 
        int                     cursor_type;
257
 
        int                     scroll_concurrency;
258
 
        int                     retrieve_data;
259
 
        int                     use_bookmarks;
 
392
        SQLLEN                  maxRows;
 
393
        SQLLEN                  maxLength;
 
394
        SQLLEN                  keyset_size;
 
395
        SQLUINTEGER             cursor_type;
 
396
        SQLUINTEGER             scroll_concurrency;
 
397
        SQLUINTEGER             retrieve_data;
 
398
        SQLUINTEGER             use_bookmarks;
260
399
        void                    *bookmark_ptr;
261
 
        int                     metadata_id;
 
400
#if (ODBCVER >= 0x0300)
 
401
        SQLUINTEGER             metadata_id;
 
402
#endif /* ODBCVER */
262
403
} StatementOptions;
263
404
 
264
405
/*      Used to pass extra query info to send_query */
265
406
typedef struct QueryInfo_
266
407
{
267
 
        int             row_size;
 
408
        SQLLEN          row_size;
268
409
        QResultClass    *result_in;
269
 
        char            *cursor;
 
410
        const char      *cursor;
270
411
} QueryInfo;
271
412
 
272
413
/*      Used to save the error information */
273
414
typedef struct
274
415
{
275
 
        SDWORD  status;
276
 
        SDWORD  errorsize;
277
 
        SWORD   recsize;
278
 
        SWORD   errorpos;
279
 
        char    sqlstate[SQLSTATE_LENGTH];
280
 
        Int4    diag_row_count;
 
416
        UInt4   status;
 
417
        Int4    errorsize;
 
418
        Int2    recsize;
 
419
        Int2    errorpos;
 
420
        char    sqlstate[8];
 
421
        SQLLEN  diag_row_count;
281
422
        char    __error_message[1];
282
423
}       PG_ErrorInfo;
283
 
 
284
424
PG_ErrorInfo    *ER_Constructor(SDWORD errornumber, const char *errormsg);
 
425
PG_ErrorInfo    *ER_Dup(const PG_ErrorInfo *from);
285
426
void ER_Destructor(PG_ErrorInfo *);
286
 
RETCODE SQL_API ER_ReturnError(PG_ErrorInfo *, SWORD, UCHAR FAR *,
287
 
                        SDWORD FAR *, UCHAR FAR *, SWORD, SWORD FAR *, UWORD);
 
427
RETCODE SQL_API ER_ReturnError(PG_ErrorInfo **, SQLSMALLINT, UCHAR FAR *,
 
428
                SQLINTEGER FAR *, UCHAR FAR *, SQLSMALLINT, SQLSMALLINT FAR *, UWORD);
288
429
 
289
430
void            logs_on_off(int cnopen, int, int);
290
431
 
291
 
#define PG_TYPE_LO_UNDEFINED            (-999)  /* hack until permanent
292
 
                                                 * type available */
293
 
#define PG_TYPE_LO_NAME                 "lo"
294
 
#define OID_ATTNUM                      (-2)    /* the attnum in pg_index
295
 
                                                 * of the oid */
 
432
#define PG_TYPE_LO_UNDEFINED                    (-999)          /* hack until permanent
 
433
                                                                                                 * type available */
 
434
#define PG_TYPE_LO_NAME                         "lo"
 
435
#define CTID_ATTNUM                             (-1)    /* the attnum of ctid */
 
436
#define OID_ATTNUM                              (-2)    /* the attnum of oid */
 
437
#define XMIN_ATTNUM                             (-3)    /* the attnum of xmin */
296
438
 
297
439
/* sizes */
298
 
#define TEXT_FIELD_SIZE                 8190    /* size of text fields
299
 
                                                 * (not including null
300
 
                                                 * term) */
301
 
#define MAX_VARCHAR_SIZE                254     /* maximum size of a varchar (not
302
 
                                                 * including null term) */
 
440
#define TEXT_FIELD_SIZE                 8190    /* size of default text fields
 
441
                                                 * (not including null term) */
 
442
#define MAX_VARCHAR_SIZE                255     /* default maximum size of
 
443
                                                 * varchar fields (not including null term) */
 
444
#define INFO_VARCHAR_SIZE               254     /* varchar field size
 
445
                                                 * used in info.c */
303
446
 
304
447
#define PG_NUMERIC_MAX_PRECISION        1000
305
448
#define PG_NUMERIC_MAX_SCALE            1000
306
449
 
307
450
#define INFO_INQUIRY_LEN                8192    /* this seems sufficiently big for
308
 
                                                 * queries used in info.c inoue
309
 
                                                 * 2001/05/17 */
 
451
                                                                                 * queries used in info.c inoue
 
452
                                                                                 * 2001/05/17 */
310
453
 
311
 
#include "misc.h"
 
454
#define LENADDR_SHIFT(x, sft)   ((x) ? (SQLLEN *)((char *)(x) + (sft)) : NULL)
312
455
 
313
456
int     initialize_global_cs(void);
314
457
#ifdef  POSIX_MULTITHREAD_SUPPORT
320
463
#ifdef  POSIX_THREADMUTEX_SUPPORT
321
464
const pthread_mutexattr_t *getMutexAttr(void);
322
465
#endif /* POSIX_THREADMUTEX_SUPPORT */
323
 
#ifdef  UNICODE_SUPPORT
 
466
#ifdef  UNICODE_SUPPORT
324
467
#define WCLEN sizeof(SQLWCHAR)
325
 
UInt4   ucs2strlen(const SQLWCHAR *ucs2str);
326
 
char    *ucs2_to_utf8(const SQLWCHAR *ucs2str, Int4 ilen, UInt4 *olen, BOOL tolower);
327
 
UInt4   utf8_to_ucs2_lf(const char * utf8str, Int4 ilen, BOOL lfconv, SQLWCHAR *ucs2str, UInt4 buflen);
 
468
SQLULEN ucs2strlen(const SQLWCHAR *ucs2str);
 
469
char    *ucs2_to_utf8(const SQLWCHAR *ucs2str, SQLLEN ilen, SQLLEN *olen, BOOL tolower);
 
470
SQLULEN utf8_to_ucs2_lf(const char * utf8str, SQLLEN ilen, BOOL lfconv, SQLWCHAR *ucs2str, SQLULEN buflen);
328
471
#define utf8_to_ucs2(utf8str, ilen, ucs2str, buflen) utf8_to_ucs2_lf(utf8str, ilen, FALSE, ucs2str, buflen)
329
472
#endif /* UNICODE_SUPPORT */
330
473
 
331
 
/*#define       _MEMORY_DEBUG_ */
 
474
 
332
475
#ifdef  _MEMORY_DEBUG_
333
476
void            *debug_alloc(size_t);
334
477
void            *debug_calloc(size_t, size_t);
335
478
void            *debug_realloc(void *, size_t);
336
479
char            *debug_strdup(const char *);
 
480
void            *debug_memcpy(void *, const void *, size_t);
 
481
void            *debug_memset(void *, int c, size_t);
 
482
char            *debug_strcpy(char *, const char *);
 
483
char            *debug_strncpy(char *, const char *, size_t);
 
484
char            *debug_strncpy_null(char *, const char *, size_t);
337
485
void            debug_free(void *);
338
486
void            debug_memory_check(void);
339
487
 
 
488
#ifdef  WIN32
 
489
#undef strdup
 
490
#endif /* WIN32 */
340
491
#define malloc  debug_alloc
341
492
#define realloc debug_realloc
342
493
#define calloc  debug_calloc
343
494
#define strdup  debug_strdup
344
495
#define free    debug_free
 
496
#define strcpy  debug_strcpy
 
497
#define strncpy debug_strncpy
 
498
/* #define strncpy_null debug_strncpy_null */
 
499
#define memcpy  debug_memcpy
 
500
#define memset  debug_memset
345
501
#endif   /* _MEMORY_DEBUG_ */
346
502
 
 
503
#ifdef  __cplusplus
 
504
}
347
505
#endif
 
506
 
 
507
#include "misc.h"
 
508
 
 
509
CSTR    NULL_STRING = "";
 
510
CSTR    PRINT_NULL = "(null)";
 
511
CSTR    OID_NAME = "oid";
 
512
#endif /* __PSQLODBC_H__ */