tracker r1401 - branches/xesam-support/src/trackerd
- From: pvanhoof svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1401 - branches/xesam-support/src/trackerd
- Date: Tue, 13 May 2008 12:27:18 +0100 (BST)
Author: pvanhoof
Date: Tue May 13 11:27:18 2008
New Revision: 1401
URL: http://svn.gnome.org/viewvc/tracker?rev=1401&view=rev
Log:
Some bugfixes
Modified:
branches/xesam-support/src/trackerd/tracker-db-sqlite.c
branches/xesam-support/src/trackerd/tracker-xesam-live-search.c
branches/xesam-support/src/trackerd/tracker-xesam-live-search.h
branches/xesam-support/src/trackerd/tracker-xesam-query.c
branches/xesam-support/src/trackerd/tracker-xesam-query.h
branches/xesam-support/src/trackerd/tracker-xesam-session.c
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 11:27:18 2008
@@ -3196,7 +3196,7 @@
TrackerDBResultSet*
-tracker_db_get_live_search_new_ids (DBConnection *db_con, const gchar *search_id, const gchar *columns, const gchar *tables, const gchar *query)
+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;
@@ -3211,15 +3211,18 @@
/* Uses the Events table */
gchar *m_query = g_strdup_printf (
- "SELECT E.ServiceID, E.EventType%s %s "
- "FROM XesamLiveSearches as X, Events as E%s %s "
- "X.ServiceID = E.ServiceID "
- "AND X.SearchID = ? "
- "AND X.EventType IS 'Create' OR X.EventType IS 'Update' "
- "%s%s%s",
- columns?",":"", columns,
- tables?",":"", tables,
- query?"AND (":"", query, query?")":"");
+ /* COLUMNS */ "SELECT E.ServiceID, E.EventType%s%s "
+ /* FROM_QUERY */ "%s%s XesamLiveSearches as X, Events as E "
+ /* WHERE_QUERY */ "%s"
+ /* AND or space */ "%sX.ServiceID = E.ServiceID "
+ "AND X.SearchID = ? "
+ "AND X.EventType IS 'Create' OR X.EventType IS 'Update' ",
+ columns?", ":"",
+ columns?columns:"",
+ from_query?from_query:"FROM",
+ from_query?",":"",
+ where_query?where_query:"WHERE",
+ where_query?"AND":" ");
tracker_debug ("LiveSearchUpdateQuery: %s", m_query);
Modified: branches/xesam-support/src/trackerd/tracker-xesam-live-search.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-live-search.c (original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-live-search.c Tue May 13 11:27:18 2008
@@ -32,7 +32,7 @@
gboolean active;
gboolean closed;
gchar *query;
- gchar *sql;
+ gchar *from_sql, *where_sql;
};
enum {
@@ -53,7 +53,8 @@
g_object_unref (priv->session);
g_free (priv->search_id);
g_free (priv->query);
- g_free (priv->sql);
+ g_free (priv->from_sql);
+ g_free (priv->where_sql);
if (priv->session)
g_object_unref (priv->session);
@@ -129,7 +130,9 @@
priv->active = FALSE;
priv->closed = FALSE;
priv->query = NULL;
- priv->sql = g_strdup ("");
+ priv->from_sql = g_strdup ("");
+ priv->where_sql = g_strdup ("");
+
}
/**
@@ -269,20 +272,19 @@
// For ottela to review (add columns and tables)
/**
- * New and Modified items:
* SELECT E.ServiceID, E.EventType, COLUMNS
- * FROM XesamLiveSearches as X, Events as E, TABLES
- * X.ServiceID = E.ServiceID
- * AND X.SearchID = ? "
+ * FROM_QUERY XesamLiveSearches as X, Events as E
+ * WHERE_QUERY"
+ * AND X.ServiceID = E.ServiceID
+ * AND X.SearchID = SEARCH_ID
* AND X.EventType IS 'Create' OR X.EventType IS 'Update'
- * AND (QUERY)
**/
result_set = tracker_db_get_live_search_new_ids (db_con,
tracker_xesam_live_search_get_id (self),
NULL, /* Columns */
- NULL, /* Tables */
- tracker_xesam_live_search_get_query (self)); /* Query */
+ tracker_xesam_live_search_get_from_query (self),
+ tracker_xesam_live_search_get_where_query (self)); /* Query */
if (!result_set)
return;
@@ -680,13 +682,9 @@
* tracker_xesam_live_search_parse_query:
* @self: a #TrackerXesamLiveSearch
*
- * * API will change *
- *
* Parses the current xml query and sets the sql
- *
- * @returns: a read-only string with the query
**/
-const gchar*
+void
tracker_xesam_live_search_parse_query (TrackerXesamLiveSearch *self,
GError **error)
{
@@ -697,10 +695,16 @@
g_object_get (proxy, "db-connection", &db_con, NULL);
- if (priv->sql)
- g_free (priv->sql);
+ g_free (priv->from_sql);
+ g_free (priv->where_sql);
+
+ priv->from_sql = NULL;
+ priv->where_sql = NULL;
- priv->sql = tracker_xesam_query_to_sql (db_con, priv->query, &parse_error);
+ tracker_xesam_query_to_sql (db_con, priv->query,
+ &priv->from_sql,
+ &priv->where_sql,
+ &parse_error);
if (parse_error) {
gchar *str = g_strdup_printf ("Parse error: %s",
@@ -712,24 +716,37 @@
g_error_free (parse_error);
}
- return priv->sql;
+ return;
}
/**
- * tracker_xesam_live_search_get_query:
+ * tracker_xesam_live_search_get_from_query:
* @self: a #TrackerXesamLiveSearch
*
- * * API will change *
+ * Gets the parsed FROM SQL string for the query
*
- * Gets the parsed sql for the query
+ * @returns: a read-only string with the FROM query
+ **/
+const gchar*
+tracker_xesam_live_search_get_from_query (TrackerXesamLiveSearch *self)
+{
+ TrackerXesamLiveSearchPriv *priv = self->priv;
+ return (const gchar *) priv->from_sql;
+}
+
+/**
+ * tracker_xesam_live_search_get_where_query:
+ * @self: a #TrackerXesamLiveSearch
*
- * @returns: a read-only string with the query
+ * Gets the parsed WHERE SQL for the query
+ *
+ * @returns: a read-only string with the WHERE query
**/
const gchar*
-tracker_xesam_live_search_get_query (TrackerXesamLiveSearch *self)
+tracker_xesam_live_search_get_where_query (TrackerXesamLiveSearch *self)
{
TrackerXesamLiveSearchPriv *priv = self->priv;
- return (const gchar *) priv->sql;
+ return (const gchar *) priv->where_sql;
}
/**
Modified: branches/xesam-support/src/trackerd/tracker-xesam-live-search.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-live-search.h (original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-live-search.h Tue May 13 11:27:18 2008
@@ -54,7 +54,8 @@
const gchar *search_id);
const gchar* tracker_xesam_live_search_get_id (TrackerXesamLiveSearch *self);
-const gchar* tracker_xesam_live_search_get_query (TrackerXesamLiveSearch *self);
+const gchar* tracker_xesam_live_search_get_where_query (TrackerXesamLiveSearch *self);
+const gchar* tracker_xesam_live_search_get_from_query (TrackerXesamLiveSearch *self);
const gchar* tracker_xesam_live_search_get_xml_query (TrackerXesamLiveSearch *self);
void tracker_xesam_live_search_set_xml_query (TrackerXesamLiveSearch *self,
const gchar *xml_query);
@@ -65,7 +66,7 @@
void tracker_xesam_live_search_activate (TrackerXesamLiveSearch *self,
GError **error);
gboolean tracker_xesam_live_search_is_active (TrackerXesamLiveSearch *self);
-const gchar* tracker_xesam_live_search_parse_query (TrackerXesamLiveSearch *self,
+void tracker_xesam_live_search_parse_query (TrackerXesamLiveSearch *self,
GError **error);
void tracker_xesam_live_search_get_hit_data (TrackerXesamLiveSearch *self,
GArray *hit_ids,
Modified: branches/xesam-support/src/trackerd/tracker-xesam-query.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-query.c (original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-query.c Tue May 13 11:27:18 2008
@@ -1168,8 +1168,8 @@
}
-char *
-tracker_xesam_query_to_sql (DBConnection *db_con, const char *query, GError **error)
+void
+tracker_xesam_query_to_sql (DBConnection *db_con, const char *query, gchar **from, gchar **where, GError **error)
{
static gboolean inited = FALSE;
ParserData data;
@@ -1216,6 +1216,9 @@
g_string_free (data.sql_from, TRUE);
g_string_free (data.sql_where, TRUE);
+ *from = NULL;
+ *where = NULL;
+
} else {
const GSList *tmp;
FieldData *tmp_field;
@@ -1234,8 +1237,9 @@
}
}
- result = g_strconcat (data.sql_from->str, " ", data.sql_where->str, NULL);
-
+ *from = g_strdup (data.sql_from->str);
+ *where = g_strdup (data.sql_where->str);
+
g_string_free (data.sql_from, TRUE);
g_string_free (data.sql_where, TRUE);
}
@@ -1256,7 +1260,7 @@
g_free (data.parser);
- return result;
+ return;
}
Modified: branches/xesam-support/src/trackerd/tracker-xesam-query.h
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-query.h (original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-query.h Tue May 13 11:27:18 2008
@@ -26,7 +26,6 @@
#include "tracker-db.h"
-
-char * tracker_xesam_query_to_sql (DBConnection *db_con, const char *query, GError **error);
+void tracker_xesam_query_to_sql (DBConnection *db_con, const char *query, gchar **from, gchar **where, GError **error);
#endif
Modified: branches/xesam-support/src/trackerd/tracker-xesam-session.c
==============================================================================
--- branches/xesam-support/src/trackerd/tracker-xesam-session.c (original)
+++ branches/xesam-support/src/trackerd/tracker-xesam-session.c Tue May 13 11:27:18 2008
@@ -377,7 +377,6 @@
{
TrackerXesamLiveSearch *search;
TrackerXesamSessionPriv *priv = self->priv;
- const gchar *query = NULL;
search = tracker_xesam_live_search_new (query_xml);
tracker_xesam_live_search_set_session (search, self);
@@ -391,9 +390,7 @@
g_strdup (tracker_xesam_live_search_get_id (search)),
g_object_ref (search));
- query = tracker_xesam_live_search_parse_query (search, error);
-
- g_print ("Created new Xesam search \n %s \n Translated to \n %s", query_xml, query);
+ tracker_xesam_live_search_parse_query (search, error);
return search;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]