[tracker/db-abstraction] libtracker-db: Simplify DB abstraction



commit 4317521432692cca46adabf81e6741691d37464b
Author: Jürg Billeter <j bitron ch>
Date:   Mon Jun 14 11:36:12 2010 +0200

    libtracker-db: Simplify DB abstraction
    
    We do not need support for runtime pluggable DB backends. This reduces
    maintenance (and performance) costs.

 src/libtracker-data/tracker-data-manager.c      |    6 +-
 src/libtracker-db/tracker-db-interface-sqlite.c |  697 +++++++++--------------
 src/libtracker-db/tracker-db-interface-sqlite.h |   28 +-
 src/libtracker-db/tracker-db-interface.c        |  518 ++---------------
 src/libtracker-db/tracker-db-interface.h        |   82 +---
 src/libtracker-db/tracker-db-manager.c          |    2 +-
 6 files changed, 338 insertions(+), 995 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 5acedee..a88fedd 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -2319,7 +2319,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 
 		/* Read first ontology and commit it into the DB */
 		tracker_data_begin_db_transaction_for_replay (tracker_db_journal_reader_get_time ());
-		tracker_db_interface_sqlite_fts_init (TRACKER_DB_INTERFACE_SQLITE (iface), TRUE);
+		tracker_db_interface_sqlite_fts_init (iface, TRUE);
 		tracker_data_ontology_import_into_db (FALSE);
 		tracker_data_commit_db_transaction ();
 		tracker_db_journal_reader_shutdown ();
@@ -2375,7 +2375,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 		/* Not an ontology transaction: this is the first ontology */
 		tracker_db_journal_start_transaction (time (NULL));
 
-		tracker_db_interface_sqlite_fts_init (TRACKER_DB_INTERFACE_SQLITE (iface), TRUE);
+		tracker_db_interface_sqlite_fts_init (iface, TRUE);
 		tracker_data_ontology_import_into_db (FALSE);
 
 		/* store ontology in database */
@@ -2413,7 +2413,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 		create_decomposed_transient_metadata_tables (iface);
 		check_ontology = TRUE;
 
