sqlite3odbc.h
Go to the documentation of this file.
1 #ifndef _SQLITE3ODBC_H
2 #define _SQLITE3ODBC_H
3 
27 #if defined(_WIN32) || defined(_WIN64)
28 #include <windows.h>
29 #include <stdio.h>
30 #include <io.h>
31 #else
32 #include <sys/time.h>
33 #include <sys/types.h>
34 #include <stdio.h>
35 #include <unistd.h>
36 #include <errno.h>
37 #endif
38 #include <stdlib.h>
39 #if defined(HAVE_LOCALECONV) || defined(_WIN32) || defined(_WIN64)
40 #include <locale.h>
41 #endif
42 #include <stdarg.h>
43 #include <stddef.h>
44 #include <string.h>
45 #include <sql.h>
46 #include <sqlext.h>
47 #include <time.h>
48 
49 #include "sqlite3.h"
50 #ifdef HAVE_IODBC
51 #include <iodbcinst.h>
52 #endif
53 #if defined(HAVE_UNIXODBC) || defined(_WIN32) || defined(_WIN64)
54 #include <odbcinst.h>
55 #endif
56 
57 #ifndef SQL_API
58 #define SQL_API
59 #endif
60 
61 #ifndef HAVE_SQLLEN
62 #define SQLLEN SQLINTEGER
63 #endif
64 
65 #define SQLLEN_PTR SQLLEN *
66 
67 #ifndef HAVE_SQLULEN
68 #define SQLULEN SQLUINTEGER
69 #endif
70 
71 #ifndef HAVE_SQLROWCOUNT
72 #define SQLROWCOUNT SQLUINTEGER
73 #endif
74 
75 #ifndef HAVE_SQLSETPOSIROW
76 #define SQLSETPOSIROW SQLUSMALLINT
77 #endif
78 
79 #ifndef HAVE_SQLROWOFFSET
80 #define SQLROWOFFSET SQLLEN
81 #endif
82 
83 #ifndef HAVE_SQLROWSETSIZE
84 #define SQLROWSETSIZE SQLULEN
85 #endif
86 
87 struct dbc;
88 struct stmt;
89 
96 typedef struct {
97  int magic;
98  int ov3;
99  int pool;
100 #if defined(_WIN32) || defined(_WIN64)
101  CRITICAL_SECTION cs;
102 #endif
103  struct dbc *dbcs;
104 } ENV;
105 
112 typedef struct dbc {
113  int magic;
114  ENV *env;
115  struct dbc *next;
116  sqlite3 *sqlite;
117  int version;
118  char *dbname;
119  char *dsn;
120  int timeout;
121  long t0;
122  int busyint;
123  int *ov3;
124  int ov3val;
126  int intrans;
127  struct stmt *stmt;
128  int naterr;
129  char sqlstate[6];
130  SQLCHAR logmsg[1024];
131  int nowchar;
132  int dobigint;
134  int longnames;
135  int nocreat;
136  int fksupport;
137  int curtype;
140  int oemcp;
141  int jdconv;
142  int ilike;
143  struct stmt *cur_s3stmt;
145  FILE *trace;
146  char *pwd;
147  int pwdLen;
148 #ifdef USE_DLOPEN_FOR_GPPS
149  void *instlib;
150  int (*gpps)(char *, char *, char *, char *, int, char *);
151 #endif
152 #if defined(_WIN32) || defined(_WIN64)
153  CRITICAL_SECTION cs;
154  DWORD owner;
155  int xcelqrx;
156 #endif
157 } DBC;
158 
165 typedef struct {
166  char *db;
167  char *table;
168  char *column;
169  int type;
170  int size;
171  int index;
172  int nosign;
173  int scale;
174  int prec;
175  int autoinc;
176  int notnull;
177  int ispk;
178  int isrowid;
179  char *typename;
180  char *label;
181 } COL;
182 
189 typedef struct {
190  SQLSMALLINT type;
191  SQLINTEGER max;
193  SQLPOINTER valp;
194  int index;
195  int offs;
196 } BINDCOL;
197 
204 typedef struct {
205  int type, stype;
206  int coldef, scale;
210  void *param;
211  void *param0;
212  int inc;
213  int need;
214  int bound;
215  int offs, len;
216  void *parbuf;
217  char strbuf[64];
218  int s3type;
219  int s3size;
220  void *s3val;
221  int s3ival;
222  sqlite_int64 s3lival;
223  double s3dval;
224 } BINDPARM;
225 
232 typedef struct stmt {
233  struct stmt *next;
234  HDBC dbc;
235  SQLCHAR cursorname[32];
236  SQLCHAR *query;
237  int *ov3;
238  int *oemcp;
239  int *jdconv;
240  int *ilike;
241  int isselect;
242  int ncols;
245  int dcols;
246  int bkmrk;
247  SQLINTEGER *bkmrkptr;
250  int nbindcols;
253  int nparams;
254  int pdcount;
255  int nrows;
256  int rowp;
257  int rowprs;
258  char **rows;
259  void (*rowfree)(char **);
260  int naterr;
261  char sqlstate[6];
262  SQLCHAR logmsg[1024];
263  int nowchar[2];
264  int dobigint;
265  int longnames;
268  SQLUSMALLINT *row_status;
269  SQLUSMALLINT *row_status0;
270  SQLUSMALLINT row_status1;
275  SQLUINTEGER paramset_nrows;
279  /* Dummies to make ADO happy */
281  SQLUSMALLINT *parm_oper;
282  SQLUSMALLINT *parm_status;
285  int curtype;
286  sqlite3_stmt *s3stmt;
289  char *bincell;
290  char *bincache;
291  int binlen;
293  int one_tbl;
294  int has_pk;
295  int has_rowid;
296 } STMT;
297 
298 #endif
299 
300 /*
301  * Local Variables:
302  * mode: c
303  * c-basic-offset: 4
304  * fill-column: 78
305  * tab-width: 8
306  * End:
307  */
sqlite3_stmt * s3stmt
SQLite statement handle or NULL.
Definition: sqlite3odbc.h:286
SQLULEN paramset_size
SQL_ATTR_PARAMSET_SIZE.
Definition: sqlite3odbc.h:273
sqlite_int64 s3lival
SQLite3 64bit integer value.
Definition: sqlite3odbc.h:222
int busyint
Interrupt busy handler from SQLCancel()
Definition: sqlite3odbc.h:122
void * parbuf
Buffer for SQL_LEN_DATA_AT_EXEC etc.
Definition: sqlite3odbc.h:216
Internal dynamic string buffer.
Definition: blobtoxy.c:1212
int longnames
Don&#39;t shorten column names.
Definition: sqlite3odbc.h:134
int nocreat
Don&#39;t auto create database file.
Definition: sqlite3odbc.h:135
#define SQLLEN
Definition: sqlite3odbc.h:62
#define SQLULEN
Definition: sqlite3odbc.h:68
struct dbc * dbcs
Pointer to first DBC.
Definition: sqlite3odbc.h:103
void * param0
Parameter buffer, initial value.
Definition: sqlite3odbc.h:211
int * ov3
True for SQL_OV_ODBC3.
Definition: sqlite3odbc.h:237
int dobigint
Force SQL_BIGINT for INTEGER columns.
Definition: sqlite3odbc.h:264
SQLCHAR * query
Current query, raw string.
Definition: sqlite3odbc.h:236
sqlite3 * sqlite
SQLITE database handle.
Definition: sqlite3odbc.h:116
int guessed_types
Flag for drvprepare()/drvexecute()
Definition: sqlite3odbc.h:292
SQLCHAR logmsg[1024]
Message for SQLError()
Definition: sqlite3odbc.h:262
char ** rows
2-dim array, result set
Definition: sqlite3odbc.h:258
int step_enable
True for sqlite_compile/step/finalize.
Definition: sqlite3odbc.h:138
int ispk
Flag for primary key (> 0)
Definition: sqlite3odbc.h:177
int intrans
True when transaction started.
Definition: sqlite3odbc.h:126
int shortnames
Always use short column names.
Definition: sqlite3odbc.h:133
SQLULEN * parm_bind_offs
SQL_ATTR_PARAM_BIND_OFFSET_PTR.
Definition: sqlite3odbc.h:280
void * s3val
SQLite3 value buffer.
Definition: sqlite3odbc.h:220
Internal structure for bound column (SQLBindCol).
Definition: sqlite3odbc.h:189
int nrows
Number of result rows.
Definition: sqlite3odbc.h:255
Driver internal structure for database connection (HDBC).
Definition: sqlite3odbc.h:112
SQLULEN row_count0
Row count.
Definition: sqlite3odbc.h:272
int s3ival
SQLite3 integer value.
Definition: sqlite3odbc.h:221
struct stmt * cur_s3stmt
Current STMT executing sqlite statement.
Definition: sqlite3odbc.h:143
int need
True when SQL_LEN_DATA_AT_EXEC.
Definition: sqlite3odbc.h:213
SQLULEN parm_bind_type
SQL_ATTR_PARAM_BIND_TYPE.
Definition: sqlite3odbc.h:284
int * ov3
True for SQL_OV_ODBC3.
Definition: sqlite3odbc.h:123
SQLULEN * row_count
Row count pointer.
Definition: sqlite3odbc.h:271
char sqlstate[6]
SQL state for SQLError()
Definition: sqlite3odbc.h:261
int inc
Increment for paramset size > 1.
Definition: sqlite3odbc.h:212
SQLLEN max
Max.
Definition: sqlite3odbc.h:207
char * column
Column name.
Definition: sqlite3odbc.h:168
int version
SQLITE version number.
Definition: sqlite3odbc.h:117
char * dsn
ODBC data source name.
Definition: sqlite3odbc.h:119
HDBC dbc
Pointer to DBC.
Definition: sqlite3odbc.h:234
int curtype
Default cursor type.
Definition: sqlite3odbc.h:137
Driver internal structure representing SQL statement (HSTMT).
Definition: sqlite3odbc.h:232
SQLUINTEGER paramset_nrows
Row count for paramset handling.
Definition: sqlite3odbc.h:275
int autocommit
Auto commit state.
Definition: sqlite3odbc.h:125
SQLCHAR logmsg[1024]
Message for SQLError()
Definition: sqlite3odbc.h:130
int isrowid
Flag for ROWID column (> 0)
Definition: sqlite3odbc.h:178
struct stmt STMT
int prec
Precision of column.
Definition: sqlite3odbc.h:174
int magic
Magic cookie.
Definition: sqlite3odbc.h:97
ENV * env
Pointer to environment.
Definition: sqlite3odbc.h:114
int pool
True for SQL_CP_ONE_PER_DRIVER.
Definition: sqlite3odbc.h:99
BINDPARM * bindparms
Array of bound parameters.
Definition: sqlite3odbc.h:252
int ilike
True for ILIKE fixup.
Definition: sqlite3odbc.h:142
COL * cols
Result column array.
Definition: sqlite3odbc.h:243
SQLULEN bind_type
SQL_ATTR_ROW_BIND_TYPE.
Definition: sqlite3odbc.h:277
SQLPOINTER valp
Value buffer.
Definition: sqlite3odbc.h:193
int ov3
True for SQL_OV_ODBC3.
Definition: sqlite3odbc.h:98
SQLUSMALLINT * parm_oper
SQL_ATTR_PARAM_OPERATION_PTR.
Definition: sqlite3odbc.h:281
char * dbname
SQLITE database name.
Definition: sqlite3odbc.h:118
int fksupport
Foreign keys on or off.
Definition: sqlite3odbc.h:136
int s3stmt_needmeta
True to get meta data in s3stmt_step().
Definition: sqlite3odbc.h:144
int rowprs
Current start row of rowset.
Definition: sqlite3odbc.h:257
char * table
Table name.
Definition: sqlite3odbc.h:167
int s3stmt_rownum
Current row number.
Definition: sqlite3odbc.h:288
int * jdconv
True for julian day conversion.
Definition: sqlite3odbc.h:239
SQLUSMALLINT row_status1
Internal status array for 1 row rowsets.
Definition: sqlite3odbc.h:270
SQLLEN * lenp
Value return, actual size of value buffer.
Definition: sqlite3odbc.h:192
SQLULEN retr_data
SQL_ATTR_RETRIEVE_DATA.
Definition: sqlite3odbc.h:266
int longnames
Don&#39;t shorten column names.
Definition: sqlite3odbc.h:265
int index
Index of column in result.
Definition: sqlite3odbc.h:194
int nosign
Unsigned type.
Definition: sqlite3odbc.h:172
SQLSMALLINT type
ODBC type.
Definition: sqlite3odbc.h:190
struct dbc * next
Pointer to next DBC.
Definition: sqlite3odbc.h:115
int nowchar
Don&#39;t try to use WCHAR.
Definition: sqlite3odbc.h:131
double s3dval
SQLite3 float value.
Definition: sqlite3odbc.h:223
struct dbc DBC
int pwdLen
Length of password.
Definition: sqlite3odbc.h:147
int ncols
Number of result columns.
Definition: sqlite3odbc.h:242
SQLUSMALLINT * row_status
Row status pointer.
Definition: sqlite3odbc.h:268
SQLCHAR cursorname[32]
Cursor name.
Definition: sqlite3odbc.h:235
struct stmt * next
Linkage for STMT list in DBC.
Definition: sqlite3odbc.h:233
char * bincache
Cache for blob data.
Definition: sqlite3odbc.h:290
SQLINTEGER * bkmrkptr
SQL_ATTR_FETCH_BOOKMARK_PTR.
Definition: sqlite3odbc.h:247
int notnull
NOT NULL constraint on column.
Definition: sqlite3odbc.h:176
int timeout
Lock timeout value.
Definition: sqlite3odbc.h:120
SQLULEN max_rows
SQL_ATTR_MAX_ROWS.
Definition: sqlite3odbc.h:276
char * label
Column label or NULL.
Definition: sqlite3odbc.h:180
int type
Data type of column.
Definition: sqlite3odbc.h:169
int nowchar[2]
Don&#39;t try to use WCHAR.
Definition: sqlite3odbc.h:263
int s3size
SQLite3 size.
Definition: sqlite3odbc.h:219
int binlen
Length of blob data.
Definition: sqlite3odbc.h:291
SQLLEN * lenp0
Actual size of parameter buffer, initial value.
Definition: sqlite3odbc.h:209
int * oemcp
True for Win32 OEM CP translation.
Definition: sqlite3odbc.h:238
SQLUSMALLINT * row_status0
Internal status array.
Definition: sqlite3odbc.h:269
SQLINTEGER max
Max.
Definition: sqlite3odbc.h:191
int nbindcols
Number of entries in bindcols.
Definition: sqlite3odbc.h:250
int isselect
0 if query is a SELECT statement
Definition: sqlite3odbc.h:241
SQLLEN * lenp
Actual size of parameter buffer.
Definition: sqlite3odbc.h:208
char * pwd
Password or NULL.
Definition: sqlite3odbc.h:146
Driver internal structure for environment (HENV).
Definition: sqlite3odbc.h:96
FILE * trace
sqlite3_trace() file pointer or NULL
Definition: sqlite3odbc.h:145
int autoinc
AUTO_INCREMENT column.
Definition: sqlite3odbc.h:175
char * db
Database name.
Definition: sqlite3odbc.h:166
long t0
Start time for SQLITE busy handler.
Definition: sqlite3odbc.h:121
int naterr
Native error code.
Definition: sqlite3odbc.h:128
char sqlstate[6]
SQL state for SQLError()
Definition: sqlite3odbc.h:129
int bound
True when SQLBindParameter() called.
Definition: sqlite3odbc.h:214
void * param
Parameter buffer.
Definition: sqlite3odbc.h:210
int one_tbl
Flag for single table (> 0)
Definition: sqlite3odbc.h:293
int * ilike
True for ILIKE fixup.
Definition: sqlite3odbc.h:240
int curtype
Cursor type.
Definition: sqlite3odbc.h:285
int scale
from SQLBindParameter()
Definition: sqlite3odbc.h:206
COL * dyncols
Column array, but malloc()ed.
Definition: sqlite3odbc.h:244
int dobigint
Force SQL_BIGINT for INTEGER columns.
Definition: sqlite3odbc.h:132
int index
Index of column in result.
Definition: sqlite3odbc.h:171
int bkmrk
True when bookmarks used.
Definition: sqlite3odbc.h:246
SQLULEN * parm_proc
SQL_ATTR_PARAMS_PROCESSED_PTR.
Definition: sqlite3odbc.h:283
SQLULEN * bind_offs
SQL_ATTR_ROW_BIND_OFFSET_PTR.
Definition: sqlite3odbc.h:278
int magic
Magic cookie.
Definition: sqlite3odbc.h:113
int size
Size of column.
Definition: sqlite3odbc.h:170
BINDCOL * bindcols
Array of bound columns.
Definition: sqlite3odbc.h:249
int rowp
Current result row.
Definition: sqlite3odbc.h:256
int scale
Scale of column.
Definition: sqlite3odbc.h:173
int ov3val
True for SQL_OV_ODBC3.
Definition: sqlite3odbc.h:124
SQLUSMALLINT * parm_status
SQL_ATTR_PARAMS_STATUS_PTR.
Definition: sqlite3odbc.h:282
int jdconv
True for julian day conversion.
Definition: sqlite3odbc.h:141
int has_rowid
Flag for ROWID (>= 0 or -1)
Definition: sqlite3odbc.h:295
BINDCOL bkmrkcol
Bookmark bound column.
Definition: sqlite3odbc.h:248
SQLULEN rowset_size
Size of rowset.
Definition: sqlite3odbc.h:267
int oemcp
True for Win32 OEM CP translation.
Definition: sqlite3odbc.h:140
void(* rowfree)(char **)
Free function for rows.
Definition: sqlite3odbc.h:259
char * bincell
Cache for blob data.
Definition: sqlite3odbc.h:289
int nparams
Number of parameters in query.
Definition: sqlite3odbc.h:253
Internal structure for bound parameter (SQLBindParameter).
Definition: sqlite3odbc.h:204
int nbindparms
Number bound parameters.
Definition: sqlite3odbc.h:251
Internal structure to describe a column in a result set.
Definition: sqlite3odbc.h:165
int has_pk
Flag for primary key (> 0)
Definition: sqlite3odbc.h:294
int offs
Byte offset for SQLGetData()
Definition: sqlite3odbc.h:195
SQLULEN paramset_count
Internal for paramset.
Definition: sqlite3odbc.h:274
int pdcount
SQLParamData() counter.
Definition: sqlite3odbc.h:254
struct stmt * stmt
STMT list of this DBC.
Definition: sqlite3odbc.h:127
int s3stmt_noreset
False when sqlite3_reset() needed.
Definition: sqlite3odbc.h:287
int trans_disable
True for no transaction support.
Definition: sqlite3odbc.h:139
int dcols
Number of entries in dyncols.
Definition: sqlite3odbc.h:245
int s3type
SQLite3 type.
Definition: sqlite3odbc.h:218
int naterr
Native error code.
Definition: sqlite3odbc.h:260

Generated on Thu Jun 26 2025 by doxygen.
Contact: chw@ch-werner.de