[Xfce4-commits] <midori:master> Fix typos and simplify SQL query for locationbar
Christian Dywan
noreply at xfce.org
Thu Jul 22 01:04:02 CEST 2010
Updating branch refs/heads/master
to 64fb6e8ee82de7dd06a939a249371d44c69d4ecb (commit)
from 5859bbe2abd8244d71a33fd4b9ae2f6d7d6baf51 (commit)
commit 64fb6e8ee82de7dd06a939a249371d44c69d4ecb
Author: Alexander Butenko <a.butenka at gmail.com>
Date: Tue Jul 20 09:40:28 2010 -0400
Fix typos and simplify SQL query for locationbar
midori/main.c | 6 +-----
midori/midori-locationaction.c | 20 +++++++++++---------
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/midori/main.c b/midori/main.c
index 35f9b99..fd5ec98 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -375,11 +375,7 @@ midori_history_initialize (KatzeArray* array,
"CREATE TABLE IF NOT EXISTS "
"history (uri text, title text, date integer, day integer);"
"CREATE TABLE IF NOT EXISTS "
- "search (keywords text, uri text, day integer);"
- "CREATE TEMP VIEW history_view AS SELECT "
- "1 AS type, uri, title, day FROM history;"
- "CREATE TEMP VIEW search_view AS SELECT "
- "2 AS type, uri, keywords AS title, day FROM search;",
+ "search (keywords text, uri text, day integer);",
NULL, NULL, errmsg) != SQLITE_OK)
return NULL;
diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c
index 927e80e..1f6ff2e 100644
--- a/midori/midori-locationaction.c
+++ b/midori/midori-locationaction.c
@@ -356,15 +356,17 @@ midori_location_action_popup_timeout_cb (gpointer data)
{
sqlite3* db;
db = g_object_get_data (G_OBJECT (action->history), "db");
- sqlcmd = "SELECT type, uri, title, count() AS ct FROM history_view "
- "WHERE uri LIKE ?1 OR title LIKE ?1 GROUP BY uri "
- "UNION ALL "
- "SELECT type, replace(uri, '%s', title) AS uri, title, count() AS ct FROM search_view "
- "WHERE title LIKE ?1 GROUP BY uri "
- "UNION ALL "
- "SELECT '1' AS type, uri, title, '100' AS ct FROM bookmarks "
- "WHERE title LIKE ?1 AND uri !='' "
- "ORDER BY ct DESC LIMIT ?2";
+ sqlcmd = "SELECT type, uri, title FROM ("
+ " SELECT 1 AS type, uri, title, count() AS ct FROM history "
+ " WHERE uri LIKE ?1 OR title LIKE ?1 GROUP BY uri "
+ " UNION ALL "
+ " SELECT 2 AS type, replace(uri, '%s', keywords) AS uri, "
+ " keywords AS title, count() AS ct FROM search "
+ " WHERE uri LIKE ?1 OR title LIKE ?1 GROUP BY uri "
+ " UNION ALL "
+ " SELECT 1 AS type, uri, title, 50 AS ct FROM bookmarks "
+ " WHERE title LIKE ?1 OR uri LIKE ?1 AND uri !='' "
+ ") GROUP BY uri ORDER BY ct DESC LIMIT ?2";
sqlite3_prepare_v2 (db, sqlcmd, strlen (sqlcmd) + 1, &stmt, NULL);
}
sqlite3_bind_text (stmt, 1, g_strdup_printf ("%%%s%%", action->key), -1, g_free);
More information about the Xfce4-commits
mailing list