Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15
tracker.10850
tracker-sqlite-3.25-rename-tables.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File tracker-sqlite-3.25-rename-tables.patch of Package tracker.10850
diff -ur tracker-2.0.3.orig/src/libtracker-data/tracker-data-manager.c tracker-2.0.3/src/libtracker-data/tracker-data-manager.c --- tracker-2.0.3.orig/src/libtracker-data/tracker-data-manager.c 2017-12-28 17:10:00.000000000 -0600 +++ tracker-2.0.3/src/libtracker-data/tracker-data-manager.c 2019-04-02 10:40:33.130713962 -0500 @@ -135,6 +135,12 @@ N_PROPS }; +#if HAVE_TRACKER_FTS +static gboolean tracker_data_manager_fts_changed (TrackerDataManager *manager); +static void tracker_data_manager_update_fts (TrackerDataManager *manager, + TrackerDBInterface *iface); +#endif + static void tracker_data_manager_initable_iface_init (GInitableIface *iface); G_DEFINE_TYPE_WITH_CODE (TrackerDataManager, tracker_data_manager, G_TYPE_OBJECT, @@ -3611,6 +3617,9 @@ TrackerProperty **properties; guint i, n_props, n_classes; gboolean base_tables_altered = FALSE; +#if HAVE_TRACKER_FTS + gboolean update_fts = FALSE; +#endif iface = tracker_db_manager_get_writable_db_interface (manager->db_manager); @@ -3621,6 +3630,15 @@ return; } +#if HAVE_TRACKER_FTS + if (base_tables_altered || in_update) { + update_fts = base_tables_altered | tracker_data_manager_fts_changed (manager); + + if (update_fts) + tracker_db_interface_sqlite_fts_delete_table (iface); + } +#endif + /* create tables */ for (i = 0; i < n_classes; i++) { GError *internal_error = NULL; @@ -3670,6 +3688,14 @@ } } } + +#if HAVE_TRACKER_FTS + if (update_fts) { + tracker_data_manager_update_fts (manager, iface); + } else { + tracker_data_manager_init_fts (iface, !in_update); + } +#endif } static gint @@ -3872,13 +3898,44 @@ #if HAVE_TRACKER_FTS static gboolean +tracker_data_manager_fts_changed (TrackerDataManager *manager) +{ + TrackerProperty **properties; + gboolean has_changed = FALSE; + guint i, len; + + properties = tracker_ontologies_get_properties (manager->ontologies, &len); + + for (i = 0; i < len; i++) { + TrackerClass *class; + + if (tracker_property_get_fulltext_indexed (properties[i]) != + tracker_property_get_orig_fulltext_indexed (properties[i])) { + has_changed |= TRUE; + } + + if (!tracker_property_get_fulltext_indexed (properties[i])) { + continue; + } + + has_changed |= tracker_property_get_is_new (properties[i]); + + /* We must also regenerate FTS if any table in the view + * updated its schema. + */ + class = tracker_property_get_domain (properties[i]); + has_changed |= tracker_class_get_db_schema_changed (class); + } + + return has_changed; +} + +static void ontology_get_fts_properties (TrackerDataManager *manager, - gboolean only_new, GHashTable **fts_properties, GHashTable **multivalued) { TrackerProperty **properties; - gboolean has_changed = FALSE; guint i, len; properties = tracker_ontologies_get_properties (manager->ontologies, &len); @@ -3890,16 +3947,10 @@ const gchar *name, *table_name; GList *list; - if (tracker_property_get_fulltext_indexed (properties[i]) != - tracker_property_get_orig_fulltext_indexed (properties[i])) { - has_changed |= TRUE; - } - if (!tracker_property_get_fulltext_indexed (properties[i])) { continue; } - has_changed |= tracker_property_get_is_new (properties[i]); table_name = tracker_property_get_table_name (properties[i]); name = tracker_property_get_name (properties[i]); list = g_hash_table_lookup (*fts_properties, table_name); @@ -3916,8 +3967,6 @@ list = g_list_append (list, (gpointer) name); } } - - return has_changed; } static void @@ -3931,29 +3980,36 @@ /* Update the stamp file */ tracker_db_manager_tokenizer_update (manager->db_manager); } -#endif gboolean tracker_data_manager_init_fts (TrackerDBInterface *iface, gboolean create) { -#if HAVE_TRACKER_FTS GHashTable *fts_props, *multivalued; TrackerDataManager *manager; manager = tracker_db_interface_get_user_data (iface); - ontology_get_fts_properties (manager, FALSE, &fts_props, &multivalued); + ontology_get_fts_properties (manager, &fts_props, &multivalued); tracker_db_interface_sqlite_fts_init (iface, fts_props, multivalued, create); g_hash_table_unref (fts_props); g_hash_table_unref (multivalued); return TRUE; -#else - g_info ("FTS support is disabled"); - return FALSE; -#endif } +static void +tracker_data_manager_update_fts (TrackerDataManager *manager, + TrackerDBInterface *iface) +{ + GHashTable *fts_properties, *multivalued; + + ontology_get_fts_properties (manager, &fts_properties, &multivalued); + tracker_db_interface_sqlite_fts_alter_table (iface, fts_properties, multivalued); + g_hash_table_unref (fts_properties); + g_hash_table_unref (multivalued); +} +#endif + GFile * tracker_data_manager_get_cache_location (TrackerDataManager *manager) { @@ -4183,8 +4239,6 @@ tracker_data_ontology_import_into_db (manager, FALSE, &internal_error); - tracker_data_manager_init_fts (iface, TRUE); - if (internal_error) { g_propagate_error (error, internal_error); return FALSE; @@ -4275,7 +4329,9 @@ } } +#if HAVE_TRACKER_FTS tracker_data_manager_init_fts (iface, FALSE); +#endif } if (!read_only) { @@ -4534,17 +4590,6 @@ } if (update_nao) { -#if HAVE_TRACKER_FTS - GHashTable *fts_properties, *multivalued; - - if (ontology_get_fts_properties (manager, TRUE, &fts_properties, &multivalued)) { - tracker_db_interface_sqlite_fts_alter_table (iface, fts_properties, multivalued); - } - - g_hash_table_unref (fts_properties); - g_hash_table_unref (multivalued); -#endif - /* Update the nao:lastModified in the database */ stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_UPDATE, &n_error, "UPDATE \"rdfs:Resource\" SET \"nao:lastModified\"= ? " Only in tracker-2.0.3/src/libtracker-data: tracker-data-manager.c.orig Only in tracker-2.0.3/src/libtracker-data: tracker-data-manager.c.rej diff -ur tracker-2.0.3.orig/src/libtracker-data/tracker-db-interface-sqlite.c tracker-2.0.3/src/libtracker-data/tracker-db-interface-sqlite.c --- tracker-2.0.3.orig/src/libtracker-data/tracker-db-interface-sqlite.c 2018-02-06 08:19:57.000000000 -0600 +++ tracker-2.0.3/src/libtracker-data/tracker-db-interface-sqlite.c 2019-04-02 10:22:33.375124760 -0500 @@ -1648,6 +1648,14 @@ #if HAVE_TRACKER_FTS void +tracker_db_interface_sqlite_fts_delete_table (TrackerDBInterface *db_interface) +{ + if (!tracker_fts_delete_table (db_interface->db, "fts5")) { + g_critical ("Failed to delete FTS table"); + } +} + +void tracker_db_interface_sqlite_fts_alter_table (TrackerDBInterface *db_interface, GHashTable *properties, GHashTable *multivalued) diff -ur tracker-2.0.3.orig/src/libtracker-data/tracker-db-interface-sqlite.h tracker-2.0.3/src/libtracker-data/tracker-db-interface-sqlite.h --- tracker-2.0.3.orig/src/libtracker-data/tracker-db-interface-sqlite.h 2017-08-05 14:51:59.000000000 -0500 +++ tracker-2.0.3/src/libtracker-data/tracker-db-interface-sqlite.h 2019-04-02 10:22:33.375124760 -0500 @@ -59,6 +59,8 @@ #if HAVE_TRACKER_FTS +void tracker_db_interface_sqlite_fts_delete_table (TrackerDBInterface *interface); + void tracker_db_interface_sqlite_fts_alter_table (TrackerDBInterface *interface, GHashTable *properties, GHashTable *multivalued); diff -ur tracker-2.0.3.orig/src/libtracker-data/tracker-property.c tracker-2.0.3/src/libtracker-data/tracker-property.c --- tracker-2.0.3.orig/src/libtracker-data/tracker-property.c 2017-07-26 06:32:44.000000000 -0500 +++ tracker-2.0.3/src/libtracker-data/tracker-property.c 2019-04-02 10:22:33.379124772 -0500 @@ -1050,6 +1050,7 @@ priv = GET_PRIV (property); priv->multiple_values = value; + g_clear_pointer (&priv->table_name, g_free); } void diff -ur tracker-2.0.3.orig/src/libtracker-fts/tracker-fts.c tracker-2.0.3/src/libtracker-fts/tracker-fts.c --- tracker-2.0.3.orig/src/libtracker-fts/tracker-fts.c 2017-07-26 06:32:44.000000000 -0500 +++ tracker-2.0.3/src/libtracker-fts/tracker-fts.c 2019-04-02 10:22:33.375124760 -0500 @@ -158,6 +158,26 @@ } gboolean +tracker_fts_delete_table (sqlite3 *db, + gchar *table_name) +{ + gchar *query; + int rc; + + query = g_strdup_printf ("DROP VIEW fts_view"); + rc = sqlite3_exec (db, query, NULL, NULL, NULL); + g_free (query); + + if (rc == SQLITE_OK) { + query = g_strdup_printf ("DROP TABLE %s", table_name); + sqlite3_exec (db, query, NULL, NULL, NULL); + g_free (query); + } + + return rc == SQLITE_OK; +} + +gboolean tracker_fts_alter_table (sqlite3 *db, gchar *table_name, GHashTable *tables, @@ -168,18 +188,6 @@ tmp_name = g_strdup_printf ("%s_TMP", table_name); - query = g_strdup_printf ("DROP VIEW fts_view"); - rc = sqlite3_exec (db, query, NULL, NULL, NULL); - g_free (query); - - query = g_strdup_printf ("DROP TABLE %s", tmp_name); - rc = sqlite3_exec (db, query, NULL, NULL, NULL); - g_free (query); - - query = g_strdup_printf ("DROP TABLE %s", table_name); - rc = sqlite3_exec (db, query, NULL, NULL, NULL); - g_free (query); - if (!tracker_fts_create_table (db, tmp_name, tables, grouped_columns)) { g_free (tmp_name); return FALSE; diff -ur tracker-2.0.3.orig/src/libtracker-fts/tracker-fts.h tracker-2.0.3/src/libtracker-fts/tracker-fts.h --- tracker-2.0.3.orig/src/libtracker-fts/tracker-fts.h 2017-07-26 06:32:44.000000000 -0500 +++ tracker-2.0.3/src/libtracker-fts/tracker-fts.h 2019-04-02 10:22:33.375124760 -0500 @@ -36,6 +36,8 @@ gchar *table_name, GHashTable *tables, GHashTable *grouped_columns); +gboolean tracker_fts_delete_table (sqlite3 *db, + gchar *table_name); gboolean tracker_fts_alter_table (sqlite3 *db, gchar *table_name, GHashTable *tables,
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor