--- sql/sqlite/parser3sqlite.C 2010/10/27 22:48:51 1.11 +++ sql/sqlite/parser3sqlite.C 2019/10/24 11:23:36 1.15 @@ -3,7 +3,7 @@ (c) Dmitry "Creator" Bobrik, 2004 */ -//static const char *RCSId="$Id: parser3sqlite.C,v 1.11 2010/10/27 22:48:51 moko Exp $"; +//static const char *RCSId="$Id: parser3sqlite.C,v 1.15 2019/10/24 11:23:36 moko Exp $"; #include "config_includes.h" @@ -14,7 +14,6 @@ #include "sqlite3.h" #include "ltdl.h" -#define MAX_COLS 500 #define MAX_STRING 0x400 #define MAX_NUMBER 20 @@ -55,6 +54,7 @@ struct Connection { const char* client_charset; bool multi_statements; bool autocommit; + int busy_timeout; }; @@ -95,9 +95,10 @@ public: *connection_ref=&connection; connection.services=&services; - connection.client_charset=SQLITE_DEFAULT_CHARSET; + connection.client_charset=SQLITE_DEFAULT_CHARSET; connection.multi_statements=false; connection.autocommit=true; + connection.busy_timeout=4000; char* db_path=0; char* db=url; @@ -127,14 +128,14 @@ public: if(strcasecmp(key, "multi_statements")==0){ if(atoi(value)!=0) connection.multi_statements=true; + } else if(strcasecmp(key, "busy_timeout")==0){ + connection.busy_timeout=atoi(value); } else if(strcasecmp(key, "autocommit")==0){ if(atoi(value)==0) connection.autocommit=false; - continue; } else if(strcmp(key, "ClientCharset")==0){ toupper_str(value, value, strlen(value)); connection.client_charset=value; - continue; } else services._throw("unknown connect option" /*key*/); } else @@ -161,6 +162,8 @@ public: _throw(connection, error_msg); } + sqlite3_busy_timeout(connection.handle, connection.busy_timeout); + _begin_transaction(connection); } @@ -257,9 +260,9 @@ public: cur+=statement_size; cur+=sprintf(cur, " LIMIT "); if(offset) - cur+=snprintf(cur, MAX_NUMBER+1, "%u,", offset); + cur+=snprintf(cur, MAX_NUMBER+1, "%lu,", offset); if(limit!=SQL_NO_LIMIT) - cur+=snprintf(cur, MAX_NUMBER, "%u", limit); + cur+=snprintf(cur, MAX_NUMBER, "%lu", limit); statement=statement_limited; } else statement=astatement; @@ -281,7 +284,7 @@ public: } if(!connection.multi_statements && next_statement_length>0){ // multi statements was not allowed but pzTail point to not empty one //sqlite3_free((char*)pzTail); - _throw(connection, "multi statements are not allowed until opption ?multi_statements=1 in connect string is specified."); + _throw(connection, "multi statements are not allowed until option ?multi_statements=1 in connect string is specified."); } #define CHECK(afailed) if(afailed){ failed=true; goto cleanup; } @@ -291,12 +294,6 @@ public: if(!column_count){ // empty result: insert|delete|update|... rc=sqlite3_step(SQL); } else { - if(column_count>MAX_COLS) - column_count=MAX_COLS; - - int column_types[MAX_COLS]; - bool transcode_column[MAX_COLS]; - for(int i=0; i