| 1 | /* $Id: dbdimp.h,v 1.2 2004/08/09 13:17:59 matt Exp $ */ | ||
| 2 | |||
| 3 | #ifndef _DBDIMP_H | ||
| 4 | #define _DBDIMP_H 1 | ||
| 5 | |||
| 6 | #include "SQLiteXS.h" | ||
| 7 | #include "sqliteInt.h" | ||
| 8 | |||
| 9 | /* 30 second timeout by default */ | ||
| 10 | #define SQL_TIMEOUT 30000 | ||
| 11 | #define BUSY_PAUSE_USEC 500 | ||
| 12 | |||
| 13 | /* Driver Handle */ | ||
| 14 | struct imp_drh_st { | ||
| 15 | dbih_drc_t com; | ||
| 16 | /* sqlite specific bits */ | ||
| 17 | }; | ||
| 18 | |||
| 19 | /* Database Handle */ | ||
| 20 | struct imp_dbh_st { | ||
| 21 | dbih_dbc_t com; | ||
| 22 | /* sqlite specific bits */ | ||
| 23 | struct sqlite *db; | ||
| 24 | bool in_tran; | ||
| 25 | bool no_utf8_flag; | ||
| 26 | bool handle_binary_nulls; | ||
| 27 | int timeout; | ||
| 28 | AV *functions; | ||
| 29 | AV *aggregates; | ||
| 30 | }; | ||
| 31 | |||
| 32 | /* Statement Handle */ | ||
| 33 | struct imp_sth_st { | ||
| 34 | dbih_stc_t com; | ||
| 35 | /* sqlite specific bits */ | ||
| 36 | AV *sql; | ||
| 37 | sqlite_vm *vm; | ||
| 38 | char **results; | ||
| 39 | char **coldata; | ||
| 40 | int retval; | ||
| 41 | int nrow; | ||
| 42 | int ncols; | ||
| 43 | AV *params; | ||
| 44 | }; | ||
| 45 | |||
| 46 | #define dbd_init sqlite2_init | ||
| 47 | #define dbd_discon_all sqlite2_discon_all | ||
| 48 | #define dbd_db_login sqlite2_db_login | ||
| 49 | #define dbd_db_do sqlite2_db_do | ||
| 50 | #define dbd_db_commit sqlite2_db_commit | ||
| 51 | #define dbd_db_rollback sqlite2_db_rollback | ||
| 52 | #define dbd_db_disconnect sqlite2_db_disconnect | ||
| 53 | #define dbd_db_destroy sqlite2_db_destroy | ||
| 54 | #define dbd_db_STORE_attrib sqlite2_db_STORE_attrib | ||
| 55 | #define dbd_db_FETCH_attrib sqlite2_db_FETCH_attrib | ||
| 56 | #define dbd_db_STORE_attrib_k sqlite2_db_STORE_attrib_k | ||
| 57 | #define dbd_db_FETCH_attrib_k sqlite2_db_FETCH_attrib_k | ||
| 58 | #define dbd_st_prepare sqlite2_st_prepare | ||
| 59 | #define dbd_st_rows sqlite2_st_rows | ||
| 60 | #define dbd_st_execute sqlite2_st_execute | ||
| 61 | #define dbd_st_fetch sqlite2_st_fetch | ||
| 62 | #define dbd_st_finish sqlite2_st_finish | ||
| 63 | #define dbd_st_destroy sqlite2_st_destroy | ||
| 64 | #define dbd_st_blob_read sqlite2_st_blob_read | ||
| 65 | #define dbd_st_STORE_attrib sqlite2_st_STORE_attrib | ||
| 66 | #define dbd_st_FETCH_attrib sqlite2_st_FETCH_attrib | ||
| 67 | #define dbd_st_STORE_attrib_k sqlite2_st_STORE_attrib_k | ||
| 68 | #define dbd_st_FETCH_attrib_k sqlite2_st_FETCH_attrib_k | ||
| 69 | #define dbd_bind_ph sqlite2_bind_ph | ||
| 70 | |||
| 71 | void sqlite2_db_create_function(SV *dbh, const char *name, int argc, SV *func); | ||
| 72 | void sqlite2_db_create_aggregate( SV *dbh, const char *name, int argc, SV *aggr ); | ||
| 73 | |||
| 74 | #ifdef SvUTF8_on | ||
| 75 | |||
| 76 | static SV * | ||
| 77 | 0 | newUTF8SVpv(char *s, STRLEN len) { | |
| 78 | register SV *sv; | ||
| 79 | |||
| 80 | 0 | sv = newSVpv(s, len); | |
| 81 | 0 | SvUTF8_on(sv); | |
| 82 | 0 | return sv; | |
| 83 | } /* End new UTF8SVpv */ | ||
| 84 | |||
| 85 | static SV * | ||
| 86 | 0 | newUTF8SVpvn(char *s, STRLEN len) { | |
| 87 | register SV *sv; | ||
| 88 | |||
| 89 | 0 | sv = newSV(0); | |
| 90 | 0 | sv_setpvn(sv, s, len); | |
| 91 | 0 | SvUTF8_on(sv); | |
| 92 | 0 | return sv; | |
| 93 | } | ||
| 94 | |||
| 95 | #else /* SvUTF8_on not defined */ | ||
| 96 | |||
| 97 | #define newUTF8SVpv newSVpv | ||
| 98 | #define newUTF8SVpvn newSVpvn | ||
| 99 | #define SvUTF8_on(a) (a) | ||
| 100 | #define sv_utf8_upgrade(a) (a) | ||
| 101 | |||
| 102 | #endif | ||
| 103 | |||
| 104 | #endif /* _DBDIMP_H */ |