Changeset View
Changeset View
Standalone View
Standalone View
src/drivers/sqlite/SqliteConnection.cpp
Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Line(s) | 152 | // const bool wasReadOnly = KDbConnection::isReadOnly(); | |||
---|---|---|---|---|---|
166 | storeResult(); | 166 | storeResult(); | ||
167 | 167 | | |||
168 | if (!m_result.isError()) { | 168 | if (!m_result.isError()) { | ||
169 | // Set the secure-delete on, so SQLite overwrites deleted content with zeros. | 169 | // Set the secure-delete on, so SQLite overwrites deleted content with zeros. | ||
170 | // The default setting is determined by the SQLITE_SECURE_DELETE compile-time option but we overwrite it here. | 170 | // The default setting is determined by the SQLITE_SECURE_DELETE compile-time option but we overwrite it here. | ||
171 | // Works with 3.6.23. Earlier version just ignore this pragma. | 171 | // Works with 3.6.23. Earlier version just ignore this pragma. | ||
172 | // See http://www.sqlite.org/pragma.html#pragma_secure_delete | 172 | // See http://www.sqlite.org/pragma.html#pragma_secure_delete | ||
173 | //! @todo add connection flags to the driver and global setting to control the "secure delete" pragma | 173 | //! @todo add connection flags to the driver and global setting to control the "secure delete" pragma | ||
174 | if (!drv_executeVoidSQL(KDbEscapedString("PRAGMA secure_delete = on"))) { | 174 | if (!drv_executeSql(KDbEscapedString("PRAGMA secure_delete = on"))) { | ||
175 | drv_closeDatabaseSilently(); | 175 | drv_closeDatabaseSilently(); | ||
176 | return false; | 176 | return false; | ||
177 | } | 177 | } | ||
178 | // Load ICU extension for unicode collations | 178 | // Load ICU extension for unicode collations | ||
179 | if (!findAndLoadExtension(QLatin1String("kdb_sqlite_icu"))) { | 179 | if (!findAndLoadExtension(QLatin1String("kdb_sqlite_icu"))) { | ||
180 | drv_closeDatabaseSilently(); | 180 | drv_closeDatabaseSilently(); | ||
181 | return false; | 181 | return false; | ||
182 | } | 182 | } | ||
183 | // load ROOT collation for use as default collation | 183 | // load ROOT collation for use as default collation | ||
184 | if (!drv_executeVoidSQL(KDbEscapedString("SELECT icu_load_collation('', '')"))) { | 184 | if (!drv_executeSql(KDbEscapedString("SELECT icu_load_collation('', '')"))) { | ||
185 | drv_closeDatabaseSilently(); | 185 | drv_closeDatabaseSilently(); | ||
186 | return false; | 186 | return false; | ||
187 | } | 187 | } | ||
188 | if (!createCustomSQLiteFunctions(d->data)) { | 188 | if (!createCustomSQLiteFunctions(d->data)) { | ||
189 | drv_closeDatabaseSilently(); | 189 | drv_closeDatabaseSilently(); | ||
190 | return false; | 190 | return false; | ||
191 | } | 191 | } | ||
192 | } | 192 | } | ||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 283 | { | |||
284 | return new SqliteCursor(this, sql, options); | 284 | return new SqliteCursor(this, sql, options); | ||
285 | } | 285 | } | ||
286 | 286 | | |||
287 | KDbCursor* SqliteConnection::prepareQuery(KDbQuerySchema* query, KDbCursor::Options options) | 287 | KDbCursor* SqliteConnection::prepareQuery(KDbQuerySchema* query, KDbCursor::Options options) | ||
288 | { | 288 | { | ||
289 | return new SqliteCursor(this, query, options); | 289 | return new SqliteCursor(this, query, options); | ||
290 | } | 290 | } | ||
291 | 291 | | |||
292 | KDbSqlResult* SqliteConnection::drv_executeSQL(const KDbEscapedString& sql) | 292 | KDbSqlResult* SqliteConnection::drv_prepareSql(const KDbEscapedString& sql) | ||
293 | { | 293 | { | ||
294 | #ifdef KDB_DEBUG_GUI | 294 | #ifdef KDB_DEBUG_GUI | ||
295 | KDb::debugGUI(QLatin1String("ExecuteSQL (SQLite): ") + sql.toString()); | 295 | KDb::debugGUI(QLatin1String("PrepareSQL (SQLite): ") + sql.toString()); | ||
296 | #endif | 296 | #endif | ||
297 | 297 | | |||
298 | sqlite3_stmt *prepared_st = nullptr; | 298 | sqlite3_stmt *prepared_st = nullptr; | ||
299 | const int res = sqlite3_prepare( | 299 | const int res = sqlite3_prepare( | ||
300 | d->data, /* Database handle */ | 300 | d->data, /* Database handle */ | ||
301 | sql.constData(), /* SQL statement, UTF-8 encoded */ | 301 | sql.constData(), /* SQL statement, UTF-8 encoded */ | ||
302 | sql.length(), /* Length of zSql in bytes. */ | 302 | sql.length(), /* Length of zSql in bytes. */ | ||
303 | &prepared_st, /* OUT: Statement handle */ | 303 | &prepared_st, /* OUT: Statement handle */ | ||
Show All 9 Lines | 311 | #endif | |||
313 | } | 313 | } | ||
314 | 314 | | |||
315 | #ifdef KDB_DEBUG_GUI | 315 | #ifdef KDB_DEBUG_GUI | ||
316 | KDb::debugGUI(QLatin1String(" Success")); | 316 | KDb::debugGUI(QLatin1String(" Success")); | ||
317 | #endif | 317 | #endif | ||
318 | return new SqliteSqlResult(this, prepared_st); | 318 | return new SqliteSqlResult(this, prepared_st); | ||
319 | } | 319 | } | ||
320 | 320 | | |||
321 | bool SqliteConnection::drv_executeVoidSQL(const KDbEscapedString& sql) | 321 | bool SqliteConnection::drv_executeSql(const KDbEscapedString& sql) | ||
322 | { | 322 | { | ||
323 | #ifdef KDB_DEBUG_GUI | 323 | #ifdef KDB_DEBUG_GUI | ||
324 | KDb::debugGUI(QLatin1String("ExecuteVoidSQL (SQLite): ") + sql.toString()); | 324 | KDb::debugGUI(QLatin1String("ExecuteSQL (SQLite): ") + sql.toString()); | ||
325 | #endif | 325 | #endif | ||
326 | 326 | | |||
327 | char *errmsg_p = nullptr; | 327 | char *errmsg_p = nullptr; | ||
328 | const int res = sqlite3_exec( | 328 | const int res = sqlite3_exec( | ||
329 | d->data, | 329 | d->data, | ||
330 | sql.constData(), | 330 | sql.constData(), | ||
331 | nullptr/*callback*/, | 331 | nullptr/*callback*/, | ||
332 | nullptr, | 332 | nullptr, | ||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |