tracker r1414 - branches/xesam-support/src/trackerd



Author: pvanhoof
Date: Tue May 13 15:08:22 2008
New Revision: 1414
URL: http://svn.gnome.org/viewvc/tracker?rev=1414&view=rev

Log:
Some improvements for the database queries

Modified:
   branches/xesam-support/src/trackerd/tracker-db-sqlite.c
   branches/xesam-support/src/trackerd/tracker-db-sqlite.h

Modified: branches/xesam-support/src/trackerd/tracker-db-sqlite.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db-sqlite.c	(original)
+++ branches/xesam-support/src/trackerd/tracker-db-sqlite.c	Tue May 13 15:08:22 2008
@@ -1426,6 +1426,24 @@
 	return TRUE;
 }
 
+
+TrackerDBResultSet *
+tracker_db_exec (TrackerDBInterface *iface, const char *query, ...)
+{
+	va_list args;
+	TrackerDBResultSet *result_set;
+
+	tracker_nfs_lock_obtain ();
+
+	va_start (args, query);
+	result_set = tracker_db_interface_execute_vquery (iface, NULL, query, args);
+	va_end (args);
+
+	tracker_nfs_lock_release ();
+
+	return result_set;
+}
+
 TrackerDBResultSet *
 tracker_exec_proc (DBConnection *db_con, const char *procedure, ...)
 {
@@ -3222,8 +3240,6 @@
 TrackerDBResultSet* 
 tracker_db_get_live_search_new_ids (DBConnection *db_con, const gchar *search_id, const gchar *columns, const gchar *from_query, const gchar *where_query)
 {
-	TrackerDBResultSet *result;
-
 	// todo: this is a query for ottela to review
 
 	/* Contract, in @result:
@@ -3240,13 +3256,14 @@
 	 *      OR X.EventType IS 'Update')
 	 **/
 
-	/* Uses the Events table */
-	gchar *m_query = g_strdup_printf (
+	tracker_debug ("LiveSearchUpdateQuery");
+
+	return tracker_db_exec (db_con->db,
 	/* COLUMNS */      "SELECT E.ServiceID, E.EventType%s%s "
 	/* FROM_QUERY */   "%s%s LiveSearches as X, Events as E "
 	/* WHERE_QUERY */  "%s"
 	/* AND or space */ "%sX.ServiceID = E.ServiceID "
-			   "AND X.SearchID = '%s' "
+			   "AND X.SearchID = '%s' " /* search_id arg */
 			   "AND (X.EventType IS 'Create' "
 			   "OR X.EventType IS 'Update') ",
 
@@ -3257,35 +3274,17 @@
 			   where_query?where_query:"WHERE",
 			   where_query?"AND":" ", 
 			   search_id);
-
-	tracker_debug ("LiveSearchUpdateQuery: %s", m_query);
-
-	result = tracker_db_interface_execute_query (db_con->db, NULL, m_query);
-
-	g_free (m_query);
-
-	return result;
 }
 
 TrackerDBResultSet *
 tracker_db_get_live_search_get_hit_data (DBConnection *db_con, const gchar *search_id)
 {
-	TrackerDBResultSet *result;
-
-	// todo
-
-	gchar *m_query = g_strdup_printf (
-			"SELECT * FROM LiveSearches as X"
-			"WHERE X.SearchID = '%s' ",
-			search_id);
-
-	tracker_debug ("LiveSearchUpdateQuery: %s", m_query);
+	tracker_debug ("tracker_db_get_live_search_get_hit_data");
 
-	result = tracker_db_interface_execute_query (db_con->db, NULL, m_query);
-
-	g_free (m_query);
-
-	return result;
+	return tracker_db_exec (db_con->db, 
+				"SELECT * FROM LiveSearches as X "
+				"WHERE X.SearchID = '%s'", 
+				search_id);
 }
 
 TrackerDBResultSet* 

Modified: branches/xesam-support/src/trackerd/tracker-db-sqlite.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-db-sqlite.h	(original)
+++ branches/xesam-support/src/trackerd/tracker-db-sqlite.h	Tue May 13 15:08:22 2008
@@ -117,6 +117,9 @@
 gboolean            tracker_db_exec_no_reply                   (TrackerDBInterface   *iface,
                                                                 const gchar          *query,
                                                                 ...);
+TrackerDBResultSet *tracker_db_exec                            (TrackerDBInterface *iface, 
+                                                                const char *query,
+                                                                ...);
 void                tracker_create_common_db                          (void);
 void                tracker_db_save_file_contents              (DBConnection   *db_con,
                                                                 GHashTable     *index_table,



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