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

Generated on Mon Aug 17 2020 by doxygen.
Contact: chw@ch-werner.de