[tracker/async-queries-cursor] libtracker-db: Get the error at cursor's iter_next



commit 4f4945795f4173a68b60ef28a45893f1dd69fd6f
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Apr 20 11:13:15 2010 +0200

    libtracker-db: Get the error at cursor's iter_next

 src/libtracker-db/tracker-db-interface-sqlite.c |   12 ++++++++----
 src/libtracker-db/tracker-db-interface-sqlite.h |    2 ++
 src/tracker-store/tracker-resources.c           |    2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-interface-sqlite.c b/src/libtracker-db/tracker-db-interface-sqlite.c
index 63a3527..07545d9 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.c
+++ b/src/libtracker-db/tracker-db-interface-sqlite.c
@@ -45,8 +45,8 @@
 #define TRACKER_IS_DB_STATEMENT_SQLITE_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((o),    TRACKER_TYPE_DB_STATEMENT_SQLITE))
 #define TRACKER_DB_STATEMENT_SQLITE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),  TRACKER_TYPE_DB_STATEMENT_SQLITE, TrackerDBStatementSqliteClass))
 
-
-#define TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_DB_INTERFACE_SQLITE, TrackerDBInterfaceSqlitePrivate))
+#define TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE(o) (((TrackerDBInterfaceSqlite *)o)->priv)
+#define TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE_O(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_DB_INTERFACE_SQLITE, TrackerDBInterfaceSqlitePrivate))
 
 #define TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE(o) (((TrackerDBStatementSqlite *)o)->priv)
 #define TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE_O(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_DB_STATEMENT_SQLITE, TrackerDBStatementSqlitePrivate))
@@ -54,7 +54,6 @@
 #define TRACKER_DB_CURSOR_SQLITE_GET_PRIVATE_O(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_DB_CURSOR_SQLITE, TrackerDBCursorSqlitePrivate))
 #define TRACKER_DB_CURSOR_SQLITE_GET_PRIVATE(o) (((TrackerDBCursorSqlite *)o)->priv)
 
-typedef struct TrackerDBInterfaceSqlitePrivate TrackerDBInterfaceSqlitePrivate;
 typedef struct TrackerDBStatementSqlitePrivate TrackerDBStatementSqlitePrivate;
 typedef struct TrackerDBCursorSqlitePrivate TrackerDBCursorSqlitePrivate;
 typedef struct TrackerDBCursorSqlite TrackerDBCursorSqlite;
@@ -575,9 +574,11 @@ tracker_db_interface_sqlite_init (TrackerDBInterfaceSqlite *db_interface)
 {
 	TrackerDBInterfaceSqlitePrivate *priv;
 
-	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (db_interface);
+	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE_O (db_interface);
 
 	priv->ro = FALSE;
+	db_interface->priv = priv;
+
 	prepare_database (priv);
 }
 
@@ -1060,6 +1061,9 @@ tracker_db_cursor_sqlite_iter_next (TrackerDBCursor *cursor,
 		if (result == SQLITE_INTERRUPT) {
 			g_set_error (error, TRACKER_DB_INTERFACE_ERROR, TRACKER_DB_INTERRUPTED,
 			             "Interrupted");
+		} else if (result != SQLITE_ROW && result != SQLITE_DONE) {
+			g_set_error (error, TRACKER_DB_INTERFACE_ERROR, TRACKER_DB_QUERY_ERROR,
+			             "%s", sqlite3_errmsg (priv->ref_stmt->priv->db_interface->priv->db));
 		}
 
 		priv->finished = (result != SQLITE_ROW);
diff --git a/src/libtracker-db/tracker-db-interface-sqlite.h b/src/libtracker-db/tracker-db-interface-sqlite.h
index adf579e..042d62c 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.h
+++ b/src/libtracker-db/tracker-db-interface-sqlite.h
@@ -37,6 +37,7 @@ G_BEGIN_DECLS
 
 typedef struct TrackerDBInterfaceSqlite      TrackerDBInterfaceSqlite;
 typedef struct TrackerDBInterfaceSqliteClass TrackerDBInterfaceSqliteClass;
+typedef struct TrackerDBInterfaceSqlitePrivate TrackerDBInterfaceSqlitePrivate;
 
 typedef gint (* TrackerDBCollationFunc) (gchar *str1,
                                          gint   len1,
@@ -45,6 +46,7 @@ typedef gint (* TrackerDBCollationFunc) (gchar *str1,
 
 struct TrackerDBInterfaceSqlite {
 	GObject parent_instance;
+	TrackerDBInterfaceSqlitePrivate *priv;
 };
 
 struct TrackerDBInterfaceSqliteClass {
diff --git a/src/tracker-store/tracker-resources.c b/src/tracker-store/tracker-resources.c
index 14170e1..9bfc107 100644
--- a/src/tracker-store/tracker-resources.c
+++ b/src/tracker-store/tracker-resources.c
@@ -213,7 +213,7 @@ query_callback (TrackerDBCursor *cursor, GError *error, gpointer user_data)
 		DBusMessageIter cols_iter;
 		guint i;
 
-		if (error != NULL) {
+		if (loop_error != NULL) {
 			break;
 		}
 



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