Fix typos and simplify SQL query for locationbar

This commit is contained in:
Alexander Butenko 2010-07-20 09:40:28 -04:00 committed by Christian Dywan
parent 5859bbe2ab
commit 64fb6e8ee8
2 changed files with 12 additions and 14 deletions

View file

@ -375,11 +375,7 @@ midori_history_initialize (KatzeArray* array,
"CREATE TABLE IF NOT EXISTS " "CREATE TABLE IF NOT EXISTS "
"history (uri text, title text, date integer, day integer);" "history (uri text, title text, date integer, day integer);"
"CREATE TABLE IF NOT EXISTS " "CREATE TABLE IF NOT EXISTS "
"search (keywords text, uri text, day integer);" "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;",
NULL, NULL, errmsg) != SQLITE_OK) NULL, NULL, errmsg) != SQLITE_OK)
return NULL; return NULL;

View file

@ -356,15 +356,17 @@ midori_location_action_popup_timeout_cb (gpointer data)
{ {
sqlite3* db; sqlite3* db;
db = g_object_get_data (G_OBJECT (action->history), "db"); db = g_object_get_data (G_OBJECT (action->history), "db");
sqlcmd = "SELECT type, uri, title, count() AS ct FROM history_view " sqlcmd = "SELECT type, uri, title FROM ("
"WHERE uri LIKE ?1 OR title LIKE ?1 GROUP BY uri " " SELECT 1 AS type, uri, title, count() AS ct FROM history "
"UNION ALL " " WHERE uri LIKE ?1 OR title LIKE ?1 GROUP BY uri "
"SELECT type, replace(uri, '%s', title) AS uri, title, count() AS ct FROM search_view " " UNION ALL "
"WHERE title LIKE ?1 GROUP BY uri " " SELECT 2 AS type, replace(uri, '%s', keywords) AS uri, "
"UNION ALL " " keywords AS title, count() AS ct FROM search "
"SELECT '1' AS type, uri, title, '100' AS ct FROM bookmarks " " WHERE uri LIKE ?1 OR title LIKE ?1 GROUP BY uri "
"WHERE title LIKE ?1 AND uri !='' " " UNION ALL "
"ORDER BY ct DESC LIMIT ?2"; " 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_prepare_v2 (db, sqlcmd, strlen (sqlcmd) + 1, &stmt, NULL);
} }
sqlite3_bind_text (stmt, 1, g_strdup_printf ("%%%s%%", action->key), -1, g_free); sqlite3_bind_text (stmt, 1, g_strdup_printf ("%%%s%%", action->key), -1, g_free);