tracker r2979 - in trunk: . data/db src/libtracker-data src/libtracker-db
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2979 - in trunk: . data/db src/libtracker-data src/libtracker-db
- Date: Thu, 26 Feb 2009 11:25:52 +0000 (UTC)
Author: carlosg
Date: Thu Feb 26 11:25:51 2009
New Revision: 2979
URL: http://svn.gnome.org/viewvc/tracker?rev=2979&view=rev
Log:
2009-02-26 Carlos Garnacho <carlos imendio com>
* src/libtracker-db/tracker-db-manager.c: Added CollateKey sqlite
function to let it handle collate key changes. Check locale on startup
and regenerate collate keys if necessary.
* src/libtracker-data/tracker-data-update.c: Remove collate key
generation from code, since now it will be handled by the database.
* data/db/sqlite-stored-procs.sql: Updated to use the CollateKey
function, added getter/setter for locale config option, stored in
Options (common.db)
Modified:
trunk/ChangeLog
trunk/data/db/sqlite-stored-procs.sql
trunk/data/db/sqlite-tracker.sql
trunk/src/libtracker-data/tracker-data-update.c
trunk/src/libtracker-db/tracker-db-manager.c
Modified: trunk/data/db/sqlite-stored-procs.sql
==============================================================================
--- trunk/data/db/sqlite-stored-procs.sql (original)
+++ trunk/data/db/sqlite-stored-procs.sql Thu Feb 26 11:25:51 2009
@@ -34,6 +34,9 @@
GetOption SELECT OptionValue FROM Options WHERE OptionKey = ?;
SetOption REPLACE INTO Options (OptionKey, OptionValue) VALUES (?,?);
+GetCollationLocale SELECT OptionValue FROM Options WHERE OptionKey = 'CollationLocale';
+SetCollationLocale UPDATE Options SET OptionValue = ? WHERE OptionKey = 'CollationLocale';
+
/*
* File queries
*/
@@ -72,7 +75,7 @@
GetMetadataNumeric SELECT MetaDataValue FROM ServiceNumericMetaData WHERE ServiceID = ? AND MetaDataID = ?;
GetMetadataTypes SELECT ID, MetaName, DataTypeID, FieldName, Weight, Embedded, MultipleValues, Delimited, Filtered, Abstract FROM MetaDataTypes;
-SetMetadata INSERT INTO ServiceMetaData (ServiceID, MetaDataID, MetaDataValue, MetaDataDisplay, MetaDataCollation) VALUES (?,?,?,?,?);
+SetMetadata INSERT INTO ServiceMetaData (ServiceID, MetaDataID, MetaDataValue, MetaDataDisplay, MetaDataCollation) VALUES (?,?,?,?,CollateKey(?));
SetMetadataKeyword INSERT INTO ServiceKeywordMetaData (ServiceID, MetaDataID, MetaDataValue) VALUES (?,?,?);
SetMetadataNumeric INSERT INTO ServiceNumericMetaData (ServiceID, MetaDataID, MetaDataValue) VALUES (?,?,?);
@@ -82,6 +85,8 @@
DeleteMetadataValue DELETE FROM ServiceMetaData WHERE ServiceID = ? AND MetaDataID = ? AND MetaDataDisplay = ?;
DeleteMetadataNumeric DELETE FROM ServiceNumericMetaData WHERE ServiceID = ? AND MetaDataID = ?;
+UpdateMetadataCollation UPDATE ServiceMetadata SET MetadataCollation=CollateKey(MetadataDisplay);
+
InsertMetaDataChildren INSERT INTO MetaDataChildren (ChildID,MetadataID) VALUES (?,(SELECT ID FROM MetaDataTypes WHERE MetaName = ?));
InsertMetadataType INSERT INTO MetaDataTypes (MetaName) VALUES (?);
InsertMimePrefixes REPLACE INTO FileMimePrefixes (MimePrefix) VALUES (?);
@@ -179,4 +184,4 @@
UpdateNewID UPDATE Options SET OptionValue = ? WHERE OptionKey = 'Sequence';
GetNewEventID SELECT OptionValue FROM Options WHERE OptionKey = 'EventSequence';
-UpdateNewEventID UPDATE Options SET OptionValue = ? WHERE OptionKey = 'EventSequence';
+UpdateNewEventID UPDATE Options SET OptionValue = ? WHERE OptionKey = 'EventSequence';
\ No newline at end of file
Modified: trunk/data/db/sqlite-tracker.sql
==============================================================================
--- trunk/data/db/sqlite-tracker.sql (original)
+++ trunk/data/db/sqlite-tracker.sql Thu Feb 26 11:25:51 2009
@@ -11,6 +11,7 @@
insert Into Options (OptionKey, OptionValue) values ('EvolutionLastModseq', '0');
insert Into Options (OptionKey, OptionValue) values ('KMailLastModseq', '0');
insert Into Options (OptionKey, OptionValue) values ('RssLastModseq', '0');
+insert Into Options (OptionKey, OptionValue) values ('CollationLocale', '');
/* store volume and HAL info here for files */
CREATE TABLE Volumes
Modified: trunk/src/libtracker-data/tracker-data-update.c
==============================================================================
--- trunk/src/libtracker-data/tracker-data-update.c (original)
+++ trunk/src/libtracker-data/tracker-data-update.c Thu Feb 26 11:25:51 2009
@@ -311,10 +311,8 @@
TrackerDBInterface *iface;
gint metadata_key;
gchar *id_str;
- gchar *collation_key;
id_str = tracker_guint32_to_string (service_id);
- collation_key = g_utf8_collate_key (value, -1);
iface = tracker_db_manager_get_db_interface_by_type (tracker_service_get_name (service),
TRACKER_DB_CONTENT_TYPE_METADATA);
@@ -338,7 +336,7 @@
tracker_field_get_id (field),
parsed_value,
value,
- collation_key,
+ value,
NULL);
break;
@@ -386,7 +384,6 @@
service_id);
}
- g_free (collation_key);
g_free (id_str);
}
Modified: trunk/src/libtracker-db/tracker-db-manager.c
==============================================================================
--- trunk/src/libtracker-db/tracker-db-manager.c (original)
+++ trunk/src/libtracker-db/tracker-db-manager.c Thu Feb 26 11:25:51 2009
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <regex.h>
#include <zlib.h>
+#include <locale.h>
#include <glib/gstdio.h>
@@ -1617,6 +1618,22 @@
return result;
}
+static GValue
+function_collate_key (TrackerDBInterface *interface,
+ gint argc,
+ GValue values[])
+{
+ GValue result = { 0 };
+ gchar *collate_key;
+
+ collate_key = g_utf8_collate_key (g_value_get_string (&values[0]), -1);
+
+ g_value_init (&result, G_TYPE_STRING);
+ g_value_take_string (&result, collate_key);
+
+ return result;
+}
+
static void
db_set_params (TrackerDBInterface *iface,
gint cache_size,
@@ -1680,6 +1697,10 @@
"replace",
function_replace,
3);
+ tracker_db_interface_sqlite_create_function (iface,
+ "CollateKey",
+ function_collate_key,
+ 1);
}
}
@@ -2538,6 +2559,40 @@
return etype;
}
+static void
+tracker_db_manager_ensure_locale (void)
+{
+ TrackerDBInterface *common, *iface;
+ TrackerDBResultSet *result_set;
+ const gchar *current_locale;
+ gchar *stored_locale = NULL;
+
+ current_locale = setlocale (LC_COLLATE, NULL);
+
+ common = dbs[TRACKER_DB_COMMON].iface;
+ result_set = tracker_db_interface_execute_procedure (common, NULL, "GetCollationLocale", NULL);
+
+ if (result_set) {
+ tracker_db_result_set_get (result_set, 0, &stored_locale, -1);
+ g_object_unref (result_set);
+ }
+
+ if (g_strcmp0 (current_locale, stored_locale) != 0) {
+ /* Locales differ, update collate keys */
+ g_debug ("Updating DB locale dependent data to: %s\n", current_locale);
+
+ iface = dbs[TRACKER_DB_FILE_METADATA].iface;
+ tracker_db_interface_execute_procedure (iface, NULL, "UpdateMetadataCollation", NULL);
+
+ iface = dbs[TRACKER_DB_EMAIL_METADATA].iface;
+ tracker_db_interface_execute_procedure (iface, NULL, "UpdateMetadataCollation", NULL);
+
+ tracker_db_interface_execute_procedure (common, NULL, "SetCollationLocale", current_locale, NULL);
+ }
+
+ g_free (stored_locale);
+}
+
void
tracker_db_manager_init (TrackerDBManagerFlags flags,
gboolean *first_time,
@@ -2727,6 +2782,8 @@
dbs[i].mtime = tracker_file_get_mtime (dbs[i].abs_filename);
}
+ tracker_db_manager_ensure_locale ();
+
initialized = TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]