tracker r2573 - in trunk: . data/db src/libtracker-data src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2573 - in trunk: . data/db src/libtracker-data src/trackerd
- Date: Wed, 26 Nov 2008 12:00:03 +0000 (UTC)
Author: mr
Date: Wed Nov 26 12:00:02 2008
New Revision: 2573
URL: http://svn.gnome.org/viewvc/tracker?rev=2573&view=rev
Log:
* data/db/sqlite-stored-procs.sql:
* src/libtracker-data/tracker-data-search.c:
* src/libtracker-data/tracker-rdf-query.c:
* src/trackerd/tracker-processor.c: Updated all queries to use the
"AS" keyword for clarity. Now we check the Volumes table for the
Enabled value as well as the Services table so we don't show files
which are disabled because the memory card isn't mounted. We also
now don't delete memory card data in the Services table when we
unmount.
Modified:
trunk/ChangeLog
trunk/data/db/sqlite-stored-procs.sql
trunk/src/libtracker-data/tracker-data-search.c
trunk/src/libtracker-data/tracker-rdf-query.c
trunk/src/trackerd/tracker-processor.c
Modified: trunk/data/db/sqlite-stored-procs.sql
==============================================================================
--- trunk/data/db/sqlite-stored-procs.sql (original)
+++ trunk/data/db/sqlite-stored-procs.sql Wed Nov 26 12:00:02 2008
@@ -6,14 +6,15 @@
/*
* Metadata queries
*/
-GetApplicationByID SELECT (S.Path || '/' || S.Name) AS uri, 'Applications', 'Application', S.KeyMetadata1, S.KeyMetadata2, S.KeyMetadata3 FROM Services S WHERE S.ID = ?;
+GetApplicationByID SELECT (S.Path || '/' || S.Name) AS uri, 'Applications', 'Application', S.KeyMetadata1, S.KeyMetadata2, S.KeyMetadata3 FROM Services AS S WHERE S.ID = ?;
GetAllServices SELECT TypeID, TypeName, Parent, PropertyPrefix, Enabled, Embedded, HasMetadata, HasFullText, HasThumbs, ContentMetadata, Database, ShowServiceFiles, ShowServiceDirectories, KeyMetadata1, KeyMetadata2, KeyMetadata3, KeyMetadata4, KeyMetadata5, KeyMetadata6, KeyMetadata7, KeyMetadata8, KeyMetadata9, KeyMetadata10, KeyMetadata11 FROM ServiceTypes;
-GetEmailByID SELECT (S.Path || '/' || S.Name) AS uri, 'Emails', S.Mime, S.KeyMetadata1, S.KeyMetadata2, S.KeyMetadata3 FROM Services S WHERE S.ID = ?;
-GetFileByID SELECT Path, Name, Mime, ServiceTypeID FROM Services WHERE ID = ? AND Enabled = 1;
-GetFileByID2 SELECT (Path || '/' || Name) AS uri, GetServiceName (ServiceTypeID), Mime FROM Services WHERE ID = ? AND Enabled = 1;
-GetFileMTime SELECT M.MetaDataValue FROM Services F inner join ServiceNumericMetaData M ON F.ID = M.ServiceID WHERE F.Path = ? AND F.Name = ? AND M.MetaDataID = (SELECT ID FROM MetaDataTypes WHERE MetaName ='File:Modified');
+GetEmailByID SELECT (S.Path || '/' || S.Name) AS uri, 'Emails', S.Mime, S.KeyMetadata1, S.KeyMetadata2, S.KeyMetadata3 FROM Services AS S WHERE S.ID = ?;
+GetFileByID SELECT S.Path, S.Name, S.Mime, S.ServiceTypeID FROM Services AS S WHERE S.ID = ? AND S.Enabled = 1 AND (S.AuxilaryID = 0 OR S.AuxilaryID IN (SELECT VolumeID FROM Volumes WHERE Enabled = 1));
+GetFileByID2 SELECT (S.Path || '/' || S.Name) AS uri, GetServiceName (ServiceTypeID), S.Mime FROM Services AS S WHERE S.ID = ? AND S.Enabled = 1 AND (S.AuxilaryID = 0 OR S.AuxilaryID IN (SELECT VolumeID FROM Volumes WHERE Enabled = 1));
+GetFileMTime SELECT M.MetaDataValue FROM Services AS S INNER JOIN ServiceNumericMetaData M ON S.ID = M.ServiceID WHERE S.Path = ? AND S.Name = ? AND M.MetaDataID = (SELECT ID FROM MetaDataTypes WHERE MetaName ='File:Modified');
GetServices SELECT TypeName, Description, Parent FROM ServiceTypes ORDER BY TypeID;
+
/*
* Live search queries
*/
@@ -51,11 +52,11 @@
DeleteServiceNumericMetadata DELETE FROM ServiceMetaData WHERE ServiceID = ?;
GetServiceID SELECT ID, IndexTime, IsDirectory, ServiceTypeID FROM Services WHERE Path = ? AND Name = ?;
-GetByServiceType SELECT DISTINCT F.Path || '/' || F.Name AS uri FROM Services F WHERE F.ServiceTypeID IN (SELECT TypeId FROM ServiceTypes WHERE TypeName = ? OR Parent = ?) LIMIT ?,?;
+GetByServiceType SELECT DISTINCT S.Path || '/' || S.Name AS uri FROM Services AS S WHERE S.Enabled = 1 AND (S.AuxilaryID = 0 OR S.AuxilaryID IN (SELECT VolumeID FROM Volumes WHERE Enabled = 1)) AND S.ServiceTypeID IN (SELECT TypeId FROM ServiceTypes WHERE TypeName = ? OR Parent = ?) LIMIT ?,?;
GetContents SELECT uncompress (Content) FROM ServiceContents WHERE ServiceID = ? AND MetadataID = ? AND Content is not null;
GetFileContents SELECT substr(uncompress (Content), ?, ?) FROM ServiceContents WHERE ServiceID = ?;
GetAllContents SELECT uncompress (Content) FROM ServiceContents WHERE ServiceID = ? AND Content is not null;
-GetKeywordList SELECT DISTINCT K.MetaDataValue, count(*) AS totalcount FROM Services S, ServiceKeywordMetaData K WHERE K.ServiceID = S.ID AND (S.ServiceTypeID IN (SELECT TypeId FROM ServiceTypes WHERE TypeName = ? OR Parent = ?)) AND K.MetaDataId = 19 GROUP BY K.MetaDataValue ORDER BY totalcount desc, K.MetaDataValue ASC;
+GetKeywordList SELECT DISTINCT K.MetaDataValue, count(*) AS totalcount FROM Services AS S, ServiceKeywordMetaData K WHERE K.ServiceID = S.ID AND (S.ServiceTypeID IN (SELECT TypeId FROM ServiceTypes WHERE TypeName = ? OR Parent = ?)) AND K.MetaDataId = 19 GROUP BY K.MetaDataValue ORDER BY totalcount desc, K.MetaDataValue ASC;
SaveServiceContents REPLACE INTO ServiceContents (ServiceID, MetadataID, Content) VALUES (?,?,compress (?));
@@ -64,8 +65,8 @@
*/
GetAllMetadata SELECT MetadataID, MetadataDisplay FROM ServiceMetadata WHERE ServiceID = ? UNION SELECT MetadataID, MetadataValue FROM ServiceKeywordMetadata WHERE ServiceID = ? UNION SELECT MetadataID, upper(MetadataValue) FROM ServiceNumericMetadata WHERE ServiceID = ?;
GetMetadata SELECT MetaDataDisplay FROM ServiceMetaData WHERE ServiceID = ? AND MetaDataID = ?;
-GetMetadataAliases SELECT DISTINCT M.MetaName, M.ID FROM MetaDataTypes M, MetaDataChildren C WHERE M.ID = C.ChildID AND C.MetaDataID = ?;
-GetMetadataAliasesForName SELECT DISTINCT M.MetaName, M.ID FROM MetaDataTypes M, MetaDataChildren C WHERE M.ID = C.ChildID AND C.MetaDataID = (SELECT ID FROM MetaDataTypes WHERE MetaName = ?) UNION SELECT M.MetaName, M.ID FROM MetaDataTypes M WHERE M.MetaName = ?;
+GetMetadataAliases SELECT DISTINCT M.MetaName, M.ID FROM MetaDataTypes AS M, MetaDataChildren AS C WHERE M.ID = C.ChildID AND C.MetaDataID = ?;
+GetMetadataAliasesForName SELECT DISTINCT M.MetaName, M.ID FROM MetaDataTypes AS M, MetaDataChildren AS C WHERE M.ID = C.ChildID AND C.MetaDataID = (SELECT ID FROM MetaDataTypes WHERE MetaName = ?) UNION SELECT M.MetaName, M.ID FROM MetaDataTypes AS M WHERE M.MetaName = ?;
GetMetadataKeyword SELECT MetaDataValue FROM ServiceKeywordMetaData WHERE ServiceID = ? AND MetaDataID = ?;
GetMetadataNumeric SELECT MetaDataValue FROM ServiceNumericMetaData WHERE ServiceID = ? AND MetaDataID = ?;
GetMetadataTypes SELECT ID, MetaName, DataTypeID, FieldName, Weight, Embedded, MultipleValues, Delimited, Filtered, Abstract FROM MetaDataTypes;
@@ -74,10 +75,11 @@
SetMetadataKeyword INSERT INTO ServiceKeywordMetaData (ServiceID, MetaDataID, MetaDataValue) VALUES (?,?,?);
SetMetadataNumeric INSERT INTO ServiceNumericMetaData (ServiceID, MetaDataID, MetaDataValue) VALUES (?,?,?);
-DeleteMetadata DELETE FROM ServiceMetaData WHERE ServiceID = ? AND MetaDataID=?;
-DeleteMetadataKeyword DELETE FROM ServiceKeywordMetaData WHERE ServiceID = ? AND MetaDataID=?;
-DeleteMetadataKeywordValue DELETE FROM ServiceKeywordMetaData WHERE ServiceID = ? AND MetaDataID=? AND MetaDataValue = ?;DeleteMetadataValue DELETE FROM ServiceMetaData WHERE ServiceID = ? AND MetaDataID=? AND MetaDataDisplay=?;
-DeleteMetadataNumeric DELETE FROM ServiceNumericMetaData WHERE ServiceID = ? AND MetaDataID=?;
+DeleteMetadata DELETE FROM ServiceMetaData WHERE ServiceID = ? AND MetaDataID = ?;
+DeleteMetadataKeyword DELETE FROM ServiceKeywordMetaData WHERE ServiceID = ? AND MetaDataID = ?;
+DeleteMetadataKeywordValue DELETE FROM ServiceKeywordMetaData WHERE ServiceID = ? AND MetaDataID = ? AND MetaDataValue = ?;
+DeleteMetadataValue DELETE FROM ServiceMetaData WHERE ServiceID = ? AND MetaDataID = ? AND MetaDataDisplay = ?;
+DeleteMetadataNumeric DELETE FROM ServiceNumericMetaData WHERE ServiceID = ? AND MetaDataID = ?;
InsertMetaDataChildren INSERT INTO MetaDataChildren (ChildID,MetadataID) VALUES (?,(SELECT ID FROM MetaDataTypes WHERE MetaName = ?));
InsertMetadataType INSERT INTO MetaDataTypes (MetaName) VALUES (?);
@@ -156,7 +158,7 @@
GetXesamMetaDataChildren SELECT Child FROM XesamMetaDataChildren WHERE Parent = ?;
GetXesamMetaDataMappings SELECT MetaName FROM XesamMetaDataMapping WHERE XesamMetaName = ?;
GetXesamMetaDataLookups SELECT DISTINCT MetaName FROM XesamMetaDataLookup WHERE XesamMetaName = ?;
-GetXesamMetaDataTextLookups SELECT DISTINCT L.MetaName FROM XesamMetaDataLookup L INNER JOIN XesamMetaDataTypes T ON (T.MetaName = L.XesamMetaName) WHERE T.DataTypeID = 3;
+GetXesamMetaDataTextLookups SELECT DISTINCT L.MetaName FROM XesamMetaDataLookup AS L INNER JOIN XesamMetaDataTypes AS T ON (T.MetaName = L.XesamMetaName) WHERE T.DataTypeID = 3;
GetXesamMetaDataTypes SELECT ID, MetaName, DataTypeID, FieldName, Weight, Embedded, MultipleValues, Delimited, Filtered, Abstract FROM XesamMetaDataTypes;
GetXesamServiceTypes SELECT TypeID, TypeName, Parents, PropertyPrefix, Enabled, Embedded, HasMetadata, HasFullText, HasThumbs, ContentMetadata, Database, ShowServiceFiles, ShowServiceDirectories, KeyMetadata1, KeyMetadata2, KeyMetadata3, KeyMetadata4, KeyMetadata5, KeyMetadata6, KeyMetadata7, KeyMetadata8, KeyMetadata9, KeyMetadata10, KeyMetadata11 FROM XesamServiceTypes;
Modified: trunk/src/libtracker-data/tracker-data-search.c
==============================================================================
--- trunk/src/libtracker-data/tracker-data-search.c (original)
+++ trunk/src/libtracker-data/tracker-data-search.c Wed Nov 26 12:00:02 2008
@@ -593,7 +593,19 @@
service = "Files";
}
- str = g_string_new ("SELECT DISTINCT F.Path || '/' || F.Name AS uri FROM Services F INNER JOIN ServiceKeywordMetaData M ON F.ID = M.ServiceID WHERE M.MetaDataID = (SELECT ID FROM MetaDataTypes WHERE MetaName ='File:Mime') AND (M.MetaDataValue IN ");
+ str = g_string_new ("SELECT DISTINCT S.Path || '/' || S.Name AS uri "
+ "FROM Services AS S "
+ "INNER JOIN ServiceKeywordMetaData AS M "
+ "ON "
+ "S.ID = M.ServiceID "
+ "WHERE "
+ "S.Enabled = 1 "
+ "AND "
+ "(S.AuxilaryID = 0 OR S.AuxilaryID IN (SELECT VolumeID FROM Volumes WHERE Enabled = 1)) "
+ "AND "
+ "(M.MetaDataID = (SELECT ID FROM MetaDataTypes WHERE MetaName ='File:Mime')) "
+ "AND "
+ "(M.MetaDataValue IN ");
g_string_append_printf (str, "('%s'", mimes[0]);
@@ -601,8 +613,12 @@
g_string_append_printf (str, ", '%s'", mimes[i]);
}
+ g_string_append (str, ")) ");
+
g_string_append_printf (str,
- ")) AND (F.ServiceTypeID in (select TypeId from ServiceTypes where TypeName = '%s' or Parent = '%s')) LIMIT %d,%d",
+ "AND "
+ "(S.ServiceTypeID IN (SELECT TypeId FROM ServiceTypes WHERE TypeName = '%s' OR Parent = '%s')) "
+ "LIMIT %d,%d",
service,
service,
offset,
@@ -740,7 +756,7 @@
iface = tracker_db_manager_get_db_interface_by_service (service_type);
sql_select = g_string_new ("SELECT DISTINCT ");
- sql_from = g_string_new ("\nFROM Services S ");
+ sql_from = g_string_new ("\nFROM Services AS S ");
sql_where = g_string_new ("\nWHERE ");
sql_order = g_string_new ("\nORDER BY ");
@@ -862,7 +878,7 @@
iface = tracker_db_manager_get_db_interface_by_service (service_type);
sql_select = g_string_new ("SELECT DISTINCT ");
- sql_from = g_string_new ("\nFROM Services S ");
+ sql_from = g_string_new ("\nFROM Services AS S ");
sql_where = g_string_new ("\nWHERE ");
sql_order = g_string_new ("\nORDER BY ");
sql_group = g_string_new ("\nGROUP BY ");
@@ -1018,7 +1034,7 @@
iface = tracker_db_manager_get_db_interface_by_service (service_type);
sql_select = g_string_new ("SELECT DISTINCT ");
- sql_from = g_string_new ("\nFROM Services S ");
+ sql_from = g_string_new ("\nFROM Services AS S ");
sql_where = g_string_new ("\nWHERE ");
sql_order = g_string_new ("\nORDER BY ");
sql_group = g_string_new ("\nGROUP BY ");
@@ -1203,7 +1219,7 @@
iface = tracker_db_manager_get_db_interface_by_service (service_type);
sql_select = g_string_new ("SELECT ");
- sql_from = g_string_new ("\nFROM Services S ");
+ sql_from = g_string_new ("\nFROM Services AS S ");
sql_where = g_string_new ("\nWHERE ");
fd = tracker_metadata_add_metadata_field (iface, service_type, &fields, field, FALSE, TRUE);
@@ -1312,7 +1328,7 @@
iface = tracker_db_manager_get_db_interface_by_service (service_type);
sql_select = g_string_new ("SELECT ");
- sql_from = g_string_new ("\nFROM Services S ");
+ sql_from = g_string_new ("\nFROM Services AS S ");
sql_where = g_string_new ("\nWHERE ");
fd = tracker_metadata_add_metadata_field (iface, service_type, &fields, field, FALSE, TRUE);
@@ -1429,7 +1445,7 @@
/* Build SELECT clause */
sql = g_string_new (" ");
g_string_append_printf (sql,
- "SELECT (F.Path || '%s' || F.Name) as PathName ",
+ "SELECT (S.Path || '%s' || S.Name) as PathName ",
G_DIR_SEPARATOR_S);
for (i = 1; i <= g_strv_length (fields); i++) {
@@ -1438,7 +1454,7 @@
field = tracker_data_schema_get_field_name ("Files", fields[i-1]);
if (field) {
- g_string_append_printf (sql, ", F.%s ", field);
+ g_string_append_printf (sql, ", S.%s ", field);
g_free (field);
needs_join[i - 1] = FALSE;
} else {
@@ -1453,7 +1469,7 @@
/* Build FROM clause */
g_string_append (sql,
- " FROM Services F ");
+ " FROM Services AS S ");
for (i = 0; i < g_strv_length (fields); i++) {
const gchar *table;
@@ -1466,7 +1482,7 @@
g_string_append_printf (sql,
" LEFT OUTER JOIN %s M%d ON "
- "F.ID = M%d.ServiceID AND "
+ "S.ID = M%d.ServiceID AND "
"M%d.MetaDataID = %s ",
table,
i + 1,
@@ -1477,8 +1493,15 @@
/* Build WHERE clause */
g_string_append_printf (sql,
- " WHERE F.Path = '%s' ",
+ " "
+ "WHERE "
+ "S.Path = '%s' "
+ "AND "
+ "S.Enabled = 1 "
+ "AND "
+ "(S.AuxilaryID = 0 OR S.AuxilaryID IN (SELECT VolumeID FROM Volumes WHERE Enabled = 1)) ",
uri_filtered);
+
g_free (uri_filtered);
query = g_string_free (sql, FALSE);
@@ -1533,7 +1556,7 @@
select = g_string_new (" Select distinct S.Path || '");
select = g_string_append (select, G_DIR_SEPARATOR_S);
select = g_string_append (select,
- "' || S.Name as EntityName from Services S, ServiceKeywordMetaData M ");
+ "' || S.Name as EntityName from Services AS S, ServiceKeywordMetaData AS M ");
/* Create where string */
related_metadata = tracker_data_schema_metadata_field_get_related_names (iface, "User:Keywords");
Modified: trunk/src/libtracker-data/tracker-rdf-query.c
==============================================================================
--- trunk/src/libtracker-data/tracker-rdf-query.c (original)
+++ trunk/src/libtracker-data/tracker-rdf-query.c Wed Nov 26 12:00:02 2008
@@ -1146,10 +1146,10 @@
gint limit,
GError **error)
{
- ParserData data;
- gchar *result;
- gchar *table_name;
- gboolean do_search = FALSE;
+ ParserData data;
+ gchar *result;
+ const gchar *table_name;
+ gboolean do_search = FALSE;
g_return_val_if_fail (TRACKER_IS_DB_INTERFACE (iface), NULL);
g_return_val_if_fail (query != NULL, NULL);
@@ -1197,11 +1197,11 @@
if (!tracker_is_empty_string (search_text)) {
do_search = TRUE;
g_string_append_printf (data.sql_from,
- "\n FROM %s S INNER JOIN SearchResults1 M ON S.ID = M.SID ",
+ "\n FROM %s AS S INNER JOIN SearchResults1 M ON S.ID = M.SID ",
table_name);
} else {
g_string_append_printf (data.sql_from,
- "\n FROM %s S ",
+ "\n FROM %s AS S ",
table_name);
}
@@ -1219,16 +1219,13 @@
data.sql_where = g_string_new ("");
- if (strlen (query) < 10) {
- g_string_append_printf (data.sql_where,
- "\n WHERE (S.ServiceTypeID in (select TypeId from ServiceTypes where TypeName = '%s' or Parent = '%s')) ",
- service,
- service);
- } else {
- g_string_append_printf (data.sql_where,
- "\n WHERE (S.ServiceTypeID in (select TypeId from ServiceTypes where TypeName = '%s' or Parent = '%s')) AND ",
- service,
- service);
+ g_string_append_printf (data.sql_where, " (S.ServiceTypeID in (select TypeId from ServiceTypes where TypeName = '%s' or Parent = '%s')) ", service, service);
+
+ /* only search for items on enabled volumes */
+ g_string_append (data.sql_where, "AND (S.AuxilaryID = 0 OR S.AuxilaryID IN (SELECT VolumeID FROM Volumes WHERE Enabled = 1)) ");
+
+ if (strlen (query) >= 10) {
+ g_string_append (data.sql_where, "AND ");
}
if (limit < 1) {
@@ -1309,9 +1306,9 @@
push_stack (&data, STATE_START);
- result = NULL;
-
if (!g_markup_parse_context_parse (data.context, query, -1, error)) {
+ result = NULL;
+
g_string_free (data.sql_select, TRUE);
g_string_free (data.sql_from, TRUE);
g_string_free (data.sql_where, TRUE);
@@ -1413,10 +1410,13 @@
data.fields = *fields;
- if (strlen (query) < 10) {
- g_string_append_printf (data.sql_where, " (S.ServiceTypeID in (select TypeId from ServiceTypes where TypeName = '%s' or Parent = '%s')) ", service, service);
- } else {
- g_string_append_printf (data.sql_where, " (S.ServiceTypeID in (select TypeId from ServiceTypes where TypeName = '%s' or Parent = '%s')) AND ", service, service);
+ g_string_append_printf (data.sql_where, " (S.ServiceTypeID in (select TypeId from ServiceTypes where TypeName = '%s' or Parent = '%s')) ", service, service);
+
+ /* only search for items on enabled volumes */
+ g_string_append (data.sql_where, "AND (S.AuxilaryID = 0 OR S.AuxilaryID IN (SELECT VolumeID FROM Volumes WHERE Enabled = 1)) ");
+
+ if (strlen (query) >= 10) {
+ g_string_append (data.sql_where, "AND ");
}
data.parser = g_new0 (GMarkupParser, 1);
Modified: trunk/src/trackerd/tracker-processor.c
==============================================================================
--- trunk/src/trackerd/tracker-processor.c (original)
+++ trunk/src/trackerd/tracker-processor.c Wed Nov 26 12:00:02 2008
@@ -1449,10 +1449,15 @@
processor = user_data;
- /* Remove the monitor and item from the database */
+ /* Remove the monitor, the volumes are updated somewhere else
+ * in main.
+ *
+ * FIXME: we _should_ really remove all monitors recursively
+ * here, because we are leaking each time a new MMC is
+ * inserted :O -mr
+ */
file = g_file_new_for_path (mount_point);
tracker_monitor_remove (processor->private->monitor, module_name, file);
- processor_files_delete (processor, module_name, file, TRUE);
g_object_unref (file);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]