[tracker/direct-access: 13/122] libtracker-data: Allow multiple statement instances for the same query
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/direct-access: 13/122] libtracker-data: Allow multiple statement instances for the same query
- Date: Fri, 6 Aug 2010 10:15:11 +0000 (UTC)
commit 46721ef89023cacfcb431d47d002bfb623e85d88
Author: Jürg Billeter <j bitron ch>
Date: Mon Jul 19 18:17:51 2010 +0200
libtracker-data: Allow multiple statement instances for the same query
src/libtracker-data/tracker-db-interface-sqlite.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c
index 9286fc4..4fd9375 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -766,6 +766,11 @@ tracker_db_interface_create_statement (TrackerDBInterface *db_interface,
stmt = g_hash_table_lookup (db_interface->dynamic_statements, full_query);
+ if (stmt && stmt->stmt_is_sunk) {
+ /* prepared statement is still in use, create new one */
+ stmt = NULL;
+ }
+
if (!stmt) {
sqlite3_stmt *sqlite_stmt;
int retval;
@@ -796,9 +801,12 @@ tracker_db_interface_create_statement (TrackerDBInterface *db_interface,
stmt = tracker_db_statement_sqlite_new (db_interface, sqlite_stmt);
- g_hash_table_insert (db_interface->dynamic_statements,
- (gpointer) sqlite3_sql (sqlite_stmt),
- stmt);
+ /* use replace instead of insert to make sure we store the string that
+ belongs to the right sqlite statement to ensure the lifetime of the string
+ matches the statement */
+ g_hash_table_replace (db_interface->dynamic_statements,
+ (gpointer) sqlite3_sql (sqlite_stmt),
+ stmt);
} else {
tracker_db_statement_sqlite_reset (stmt);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]