From 6267e6e241400daf0d986ea2e57d673beac06208 Mon Sep 17 00:00:00 2001 From: Claudio Saavedra Date: Tue, 10 Jan 2012 19:15:50 +0200 Subject: history-service: take into account the query's result limit --- lib/history/ephy-history-service-urls-table.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/history/ephy-history-service-urls-table.c b/lib/history/ephy-history-service-urls-table.c index 4892fd4a5..c2178eee5 100644 --- a/lib/history/ephy-history-service-urls-table.c +++ b/lib/history/ephy-history-service-urls-table.c @@ -256,7 +256,11 @@ ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery * for (substring = query->substring_list; substring != NULL; substring = substring->next) statement_str = g_string_append (statement_str, "(urls.url LIKE ? OR urls.title LIKE ?) AND "); - statement_str = g_string_append (statement_str, "1"); + statement_str = g_string_append (statement_str, "1 "); + + if (query->limit) { + statement_str = g_string_append (statement_str, "LIMIT ? "); + } statement = ephy_sqlite_connection_create_statement (priv->history_database, statement_str->str, &error); @@ -304,6 +308,14 @@ ephy_history_service_find_url_rows (EphyHistoryService *self, EphyHistoryQuery * g_free (string); } + if (query->limit) + if (ephy_sqlite_statement_bind_int (statement, i++, query->limit, &error) == FALSE) { + g_error ("Could not build urls table query statement: %s", error->message); + g_error_free (error); + g_object_unref (statement); + return NULL; + } + while (ephy_sqlite_statement_step (statement, &error)) urls = g_list_prepend (urls, create_url_from_statement (statement)); -- cgit v1.2.3