[tracker/wip/carlosg/update-perf: 9/65] core: Bump database version




commit b3fb19ca63cfe28a77abb6d55bb63e219367411a
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Aug 22 16:15:59 2022 +0200

    core: Bump database version
    
    In order to fix the fts_view views as per the previous commit.

 src/libtracker-sparql/core/tracker-data-manager.c | 19 +++++++++++++++++++
 src/libtracker-sparql/core/tracker-db-manager.h   |  3 ++-
 src/libtracker-sparql/core/tracker-fts.c          |  2 +-
 3 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-sparql/core/tracker-data-manager.c 
b/src/libtracker-sparql/core/tracker-data-manager.c
index 192bcf4a2..759867604 100644
--- a/src/libtracker-sparql/core/tracker-data-manager.c
+++ b/src/libtracker-sparql/core/tracker-data-manager.c
@@ -4194,6 +4194,25 @@ tracker_data_manager_update_from_version (TrackerDataManager  *manager,
                        goto error;
        }
 
+       if (version < TRACKER_DB_VERSION_3_4) {
+               GHashTableIter iter;
+               const gchar *graph;
+
+               if (!tracker_db_interface_sqlite_fts_delete_table (iface, "main", &internal_error))
+                       goto error;
+               if (!tracker_data_manager_update_fts (manager, iface, "main", &internal_error))
+                       goto error;
+
+               g_hash_table_iter_init (&iter, manager->graphs);
+
+               while (g_hash_table_iter_next (&iter, (gpointer *) &graph, NULL)) {
+                       if (!tracker_db_interface_sqlite_fts_delete_table (iface, graph, &internal_error))
+                               goto error;
+                       if (!tracker_data_manager_update_fts (manager, iface, graph, &internal_error))
+                               goto error;
+               }
+       }
+
        tracker_db_manager_update_version (manager->db_manager);
        return TRUE;
 
diff --git a/src/libtracker-sparql/core/tracker-db-manager.h b/src/libtracker-sparql/core/tracker-db-manager.h
index 941ecad9d..413b6b55d 100644
--- a/src/libtracker-sparql/core/tracker-db-manager.h
+++ b/src/libtracker-sparql/core/tracker-db-manager.h
@@ -52,10 +52,11 @@ typedef enum {
        /* Starts at 25 because we forgot to clean up */
        TRACKER_DB_VERSION_3_0 = 25, /* 3.0 */
        TRACKER_DB_VERSION_3_3,      /* Blank nodes */
+       TRACKER_DB_VERSION_3_4,      /* Fixed FTS view */
 } TrackerDBVersion;
 
 /* Set current database version we are working with */
-#define TRACKER_DB_VERSION_NOW        TRACKER_DB_VERSION_3_3
+#define TRACKER_DB_VERSION_NOW        TRACKER_DB_VERSION_3_4
 
 void                tracker_db_manager_rollback_db_creation   (TrackerDBManager *db_manager);
 
diff --git a/src/libtracker-sparql/core/tracker-fts.c b/src/libtracker-sparql/core/tracker-fts.c
index be351817b..8398b6e7a 100644
--- a/src/libtracker-sparql/core/tracker-fts.c
+++ b/src/libtracker-sparql/core/tracker-fts.c
@@ -179,7 +179,7 @@ tracker_fts_delete_table (sqlite3      *db,
        gchar *query;
        int rc;
 
-       query = g_strdup_printf ("DROP VIEW IF EXISTS fts_view");
+       query = g_strdup_printf ("DROP VIEW IF EXISTS \"%s\".fts_view", database);
        rc = sqlite3_exec (db, query, NULL, NULL, NULL);
        g_free (query);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]