[grilo-plugins] tracker: Do not allow LIMIT and OFFSET in the query
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] tracker: Do not allow LIMIT and OFFSET in the query
- Date: Sat, 23 Mar 2013 23:04:27 +0000 (UTC)
commit 457c4e6b6d56eadcbc1b12cd133f7714e26b106c
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Sat Mar 23 23:01:12 2013 +0000
tracker: Do not allow LIMIT and OFFSET in the query
Rather, they should be specified in the skip and count parameters.
src/tracker/grl-tracker-source-api.c | 27 +++++++++++++++++++--------
1 files changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/src/tracker/grl-tracker-source-api.c b/src/tracker/grl-tracker-source-api.c
index 8adea4c..dfccb4e 100644
--- a/src/tracker/grl-tracker-source-api.c
+++ b/src/tracker/grl-tracker-source-api.c
@@ -57,12 +57,19 @@ GRL_LOG_DOMAIN_STATIC(tracker_source_result_log_domain);
/* ------- Definitions ------- */
-#define TRACKER_QUERY_REQUEST \
+#define TRACKER_QUERY_LIMIT \
+ "OFFSET %u " \
+ "LIMIT %u"
+
+#define TRACKER_QUERY_PARTIAL_REQUEST \
"SELECT rdf:type(?urn) %s " \
"WHERE { %s . %s } " \
"ORDER BY DESC(nfo:fileLastModified(?urn)) " \
- "OFFSET %u " \
- "LIMIT %u"
+ TRACKER_QUERY_LIMIT
+
+#define TRACKER_QUERY_FULL_REQUEST \
+ "%s " \
+ TRACKER_QUERY_LIMIT
#define TRACKER_SEARCH_REQUEST \
"SELECT rdf:type(?urn) %s " \
@@ -626,7 +633,7 @@ grl_tracker_source_query (GrlSource *source,
if (g_ascii_strncasecmp (qs->query, "select ", 7) != 0) {
constraint = grl_tracker_source_get_device_constraint (priv);
sparql_select = grl_tracker_source_get_select_string (qs->keys);
- sparql_final = g_strdup_printf (TRACKER_QUERY_REQUEST,
+ sparql_final = g_strdup_printf (TRACKER_QUERY_PARTIAL_REQUEST,
sparql_select,
qs->query,
constraint,
@@ -636,12 +643,16 @@ grl_tracker_source_query (GrlSource *source,
g_free (qs->query);
g_free (sparql_select);
qs->query = sparql_final;
- grl_tracker_source_query (source, qs);
- return;
+ } else {
+ /* Append offset and limit */
+ sparql_final = g_strdup_printf (TRACKER_QUERY_FULL_REQUEST,
+ qs->query,
+ skip,
+ count);
+ g_free (qs->query);
+ qs->query = sparql_final;
}
- GRL_IDEBUG ("\tselect : '%s'", qs->query);
-
os = grl_tracker_op_initiate_query (qs->operation_id,
g_strdup (qs->query),
(GAsyncReadyCallback) tracker_query_cb,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]