|
|
| version 1.11, 2010/10/27 22:48:51 | version 1.12, 2012/04/19 21:33:08 |
|---|---|
| Line 55 struct Connection { | Line 55 struct Connection { |
| const char* client_charset; | const char* client_charset; |
| bool multi_statements; | bool multi_statements; |
| bool autocommit; | bool autocommit; |
| int busy_timeout; | |
| }; | }; |
| Line 95 public: | Line 96 public: |
| *connection_ref=&connection; | *connection_ref=&connection; |
| connection.services=&services; | connection.services=&services; |
| connection.client_charset=SQLITE_DEFAULT_CHARSET; | connection.client_charset=SQLITE_DEFAULT_CHARSET; |
| connection.multi_statements=false; | connection.multi_statements=false; |
| connection.autocommit=true; | connection.autocommit=true; |
| connection.busy_timeout=4000; | |
| char* db_path=0; | char* db_path=0; |
| char* db=url; | char* db=url; |
| Line 127 public: | Line 129 public: |
| if(strcasecmp(key, "multi_statements")==0){ | if(strcasecmp(key, "multi_statements")==0){ |
| if(atoi(value)!=0) | if(atoi(value)!=0) |
| connection.multi_statements=true; | connection.multi_statements=true; |
| } else if(strcasecmp(key, "busy_timeout")==0){ | |
| connection.busy_timeout=atoi(value); | |
| } else if(strcasecmp(key, "autocommit")==0){ | } else if(strcasecmp(key, "autocommit")==0){ |
| if(atoi(value)==0) | if(atoi(value)==0) |
| connection.autocommit=false; | connection.autocommit=false; |
| continue; | |
| } else if(strcmp(key, "ClientCharset")==0){ | } else if(strcmp(key, "ClientCharset")==0){ |
| toupper_str(value, value, strlen(value)); | toupper_str(value, value, strlen(value)); |
| connection.client_charset=value; | connection.client_charset=value; |
| continue; | |
| } else | } else |
| services._throw("unknown connect option" /*key*/); | services._throw("unknown connect option" /*key*/); |
| } else | } else |
| Line 161 public: | Line 163 public: |
| _throw(connection, error_msg); | _throw(connection, error_msg); |
| } | } |
| sqlite3_busy_timeout(connection.handle, connection.busy_timeout); | |
| _begin_transaction(connection); | _begin_transaction(connection); |
| } | } |
| Line 257 public: | Line 261 public: |
| cur+=statement_size; | cur+=statement_size; |
| cur+=sprintf(cur, " LIMIT "); | cur+=sprintf(cur, " LIMIT "); |
| if(offset) | if(offset) |
| cur+=snprintf(cur, MAX_NUMBER+1, "%u,", offset); | cur+=snprintf(cur, MAX_NUMBER+1, "%lu,", offset); |
| if(limit!=SQL_NO_LIMIT) | if(limit!=SQL_NO_LIMIT) |
| cur+=snprintf(cur, MAX_NUMBER, "%u", limit); | cur+=snprintf(cur, MAX_NUMBER, "%lu", limit); |
| statement=statement_limited; | statement=statement_limited; |
| } else | } else |
| statement=astatement; | statement=astatement; |
| Line 438 private: // sqlite client library funcs | Line 442 private: // sqlite client library funcs |
| typedef int (*t_sqlite3_close)(sqlite3 *); t_sqlite3_close sqlite3_close; | typedef int (*t_sqlite3_close)(sqlite3 *); t_sqlite3_close sqlite3_close; |
| typedef int (*t_sqlite3_busy_timeout)(sqlite3*, int ms); t_sqlite3_busy_timeout sqlite3_busy_timeout; | |
| typedef int (*t_sqlite3_exec)(sqlite3*, const char *sql, sqlite3_callback, void *, char **errmsg); t_sqlite3_exec sqlite3_exec; | typedef int (*t_sqlite3_exec)(sqlite3*, const char *sql, sqlite3_callback, void *, char **errmsg); t_sqlite3_exec sqlite3_exec; |
| typedef void (*t_sqlite3_free)(char *z); t_sqlite3_free sqlite3_free; | typedef void (*t_sqlite3_free)(char *z); t_sqlite3_free sqlite3_free; |
| Line 486 private: // sqlite client library funcs | Line 492 private: // sqlite client library funcs |
| DLINK(sqlite3_open); | DLINK(sqlite3_open); |
| DLINK(sqlite3_close); | DLINK(sqlite3_close); |
| DLINK(sqlite3_busy_timeout); | |
| DLINK(sqlite3_exec); | DLINK(sqlite3_exec); |
| DLINK(sqlite3_free); | DLINK(sqlite3_free); |
| DLINK(sqlite3_errmsg); | DLINK(sqlite3_errmsg); |