~ubuntu-branches/ubuntu/gutsy/psqlodbc/gutsy

« back to all changes in this revision

Viewing changes to psqlodbc.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2004-05-13 10:47:36 UTC
  • Revision ID: james.westby@ubuntu.com-20040513104736-a530gmn0p3knep89
Tags: upstream-07.03.0200
ImportĀ upstreamĀ versionĀ 07.03.0200

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.78 2003/08/27 10:17:53 hinoue Exp $
 
9
 *
 
10
 */
 
11
 
 
12
#ifndef __PSQLODBC_H__
 
13
#define __PSQLODBC_H__
 
14
 
 
15
#ifndef WIN32
 
16
#include "config.h"
 
17
#else
 
18
#include <windows.h>
 
19
#endif
 
20
 
 
21
#include <stdio.h>                              /* for FILE* pointers: see GLOBAL_VALUES */
 
22
 
 
23
#include "version.h"
 
24
 
 
25
/* Must come before sql.h */
 
26
#ifndef ODBCVER
 
27
#define ODBCVER                                         0x0250
 
28
#endif   /* ODBCVER_REP */
 
29
 
 
30
#define NAMEDATALEN_V72                                 32
 
31
#define NAMEDATALEN_V73                                 64
 
32
#ifndef NAMESTORAGELEN
 
33
#define NAMESTORAGELEN                                  64
 
34
#endif   /* NAMEDATALEN */
 
35
 
 
36
 
 
37
#ifndef WIN32
 
38
#undef  WIN_MULTITHREAD_SUPPORT
 
39
#endif
 
40
#if defined(WIN32) || defined(WITH_UNIXODBC) || defined(WITH_IODBC)
 
41
#include <sql.h>
 
42
#include <sqlext.h>
 
43
#else
 
44
#include "iodbc.h"
 
45
#include "isql.h"
 
46
#include "isqlext.h"
 
47
#endif
 
48
 
 
49
#if defined(WIN32)
 
50
#include <odbcinst.h>
 
51
#elif defined(WITH_UNIXODBC)
 
52
#include <odbcinst.h>
 
53
#elif defined(WITH_IODBC)
 
54
#include <iodbcinst.h>
 
55
#else
 
56
#include "gpps.h"
 
57
#endif
 
58
 
 
59
#ifndef WIN32
 
60
#define Int4 long int
 
61
#define UInt4 unsigned int
 
62
#define Int2 short
 
63
#define UInt2 unsigned short
 
64
 
 
65
#if !defined(WITH_UNIXODBC) && !defined(WITH_IODBC)
 
66
typedef float SFLOAT;
 
67
typedef double SDOUBLE;
 
68
#endif
 
69
 
 
70
#ifndef CALLBACK
 
71
#define CALLBACK
 
72
#endif
 
73
 
 
74
#else
 
75
#define Int4 int
 
76
#define UInt4 unsigned int
 
77
#define Int2 short
 
78
#define UInt2 unsigned short
 
79
#endif
 
80
 
 
81
typedef UInt4 Oid;
 
82
 
 
83
#ifndef WIN32
 
84
#define stricmp strcasecmp
 
85
#define strnicmp strncasecmp
 
86
#else
 
87
#define snprintf _snprintf
 
88
#endif
 
89
 
 
90
/* Driver stuff */
 
91
 
 
92
#define DRIVERNAME                              "PostgreSQL ODBC"
 
93
#if (ODBCVER >= 0x0300)
 
94
#define DRIVER_ODBC_VER                         "03.00"
 
95
#ifdef  UNICODE_SUPPORT
 
96
#define DBMS_NAME                               "PostgreSQL Unicode (Beta)"
 
97
#else
 
98
#define DBMS_NAME                               "PostgreSQL"
 
99
#endif /* UNICODE_SUPPORT */
 
100
#else
 
101
#define DRIVER_ODBC_VER                         "02.50"
 
102
#define DBMS_NAME                               "PostgreSQL Legacy"
 
103
#endif   /* ODBCVER */
 
104
 
 
105
#ifdef WIN32
 
106
#if (ODBCVER >= 0x0300)
 
107
#ifdef  UNICODE_SUPPORT
 
108
#define DRIVER_FILE_NAME                        "PSQLODBC30W.DLL"
 
109
#else
 
110
#define DRIVER_FILE_NAME                        "PSQLODBC30.DLL"
 
111
#endif   /* UNICODE_SUPPORT */
 
112
#else
 
113
#define DRIVER_FILE_NAME                        "PSQLODBC.DLL"
 
114
#endif   /* ODBCVER */
 
115
#else
 
116
#define DRIVER_FILE_NAME                        "libpsqlodbc.so"
 
117
#endif   /* WIN32 */
 
118
 
 
119
/* Limits */
 
120
#define BLCKSZ                                          4096
 
