From: Alexander Butenko Date: Tue, 20 Jul 2010 13:40:28 +0000 (-0400) Subject: Fix typos and simplify SQL query for locationbar X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64fb6e8ee82de7dd06a939a249371d44c69d4ecb;p=midori Fix typos and simplify SQL query for locationbar --- diff --git a/midori/main.c b/midori/main.c index 35f9b99c..fd5ec988 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 927e80e9..1f6ff2e9 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);