00001 #ifndef _SQLITE3ODBC_H 00002 #define _SQLITE3ODBC_H 00003 00027 #if defined(_WIN32) || defined(_WIN64) 00028 #include <windows.h> 00029 #include <stdio.h> 00030 #include <io.h> 00031 #else 00032 #include <sys/time.h> 00033 #include <sys/types.h> 00034 #include <stdio.h> 00035 #include <unistd.h> 00036 #include <errno.h> 00037 #endif 00038 #include <stdlib.h> 00039 #if defined(HAVE_LOCALECONV) || defined(_WIN32) || defined(_WIN64) 00040 #include <locale.h> 00041 #endif 00042 #include <stdarg.h> 00043 #include <stddef.h> 00044 #include <string.h> 00045 #include <sql.h> 00046 #include <sqlext.h> 00047 #include <time.h> 00048 00049 #include "sqlite3.h" 00050 #ifdef HAVE_IODBC 00051 #include <iodbcinst.h> 00052 #endif 00053 #if defined(HAVE_UNIXODBC) || defined(_WIN32) || defined(_WIN64) 00054 #include <odbcinst.h> 00055 #endif 00056 00057 #ifndef SQL_API 00058 #define SQL_API 00059 #endif 00060 00061 #ifndef HAVE_SQLLEN 00062 #define SQLLEN SQLINTEGER 00063 #endif 00064 00065 #define SQLLEN_PTR SQLLEN * 00066 00067 #ifndef HAVE_SQLULEN 00068 #define SQLULEN SQLUINTEGER 00069 #endif 00070 00071 #ifndef HAVE_SQLROWCOUNT 00072 #define SQLROWCOUNT SQLUINTEGER 00073 #endif 00074 00075 #ifndef HAVE_SQLSETPOSIROW 00076 #define SQLSETPOSIROW SQLUSMALLINT 00077 #endif 00078 00079 #ifndef HAVE_SQLROWOFFSET 00080 #define SQLROWOFFSET SQLLEN 00081 #endif 00082 00083 #ifndef HAVE_SQLROWSETSIZE 00084 #define SQLROWSETSIZE SQLULEN 00085 #endif 00086 00087 struct dbc; 00088 struct stmt; 00089 00096 typedef struct { 00097 int magic; 00098 int ov3; 00099 #if defined(_WIN32) || defined(_WIN64) 00100 CRITICAL_SECTION cs; 00101 DWORD owner; 00102 #endif 00103 struct dbc *dbcs; 00104 } ENV; 00105 00112 typedef struct dbc { 00113 int magic; 00114 ENV *env; 00115 struct dbc *next; 00116 sqlite3 *sqlite; 00117 int version; 00118 char *dbname; 00119 char *dsn; 00120 int timeout; 00121 long t0; 00122 int busyint; 00123 int *ov3; 00124 int ov3val; 00125 int autocommit; 00126 int intrans; 00127 struct stmt *stmt; 00128 int naterr; 00129 char sqlstate[6]; 00130 SQLCHAR logmsg[1024]; 00131 int nowchar; 00132 int dobigint; 00133 int shortnames; 00134 int longnames; 00135 int nocreat; 00136 int fksupport; 00137 int curtype; 00138 int step_enable; 00139 int trans_disable; 00140 int oemcp; 00141 int jdconv; 00142 struct stmt *cur_s3stmt; 00143 int s3stmt_needmeta; 00144 FILE *trace; 00145 char *pwd; 00146 int pwdLen; 00147 #ifdef USE_DLOPEN_FOR_GPPS 00148 void *instlib; 00149 int (*gpps)(); 00150 #endif 00151 #if defined(_WIN32) || defined(_WIN64) 00152 int xcelqrx; 00153 #endif 00154 } DBC; 00155 00162 typedef struct { 00163 char *db; 00164 char *table; 00165 char *column; 00166 int type; 00167 int size; 00168 int index; 00169 int nosign; 00170 int scale; 00171 int prec; 00172 int autoinc; 00173 int notnull; 00174 char *typename; 00175 char *label; 00176 } COL; 00177 00184 typedef struct { 00185 SQLSMALLINT type; 00186 SQLINTEGER max; 00187 SQLLEN *lenp; 00188 SQLPOINTER valp; 00189 int index; 00190 int offs; 00191 } BINDCOL; 00192 00199 typedef struct { 00200 int type, stype; 00201 int coldef, scale; 00202 SQLLEN max; 00203 SQLLEN *lenp; 00204 SQLLEN *lenp0; 00205 void *param; 00206 void *param0; 00207 int inc; 00208 int need; 00209 int bound; 00210 int offs, len; 00211 void *parbuf; 00212 char strbuf[64]; 00213 int s3type; 00214 int s3size; 00215 void *s3val; 00216 int s3ival; 00217 sqlite_int64 s3lival; 00218 double s3dval; 00219 } BINDPARM; 00220 00227 typedef struct stmt { 00228 struct stmt *next; 00229 HDBC dbc; 00230 SQLCHAR cursorname[32]; 00231 SQLCHAR *query; 00232 int *ov3; 00233 int *oemcp; 00234 int *jdconv; 00235 int isselect; 00236 int ncols; 00237 COL *cols; 00238 COL *dyncols; 00239 int dcols; 00240 int bkmrk; 00241 BINDCOL bkmrkcol; 00242 BINDCOL *bindcols; 00243 int nbindcols; 00244 int nbindparms; 00245 BINDPARM *bindparms; 00246 int nparams; 00247 int pdcount; 00248 int nrows; 00249 int rowp; 00250 char **rows; 00251 void (*rowfree)(); 00252 int naterr; 00253 char sqlstate[6]; 00254 SQLCHAR logmsg[1024]; 00255 int nowchar[2]; 00256 int dobigint; 00257 int longnames; 00258 SQLULEN retr_data; 00259 SQLULEN rowset_size; 00260 SQLUSMALLINT *row_status; 00261 SQLUSMALLINT *row_status0; 00262 SQLUSMALLINT row_status1; 00263 SQLULEN *row_count; 00264 SQLULEN row_count0; 00265 SQLULEN paramset_size; 00266 SQLULEN paramset_count; 00267 SQLUINTEGER paramset_nrows; 00268 SQLULEN max_rows; 00269 SQLULEN bind_type; 00270 SQLULEN *bind_offs; 00271 /* Dummies to make ADO happy */ 00272 SQLULEN *parm_bind_offs; 00273 SQLUSMALLINT *parm_oper; 00274 SQLUSMALLINT *parm_status; 00275 SQLULEN *parm_proc; 00276 SQLULEN parm_bind_type; 00277 int curtype; 00278 sqlite3_stmt *s3stmt; 00279 int s3stmt_noreset; 00280 int s3stmt_rownum; 00281 char *bincell; 00282 char *bincache; 00283 int binlen; 00284 int guessed_types; 00285 } STMT; 00286 00287 #endif