121
#define MAXPGPATH                                       1024
 
122
 
 
123
#define MAX_MESSAGE_LEN                         65536           /* This puts a limit on
 
124
                                                                                                 * query size but I don't */
 
125
 /* see an easy way round this - DJP 24-1-2001 */
 
126
#define MAX_CONNECT_STRING                      4096
 
127
#define ERROR_MSG_LENGTH                        4096
 
128
#define FETCH_MAX                                       100 /* default number of rows to cache
 
129
                                                                                 * for declare/fetch */
 
130
#define TUPLE_MALLOC_INC                        100
 
131
#define SOCK_BUFFER_SIZE                        4096            /* default socket buffer
 
132
                                                                                                 * size */
 
133
#define MAX_CONNECTIONS                         128 /* conns per environment
 
134
                                                                                 * (arbitrary)  */
 
135
#define MAX_FIELDS                                      512
 
136
#define BYTELEN                                         8
 
137
#define VARHDRSZ                                        sizeof(Int4)
 
138
 
 
139
#ifdef  NAMEDATALEN
 
140
#define MAX_SCHEMA_LEN                          NAMEDATALEN
 
141
#define MAX_TABLE_LEN                           NAMEDATALEN
 
142
#define MAX_COLUMN_LEN                          NAMEDATALEN
 
143
#define NAME_FIELD_SIZE                         NAMEDATALEN /* size of name fields */
 
144
#if (NAMEDATALEN > NAMESTORAGELEN)
 
145
#undef  NAMESTORAGELEN
 
146
#define NAMESTORAGELEN  NAMEDATALEN
 
147
#endif
 
148
#endif /* NAMEDATALEN */
 
149
#define MAX_CURSOR_LEN                          32
 
150
 
 
151
#define SCHEMA_NAME_STORAGE_LEN                 NAMESTORAGELEN
 
152
#define TABLE_NAME_STORAGE_LEN                  NAMESTORAGELEN
 
153
#define COLUMN_NAME_STORAGE_LEN                 NAMESTORAGELEN
 
154
#define INDEX_KEYS_STORAGE_COUNT                32
 
155
 
 
156
/*      Registry length limits */
 
157
#define LARGE_REGISTRY_LEN                      4096            /* used for special cases */
 
158
#define MEDIUM_REGISTRY_LEN                     256 /* normal size for
 
159
                                                                                 * user,database,etc. */
 
160
#define SMALL_REGISTRY_LEN                      10      /* for 1/0 settings */
 
161
 
 
162
 
 
163
/*      These prefixes denote system tables */
 
164
#define POSTGRES_SYS_PREFIX                     "pg_"
 
165
#define KEYS_TABLE                                      "dd_fkey"
 
166
 
 
167
/*      Info limits */
 
168
#define MAX_INFO_STRING                         128
 
169
#define MAX_KEYPARTS                            20
 
170
#define MAX_KEYLEN                                      512 /* max key of the form
 
171
                                                                                 * "date+outlet+invoice" */
 
172
#define MAX_ROW_SIZE                            0       /* Unlimited rowsize with the
 
173
                                                                                 * Tuple Toaster */
 
174
#define MAX_STATEMENT_LEN                       0       /* Unlimited statement size with
 
175
                                                                                 * 7.0 */
 
176
 
 
177
/* Previously, numerous query strings were defined of length MAX_STATEMENT_LEN */
 
178
/* Now that's 0, lets use this instead. DJP 24-1-2001 */
 
179
#define STD_STATEMENT_LEN                       MAX_MESSAGE_LEN
 
180
 
 
181
#define PG62                                            "6.2"           /* "Protocol" key setting
 
182
                                                                                                 * to force Postgres 6.2 */
 
183
#define PG63                                            "6.3"           /* "Protocol" key setting
 
184
                                                                                                 * to force postgres 6.3 */
 
185
#define PG64                                            "6.4"
 
186
 
 
187
typedef struct ConnectionClass_ ConnectionClass;
 
188
typedef struct StatementClass_ StatementClass;
 
189
typedef struct QResultClass_ QResultClass;
 
190
typedef struct SocketClass_ SocketClass;
 
191
typedef struct BindInfoClass_ BindInfoClass;
 
192
typedef struct ParameterInfoClass_ ParameterInfoClass;
 
193
typedef struct ParameterImplClass_ ParameterImplClass;
 
194
typedef struct ColumnInfoClass_ ColumnInfoClass;
 
195
typedef struct TupleListClass_ TupleListClass;
 
196
typedef struct EnvironmentClass_ EnvironmentClass;
 
197
typedef struct TupleNode_ TupleNode;
 
198
typedef struct TupleField_ TupleField;
 
199
typedef struct KeySet_ KeySet;
 
200
typedef struct Rollback_ Rollback;
 
201
typedef struct ARDFields_ ARDFields;
 
