tracker r1515 - branches/xesam-support/src/trackerd
- From: mottela svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1515 - branches/xesam-support/src/trackerd
- Date: Wed, 28 May 2008 13:23:20 +0000 (UTC)
Author: mottela
Date: Wed May 28 13:23:19 2008
New Revision: 1515
URL: http://svn.gnome.org/viewvc/tracker?rev=1515&view=rev
Log:
Split the SQL FROM to FROM and JOIN fields in live searches
Modified:
branches/xesam-support/src/trackerd/tracker-db-sqlite.c
branches/xesam-support/src/trackerd/tracker-db-sqlite.h
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
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 Wed May 28 13:23:19 2008
@@ -3339,7 +3339,7 @@
void
-tracker_db_start_live_search (DBConnection *db_con, const gchar *from_query, const gchar *where_query, const gchar *search_id)
+tracker_db_start_live_search (DBConnection *db_con, const gchar *from_query, const gchar *join_query, const gchar *where_query, const gchar *search_id)
{
/* INSERT
* INTO LiveSearches
@@ -3355,7 +3355,7 @@
}
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)
+tracker_db_get_live_search_new_ids (DBConnection *db_con, const gchar *search_id, const gchar *columns, const gchar *from_query, const gchar *join_query, const gchar *where_query)
{
TrackerDBResultSet *result_set;
@@ -3426,7 +3426,7 @@
TrackerDBResultSet*
-tracker_db_get_live_search_all_ids (DBConnection *db_con, const gchar *search_id, const gchar *columns, const gchar *from_query, const gchar *where_query)
+tracker_db_get_live_search_all_ids (DBConnection *db_con, const gchar *search_id, const gchar *columns, const gchar *from_query, const gchar *join_query, const gchar *where_query)
{
// todo: this is a query for ottela to review
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 Wed May 28 13:23:19 2008
@@ -328,13 +328,15 @@
TrackerDBResultSet *tracker_db_get_live_search_new_ids (DBConnection *db_con,
const gchar *search_id,
const gchar *columns,
- const gchar *tables,
- const gchar *query);
+ const gchar *from_query,
+ const gchar *join_query,
+ const gchar *where_query);
TrackerDBResultSet *tracker_db_get_live_search_all_ids (DBConnection *db_con,
const gchar *search_id,
const gchar *columns,
- const gchar *tables,
- const gchar *query);
+ const gchar *from_query,
+ const gchar *join_query,
+ const gchar *where_query);
TrackerDBResultSet *tracker_db_get_live_search_hit_count (DBConnection *db_con,
const gchar *search_id);
@@ -350,7 +352,8 @@
void tracker_db_stop_live_search (DBConnection *db_con,
const gchar *search_id);
void tracker_db_start_live_search (DBConnection *db_con,
- const gchar *from_query,
+ const gchar *from_query,
+ const gchar *join_query,
const gchar *where_query,
const gchar *search_id);
TrackerDBResultSet *tracker_db_get_live_search_get_hit_data (DBConnection *db_con,
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 Wed May 28 13:23:19 2008
@@ -33,7 +33,7 @@
gboolean active;
gboolean closed;
gchar *query;
- gchar *from_sql, *where_sql;
+ gchar *from_sql, *join_sql, *where_sql;
};
enum {
@@ -58,6 +58,7 @@
g_free (priv->query);
g_free (priv->from_sql);
+ g_free (priv->join_sql);
g_free (priv->where_sql);
}
@@ -134,6 +135,7 @@
priv->closed = FALSE;
priv->query = NULL;
priv->from_sql = g_strdup ("");
+ priv->join_sql = g_strdup ("");
priv->where_sql = g_strdup ("");
}
@@ -225,6 +227,7 @@
tracker_xesam_live_search_get_id (self),
NULL, /* Columns */
tracker_xesam_live_search_get_from_query (self),
+ tracker_xesam_live_search_get_join_query (self),
tracker_xesam_live_search_get_where_query (self)); /* Query */
if (!result_set)
@@ -290,6 +293,7 @@
tracker_xesam_live_search_get_id (self),
NULL, /* Columns */
tracker_xesam_live_search_get_from_query (self),
+ tracker_xesam_live_search_get_join_query (self),
tracker_xesam_live_search_get_where_query (self)); /* Query */
if (!result_set)
@@ -720,10 +724,9 @@
g_object_get (proxy, "db-connection", &db_con, NULL);
- g_debug ("The from query for activate: %s",tracker_xesam_live_search_get_from_query (self));
-
tracker_db_start_live_search (db_con,
tracker_xesam_live_search_get_from_query (self),
+ tracker_xesam_live_search_get_join_query (self),
tracker_xesam_live_search_get_where_query (self),
tracker_xesam_live_search_get_id (self));
@@ -809,18 +812,21 @@
TrackerDBusXesam *proxy = TRACKER_DBUS_XESAM (tracker_dbus_get_object (TRACKER_TYPE_DBUS_XESAM));
DBConnection *db_con = NULL;
GError *parse_error = NULL;
- gchar *orig_from, *orig_where;
+ gchar *orig_from, *orig_join, *orig_where;
g_object_get (proxy, "db-connection", &db_con, NULL);
orig_from = priv->from_sql;
+ orig_join = priv->join_sql;
orig_where = priv->where_sql;
priv->from_sql = NULL;
+ priv->join_sql = NULL;
priv->where_sql = NULL;
tracker_xesam_query_to_sql (db_con, priv->query,
- &priv->from_sql,
+ &priv->from_sql,
+ &priv->join_sql,
&priv->where_sql,
&parse_error);
@@ -834,19 +840,20 @@
g_error_free (parse_error);
g_free (priv->from_sql);
+ g_free (priv->join_sql);
g_free (priv->where_sql);
priv->from_sql = orig_from;
+ priv->join_sql = orig_join;
priv->where_sql = orig_where;
return FALSE;
} else {
g_free (orig_from);
+ g_free (orig_join);
g_free (orig_where);
}
- g_message ("Parsed to '%s' and '%s'", priv->from_sql, priv->where_sql);
-
return TRUE;
}
@@ -866,6 +873,21 @@
}
/**
+ * tracker_xesam_live_search_get_join_query:
+ * @self: a #TrackerXesamLiveSearch
+ *
+ * Gets the parsed JOIN SQL string for the query
+ *
+ * @returns: a read-only string with the JOIN query
+ **/
+const gchar*
+tracker_xesam_live_search_get_join_query (TrackerXesamLiveSearch *self)
+{
+ TrackerXesamLiveSearchPriv *priv = self->priv;
+ return (const gchar *) priv->join_sql;
+}
+
+/**
* tracker_xesam_live_search_get_where_query:
* @self: a #TrackerXesamLiveSearch
*
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 Wed May 28 13:23:19 2008
@@ -55,6 +55,7 @@
const gchar* tracker_xesam_live_search_get_id (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_join_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);
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 Wed May 28 13:23:19 2008
@@ -155,6 +155,7 @@
char *current_value;
DBConnection *db_con;
GString *sql_from;
+ GString *sql_join;
GString *sql_where;
char *service;
} ParserData;
@@ -1203,7 +1204,7 @@
void
-tracker_xesam_query_to_sql (DBConnection *db_con, const char *query, gchar **from, gchar **where, GError **error)
+tracker_xesam_query_to_sql (DBConnection *db_con, const char *query, gchar **from, gchar **join, gchar **where, GError **error)
{
static gboolean inited = FALSE;
ParserData data;
@@ -1224,9 +1225,9 @@
table_name = "Services";
data.sql_from = g_string_new ("");
-
g_string_append_printf (data.sql_from, "\n FROM %s S ", table_name);
+ data.sql_join = g_string_new ("");
data.sql_where = g_string_new ("");
data.parser = g_new0 (GMarkupParser, 1);
@@ -1249,8 +1250,10 @@
g_string_free (data.sql_from, TRUE);
g_string_free (data.sql_where, TRUE);
+ g_string_free (data.sql_join, TRUE);
*from = NULL;
+ *join = NULL;
*where = NULL;
} else {
@@ -1259,7 +1262,7 @@
for (l = data.fields; l; l = l->next) {
if (!tracker_field_data_get_is_condition (l->data)) {
if (tracker_field_data_get_needs_join (l->data)) {
- g_string_append_printf (data.sql_from,
+ g_string_append_printf (data.sql_join,
"\n LEFT OUTER JOIN %s %s ON (S.ID = %s.ServiceID and %s.MetaDataID = %s) ",
tracker_field_data_get_table_name (l->data),
tracker_field_data_get_alias (l->data),
@@ -1272,7 +1275,7 @@
related_metadata = tracker_get_related_metadata_names (db_con,
tracker_field_data_get_field_name (l->data));
- g_string_append_printf (data.sql_from,
+ g_string_append_printf (data.sql_join,
"\n INNER JOIN %s %s ON (S.ID = %s.ServiceID and %s.MetaDataID in (%s)) ",
tracker_field_data_get_table_name (l->data),
tracker_field_data_get_alias (l->data),
@@ -1284,9 +1287,11 @@
}
*from = g_strdup (data.sql_from->str);
+ *join = g_strdup (data.sql_join->str);
*where = g_strdup (data.sql_where->str);
g_string_free (data.sql_from, TRUE);
+ g_string_free (data.sql_join, TRUE);
g_string_free (data.sql_where, TRUE);
}
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 Wed May 28 13:23:19 2008
@@ -28,7 +28,8 @@
void tracker_xesam_query_to_sql (DBConnection *db_con,
const char *query,
- gchar **from,
+ gchar **from,
+ gchar **join,
gchar **where,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]