[tracker/sql-error-checks-for-master: 7/7] libtracker-db: Add interrupt handling to create_result_set_from_stmt



commit 1e8bda9fb86e5eb258f995caa4af0d364dd34643
Author: Philip Van Hoof <philip codeminded be>
Date:   Wed May 26 13:18:14 2010 +0200

    libtracker-db: Add interrupt handling to create_result_set_from_stmt

 src/libtracker-db/tracker-db-interface-sqlite.c |   24 +++++++++++++++++-----
 1 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-interface-sqlite.c b/src/libtracker-db/tracker-db-interface-sqlite.c
index 20b2b13..c76fb9a 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.c
+++ b/src/libtracker-db/tracker-db-interface-sqlite.c
@@ -828,7 +828,12 @@ create_result_set_from_stmt (TrackerDBInterfaceSqlite  *interface,
 	while (result == SQLITE_OK  ||
 	       result == SQLITE_ROW) {
 
-		result = sqlite3_step (stmt);
+		if (g_atomic_int_get (&priv->interrupt) == 1) {
+			result = SQLITE_INTERRUPT;
+			sqlite3_reset (stmt);
+		} else {
+			result = sqlite3_step (stmt);
+		}
 
 		switch (result) {
 		case SQLITE_ERROR:
@@ -873,11 +878,18 @@ create_result_set_from_stmt (TrackerDBInterfaceSqlite  *interface,
 			           sqlite3_errcode (priv->db),
 			           sqlite3_errmsg (priv->db));
 		} else {
-			g_set_error (error,
-			             TRACKER_DB_INTERFACE_ERROR,
-			             TRACKER_DB_QUERY_ERROR,
-			             "%s",
-			             sqlite3_errmsg (priv->db));
+			if (result == SQLITE_INTERRUPT) {
+				g_set_error (error,
+				             TRACKER_DB_INTERFACE_ERROR,
+				             TRACKER_DB_INTERRUPTED,
+				             "Interrupted");
+			} else {
+				g_set_error (error,
+				             TRACKER_DB_INTERFACE_ERROR,
+				             TRACKER_DB_QUERY_ERROR,
+				             "%s",
+				             sqlite3_errmsg (priv->db));
+			}
 		}
 
 		/* If there was an error, result set may be invalid or incomplete */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]