202
typedef struct APDFields_ APDFields;
 
203
typedef struct IRDFields_ IRDFields;
 
204
typedef struct IPDFields_ IPDFields;
 
205
 
 
206
typedef struct col_info COL_INFO;
 
207
typedef struct lo_arg LO_ARG;
 
208
 
 
209
typedef struct GlobalValues_
 
210
{
 
211
        int                     fetch_max;
 
212
        int                     socket_buffersize;
 
213
        int                     unknown_sizes;
 
214
        int                     max_varchar_size;
 
215
        int                     max_longvarchar_size;
 
216
        char            debug;
 
217
        char            commlog;
 
218
        char            disable_optimizer;
 
219
        char            ksqo;
 
220
        char            unique_index;
 
221
        char            onlyread;               /* readonly is reserved on Digital C++
 
222
                                                                 * compiler */
 
223
        char            use_declarefetch;
 
224
        char            text_as_longvarchar;
 
225
        char            unknowns_as_longvarchar;
 
226
        char            bools_as_char;
 
227
        char            lie;
 
228
        char            parse;
 
229
        char            cancel_as_freestmt;
 
230
        char            extra_systable_prefixes[MEDIUM_REGISTRY_LEN];
 
231
        char            conn_settings[LARGE_REGISTRY_LEN];
 
232
        char            protocol[SMALL_REGISTRY_LEN];
 
233
} GLOBAL_VALUES;
 
234
 
 
235
typedef struct StatementOptions_
 
236
{
 
237
        int                     maxRows;
 
238
        int                     maxLength;
 
239
        int                     keyset_size;
 
240
        int                     cursor_type;
 
241
        int                     scroll_concurrency;
 
242
        int                     retrieve_data;
 
243
        int                     use_bookmarks;
 
244
        void                    *bookmark_ptr;
 
245
#if (ODBCVER >= 0x0300)
 
246
        int                     metadata_id;
 
247
#endif /* ODBCVER */
 
248
} StatementOptions;
 
249
 
 
250
/*      Used to pass extra query info to send_query */
 
251
typedef struct QueryInfo_
 
252
{
 
253
        int                     row_size;
 
254
        QResultClass *result_in;
 
255
        char       *cursor;
 
256
} QueryInfo;
 
257
 
 
258
void            logs_on_off(int cnopen, int, int);
 
259
 
 
260
#define PG_TYPE_LO_UNDEFINED                    (-999)          /* hack until permanent
 
261
                                                                                                 * type available */
 
262
#define PG_TYPE_LO_NAME                         "lo"
 
263
#define OID_ATTNUM                                      (-2)            /* the attnum in pg_index
 
264
                                                                                                 * of the oid */
 
265
 
 
266
/* sizes */
 
267
#define TEXT_FIELD_SIZE                         8190            /* size of text fields
 
268
                                                                                                 * (not including null
 
269
                                                                                                 * term) */
 
270
#define MAX_VARCHAR_SIZE                        254 /* maximum size of a varchar (not
 
271
                                                                                 * including null term) */
 
272
 
 
273
#define PG_NUMERIC_MAX_PRECISION        1000
 
274
#define PG_NUMERIC_MAX_SCALE            1000
 
275
 
 
276
#define INFO_INQUIRY_LEN                8192    /* this seems sufficiently big for
 
277
                                                                                 * queries used in info.c inoue
 
278
                                                                                 * 2001/05/17 */
 
279
 
 
280
#include "misc.h"
 
281
 
 
282
#ifdef  UNICODE_SUPPORT
 
283
UInt4   ucs2strlen(const SQLWCHAR *ucs2str);
 
284
char    *ucs2_to_utf8(const SQLWCHAR *ucs2str, Int4 ilen, UInt4 *olen, BOOL tolower);
 
285
UInt4   utf8_to_ucs2_lf(const char * utf8str, Int4 ilen, BOOL lfconv, SQLWCHAR *ucs2str, UInt4 buflen);
 
286
#define utf8_to_ucs2(utf8str, ilen, ucs2str, buflen) utf8_to_ucs2_lf(utf8str, ilen, FALSE, ucs2str, buflen)
 
287
#endif /* UNICODE_SUPPORT */
 
288
/*#define       _MEMORY_DEBUG_ */
 
289
#ifdef  _MEMORY_DEBUG_
 
290
void       *debug_alloc(size_t);
 
291
void       *debug_realloc(void *, size_t);
 
292
char       *debug_strdup(const char *);
 
293
void            debug_free(void *);
 
294
void            debug_memory_check(void);
 
295
 
 
296
#define malloc  debug_alloc
 
297
#define realloc debug_realloc
 
298
#define strdup  debug_strdup
 
299
#define free    debug_free
 
300
#endif   /* _MEMORY_DEBUG_ */
 
301
 
 
302
#endif