-		tracker_db_interface_sqlite_fts_init (TRACKER_DB_INTERFACE_SQLITE (iface), FALSE);
+		tracker_db_interface_sqlite_fts_init (iface, FALSE);
 	}
 
 	if (check_ontology) {
diff --git a/src/libtracker-db/tracker-db-interface-sqlite.c b/src/libtracker-db/tracker-db-interface-sqlite.c
index c76fb9a..9051548 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.c
+++ b/src/libtracker-db/tracker-db-interface-sqlite.c
@@ -30,47 +30,9 @@
 
 #include "tracker-db-interface-sqlite.h"
 
-#define TRACKER_TYPE_DB_CURSOR_SQLITE         (tracker_db_cursor_sqlite_get_type ())
-#define TRACKER_DB_CURSOR_SQLITE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_DB_CURSOR_SQLITE, TrackerDBCursorSqlite))
-#define TRACKER_DB_CURSOR_SQLITE_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST ((c),    TRACKER_TYPE_DB_CURSOR_SQLITE, TrackerDBCursorSqliteClass))
-#define TRACKER_IS_DB_CURSOR_SQLITE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_DB_CURSOR_SQLITE))
-#define TRACKER_IS_DB_CURSOR_SQLITE_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((o),    TRACKER_TYPE_DB_CURSOR_SQLITE))
-#define TRACKER_DB_CURSOR_SQLITE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),  TRACKER_TYPE_DB_CURSOR_SQLITE, TrackerDBCursorSqliteClass))
-
-#define TRACKER_TYPE_DB_STATEMENT_SQLITE         (tracker_db_statement_sqlite_get_type ())
-#define TRACKER_DB_STATEMENT_SQLITE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_DB_STATEMENT_SQLITE, TrackerDBStatementSqlite))
-#define TRACKER_DB_STATEMENT_SQLITE_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST ((c),    TRACKER_TYPE_DB_STATEMENT_SQLITE, TrackerDBStatementSqliteClass))
-#define TRACKER_IS_DB_STATEMENT_SQLITE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_DB_STATEMENT_SQLITE))
-
-#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) (((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))
-
-#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 TrackerDBStatementSqlitePrivate TrackerDBStatementSqlitePrivate;
-typedef struct TrackerDBCursorSqlitePrivate TrackerDBCursorSqlitePrivate;
-typedef struct TrackerDBCursorSqlite TrackerDBCursorSqlite;
-typedef struct TrackerDBCursorSqliteClass TrackerDBCursorSqliteClass;
-typedef struct TrackerDBStatementSqlite      TrackerDBStatementSqlite;
-typedef struct TrackerDBStatementSqliteClass TrackerDBStatementSqliteClass;
-
-struct TrackerDBCursorSqlite {
+struct TrackerDBInterface {
 	GObject parent_instance;
-	TrackerDBCursorSqlitePrivate *priv;
-};
-
-struct TrackerDBCursorSqliteClass {
-	GObjectClass parent_class;
-};
 
-struct TrackerDBInterfaceSqlitePrivate {
 	gchar *filename;
 	sqlite3 *db;
 
@@ -78,64 +40,54 @@ struct TrackerDBInterfaceSqlitePrivate {
 
 	GSList *function_data;
 
-	guint in_transaction : 1;
 	guint ro : 1;
 	guint fts_initialized : 1;
 	volatile gint interrupt;
 };
 
-struct TrackerDBStatementSqlitePrivate {
-	TrackerDBInterfaceSqlite *db_interface;
-	sqlite3_stmt *stmt;
-	gboolean stmt_is_sunk;
+struct TrackerDBInterfaceClass {
+	GObjectClass parent_class;
 };
 
-struct TrackerDBCursorSqlitePrivate {
+struct TrackerDBCursor {
+	GObject parent_instance;
 	sqlite3_stmt *stmt;
-	TrackerDBStatementSqlite *ref_stmt;
+	TrackerDBStatement *ref_stmt;
 	gboolean finished;
 };
 
-struct TrackerDBStatementSqlite {
+struct TrackerDBCursorClass {
+	GObjectClass parent_class;
+};
+
+struct TrackerDBStatement {
 	GObject parent_instance;
-	TrackerDBStatementSqlitePrivate *priv;
+	TrackerDBInterface *db_interface;
+	sqlite3_stmt *stmt;
+	gboolean stmt_is_sunk;
 };
 
-struct TrackerDBStatementSqliteClass {
+struct TrackerDBStatementClass {
 	GObjectClass parent_class;
 };
 
-static GType tracker_db_cursor_sqlite_get_type (void);
-static GType tracker_db_statement_sqlite_get_type (void);
-
-static void tracker_db_interface_sqlite_iface_init (TrackerDBInterfaceIface *iface);
-static void tracker_db_statement_sqlite_iface_init (TrackerDBStatementIface *iface);
-static void tracker_db_cursor_sqlite_iface_init (TrackerDBCursorIface *iface);
-
-static TrackerDBStatementSqlite * tracker_db_statement_sqlite_new (TrackerDBInterfaceSqlite     *db_interface,
+static TrackerDBStatement       * tracker_db_statement_sqlite_new (TrackerDBInterface     *db_interface,
                                                                    sqlite3_stmt                         *sqlite_stmt);
 static TrackerDBCursor          * tracker_db_cursor_sqlite_new    (sqlite3_stmt                         *sqlite_stmt,
-                                                                   TrackerDBStatementSqlite     *ref_stmt);
-static void tracker_db_statement_sqlite_reset (TrackerDBStatementSqlite *stmt);
+                                                                   TrackerDBStatement     *ref_stmt);
+static void tracker_db_statement_sqlite_reset (TrackerDBStatement *stmt);
 
 enum {
 	PROP_0,
 	PROP_FILENAME,
-	PROP_IN_TRANSACTION,
 	PROP_RO
 };
 
-G_DEFINE_TYPE_WITH_CODE (TrackerDBInterfaceSqlite, tracker_db_interface_sqlite, G_TYPE_OBJECT,
-                         G_IMPLEMENT_INTERFACE (TRACKER_TYPE_DB_INTERFACE,
-                                                tracker_db_interface_sqlite_iface_init))
+G_DEFINE_TYPE (TrackerDBInterface, tracker_db_interface, G_TYPE_OBJECT)
 
-G_DEFINE_TYPE_WITH_CODE (TrackerDBStatementSqlite, tracker_db_statement_sqlite, G_TYPE_OBJECT,
-                         G_IMPLEMENT_INTERFACE (TRACKER_TYPE_DB_STATEMENT,
-                                                tracker_db_statement_sqlite_iface_init))
+G_DEFINE_TYPE (TrackerDBStatement, tracker_db_statement, G_TYPE_OBJECT)
 
-G_DEFINE_TYPE_WITH_CODE (TrackerDBCursorSqlite, tracker_db_cursor_sqlite, G_TYPE_OBJECT,
-                         G_IMPLEMENT_INTERFACE (TRACKER_TYPE_DB_CURSOR,
-                                                tracker_db_cursor_sqlite_iface_init))
+G_DEFINE_TYPE (TrackerDBCursor, tracker_db_cursor, G_TYPE_OBJECT)
 
 void
 tracker_db_interface_sqlite_enable_shared_cache (void)
@@ -491,62 +443,62 @@ function_sparql_regex (sqlite3_context *context,
 static int
 check_interrupt (void *user_data)
 {
-	TrackerDBInterfaceSqlitePrivate *priv = user_data;
-	return g_atomic_int_get (&priv->interrupt);
+	TrackerDBInterface *db_interface = user_data;
+	return g_atomic_int_get (&db_interface->interrupt);
 }
 
 static void
-open_database (TrackerDBInterfaceSqlitePrivate *priv)
+open_database (TrackerDBInterface *db_interface)
 {
-	g_assert (priv->filename != NULL);
+	g_assert (db_interface->filename != NULL);
 
-	if (!priv->ro) {
-		if (sqlite3_open (priv->filename, &priv->db) != SQLITE_OK) {
-			g_critical ("Could not open sqlite3 database:'%s'", priv->filename);
+	if (!db_interface->ro) {
+		if (sqlite3_open (db_interface->filename, &db_interface->db) != SQLITE_OK) {
+			g_critical ("Could not open sqlite3 database:'%s'", db_interface->filename);
 		} else {
-			g_message ("Opened sqlite3 database:'%s'", priv->filename);
+			g_message ("Opened sqlite3 database:'%s'", db_interface->filename);
 		}
 	} else {
-		if (sqlite3_open_v2 (priv->filename, &priv->db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
-			g_critical ("Could not open sqlite3 database:'%s'", priv->filename);
+		if (sqlite3_open_v2 (db_interface->filename, &db_interface->db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
+			g_critical ("Could not open sqlite3 database:'%s'", db_interface->filename);
 		} else {
-			g_message ("Opened sqlite3 database:'%s'", priv->filename);
+			g_message ("Opened sqlite3 database:'%s'", db_interface->filename);
 		}
 	}
 
-	sqlite3_progress_handler (priv->db, 100,
-	                          check_interrupt, priv);
+	sqlite3_progress_handler (db_interface->db, 100,
+	                          check_interrupt, db_interface);
 
-	sqlite3_create_function (priv->db, "SparqlRegex", 3, SQLITE_ANY,
-	                         priv, &function_sparql_regex,
+	sqlite3_create_function (db_interface->db, "SparqlRegex", 3, SQLITE_ANY,
+	                         db_interface, &function_sparql_regex,
 	                         NULL, NULL);
 
-	sqlite3_create_function (priv->db, "SparqlHaversineDistance", 4, SQLITE_ANY,
-	                         priv, &function_sparql_haversine_distance,
+	sqlite3_create_function (db_interface->db, "SparqlHaversineDistance", 4, SQLITE_ANY,
+	                         db_interface, &function_sparql_haversine_distance,
 	                         NULL, NULL);
 
-	sqlite3_create_function (priv->db, "SparqlCartesianDistance", 4, SQLITE_ANY,
-	                         priv, &function_sparql_cartesian_distance,
+	sqlite3_create_function (db_interface->db, "SparqlCartesianDistance", 4, SQLITE_ANY,
+	                         db_interface, &function_sparql_cartesian_distance,
 	                         NULL, NULL);
 
-	sqlite3_create_function (priv->db, "SparqlStringFromFilename", 1, SQLITE_ANY,
-	                         priv, &function_sparql_string_from_filename,
+	sqlite3_create_function (db_interface->db, "SparqlStringFromFilename", 1, SQLITE_ANY,
+	                         db_interface, &function_sparql_string_from_filename,
 	                         NULL, NULL);
 
-	sqlite3_create_function (priv->db, "SparqlStringJoin", -1, SQLITE_ANY,
-	                         priv, &function_sparql_string_join,
+	sqlite3_create_function (db_interface->db, "SparqlStringJoin", -1, SQLITE_ANY,
+	                         db_interface, &function_sparql_string_join,
 	                         NULL, NULL);
 
-	sqlite3_create_function (priv->db, "SparqlUriIsParent", 2, SQLITE_ANY,
-	                         priv, &function_sparql_uri_is_parent,
+	sqlite3_create_function (db_interface->db, "SparqlUriIsParent", 2, SQLITE_ANY,
+	                         db_interface, &function_sparql_uri_is_parent,
 	                         NULL, NULL);
 
-	sqlite3_create_function (priv->db, "SparqlUriIsDescendant", 2, SQLITE_ANY,
-	                         priv, &function_sparql_uri_is_descendant,
+	sqlite3_create_function (db_interface->db, "SparqlUriIsDescendant", 2, SQLITE_ANY,
+	                         db_interface, &function_sparql_uri_is_descendant,
 	                         NULL, NULL);
 
-	sqlite3_extended_result_codes (priv->db, 0);
-	sqlite3_busy_timeout (priv->db, 100000);
+	sqlite3_extended_result_codes (db_interface->db, 0);
+	sqlite3_busy_timeout (db_interface->db, 100000);
 }
 
 static GObject *
@@ -555,14 +507,14 @@ tracker_db_interface_sqlite_constructor (GType                  type,
                                          GObjectConstructParam *construct_params)
 {
 	GObject *object;
-	TrackerDBInterfaceSqlitePrivate *priv;
+	TrackerDBInterface *db_iface;
 
-	object = (* G_OBJECT_CLASS (tracker_db_interface_sqlite_parent_class)->constructor) (type,
+	object = (* G_OBJECT_CLASS (tracker_db_interface_parent_class)->constructor) (type,
 		               n_construct_properties,
 		               construct_params);
-	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (object);
+	db_iface = TRACKER_DB_INTERFACE (object);
 
-	open_database (priv);
+	open_database (db_iface);
 
 	return object;
 }
@@ -573,19 +525,16 @@ tracker_db_interface_sqlite_set_property (GObject       *object,
                                           const GValue  *value,
                                           GParamSpec    *pspec)
 {
-	TrackerDBInterfaceSqlitePrivate *priv;
+	TrackerDBInterface *db_iface;
 
-	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (object);
+	db_iface = TRACKER_DB_INTERFACE (object);
 
 	switch (prop_id) {
 	case PROP_RO:
-		priv->ro = g_value_get_boolean (value);
+		db_iface->ro = g_value_get_boolean (value);
 		break;
 	case PROP_FILENAME:
-		priv->filename = g_value_dup_string (value);
-		break;
-	case PROP_IN_TRANSACTION:
-		priv->in_transaction = g_value_get_boolean (value);
+		db_iface->filename = g_value_dup_string (value);
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -598,19 +547,16 @@ tracker_db_interface_sqlite_get_property (GObject    *object,
                                           GValue     *value,
                                           GParamSpec *pspec)
 {
-	TrackerDBInterfaceSqlitePrivate *priv;
+	TrackerDBInterface *db_iface;
 
-	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (object);
+	db_iface = TRACKER_DB_INTERFACE (object);
 
 	switch (prop_id) {
 	case PROP_RO:
-		g_value_set_boolean (value, priv->ro);
+		g_value_set_boolean (value, db_iface->ro);
 		break;
 	case PROP_FILENAME:
-		g_value_set_string (value, priv->filename);
-		break;
-	case PROP_IN_TRANSACTION:
-		g_value_set_boolean (value, priv->in_transaction);
+		g_value_set_string (value, db_iface->filename);
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -618,57 +564,52 @@ tracker_db_interface_sqlite_get_property (GObject    *object,
 }
 
 static void
-close_database (GObject                         *object,
-                TrackerDBInterfaceSqlitePrivate *priv)
+close_database (TrackerDBInterface *db_interface)
 {
 	gint rc;
 
-	g_hash_table_unref (priv->dynamic_statements);
-	priv->dynamic_statements = NULL;
+	g_hash_table_unref (db_interface->dynamic_statements);
+	db_interface->dynamic_statements = NULL;
 
-	g_slist_foreach (priv->function_data, (GFunc) g_free, NULL);
-	g_slist_free (priv->function_data);
-	priv->function_data = NULL;
+	g_slist_foreach (db_interface->function_data, (GFunc) g_free, NULL);
+	g_slist_free (db_interface->function_data);
+	db_interface->function_data = NULL;
 
-	if (priv->fts_initialized) {
-		tracker_fts_shutdown (object);
+	if (db_interface->fts_initialized) {
+		tracker_fts_shutdown (G_OBJECT (db_interface));
 	}
 
-	rc = sqlite3_close (priv->db);
+	rc = sqlite3_close (db_interface->db);
 	g_warn_if_fail (rc == SQLITE_OK);
 }
 
 void
-tracker_db_interface_sqlite_fts_init (TrackerDBInterfaceSqlite *interface,
+tracker_db_interface_sqlite_fts_init (TrackerDBInterface *db_interface,
                                       gboolean                  create)
 {
-	TrackerDBInterfaceSqlitePrivate *priv;
-
-	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (interface);
-
-	tracker_fts_init (priv->db, create, G_OBJECT (interface));
-	priv->fts_initialized = TRUE;
+	tracker_fts_init (db_interface->db, create, G_OBJECT (db_interface));
+	db_interface->fts_initialized = TRUE;
 }
 
 static void
 tracker_db_interface_sqlite_finalize (GObject *object)
 {
-	TrackerDBInterfaceSqlitePrivate *priv;
+	TrackerDBInterface *db_interface;
 
-	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (object);
+	db_interface = TRACKER_DB_INTERFACE (object);
 
-	close_database (object, priv);
+	close_database (db_interface);
 
-	g_message ("Closed sqlite3 database:'%s'", priv->filename);
+	g_message ("Closed sqlite3 database:'%s'", db_interface->filename);
 
 
-	g_free (priv->filename);
+	g_free (db_interface->filename);
 
-	G_OBJECT_CLASS (tracker_db_interface_sqlite_parent_class)->finalize (object);
+	G_OBJECT_CLASS (tracker_db_interface_parent_class)->finalize (object);
 }
 
 static void
-tracker_db_interface_sqlite_class_init (TrackerDBInterfaceSqliteClass *class)
+tracker_db_interface_class_init (TrackerDBInterfaceClass *class)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (class);
 
@@ -684,10 +625,6 @@ tracker_db_interface_sqlite_class_init (TrackerDBInterfaceSqliteClass *class)
 	                                                      "DB filename",
 	                                                      NULL,
 	                                                      G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-	/* Override properties from interface */
-	g_object_class_override_property (object_class,
-	                                  PROP_IN_TRANSACTION,
-	                                  "in-transaction");
 
 	g_object_class_install_property (object_class,
 	                                 PROP_RO,
@@ -696,30 +633,39 @@ tracker_db_interface_sqlite_class_init (TrackerDBInterfaceSqliteClass *class)
 	                                                       "Whether the connection is read only",
 	                                                       FALSE,
 	                                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
-	g_type_class_add_private (object_class,
-	                          sizeof (TrackerDBInterfaceSqlitePrivate));
 }
 
 static void
-prepare_database (TrackerDBInterfaceSqlitePrivate *priv)
+prepare_database (TrackerDBInterface *db_interface)
 {
-	priv->dynamic_statements = g_hash_table_new_full (g_str_hash, g_str_equal,
-	                                                  (GDestroyNotify) g_free,
-	                                                  (GDestroyNotify) g_object_unref);
+	db_interface->dynamic_statements = g_hash_table_new_full (g_str_hash, g_str_equal,
+	                                                          (GDestroyNotify) g_free,
+	                                                          (GDestroyNotify) g_object_unref);
 }
 
 static void
-tracker_db_interface_sqlite_init (TrackerDBInterfaceSqlite *db_interface)
+tracker_db_interface_init (TrackerDBInterface *db_interface)
 {
-	TrackerDBInterfaceSqlitePrivate *priv;
+	db_interface->ro = FALSE;
 
-	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE_O (db_interface);
+	prepare_database (db_interface);
+}
 
-	priv->ro = FALSE;
-	db_interface->priv = priv;
+static TrackerDBResultSet *
+ensure_result_set_state (TrackerDBResultSet *result_set)
+{
+	if (!result_set)
+		return NULL;
 
-	prepare_database (priv);
+	if (tracker_db_result_set_get_n_rows (result_set) == 0) {
+		g_object_unref (result_set);
+		return NULL;
+	}
+
+	/* ensure that it's at the first item */
+	tracker_db_result_set_rewind (result_set);
+
+	return result_set;
 }
 
 static void
@@ -765,25 +711,31 @@ add_row (TrackerDBResultSet *result_set,
 }
 
 
-static TrackerDBStatement *
-tracker_db_interface_sqlite_create_statement (TrackerDBInterface  *db_interface,
-                                              GError             **error,
-                                              const gchar         *query)
+TrackerDBStatement *
+tracker_db_interface_create_statement (TrackerDBInterface  *db_interface,
+                                       GError             **error,
+                                       const gchar         *query,
+                                       ...)
 {
-	TrackerDBInterfaceSqlitePrivate *priv;
-	TrackerDBStatementSqlite *stmt;
+	TrackerDBStatement *stmt;
+	va_list args;
+	gchar *full_query;
+
+	g_return_val_if_fail (TRACKER_IS_DB_INTERFACE (db_interface), NULL);
 
-	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (db_interface);
+	va_start (args, query);
+	full_query = g_strdup_vprintf (query, args);
+	va_end (args);
 
-	stmt = g_hash_table_lookup (priv->dynamic_statements, query);
+	stmt = g_hash_table_lookup (db_interface->dynamic_statements, full_query);
 
 	if (!stmt) {
 		sqlite3_stmt *sqlite_stmt;
 		int retval;
 
-		g_debug ("Preparing query: '%s'", query);
+		g_debug ("Preparing query: '%s'", full_query);
 
-		retval = sqlite3_prepare_v2 (priv->db, query, -1, &sqlite_stmt, NULL);
+		retval = sqlite3_prepare_v2 (db_interface->db, full_query, -1, &sqlite_stmt, NULL);
 
 		if (retval != SQLITE_OK) {
 
@@ -797,15 +749,21 @@ tracker_db_interface_sqlite_create_statement (TrackerDBInterface  *db_interface,
 				             TRACKER_DB_INTERFACE_ERROR,
 				             TRACKER_DB_QUERY_ERROR,
 				             "%s",
-				             sqlite3_errmsg (priv->db));
+				             sqlite3_errmsg (db_interface->db));
 			}
 
+			g_free (full_query);
+
 			return NULL;
 		}
 
-		stmt = tracker_db_statement_sqlite_new (TRACKER_DB_INTERFACE_SQLITE (db_interface), sqlite_stmt);
-		g_hash_table_insert (priv->dynamic_statements, g_strdup (query), stmt);
+		stmt = tracker_db_statement_sqlite_new (db_interface, sqlite_stmt);
+
+		/* ownership of full_query is transferred to the hash table */
+		g_hash_table_insert (db_interface->dynamic_statements, full_query, stmt);
 	} else {
+		g_free (full_query);
+
 		tracker_db_statement_sqlite_reset (stmt);
 	}
 
@@ -813,22 +771,20 @@ tracker_db_interface_sqlite_create_statement (TrackerDBInterface  *db_interface,
 }
 
 static TrackerDBResultSet *
-create_result_set_from_stmt (TrackerDBInterfaceSqlite  *interface,
+create_result_set_from_stmt (TrackerDBInterface  *interface,
                              sqlite3_stmt              *stmt,
                              GError                   **error)
 {
-	TrackerDBInterfaceSqlitePrivate *priv;
 	TrackerDBResultSet *result_set = NULL;
 	gint columns, result;
 
-	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (interface);
 	columns = sqlite3_column_count (stmt);
 	result = SQLITE_OK;
 
 	while (result == SQLITE_OK  ||
 	       result == SQLITE_ROW) {
 
-		if (g_atomic_int_get (&priv->interrupt) == 1) {
+		if (g_atomic_int_get (&interface->interrupt) == 1) {
 			result = SQLITE_INTERRUPT;
 			sqlite3_reset (stmt);
 		} else {
@@ -854,29 +810,29 @@ create_result_set_from_stmt (TrackerDBInterfaceSqlite  *interface,
 	if (result != SQLITE_DONE) {
 
 		/* This is rather fatal */
-		if (sqlite3_errcode (priv->db) == SQLITE_IOERR ||
-		    sqlite3_errcode (priv->db) == SQLITE_CORRUPT ||
-		    sqlite3_errcode (priv->db) == SQLITE_NOTADB) {
+		if (sqlite3_errcode (interface->db) == SQLITE_IOERR ||
+		    sqlite3_errcode (interface->db) == SQLITE_CORRUPT ||
+		    sqlite3_errcode (interface->db) == SQLITE_NOTADB) {
 
 			sqlite3_finalize (stmt);
-			sqlite3_close (priv->db);
+			sqlite3_close (interface->db);
 
-			g_unlink (priv->filename);
+			g_unlink (interface->filename);
 
 			g_error ("SQLite experienced an error with file:'%s'. "
 			         "It is either NOT a SQLite database or it is "
 			         "corrupt or there was an IO error accessing the data. "
 			         "This file has now been removed and will be recreated on the next start. "
 			         "Shutting down now.",
-			         priv->filename);
+			         interface->filename);
 
 			return NULL;
 		}
 
 		if (!error) {
 			g_warning ("Could not perform SQLite operation, error:%d->'%s'",
-			           sqlite3_errcode (priv->db),
-			           sqlite3_errmsg (priv->db));
+			           sqlite3_errcode (interface->db),
+			           sqlite3_errmsg (interface->db));
 		} else {
 			if (result == SQLITE_INTERRUPT) {
 				g_set_error (error,
@@ -888,7 +844,7 @@ create_result_set_from_stmt (TrackerDBInterfaceSqlite  *interface,
 				             TRACKER_DB_INTERFACE_ERROR,
 				             TRACKER_DB_QUERY_ERROR,
 				             "%s",
-				             sqlite3_errmsg (priv->db));
+				             sqlite3_errmsg (interface->db));
 			}
 		}
 
@@ -900,81 +856,69 @@ create_result_set_from_stmt (TrackerDBInterfaceSqlite  *interface,
 		return NULL;
 	}
 
-	return result_set;
+	return ensure_result_set_state (result_set);
 }
 
-
-static TrackerDBResultSet *
-tracker_db_interface_sqlite_execute_query (TrackerDBInterface  *db_interface,
-                                           GError             **error,
-                                           const gchar         *query)
+TrackerDBResultSet *
+tracker_db_interface_execute_vquery (TrackerDBInterface  *db_interface,
+                                     GError             **error,
+                                     const gchar         *query,
+                                     va_list              args)
 {
-	TrackerDBInterfaceSqlitePrivate *priv;
+	gchar *full_query;
 	TrackerDBResultSet *result_set;
 	sqlite3_stmt *stmt;
 	int retval;
 
-	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (db_interface);
+	full_query = g_strdup_vprintf (query, args);
 
-	/* g_debug ("Running query: '%s'", query); */
-	retval = sqlite3_prepare_v2 (priv->db, query, -1, &stmt, NULL);
+	/* g_debug ("Running query: '%s'", full_query); */
+	retval = sqlite3_prepare_v2 (db_interface->db, full_query, -1, &stmt, NULL);
 
 	if (retval != SQLITE_OK) {
 		g_set_error (error,
 		             TRACKER_DB_INTERFACE_ERROR,
 		             TRACKER_DB_QUERY_ERROR,
 		             "%s",
-		             sqlite3_errmsg (priv->db));
+		             sqlite3_errmsg (db_interface->db));
+		g_free (full_query);
 		return NULL;
 	} else if (stmt == NULL) {
 		g_set_error (error,
 		             TRACKER_DB_INTERFACE_ERROR,
 		             TRACKER_DB_QUERY_ERROR,
 		             "Could not prepare SQL statement:'%s'",
-		             query);
+		             full_query);
 
+		g_free (full_query);
 		return NULL;
 	}
 
-	result_set = create_result_set_from_stmt (TRACKER_DB_INTERFACE_SQLITE (db_interface), stmt, error);
+	result_set = create_result_set_from_stmt (db_interface, stmt, error);
 	sqlite3_finalize (stmt);
 
+	g_free (full_query);
 	return result_set;
 }
 
-static gboolean
-tracker_db_interface_sqlite_interrupt (TrackerDBInterface *iface)
+gboolean
+tracker_db_interface_interrupt (TrackerDBInterface *iface)
 {
-	TrackerDBInterfaceSqlitePrivate *priv;
-
-	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (iface);
-
-	g_atomic_int_set (&priv->interrupt, 1);
+	g_atomic_int_set (&iface->interrupt, 1);
 
 	return TRUE;
 }
 
-static void
-tracker_db_interface_sqlite_reset_interrupt (TrackerDBInterface *iface)
-{
-	TrackerDBInterfaceSqlitePrivate *priv;
-	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (iface);
-	priv->interrupt = 0;
-}
-
-static void
-tracker_db_interface_sqlite_iface_init (TrackerDBInterfaceIface *iface)
+void
+tracker_db_interface_reset_interrupt (TrackerDBInterface *iface)
 {
-	iface->create_statement = tracker_db_interface_sqlite_create_statement;
-	iface->execute_query = tracker_db_interface_sqlite_execute_query;
-	iface->interrupt = tracker_db_interface_sqlite_interrupt;
-	iface->reset_interrupt = tracker_db_interface_sqlite_reset_interrupt;
+	iface->interrupt = 0;
 }
 
 TrackerDBInterface *
 tracker_db_interface_sqlite_new (const gchar *filename)
 {
-	return g_object_new (TRACKER_TYPE_DB_INTERFACE_SQLITE,
+	return g_object_new (TRACKER_TYPE_DB_INTERFACE,
 	                     "filename", filename,
 	                     NULL);
 }
@@ -982,7 +926,7 @@ tracker_db_interface_sqlite_new (const gchar *filename)
 TrackerDBInterface *
 tracker_db_interface_sqlite_new_ro (const gchar *filename)
 {
-	return g_object_new (TRACKER_TYPE_DB_INTERFACE_SQLITE,
+	return g_object_new (TRACKER_TYPE_DB_INTERFACE,
 	                     "filename", filename,
 	                     "read-only", TRUE,
 	                     NULL);
@@ -1003,236 +947,198 @@ collation_function (gpointer      data,
 }
 
 gboolean
-tracker_db_interface_sqlite_set_collation_function (TrackerDBInterfaceSqlite *interface,
+tracker_db_interface_sqlite_set_collation_function (TrackerDBInterface *interface,
                                                     const gchar                      *name,
                                                     TrackerDBCollationFunc    func)
 {
-	TrackerDBInterfaceSqlitePrivate *priv;
 	gint result;
 
-	g_return_val_if_fail (TRACKER_IS_DB_INTERFACE_SQLITE (interface), FALSE);
+	g_return_val_if_fail (TRACKER_IS_DB_INTERFACE (interface), FALSE);
 
-	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (interface);
-
-	result = sqlite3_create_collation (priv->db, name, SQLITE_UTF8, func, &collation_function);
+	result = sqlite3_create_collation (interface->db, name, SQLITE_UTF8, func, &collation_function);
 
 	return (result == SQLITE_OK);
 }
 
 gint64
-tracker_db_interface_sqlite_get_last_insert_id (TrackerDBInterfaceSqlite *interface)
+tracker_db_interface_sqlite_get_last_insert_id (TrackerDBInterface *interface)
 {
-	TrackerDBInterfaceSqlitePrivate *priv;
-
-	g_return_val_if_fail (TRACKER_IS_DB_INTERFACE_SQLITE (interface), 0);
-
-	priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (interface);
+	g_return_val_if_fail (TRACKER_IS_DB_INTERFACE (interface), 0);
 
-	return (gint64) sqlite3_last_insert_rowid (priv->db);
+	return (gint64) sqlite3_last_insert_rowid (interface->db);
 }
 
 static void
-tracker_db_statement_sqlite_finalize (GObject *object)
+tracker_db_statement_finalize (GObject *object)
 {
-	TrackerDBStatementSqlitePrivate *priv;
+	TrackerDBStatement *stmt;
 
-	priv = TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE (object);
+	stmt = TRACKER_DB_STATEMENT (object);
 
 	/* A cursor was still open while we're being finalized, because a cursor
 	 * holds its own reference, this means that somebody is unreffing a stmt
 	 * too often. We mustn't sqlite3_finalize the priv->stmt in this case,
 	 * though. It would crash&burn the cursor. */
 
-	g_assert (!priv->stmt_is_sunk);
+	g_assert (!stmt->stmt_is_sunk);
 
-	sqlite3_finalize (priv->stmt);
+	sqlite3_finalize (stmt->stmt);
 
-	G_OBJECT_CLASS (tracker_db_statement_sqlite_parent_class)->finalize (object);
+	G_OBJECT_CLASS (tracker_db_statement_parent_class)->finalize (object);
 }
 
 static void
-tracker_db_statement_sqlite_class_init (TrackerDBStatementSqliteClass *class)
+tracker_db_statement_class_init (TrackerDBStatementClass *class)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (class);
 
-	object_class->finalize = tracker_db_statement_sqlite_finalize;
-
-	g_type_class_add_private (object_class,
-	                          sizeof (TrackerDBStatementSqlitePrivate));
+	object_class->finalize = tracker_db_statement_finalize;
 }
 
-static TrackerDBStatementSqlite *
-tracker_db_statement_sqlite_new (TrackerDBInterfaceSqlite       *db_interface,
-                                 sqlite3_stmt                   *sqlite_stmt)
+static TrackerDBStatement *
+tracker_db_statement_sqlite_new (TrackerDBInterface       *db_interface,
+                                 sqlite3_stmt             *sqlite_stmt)
 {
-	TrackerDBStatementSqlite *stmt;
-	TrackerDBStatementSqlitePrivate *priv;
-
-	stmt = g_object_new (TRACKER_TYPE_DB_STATEMENT_SQLITE, NULL);
+	TrackerDBStatement *stmt;
 
-	priv = TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE (stmt);
+	stmt = g_object_new (TRACKER_TYPE_DB_STATEMENT, NULL);
 
-	priv->db_interface = db_interface;
-	priv->stmt = sqlite_stmt;
-	priv->stmt_is_sunk = FALSE;
+	stmt->db_interface = db_interface;
+	stmt->stmt = sqlite_stmt;
+	stmt->stmt_is_sunk = FALSE;
 
 	return stmt;
 }
 
 static void
-tracker_db_cursor_sqlite_finalize (GObject *object)
+tracker_db_cursor_finalize (GObject *object)
 {
-	TrackerDBCursorSqlitePrivate *priv;
+	TrackerDBCursor *cursor;
 
-	priv = TRACKER_DB_CURSOR_SQLITE_GET_PRIVATE (object);
+	cursor = TRACKER_DB_CURSOR (object);
 
-	if (priv->ref_stmt) {
-		TrackerDBStatementSqlitePrivate *stmt_priv;
-		stmt_priv = TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE (priv->ref_stmt);
-		stmt_priv->stmt_is_sunk = FALSE;
-		tracker_db_statement_sqlite_reset (priv->ref_stmt);
-		g_object_unref (priv->ref_stmt);
+	if (cursor->ref_stmt) {
+		cursor->ref_stmt->stmt_is_sunk = FALSE;
+		tracker_db_statement_sqlite_reset (cursor->ref_stmt);
+		g_object_unref (cursor->ref_stmt);
 	} else {
-		sqlite3_finalize (priv->stmt);
+		sqlite3_finalize (cursor->stmt);
 	}
 
-	G_OBJECT_CLASS (tracker_db_cursor_sqlite_parent_class)->finalize (object);
+	G_OBJECT_CLASS (tracker_db_cursor_parent_class)->finalize (object);
 }
 
 static void
-tracker_db_cursor_sqlite_class_init (TrackerDBCursorSqliteClass *class)
+tracker_db_cursor_class_init (TrackerDBCursorClass *class)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (class);
 
-	object_class->finalize = tracker_db_cursor_sqlite_finalize;
-
-	g_type_class_add_private (object_class,
-	                          sizeof (TrackerDBCursorSqlitePrivate));
+	object_class->finalize = tracker_db_cursor_finalize;
 }
 
 static TrackerDBCursor *
 tracker_db_cursor_sqlite_new (sqlite3_stmt              *sqlite_stmt,
-                              TrackerDBStatementSqlite  *ref_stmt)
+                              TrackerDBStatement        *ref_stmt)
 {
 	TrackerDBCursor *cursor;
-	TrackerDBCursorSqlitePrivate *priv;
-
-	cursor = g_object_new (TRACKER_TYPE_DB_CURSOR_SQLITE, NULL);
 
-	priv = TRACKER_DB_CURSOR_SQLITE_GET_PRIVATE (cursor);
+	cursor = g_object_new (TRACKER_TYPE_DB_CURSOR, NULL);
 
-	priv->stmt = sqlite_stmt;
-	priv->finished = FALSE;
+	cursor->stmt = sqlite_stmt;
+	cursor->finished = FALSE;
 
 	if (ref_stmt) {
-		TrackerDBStatementSqlitePrivate *stmt_priv;
-		stmt_priv = TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE (ref_stmt);
-		stmt_priv->stmt_is_sunk = TRUE;
-		priv->ref_stmt = g_object_ref (ref_stmt);
+		ref_stmt->stmt_is_sunk = TRUE;
+		cursor->ref_stmt = g_object_ref (ref_stmt);
 	} else {
-		priv->ref_stmt = NULL;
+		cursor->ref_stmt = NULL;
 	}
 
 	return cursor;
 }
 
-static void
-tracker_db_statement_sqlite_bind_double (TrackerDBStatement      *stmt,
+void
+tracker_db_statement_bind_double (TrackerDBStatement      *stmt,
                                          int                      index,
                                          double                           value)
 {
-	TrackerDBStatementSqlitePrivate *priv;
-
-	priv = TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE (stmt);
+	g_return_if_fail (TRACKER_IS_DB_STATEMENT (stmt));
 
-	g_assert (!priv->stmt_is_sunk);
+	g_assert (!stmt->stmt_is_sunk);
 
-	sqlite3_bind_double (priv->stmt, index + 1, value);
+	sqlite3_bind_double (stmt->stmt, index + 1, value);
 }
 
-static void
-tracker_db_statement_sqlite_bind_int (TrackerDBStatement         *stmt,
+void
+tracker_db_statement_bind_int (TrackerDBStatement         *stmt,
                                       int                         index,
                                       int                         value)
 {
-	TrackerDBStatementSqlitePrivate *priv;
-
-	priv = TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE (stmt);
+	g_return_if_fail (TRACKER_IS_DB_STATEMENT (stmt));
 
-	g_assert (!priv->stmt_is_sunk);
+	g_assert (!stmt->stmt_is_sunk);
 
-	sqlite3_bind_int (priv->stmt, index + 1, value);
+	sqlite3_bind_int (stmt->stmt, index + 1, value);
 }
 
-static void
-tracker_db_statement_sqlite_bind_int64 (TrackerDBStatement       *stmt,
+void
+tracker_db_statement_bind_int64 (TrackerDBStatement       *stmt,
                                         int                      index,
                                         gint64                           value)
 {
-	TrackerDBStatementSqlitePrivate *priv;
-
-	priv = TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE (stmt);
+	g_return_if_fail (TRACKER_IS_DB_STATEMENT (stmt));
 
-	g_assert (!priv->stmt_is_sunk);
+	g_assert (!stmt->stmt_is_sunk);
 
-	sqlite3_bind_int64 (priv->stmt, index + 1, value);
+	sqlite3_bind_int64 (stmt->stmt, index + 1, value);
 }
 
-static void
-tracker_db_statement_sqlite_bind_null (TrackerDBStatement        *stmt,
+void
+tracker_db_statement_bind_null (TrackerDBStatement        *stmt,
                                        int                        index)
 {
-	TrackerDBStatementSqlitePrivate *priv;
-
-	priv = TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE (stmt);
+	g_return_if_fail (TRACKER_IS_DB_STATEMENT (stmt));
 
-	g_assert (!priv->stmt_is_sunk);
+	g_assert (!stmt->stmt_is_sunk);
 
-	sqlite3_bind_null (priv->stmt, index + 1);
+	sqlite3_bind_null (stmt->stmt, index + 1);
 }
 
-static void
-tracker_db_statement_sqlite_bind_text (TrackerDBStatement        *stmt,
+void
+tracker_db_statement_bind_text (TrackerDBStatement        *stmt,
                                        int                        index,
                                        const gchar               *value)
 {
-	TrackerDBStatementSqlitePrivate *priv;
-
-	priv = TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE (stmt);
+	g_return_if_fail (TRACKER_IS_DB_STATEMENT (stmt));
 
-	g_assert (!priv->stmt_is_sunk);
+	g_assert (!stmt->stmt_is_sunk);
 
-	sqlite3_bind_text (priv->stmt, index + 1, value, -1, SQLITE_TRANSIENT);
+	sqlite3_bind_text (stmt->stmt, index + 1, value, -1, SQLITE_TRANSIENT);
 }
 
-static void
-tracker_db_cursor_sqlite_rewind (TrackerDBCursor *cursor)
+void
+tracker_db_cursor_rewind (TrackerDBCursor *cursor)
 {
-	TrackerDBCursorSqlitePrivate *priv;
-
-	priv = TRACKER_DB_CURSOR_SQLITE_GET_PRIVATE (cursor);
+	g_return_if_fail (TRACKER_IS_DB_CURSOR (cursor));
 
-	sqlite3_reset (priv->stmt);
+	sqlite3_reset (cursor->stmt);
 }
 
-static gboolean
-tracker_db_cursor_sqlite_iter_next (TrackerDBCursor *cursor,
+gboolean
+tracker_db_cursor_iter_next (TrackerDBCursor *cursor,
                                     GError         **error)
 {
-	TrackerDBCursorSqlitePrivate *priv = TRACKER_DB_CURSOR_SQLITE_GET_PRIVATE (cursor);
-	TrackerDBStatementSqlite *stmt = priv->ref_stmt;
-	TrackerDBStatementSqlitePrivate *stmt_priv = TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE (stmt);
-	TrackerDBInterfaceSqlite *iface = stmt_priv->db_interface;
-	TrackerDBInterfaceSqlitePrivate *iface_priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (iface);
+	TrackerDBStatement *stmt = cursor->ref_stmt;
+	TrackerDBInterface *iface = stmt->db_interface;
 
-	if (!priv->finished) {
+	if (!cursor->finished) {
 		guint result;
 
-		if (g_atomic_int_get (&iface_priv->interrupt) == 1) {
+		if (g_atomic_int_get (&iface->interrupt) == 1) {
 			result = SQLITE_INTERRUPT;
-			sqlite3_reset (priv->stmt);
+			sqlite3_reset (cursor->stmt);
 		} else {
-			result = sqlite3_step (priv->stmt);
+			result = sqlite3_step (cursor->stmt);
 		}
 
 		if (result == SQLITE_INTERRUPT) {
@@ -1245,47 +1151,40 @@ tracker_db_cursor_sqlite_iter_next (TrackerDBCursor *cursor,
 			g_set_error (error,
 			             TRACKER_DB_INTERFACE_ERROR,
 			             TRACKER_DB_QUERY_ERROR,
-			             "%s", sqlite3_errmsg (iface_priv->db));
+			             "%s", sqlite3_errmsg (iface->db));
 		}
 
-		priv->finished = (result != SQLITE_ROW);
+		cursor->finished = (result != SQLITE_ROW);
 	}
 
-	return (!priv->finished);
+	return (!cursor->finished);
 }
 
-static guint
-tracker_db_cursor_sqlite_get_n_columns (TrackerDBCursor *cursor)
+guint
+tracker_db_cursor_get_n_columns (TrackerDBCursor *cursor)
 {
-	TrackerDBCursorSqlitePrivate *priv;
-
-	priv = TRACKER_DB_CURSOR_SQLITE_GET_PRIVATE (cursor);
-
-	return sqlite3_column_count (priv->stmt);
+	return sqlite3_column_count (cursor->stmt);
 }
 
-static void
-tracker_db_cursor_sqlite_get_value (TrackerDBCursor *cursor,  guint column, GValue *value)
+void
+tracker_db_cursor_get_value (TrackerDBCursor *cursor,  guint column, GValue *value)
 {
-	TrackerDBCursorSqlitePrivate *priv;
 	gint col_type;
 
-	priv = TRACKER_DB_CURSOR_SQLITE_GET_PRIVATE (cursor);
-
-	col_type = sqlite3_column_type (priv->stmt, column);
+	col_type = sqlite3_column_type (cursor->stmt, column);
 
 	switch (col_type) {
 	case SQLITE_TEXT:
 		g_value_init (value, G_TYPE_STRING);
-		g_value_set_string (value, (gchar *) sqlite3_column_text (priv->stmt, column));
+		g_value_set_string (value, (gchar *) sqlite3_column_text (cursor->stmt, column));
 		break;
 	case SQLITE_INTEGER:
 		g_value_init (value, G_TYPE_INT);
-		g_value_set_int (value, sqlite3_column_int (priv->stmt, column));
+		g_value_set_int (value, sqlite3_column_int (cursor->stmt, column));
 		break;
 	case SQLITE_FLOAT:
 		g_value_init (value, G_TYPE_DOUBLE);
-		g_value_set_double (value, sqlite3_column_double (priv->stmt, column));
+		g_value_set_double (value, sqlite3_column_double (cursor->stmt, column));
 		break;
 	case SQLITE_NULL:
 		/* just ignore NULLs */
@@ -1296,107 +1195,61 @@ tracker_db_cursor_sqlite_get_value (TrackerDBCursor *cursor,  guint column, GVal
 
 }
 
-static gint
-tracker_db_cursor_sqlite_get_int (TrackerDBCursor *cursor,  guint column)
+gint
+tracker_db_cursor_get_int (TrackerDBCursor *cursor,  guint column)
 {
-	TrackerDBCursorSqlitePrivate *priv;
-	priv = TRACKER_DB_CURSOR_SQLITE_GET_PRIVATE (cursor);
-	return (gint) sqlite3_column_int (priv->stmt, column);
+	return (gint) sqlite3_column_int (cursor->stmt, column);
 }
 
-static gdouble
-tracker_db_cursor_sqlite_get_double (TrackerDBCursor *cursor,  guint column)
+gdouble
+tracker_db_cursor_get_double (TrackerDBCursor *cursor,  guint column)
 {
-	TrackerDBCursorSqlitePrivate *priv;
-	priv = TRACKER_DB_CURSOR_SQLITE_GET_PRIVATE (cursor);
-	return (gdouble) sqlite3_column_double (priv->stmt, column);
+	return (gdouble) sqlite3_column_double (cursor->stmt, column);
 }
 
 
-static const gchar*
-tracker_db_cursor_sqlite_get_string (TrackerDBCursor *cursor,  guint column)
+const gchar*
+tracker_db_cursor_get_string (TrackerDBCursor *cursor,  guint column)
 {
-	TrackerDBCursorSqlitePrivate *priv;
-	priv = TRACKER_DB_CURSOR_SQLITE_GET_PRIVATE (cursor);
-	return (const gchar *) sqlite3_column_text (priv->stmt, column);
+	return (const gchar *) sqlite3_column_text (cursor->stmt, column);
 }
 
 
-static TrackerDBResultSet *
-tracker_db_statement_sqlite_execute (TrackerDBStatement                  *stmt,
+TrackerDBResultSet *
+tracker_db_statement_execute (TrackerDBStatement                  *stmt,
                                      GError                     **error)
 {
-	TrackerDBStatementSqlitePrivate *priv;
-
-	priv = TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE (stmt);
+	g_return_val_if_fail (!stmt->stmt_is_sunk, NULL);
 
-	g_return_val_if_fail (!priv->stmt_is_sunk, NULL);
-
-	return create_result_set_from_stmt (priv->db_interface, priv->stmt, error);
+	return create_result_set_from_stmt (stmt->db_interface, stmt->stmt, error);
 }
 
-static TrackerDBCursor *
-tracker_db_statement_sqlite_start_cursor (TrackerDBStatement             *stmt,
+TrackerDBCursor *
+tracker_db_statement_start_cursor (TrackerDBStatement             *stmt,
                                           GError                        **error)
 {
-	TrackerDBStatementSqlitePrivate *priv;
-
-	priv = TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE (stmt);
+	g_return_val_if_fail (!stmt->stmt_is_sunk, NULL);
 
-	g_return_val_if_fail (!priv->stmt_is_sunk, NULL);
-
-	return tracker_db_cursor_sqlite_new (priv->stmt, TRACKER_DB_STATEMENT_SQLITE (stmt));
-}
-
-
-static void
-tracker_db_statement_sqlite_iface_init (TrackerDBStatementIface *iface)
-{
-	iface->bind_double = tracker_db_statement_sqlite_bind_double;
-	iface->bind_int = tracker_db_statement_sqlite_bind_int;
-	iface->bind_int64 = tracker_db_statement_sqlite_bind_int64;
-	iface->bind_null = tracker_db_statement_sqlite_bind_null;
-	iface->bind_text = tracker_db_statement_sqlite_bind_text;
-	iface->execute = tracker_db_statement_sqlite_execute;
-	iface->start_cursor = tracker_db_statement_sqlite_start_cursor;
+	return tracker_db_cursor_sqlite_new (stmt->stmt, stmt);
 }
 
 
 static void
-tracker_db_cursor_sqlite_iface_init (TrackerDBCursorIface *iface)
+tracker_db_statement_init (TrackerDBStatement *stmt)
 {
-	iface->rewind = tracker_db_cursor_sqlite_rewind;
-	iface->iter_next = tracker_db_cursor_sqlite_iter_next;
-	iface->get_n_columns = tracker_db_cursor_sqlite_get_n_columns;
-	iface->get_value = tracker_db_cursor_sqlite_get_value;
-	iface->get_int = tracker_db_cursor_sqlite_get_int;
-	iface->get_double = tracker_db_cursor_sqlite_get_double;
-	iface->get_string = tracker_db_cursor_sqlite_get_string;
 }
 
 static void
-tracker_db_statement_sqlite_init (TrackerDBStatementSqlite *stmt)
+tracker_db_cursor_init (TrackerDBCursor *cursor)
 {
-	stmt->priv = TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE_O(stmt);
 }
 
 static void
-tracker_db_cursor_sqlite_init (TrackerDBCursorSqlite *cursor)
+tracker_db_statement_sqlite_reset (TrackerDBStatement *stmt)
 {
-	TrackerDBCursorSqlitePrivate *priv = TRACKER_DB_CURSOR_SQLITE_GET_PRIVATE_O (cursor);
-	cursor->priv = priv;
-}
-
-static void
-tracker_db_statement_sqlite_reset (TrackerDBStatementSqlite *stmt)
-{
-	TrackerDBStatementSqlitePrivate *priv;
-
-	priv = TRACKER_DB_STATEMENT_SQLITE_GET_PRIVATE (stmt);
-
-	g_assert (!priv->stmt_is_sunk);
+	g_assert (!stmt->stmt_is_sunk);
 
-	sqlite3_reset (priv->stmt);
-	sqlite3_clear_bindings (priv->stmt);
+	sqlite3_reset (stmt->stmt);
+	sqlite3_clear_bindings (stmt->stmt);
 }
 
diff --git a/src/libtracker-db/tracker-db-interface-sqlite.h b/src/libtracker-db/tracker-db-interface-sqlite.h
index 042d62c..04cecd0 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.h
+++ b/src/libtracker-db/tracker-db-interface-sqlite.h
@@ -28,41 +28,19 @@ G_BEGIN_DECLS
 #error "only <libtracker-db/tracker-db.h> must be included directly."
 #endif
 
-#define TRACKER_TYPE_DB_INTERFACE_SQLITE         (tracker_db_interface_sqlite_get_type ())
-#define TRACKER_DB_INTERFACE_SQLITE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_DB_INTERFACE_SQLITE, TrackerDBInterfaceSqlite))
-#define TRACKER_DB_INTERFACE_SQLITE_CLASS(c)     (G_TYPE_CHECK_CLASS_CAST ((c),    TRACKER_TYPE_DB_INTERFACE_SQLITE, TrackerDBInterfaceSqliteClass))
-#define TRACKER_IS_DB_INTERFACE_SQLITE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_DB_INTERFACE_SQLITE))
-#define TRACKER_IS_DB_INTERFACE_SQLITE_CLASS(c)  (G_TYPE_CHECK_CLASS_TYPE ((o),    TRACKER_TYPE_DB_INTERFACE_SQLITE))
-#define TRACKER_DB_INTERFACE_SQLITE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),  TRACKER_TYPE_DB_INTERFACE_SQLITE, TrackerDBInterfaceSqliteClass))
-
-typedef struct TrackerDBInterfaceSqlite      TrackerDBInterfaceSqlite;
-typedef struct TrackerDBInterfaceSqliteClass TrackerDBInterfaceSqliteClass;
-typedef struct TrackerDBInterfaceSqlitePrivate TrackerDBInterfaceSqlitePrivate;
-
 typedef gint (* TrackerDBCollationFunc) (gchar *str1,
                                          gint   len1,
                                          gchar *str2,
                                          gint   len2);
 
-struct TrackerDBInterfaceSqlite {
-	GObject parent_instance;
-	TrackerDBInterfaceSqlitePrivate *priv;
-};
-
-struct TrackerDBInterfaceSqliteClass {
-	GObjectClass parent_class;
-};
-
-GType               tracker_db_interface_sqlite_get_type               (void);
-
 TrackerDBInterface *tracker_db_interface_sqlite_new                    (const gchar              *filename);
 TrackerDBInterface *tracker_db_interface_sqlite_new_ro                 (const gchar              *filename);
-gboolean            tracker_db_interface_sqlite_set_collation_function (TrackerDBInterfaceSqlite *interface,
+gboolean            tracker_db_interface_sqlite_set_collation_function (TrackerDBInterface       *interface,
                                                                         const gchar              *name,
                                                                         TrackerDBCollationFunc    func);
-gint64              tracker_db_interface_sqlite_get_last_insert_id     (TrackerDBInterfaceSqlite *interface);
+gint64              tracker_db_interface_sqlite_get_last_insert_id     (TrackerDBInterface       *interface);
 void                tracker_db_interface_sqlite_enable_shared_cache    (void);
-void                tracker_db_interface_sqlite_fts_init               (TrackerDBInterfaceSqlite *interface,
+void                tracker_db_interface_sqlite_fts_init               (TrackerDBInterface       *interface,
                                                                         gboolean                  create);
 
 G_END_DECLS
diff --git a/src/libtracker-db/tracker-db-interface.c b/src/libtracker-db/tracker-db-interface.c
index 379a3d4..f4a6d11 100644
--- a/src/libtracker-db/tracker-db-interface.c
+++ b/src/libtracker-db/tracker-db-interface.c
@@ -23,19 +23,16 @@
 
 #include "tracker-db-interface.h"
 
-#define TRACKER_DB_RESULT_SET_GET_PRIVATE_O(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_DB_RESULT_SET, TrackerDBResultSetPrivate))
-#define TRACKER_DB_RESULT_SET_GET_PRIVATE(o) (((TrackerDBResultSet*)o)->priv)
-
-struct TrackerDBResultSetPrivate {
+struct TrackerDBResultSet {
+	GObject parent_class;
 	GType *col_types;
 	GPtrArray *array;
 	guint columns;
 	guint current_row;
 };
 
-enum {
-	PROP_0,
-	PROP_COLUMNS
+struct TrackerDBResultSetClass {
+	GObjectClass parent_class;
 };
 
 G_DEFINE_TYPE (TrackerDBResultSet, tracker_db_result_set, G_TYPE_OBJECT)
@@ -47,112 +44,6 @@ tracker_db_interface_error_quark (void)
 }
 
 static void
-tracker_db_interface_class_init (gpointer iface)
-{
-	g_object_interface_install_property (iface,
-	                                     g_param_spec_boolean ("in-transaction",
-	                                                           "In transaction",
-	                                                           "Whether the connection has a transaction opened",
-	                                                           FALSE,
-	                                                           G_PARAM_READWRITE));
-}
-
-GType
-tracker_db_interface_get_type (void)
-{
-	static GType type = 0;
-
-	if (G_UNLIKELY (type == 0)) {
-		type = g_type_register_static_simple (G_TYPE_INTERFACE,
-		                                      "TrackerDBInterface",
-		                                      sizeof (TrackerDBInterfaceIface),
-		                                      (GClassInitFunc) tracker_db_interface_class_init,
-		                                      0, NULL, 0);
-
-		g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
-	}
-
-	return type;
-}
-
-GType
-tracker_db_statement_get_type (void)
-{
-	static GType type = 0;
-
-	if (G_UNLIKELY (type == 0)) {
-		type = g_type_register_static_simple (G_TYPE_INTERFACE,
-		                                      "TrackerDBStatement",
-		                                      sizeof (TrackerDBStatementIface),
-		                                      NULL,
-		                                      0, NULL, 0);
-
-		g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
-	}
-
-	return type;
-}
-
-GType
-tracker_db_cursor_get_type (void)
-{
-	static GType type = 0;
-
-	if (G_UNLIKELY (type == 0)) {
-		type = g_type_register_static_simple (G_TYPE_INTERFACE,
-		                                      "TrackerDBCursor",
-		                                      sizeof (TrackerDBCursorIface),
-		                                      NULL,
-		                                      0, NULL, 0);
-
-		g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
-	}
-
-	return type;
-}
-
-
-/* TrackerDBResultSet */
-static void
-tracker_db_result_set_set_property (GObject       *object,
-                                    guint          prop_id,
-                                    const GValue  *value,
-                                    GParamSpec    *pspec)
-{
-	TrackerDBResultSetPrivate *priv;
-
-	priv = TRACKER_DB_RESULT_SET_GET_PRIVATE (object);
-
-	switch (prop_id) {
-	case PROP_COLUMNS:
-		priv->columns = g_value_get_uint (value);
-		priv->col_types = g_new0 (GType, priv->columns);
-		break;
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-	}
-}
-
-static void
-tracker_db_result_set_get_property (GObject    *object,
-                                    guint       prop_id,
-                                    GValue     *value,
-                                    GParamSpec *pspec)
-{
-	TrackerDBResultSetPrivate *priv;
-
-	priv = TRACKER_DB_RESULT_SET_GET_PRIVATE (object);
-
-	switch (prop_id) {
-	case PROP_COLUMNS:
-		g_value_set_uint (value, priv->columns);
-		break;
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-	}
-}
-
-static void
 free_row (gpointer *row,
           gpointer  data)
 {
@@ -172,17 +63,17 @@ free_row (gpointer *row,
 static void
 tracker_db_result_set_finalize (GObject *object)
 {
-	TrackerDBResultSetPrivate *priv;
+	TrackerDBResultSet *result_set;
 
-	priv = TRACKER_DB_RESULT_SET_GET_PRIVATE (object);
+	result_set = TRACKER_DB_RESULT_SET (object);
 
-	if (priv->array) {
-		g_ptr_array_foreach (priv->array, (GFunc) free_row,
-		                     GUINT_TO_POINTER (priv->columns));
-		g_ptr_array_free (priv->array, TRUE);
+	if (result_set->array) {
+		g_ptr_array_foreach (result_set->array, (GFunc) free_row,
+		                     GUINT_TO_POINTER (result_set->columns));
+		g_ptr_array_free (result_set->array, TRUE);
 	}
 
-	g_free (priv->col_types);
+	g_free (result_set->col_types);
 
 	G_OBJECT_CLASS (tracker_db_result_set_parent_class)->finalize (object);
 }
@@ -192,106 +83,14 @@ tracker_db_result_set_class_init (TrackerDBResultSetClass *class)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (class);
 
-	object_class->set_property = tracker_db_result_set_set_property;
-	object_class->get_property = tracker_db_result_set_get_property;
 	object_class->finalize = tracker_db_result_set_finalize;
-
-	g_object_class_install_property (object_class,
-	                                 PROP_COLUMNS,
-	                                 g_param_spec_uint ("columns",
-	                                                    "Columns",
-	                                                    "Resultset columns",
-	                                                    0, G_MAXUINT, 0,
-	                                                    G_PARAM_READWRITE |
-	                                                    G_PARAM_CONSTRUCT_ONLY));
-
-
-	g_type_class_add_private (object_class,
-	                          sizeof (TrackerDBResultSetPrivate));
 }
 
 static void
 tracker_db_result_set_init (TrackerDBResultSet *result_set)
 {
-	result_set->priv = TRACKER_DB_RESULT_SET_GET_PRIVATE_O (result_set);
 }
 
-static TrackerDBResultSet *
-ensure_result_set_state (TrackerDBResultSet *result_set)
-{
-	if (!result_set)
-		return NULL;
-
-	if (tracker_db_result_set_get_n_rows (result_set) == 0) {
-		g_object_unref (result_set);
-		return NULL;
-	}
-
-	/* ensure that it's at the first item */
-	tracker_db_result_set_rewind (result_set);
-
-	return result_set;
-}
-
-TrackerDBStatement *
-tracker_db_interface_create_statement (TrackerDBInterface  *interface,
-                                       GError             **error,
-                                       const gchar         *query,
-                                       ...)
-{
-	TrackerDBStatement *stmt;
-	TrackerDBInterfaceIface *iface;
-	va_list args;
-	gchar *str;
-
-	/* Removed for performance 
-	g_return_val_if_fail (TRACKER_IS_DB_INTERFACE (interface), NULL); */
-
-	g_return_val_if_fail (interface != NULL, NULL);
-	g_return_val_if_fail (query != NULL, NULL);
-
-	va_start (args, query);
-	str = g_strdup_vprintf (query, args);
-	va_end (args);
-
-	iface = TRACKER_DB_INTERFACE_GET_IFACE (interface);
-	stmt = iface->create_statement (interface, error, str);
-	g_free (str);
-
-	return stmt;
-}
-
-
-TrackerDBResultSet *
-tracker_db_interface_execute_vquery (TrackerDBInterface  *interface,
-                                     GError             **error,
-                                     const gchar         *query,
-                                     va_list              args)
-{
-	TrackerDBResultSet *result_set = NULL;
-	gchar *str;
-
-	g_return_val_if_fail (TRACKER_IS_DB_INTERFACE (interface), NULL);
-	g_return_val_if_fail (query != NULL, NULL);
-
-	if (!TRACKER_DB_INTERFACE_GET_IFACE (interface)->execute_query) {
-		g_critical ("Database abstraction %s doesn't implement "
-		            "the method execute_vquery()",
-		            G_OBJECT_TYPE_NAME (interface));
-		return NULL;
-	}
-
-	str = g_strdup_vprintf (query, args);
-	result_set = TRACKER_DB_INTERFACE_GET_IFACE (interface)->execute_query (interface,
-		  error,
-		  str);
-	g_free (str);
-
-	return ensure_result_set_state (result_set);
-}
-
-
-
 TrackerDBResultSet *
 tracker_db_interface_execute_query (TrackerDBInterface  *interface,
                                     GError             **error,
@@ -312,36 +111,6 @@ tracker_db_interface_execute_query (TrackerDBInterface  *interface,
 }
 
 gboolean
-tracker_db_interface_interrupt (TrackerDBInterface *interface)
-{
-	g_return_val_if_fail (TRACKER_IS_DB_INTERFACE (interface), FALSE);
-
-	if (!TRACKER_DB_INTERFACE_GET_IFACE (interface)->interrupt) {
-		g_critical ("Database abstraction %s doesn't implement "
-		            "the method interrupt()",
-		            G_OBJECT_TYPE_NAME (interface));
-		return FALSE;
-	}
-
-	return TRACKER_DB_INTERFACE_GET_IFACE (interface)->interrupt (interface);
-}
-
-void
-tracker_db_interface_reset_interrupt (TrackerDBInterface *interface)
-{
-	g_return_if_fail (TRACKER_IS_DB_INTERFACE (interface));
-
-	if (!TRACKER_DB_INTERFACE_GET_IFACE (interface)->reset_interrupt) {
-		g_critical ("Database abstraction %s doesn't implement "
-		            "the method reset_interrupt()",
-		            G_OBJECT_TYPE_NAME (interface));
-		return;
-	}
-
-	TRACKER_DB_INTERFACE_GET_IFACE (interface)->reset_interrupt (interface);
-}
-
-gboolean
 tracker_db_interface_start_transaction (TrackerDBInterface *interface)
 {
 	GError *error = NULL;
@@ -356,24 +125,14 @@ tracker_db_interface_start_transaction (TrackerDBInterface *interface)
 		return FALSE;
 	}
 
-	g_object_set (interface, "in-transaction", TRUE, NULL);
-
 	return TRUE;
 }
 
 gboolean
 tracker_db_interface_end_db_transaction (TrackerDBInterface *interface)
 {
-	gboolean in_transaction;
 	GError *error = NULL;
 
-	g_object_get (interface, "in-transaction", &in_transaction, NULL);
-
-	if (!in_transaction) {
-		return FALSE;
-	}
-
-	g_object_set (interface, "in-transaction", FALSE, NULL);
 	tracker_db_interface_execute_query (interface, &error, "COMMIT");
 
 	if (error) {
@@ -389,206 +148,38 @@ tracker_db_interface_end_db_transaction (TrackerDBInterface *interface)
 }
 
 
-void
-tracker_db_statement_bind_double (TrackerDBStatement    *stmt,
-                                  int                    idx,
-                                  double                 value)
-{
-	/* Removed for performance 
-	g_return_val_if_fail (TRACKER_IS_DB_STATEMENT (stmt), NULL); */
-
-	g_return_if_fail (stmt != NULL);
-
-	TRACKER_DB_STATEMENT_GET_IFACE (stmt)->bind_double (stmt, idx, value);
-}
-
-void
-tracker_db_statement_bind_int (TrackerDBStatement       *stmt,
-                               int                       idx,
-                               int                       value)
-{
-	/* Removed for performance:
-	g_return_if_fail (TRACKER_IS_DB_STATEMENT (stmt)); */
-
-	g_return_if_fail (stmt != NULL);
-
-	TRACKER_DB_STATEMENT_GET_IFACE (stmt)->bind_int (stmt, idx, value);
-}
-
-void
-tracker_db_statement_bind_int64 (TrackerDBStatement     *stmt,
-                                 int                     idx,
-                                 gint64                          value)
-{
-	/* Removed for performance 
-	g_return_val_if_fail (TRACKER_IS_DB_STATEMENT (stmt), NULL); */
-
-	g_return_if_fail (stmt != NULL);
-
-	TRACKER_DB_STATEMENT_GET_IFACE (stmt)->bind_int64 (stmt, idx, value);
-}
-
-void
-tracker_db_statement_bind_null (TrackerDBStatement      *stmt,
-                                int                      idx)
-{
-	/* Removed for performance 
-	g_return_val_if_fail (TRACKER_IS_DB_STATEMENT (stmt), NULL); */
-
-	g_return_if_fail (stmt != NULL);
-
-	TRACKER_DB_STATEMENT_GET_IFACE (stmt)->bind_null (stmt, idx);
-}
-
-void
-tracker_db_statement_bind_text (TrackerDBStatement      *stmt,
-                                int                      idx,
-                                const gchar             *value)
-{
-	/* Removed for performance 
-	g_return_val_if_fail (TRACKER_IS_DB_STATEMENT (stmt), NULL); */
-
-	g_return_if_fail (stmt != NULL);
-
-	TRACKER_DB_STATEMENT_GET_IFACE (stmt)->bind_text (stmt, idx, value);
-}
-
+/* TrackerDBResultSet semiprivate API */
 TrackerDBResultSet *
-tracker_db_statement_execute (TrackerDBStatement         *stmt,
-                              GError                    **error)
+_tracker_db_result_set_new (guint columns)
 {
 	TrackerDBResultSet *result_set;
 
-	/* Removed for performance 
-	g_return_val_if_fail (TRACKER_IS_DB_STATEMENT (stmt), NULL); */
-
-	g_return_val_if_fail (stmt != NULL, NULL); 
-
-	result_set = TRACKER_DB_STATEMENT_GET_IFACE (stmt)->execute (stmt, error);
-
-	return ensure_result_set_state (result_set);
-}
-
-TrackerDBCursor *
-tracker_db_statement_start_cursor (TrackerDBStatement    *stmt,
-                                   GError               **error)
-{
-	/* Removed for performance
-	g_return_val_if_fail (TRACKER_IS_DB_STATEMENT (stmt), NULL); */
-
-	g_return_val_if_fail (stmt != NULL, NULL);
-
-	return TRACKER_DB_STATEMENT_GET_IFACE (stmt)->start_cursor (stmt, error);
-}
-
-/* TrackerDBCursor API */
-
-void
-tracker_db_cursor_rewind (TrackerDBCursor *cursor)
-{
-	g_return_if_fail (TRACKER_IS_DB_CURSOR (cursor));
-
-	TRACKER_DB_CURSOR_GET_IFACE (cursor)->rewind (cursor);
-}
-
-gboolean
-tracker_db_cursor_iter_next (TrackerDBCursor *cursor,
-                             GError         **error)
-{
-	/* Removed for performance 
-	g_return_val_if_fail (TRACKER_IS_DB_CURSOR (cursor), FALSE); */
-
-	g_return_val_if_fail (cursor != NULL, FALSE);
+	result_set = g_object_new (TRACKER_TYPE_DB_RESULT_SET, NULL);
 
-	return TRACKER_DB_CURSOR_GET_IFACE (cursor)->iter_next (cursor, error);
-}
-
-guint
-tracker_db_cursor_get_n_columns (TrackerDBCursor *cursor)
-{
-	g_return_val_if_fail (TRACKER_IS_DB_CURSOR (cursor), 0);
-
-	return TRACKER_DB_CURSOR_GET_IFACE (cursor)->get_n_columns (cursor);
-}
-
-void
-tracker_db_cursor_get_value (TrackerDBCursor *cursor,  guint column, GValue *value)
-{
-	/* Removed for performance 
-	g_return_if_fail (TRACKER_IS_DB_CURSOR (cursor)); */
+	result_set->columns = columns;
+	result_set->col_types = g_new0 (GType, result_set->columns);
 
-	g_return_if_fail (cursor != NULL);
-
-	TRACKER_DB_CURSOR_GET_IFACE (cursor)->get_value (cursor, column, value);
-}
-
-const gchar*
-tracker_db_cursor_get_string (TrackerDBCursor *cursor, guint            column)
-{
-	/* Removed for performance 
-	g_return_val_if_fail (TRACKER_IS_DB_CURSOR (cursor), NULL); */
-
-	g_return_val_if_fail (cursor != NULL, NULL);
-
-	return TRACKER_DB_CURSOR_GET_IFACE (cursor)->get_string (cursor, column);
-}
-
-gint
-tracker_db_cursor_get_int (TrackerDBCursor *cursor, guint            column)
-{
-	/* Removed for performance
-	g_return_val_if_fail (TRACKER_IS_DB_CURSOR (cursor), -1); */
-
-	g_return_val_if_fail (cursor != NULL, -1);
-
-	return TRACKER_DB_CURSOR_GET_IFACE (cursor)->get_int (cursor, column);
-}
-
-gdouble
-tracker_db_cursor_get_double (TrackerDBCursor *cursor, guint            column)
-{
-	/* Removed for performance
-	g_return_val_if_fail (TRACKER_IS_DB_CURSOR (cursor), -1); */
-
-	g_return_val_if_fail (cursor != NULL, -1);
-
-	return TRACKER_DB_CURSOR_GET_IFACE (cursor)->get_double (cursor, column);
-}
-
-
-
-/* TrackerDBResultSet semiprivate API */
-TrackerDBResultSet *
-_tracker_db_result_set_new (guint columns)
-{
-	return g_object_new (TRACKER_TYPE_DB_RESULT_SET,
-	                     "columns", columns,
-	                     NULL);
+	return result_set;
 }
 
 void
 _tracker_db_result_set_append (TrackerDBResultSet *result_set)
 {
-	TrackerDBResultSetPrivate *priv;
-
 	g_return_if_fail (TRACKER_IS_DB_RESULT_SET (result_set));
 
-	priv = TRACKER_DB_RESULT_SET_GET_PRIVATE (result_set);
-
-	if (G_UNLIKELY (!priv->array)) {
-		priv->array = g_ptr_array_sized_new (100);
+	if (G_UNLIKELY (!result_set->array)) {
+		result_set->array = g_ptr_array_sized_new (100);
 	}
 
-	g_ptr_array_add (priv->array, NULL);
-	priv->current_row = priv->array->len - 1;
+	g_ptr_array_add (result_set->array, NULL);
+	result_set->current_row = result_set->array->len - 1;
 }
 
 void
 _tracker_db_result_set_set_value (TrackerDBResultSet *result_set,
-                                  guint                       column,
+                                  guint               column,
                                   const GValue       *value)
 {
-	TrackerDBResultSetPrivate *priv;
 	gpointer *row = NULL;
 
 	g_return_if_fail (TRACKER_IS_DB_RESULT_SET (result_set));
@@ -597,23 +188,21 @@ _tracker_db_result_set_set_value (TrackerDBResultSet *result_set,
 	if (G_VALUE_TYPE (value) == 0)
 		return;
 
-	priv = TRACKER_DB_RESULT_SET_GET_PRIVATE (result_set);
-
-	g_return_if_fail (column < priv->columns);
+	g_return_if_fail (column < result_set->columns);
 
 	/* Assign a GType if it didn't have any */
-	/* if (G_UNLIKELY (priv->col_types[column] == 0)) */
-	priv->col_types[column] = G_VALUE_TYPE (value);
+	/* if (G_UNLIKELY (result_set->col_types[column] == 0)) */
+	result_set->col_types[column] = G_VALUE_TYPE (value);
 
-	row = g_ptr_array_index (priv->array, priv->current_row);
+	row = g_ptr_array_index (result_set->array, result_set->current_row);
 
 	/* Allocate space for the row, if it wasn't allocated previously */
 	if (G_UNLIKELY (!row)) {
-		row = g_new0 (gpointer, priv->columns);
-		g_ptr_array_index (priv->array, priv->current_row) = row;
+		row = g_new0 (gpointer, result_set->columns);
+		g_ptr_array_index (result_set->array, result_set->current_row) = row;
 	}
 
-	switch (priv->col_types [column]) {
+	switch (result_set->col_types [column]) {
 	case G_TYPE_INT: {
 		gint *val;
 
@@ -663,16 +252,14 @@ _tracker_db_result_set_get_value (TrackerDBResultSet *result_set,
                                   guint                       column,
                                   GValue             *value)
 {
-	TrackerDBResultSetPrivate *priv;
 	gpointer *row;
 
 	g_return_if_fail (TRACKER_IS_DB_RESULT_SET (result_set));
 
-	priv = TRACKER_DB_RESULT_SET_GET_PRIVATE (result_set);
-	row = g_ptr_array_index (priv->array, priv->current_row);
+	row = g_ptr_array_index (result_set->array, result_set->current_row);
 
-	if (priv->col_types[column] != G_TYPE_INVALID && row && row[column]) {
-		g_value_init (value, priv->col_types[column]);
+	if (result_set->col_types[column] != G_TYPE_INVALID && row && row[column]) {
+		g_value_init (value, result_set->col_types[column]);
 		fill_in_value (value, row[column]);
 	} else {
 		/* NULL, keep value unset */
@@ -684,7 +271,6 @@ void
 tracker_db_result_set_get (TrackerDBResultSet *result_set,
                            ...)
 {
-	TrackerDBResultSetPrivate *priv;
 	va_list args;
 	gint n_col;
 	GValue value = { 0, };
@@ -693,22 +279,21 @@ tracker_db_result_set_get (TrackerDBResultSet *result_set,
 
 	g_return_if_fail (TRACKER_IS_DB_RESULT_SET (result_set));
 
-	priv = TRACKER_DB_RESULT_SET_GET_PRIVATE (result_set);
-	g_return_if_fail (priv->array != NULL);
+	g_return_if_fail (result_set->array != NULL);
 
-	row = g_ptr_array_index (priv->array, priv->current_row);
+	row = g_ptr_array_index (result_set->array, result_set->current_row);
 	va_start (args, result_set);
 
 	while ((n_col = va_arg (args, gint)) >= 0) {
-		if ((guint) n_col >= priv->columns) {
+		if ((guint) n_col >= result_set->columns) {
 			g_critical ("Result set has %d columns, trying to access column %d, "
 			            "maybe -1 is missing at the end of the arguments?",
-			            priv->columns, n_col);
+			            result_set->columns, n_col);
 			break;
 		}
 
-		if (priv->col_types[n_col] != G_TYPE_INVALID) {
-			g_value_init (&value, priv->col_types[n_col]);
+		if (result_set->col_types[n_col] != G_TYPE_INVALID) {
+			g_value_init (&value, result_set->col_types[n_col]);
 			fill_in_value (&value, row[n_col]);
 			G_VALUE_LCOPY (&value, args, 0, &error);
 			g_value_unset (&value);
@@ -732,53 +317,38 @@ tracker_db_result_set_get (TrackerDBResultSet *result_set,
 void
 tracker_db_result_set_rewind (TrackerDBResultSet *result_set)
 {
-	TrackerDBResultSetPrivate *priv;
-
 	g_return_if_fail (TRACKER_IS_DB_RESULT_SET (result_set));
 
-	priv = TRACKER_DB_RESULT_SET_GET_PRIVATE (result_set);
-	priv->current_row = 0;
+	result_set->current_row = 0;
 }
 
 gboolean
 tracker_db_result_set_iter_next (TrackerDBResultSet *result_set)
 {
-	TrackerDBResultSetPrivate *priv;
-
 	g_return_val_if_fail (TRACKER_IS_DB_RESULT_SET (result_set), FALSE);
 
-	priv = TRACKER_DB_RESULT_SET_GET_PRIVATE (result_set);
-
-	if (priv->current_row + 1 >= priv->array->len)
+	if (result_set->current_row + 1 >= result_set->array->len)
 		return FALSE;
 
-	priv->current_row++;
+	result_set->current_row++;
 	return TRUE;
 }
 
 guint
 tracker_db_result_set_get_n_columns (TrackerDBResultSet *result_set)
 {
-	TrackerDBResultSetPrivate *priv;
-
 	g_return_val_if_fail (TRACKER_IS_DB_RESULT_SET (result_set), 0);
 
-	priv = TRACKER_DB_RESULT_SET_GET_PRIVATE (result_set);
-
-	return priv->columns;
+	return result_set->columns;
 }
 
 guint
 tracker_db_result_set_get_n_rows (TrackerDBResultSet *result_set)
 {
-	TrackerDBResultSetPrivate *priv;
-
 	g_return_val_if_fail (TRACKER_IS_DB_RESULT_SET (result_set), 0);
 
-	priv = TRACKER_DB_RESULT_SET_GET_PRIVATE (result_set);
-
-	if (!priv->array)
+	if (!result_set->array)
 		return 0;
 
-	return priv->array->len;
+	return result_set->array->len;
 }
diff --git a/src/libtracker-db/tracker-db-interface.h b/src/libtracker-db/tracker-db-interface.h
index 459dde4..5bb0117 100644
--- a/src/libtracker-db/tracker-db-interface.h
+++ b/src/libtracker-db/tracker-db-interface.h
@@ -30,18 +30,24 @@ G_BEGIN_DECLS
 
 #define TRACKER_TYPE_DB_INTERFACE           (tracker_db_interface_get_type ())
 #define TRACKER_DB_INTERFACE(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRACKER_TYPE_DB_INTERFACE, TrackerDBInterface))
+#define TRACKER_DB_INTERFACE_CLASS(c)       (G_TYPE_CHECK_CLASS_CAST ((c),      TRACKER_TYPE_DB_INTERFACE, TrackerDBInterfaceClass))
 #define TRACKER_IS_DB_INTERFACE(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRACKER_TYPE_DB_INTERFACE))
-#define TRACKER_DB_INTERFACE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TRACKER_TYPE_DB_INTERFACE, TrackerDBInterfaceIface))
+#define TRACKER_IS_DB_INTERFACE_CLASS(c)    (G_TYPE_CHECK_CLASS_TYPE ((o),      TRACKER_TYPE_DB_INTERFACE))
+#define TRACKER_DB_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRACKER_TYPE_DB_INTERFACE, TrackerDBInterfaceClass))
 
 #define TRACKER_TYPE_DB_STATEMENT           (tracker_db_statement_get_type ())
 #define TRACKER_DB_STATEMENT(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRACKER_TYPE_DB_STATEMENT, TrackerDBStatement))
+#define TRACKER_DB_STATEMENT_CLASS(c)       (G_TYPE_CHECK_CLASS_CAST ((c),      TRACKER_TYPE_DB_STATEMENT, TrackerDBStatementClass))
 #define TRACKER_IS_DB_STATEMENT(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRACKER_TYPE_DB_STATEMENT))
-#define TRACKER_DB_STATEMENT_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TRACKER_TYPE_DB_STATEMENT, TrackerDBStatementIface))
+#define TRACKER_IS_DB_STATEMENT_CLASS(c)    (G_TYPE_CHECK_CLASS_TYPE ((o),      TRACKER_TYPE_DB_STATEMENT))
+#define TRACKER_DB_STATEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRACKER_TYPE_DB_STATEMENT, TrackerDBStatementClass))
 
 #define TRACKER_TYPE_DB_CURSOR              (tracker_db_cursor_get_type ())
 #define TRACKER_DB_CURSOR(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRACKER_TYPE_DB_CURSOR, TrackerDBCursor))
+#define TRACKER_DB_CURSOR_CLASS(c)          (G_TYPE_CHECK_CLASS_CAST ((c),      TRACKER_TYPE_DB_CURSOR, TrackerDBCursorClass))
 #define TRACKER_IS_DB_CURSOR(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRACKER_TYPE_DB_CURSOR))
-#define TRACKER_DB_CURSOR_GET_IFACE(obj)    (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TRACKER_TYPE_DB_CURSOR, TrackerDBCursorIface))
+#define TRACKER_IS_DB_CURSOR_CLASS(c)       (G_TYPE_CHECK_CLASS_TYPE ((o),      TRACKER_TYPE_DB_CURSOR))
+#define TRACKER_DB_CURSOR_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj),  TRACKER_TYPE_DB_CURSOR, TrackerDBCursorClass))
 
 #define TRACKER_TYPE_DB_RESULT_SET          (tracker_db_result_set_get_type ())
 #define TRACKER_DB_RESULT_SET(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_DB_RESULT_SET, TrackerDBResultSet))
@@ -59,79 +65,15 @@ typedef enum {
 } TrackerDBInterfaceError;
 
 typedef struct TrackerDBInterface      TrackerDBInterface;
-typedef struct TrackerDBInterfaceIface TrackerDBInterfaceIface;
+typedef struct TrackerDBInterfaceClass TrackerDBInterfaceClass;
 typedef struct TrackerDBStatement      TrackerDBStatement;
-typedef struct TrackerDBStatementIface TrackerDBStatementIface;
+typedef struct TrackerDBStatementClass TrackerDBStatementClass;
 typedef struct TrackerDBResultSet      TrackerDBResultSet;
 typedef struct TrackerDBResultSetClass TrackerDBResultSetClass;
 typedef struct TrackerDBCursor         TrackerDBCursor;
-typedef struct TrackerDBCursorIface    TrackerDBCursorIface;
+typedef struct TrackerDBCursorClass    TrackerDBCursorClass;
 typedef struct TrackerDBResultSetPrivate TrackerDBResultSetPrivate;
 
-struct TrackerDBInterfaceIface {
-	GTypeInterface iface;
-
-	TrackerDBStatement * (* create_statement) (TrackerDBInterface  *interface,
-	                                           GError             **error,
-	                                           const gchar         *query);
-	TrackerDBResultSet * (* execute_query)    (TrackerDBInterface  *interface,
-	                                           GError             **error,
-	                                           const gchar         *query);
-	gboolean             (* interrupt)        (TrackerDBInterface  *interface);
-	void                 (* reset_interrupt)  (TrackerDBInterface  *interface);
-};
-
-struct TrackerDBStatementIface {
-	GTypeInterface iface;
-
-	void                 (* bind_double)    (TrackerDBStatement  *stmt,
-	                                         int                  index,
-	                                         double                       value);
-	void                 (* bind_int)       (TrackerDBStatement  *stmt,
-	                                         int                  index,
-	                                         int                  value);
-	void                 (* bind_int64)     (TrackerDBStatement  *stmt,
-	                                         int                  index,
-	                                         gint64                       value);
-	void                 (* bind_null)      (TrackerDBStatement  *stmt,
-	                                         int                  index);
-	void                 (* bind_text)      (TrackerDBStatement  *stmt,
-	                                         int                  index,
-	                                         const gchar         *value);
-	TrackerDBResultSet * (* execute)        (TrackerDBStatement  *stmt,
-	                                         GError                     **error);
-	TrackerDBCursor    * (* start_cursor)   (TrackerDBStatement  *stmt,
-	                                         GError                     **error);
-};
-
-struct TrackerDBResultSet {
-	GObject parent_class;
-	TrackerDBResultSetPrivate *priv;
-};
-
-struct TrackerDBResultSetClass {
-	GObjectClass parent_class;
-};
-
-struct TrackerDBCursorIface {
-	GTypeInterface iface;
-
-	void          (*rewind)        (TrackerDBCursor *cursor);
-	gboolean      (*iter_next)     (TrackerDBCursor *cursor,
-	                                GError         **error);
-	guint         (*get_n_columns) (TrackerDBCursor *cursor);
-	void          (*get_value)     (TrackerDBCursor *cursor,
-	                                guint            column,
-	                                GValue          *value);
-	const gchar*  (*get_string)    (TrackerDBCursor *cursor,
-	                                guint            column);
-	gint          (*get_int)       (TrackerDBCursor *cursor,
-	                                guint            column);
-	gdouble       (*get_double)    (TrackerDBCursor *cursor,
-	                                guint            column);
-
-};
-
 GQuark              tracker_db_interface_error_quark       (void);
 
 GType               tracker_db_interface_get_type          (void);
diff --git a/src/libtracker-db/tracker-db-manager.c b/src/libtracker-db/tracker-db-manager.c
index 7201ab9..e777ed7 100644
--- a/src/libtracker-db/tracker-db-manager.c
+++ b/src/libtracker-db/tracker-db-manager.c
@@ -1264,7 +1264,7 @@ tracker_db_manager_get_db_interface (void)
 			                                          TRACKER_DB_FULLTEXT,
 			                                          TRACKER_DB_CONTENTS);
 
-		tracker_db_interface_sqlite_fts_init (TRACKER_DB_INTERFACE_SQLITE (interface), FALSE);
+		tracker_db_interface_sqlite_fts_init (interface, FALSE);
 
 		g_static_private_set (&interface_data_key, interface, free_thread_interface);
 



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