Mercurial > mercurial > hgweb_searcher03.cgi
diff src/wxsqlite3.cpp @ 21:a2ad87cad48b
Enhanced the convenience of Cache dialog.
author | pyon@macmini |
---|---|
date | Wed, 17 Dec 2014 00:52:43 +0900 |
parents | 0c0701a935f8 |
children |
line wrap: on
line diff
--- a/src/wxsqlite3.cpp Mon Dec 08 19:47:42 2014 +0900 +++ b/src/wxsqlite3.cpp Wed Dec 17 00:52:43 2014 +0900 @@ -97,6 +97,19 @@ #include "wx/wxsqlite3dyn.h" #undef DYNFUNC +#else +// Define Windows specific SQLite API functions (not defined in sqlite3.h) +#if SQLITE_VERSION_NUMBER >= 3007014 +#if defined(__WXMSW__) +#ifdef __cplusplus +extern "C" { +#endif +SQLITE_API int sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue); +#ifdef __cplusplus +} +#endif +#endif +#endif #endif // wxUSE_DYNAMIC_SQLITE3_LOAD // Error messages @@ -137,10 +150,11 @@ const char* wxERRMSG_INITIALIZE = wxTRANSLATE("Initialization of SQLite failed"); const char* wxERRMSG_SHUTDOWN = wxTRANSLATE("Shutdown of SQLite failed"); - -const char* wxERRMSG_SOURCEDB_BUSY = wxTRANSLATE("Source database is busy"); -const char* wxERRMSG_DBOPEN_FAILED = wxTRANSLATE("Database open failed"); -const char* wxERRMSG_DBCLOSE_FAILED = wxTRANSLATE("Database close failed"); +const char* wxERRMSG_TEMPDIR = wxTRANSLATE("Setting temporary directory failed"); + +const char* wxERRMSG_SOURCEDB_BUSY = wxTRANSLATE("Source database is busy"); +const char* wxERRMSG_DBOPEN_FAILED = wxTRANSLATE("Database open failed"); +const char* wxERRMSG_DBCLOSE_FAILED = wxTRANSLATE("Database close failed"); const char* wxERRMSG_DBASSIGN_FAILED = wxTRANSLATE("Database assignment failed"); const char* wxERRMSG_FINALIZE_FAILED = wxTRANSLATE("Finalize failed"); #else @@ -179,10 +193,11 @@ const wxChar* wxERRMSG_INITIALIZE = wxTRANSLATE("Initialization of SQLite failed"); const wxChar* wxERRMSG_SHUTDOWN = wxTRANSLATE("Shutdown of SQLite failed"); +const wxChar* wxERRMSG_TEMPDIR = wxTRANSLATE("Setting temporary directory failed"); const wxChar* wxERRMSG_SOURCEDB_BUSY = wxTRANSLATE("Source database is busy"); const wxChar* wxERRMSG_DBOPEN_FAILED = wxTRANSLATE("Database open failed"); -const wxChar* wxERRMSG_DBCLOSE_FAILED = wxTRANSLATE("Database close failed"); +const wxChar* wxERRMSG_DBCLOSE_FAILED = wxTRANSLATE("Database close failed"); const wxChar* wxERRMSG_DBASSIGN_FAILED = wxTRANSLATE("Database assignment failed"); const wxChar* wxERRMSG_FINALIZE_FAILED = wxTRANSLATE("Finalize failed"); #endif @@ -2206,6 +2221,16 @@ #endif } +int wxSQLite3Statement::Status(wxSQLite3StatementStatus opCode, bool resetFlag) +{ + int count = 0; +#if SQLITE_VERSION_NUMBER >= 3007000 + CheckStmt(); + count = sqlite3_stmt_status(m_stmt->m_stmt, (int) opCode, (resetFlag) ? 1 : 0 ); +#endif + return count; +} + void wxSQLite3Statement::CheckDatabase() { if (m_db == NULL || m_db->m_db == NULL || !m_db->m_isValid) @@ -3503,24 +3528,38 @@ #endif } -bool wxSQLite3Database::CreateFunction(const wxString& funcName, int argCount, wxSQLite3ScalarFunction& function) +bool wxSQLite3Database::CreateFunction(const wxString& funcName, int argCount, wxSQLite3ScalarFunction& function, bool isDeterministic) { CheckDatabase(); wxCharBuffer strFuncName = funcName.ToUTF8(); const char* localFuncName = strFuncName; + int flags = SQLITE_UTF8; +#if SQLITE_VERSION_NUMBER >= 3008003 + if (isDeterministic) + { + flags |= SQLITE_DETERMINISTIC; + } +#endif int rc = sqlite3_create_function(m_db->m_db, localFuncName, argCount, - SQLITE_UTF8, &function, + flags, &function, (void (*)(sqlite3_context*,int,sqlite3_value**)) wxSQLite3FunctionContext::ExecScalarFunction, NULL, NULL); return rc == SQLITE_OK; } -bool wxSQLite3Database::CreateFunction(const wxString& funcName, int argCount, wxSQLite3AggregateFunction& function) +bool wxSQLite3Database::CreateFunction(const wxString& funcName, int argCount, wxSQLite3AggregateFunction& function, bool isDeterministic) { CheckDatabase(); wxCharBuffer strFuncName = funcName.ToUTF8(); const char* localFuncName = strFuncName; + int flags = SQLITE_UTF8; +#if SQLITE_VERSION_NUMBER >= 3008003 + if (isDeterministic) + { + flags |= SQLITE_DETERMINISTIC; + } +#endif int rc = sqlite3_create_function(m_db->m_db, localFuncName, argCount, - SQLITE_UTF8, &function, + flags, &function, NULL, (void (*)(sqlite3_context*,int,sqlite3_value**)) wxSQLite3FunctionContext::ExecAggregateStep, (void (*)(sqlite3_context*)) wxSQLite3FunctionContext::ExecAggregateFinalize); @@ -3916,6 +3955,31 @@ } /* static */ +bool wxSQLite3Database::SetTemporaryDirectory(const wxString& tempDirectory) +{ + bool ok = false; +#if SQLITE_VERSION_NUMBER >= 3007014 +#if defined(__WXMSW__) + DWORD SQLITE_WIN32_TEMP_DIRECTORY_TYPE = 2; +#if wxUSE_UNICODE + const wxChar* zValue = tempDirectory.wc_str(); +#else + const wxWCharBuffer zValue = tempDirectory.wc_str(wxConvLocal); +#endif + int rc = sqlite3_win32_set_directory(SQLITE_WIN32_TEMP_DIRECTORY_TYPE, zValue); + ok = (rc == SQLITE_OK); +#if 0 + if (rc != SQLITE_OK) + { + throw wxSQLite3Exception(rc, wxERRMSG_TEMPDIR); + } +#endif +#endif +#endif + return ok; +} + +/* static */ bool wxSQLite3Database::Randomness(int n, wxMemoryBuffer& random) { bool ok = false; @@ -4232,7 +4296,8 @@ wxT("SQLITE_SELECT"), wxT("SQLITE_TRANSACTION"), wxT("SQLITE_UPDATE"), wxT("SQLITE_ATTACH"), wxT("SQLITE_DETACH"), wxT("SQLITE_ALTER_TABLE"), wxT("SQLITE_REINDEX"), wxT("SQLITE_ANALYZE"), wxT("SQLITE_CREATE_VTABLE"), - wxT("SQLITE_DROP_VTABLE"), wxT("SQLITE_FUNCTION"), wxT("SQLITE_SAVEPOINT") + wxT("SQLITE_DROP_VTABLE"), wxT("SQLITE_FUNCTION"), wxT("SQLITE_SAVEPOINT"), + wxT("SQLITE_RECURSIVE") };