Sync from SUSE:SLFO:Main tracker revision 4ec2d63d72f197d34708c668d66790ac

This commit is contained in:
Adrian Schröter 2024-07-22 17:47:14 +02:00
parent 60240fe44f
commit 4bd0b63db2
6 changed files with 461 additions and 11 deletions

View File

@ -0,0 +1,313 @@
From 26c69a82ceb44d0f4311cb04d38bcd44b94634e2 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Thu, 7 Dec 2023 09:33:44 +0100
Subject: [PATCH] libtracker-sparql: Decouple FTS initialization from
ontologies
Since we just need the FTS properties for fts:offsets being called
at runtime, we can pass the TrackerDataManager (that we know early
in startup) and let it figure out the FTS properties from there
when it's actually needed.
This is just the refactor to make that possible, there's no
functional changes in this commit.
---
.../core/tracker-data-manager.c | 13 +++--
.../core/tracker-db-interface-sqlite.c | 29 ++++++-----
.../core/tracker-db-interface-sqlite.h | 5 +-
.../core/tracker-fts-tokenizer.c | 48 +++++++++++++++++--
.../core/tracker-fts-tokenizer.h | 4 +-
src/libtracker-sparql/core/tracker-fts.c | 40 ----------------
src/libtracker-sparql/core/tracker-fts.h | 5 --
7 files changed, 75 insertions(+), 69 deletions(-)
diff --git a/src/libtracker-sparql/core/tracker-data-manager.c b/src/libtracker-sparql/core/tracker-data-manager.c
index ef3497a834..f0797d642d 100644
--- a/src/libtracker-sparql/core/tracker-data-manager.c
+++ b/src/libtracker-sparql/core/tracker-data-manager.c
@@ -3863,11 +3863,14 @@ tracker_data_manager_init_fts (TrackerDataManager *manager,
gboolean create,
GError **error)
{
- return tracker_db_interface_sqlite_fts_init (iface,
- database,
- manager->ontologies,
- create,
- error);
+ if (!tracker_db_interface_sqlite_fts_init (iface, manager->flags, error))
+ return FALSE;
+ if (!create)
+ return TRUE;
+ return tracker_db_interface_sqlite_fts_create_table (iface,
+ database,
+ manager->ontologies,
+ error);
}
static gboolean
diff --git a/src/libtracker-sparql/core/tracker-db-interface-sqlite.c b/src/libtracker-sparql/core/tracker-db-interface-sqlite.c
index c001c9aafc..05773bd3e5 100644
--- a/src/libtracker-sparql/core/tracker-db-interface-sqlite.c
+++ b/src/libtracker-sparql/core/tracker-db-interface-sqlite.c
@@ -37,6 +37,7 @@
#include <libtracker-sparql/tracker-private.h>
#include "tracker-fts.h"
+#include "tracker-fts-tokenizer.h"
#include "tracker-collation.h"
#include "tracker-db-interface-sqlite.h"
#include "tracker-db-manager.h"
@@ -2027,20 +2028,26 @@ close_database (TrackerDBInterface *db_interface)
}
gboolean
-tracker_db_interface_sqlite_fts_init (TrackerDBInterface *db_interface,
- const gchar *database,
- TrackerOntologies *ontologies,
- gboolean create,
- GError **error)
+tracker_db_interface_sqlite_fts_init (TrackerDBInterface *db_interface,
+ TrackerDBManagerFlags fts_flags,
+ GError **error)
{
- GError *inner_error = NULL;
+ return tracker_tokenizer_initialize (db_interface->db,
+ db_interface,
+ fts_flags,
+ db_interface->user_data,
+ error);
+}
- if (!tracker_fts_init_db (db_interface->db, db_interface,
- db_interface->flags, ontologies, error))
- return FALSE;
+gboolean
+tracker_db_interface_sqlite_fts_create_table (TrackerDBInterface *db_interface,
+ const gchar *database,
+ TrackerOntologies *ontologies,
+ GError **error)
+{
+ GError *inner_error = NULL;
- if (create &&
- !tracker_fts_create_table (db_interface->db, database, "fts5",
+ if (!tracker_fts_create_table (db_interface->db, database, "fts5",
ontologies,
&inner_error)) {
g_propagate_prefixed_error (error,
diff --git a/src/libtracker-sparql/core/tracker-db-interface-sqlite.h b/src/libtracker-sparql/core/tracker-db-interface-sqlite.h
index 64b0be2a78..cb779ea3c7 100644
--- a/src/libtracker-sparql/core/tracker-db-interface-sqlite.h
+++ b/src/libtracker-sparql/core/tracker-db-interface-sqlite.h
@@ -23,6 +23,7 @@
#include "config.h"
#include "tracker-db-interface.h"
+#include "tracker-db-manager.h"
G_BEGIN_DECLS
@@ -46,9 +47,11 @@ TrackerDBInterface *tracker_db_interface_sqlite_new (const gc
gint64 tracker_db_interface_sqlite_get_last_insert_id (TrackerDBInterface *interface);
void tracker_db_interface_sqlite_enable_shared_cache (void);
gboolean tracker_db_interface_sqlite_fts_init (TrackerDBInterface *interface,
+ TrackerDBManagerFlags fts_flags,
+ GError **error);
+gboolean tracker_db_interface_sqlite_fts_create_table (TrackerDBInterface *interface,
const gchar *database,
TrackerOntologies *ontologies,
- gboolean create,
GError **error);
void tracker_db_interface_sqlite_reset_collator (TrackerDBInterface *interface);
gboolean tracker_db_interface_sqlite_wal_checkpoint (TrackerDBInterface *interface,
diff --git a/src/libtracker-sparql/core/tracker-fts-tokenizer.c b/src/libtracker-sparql/core/tracker-fts-tokenizer.c
index 9cf71b99f0..2e6dd0591c 100644
--- a/src/libtracker-sparql/core/tracker-fts-tokenizer.c
+++ b/src/libtracker-sparql/core/tracker-fts-tokenizer.c
@@ -48,6 +48,7 @@ struct TrackerTokenizer {
struct TrackerTokenizerFunctionData {
TrackerDBInterface *interface;
+ TrackerDataManager *data_manager;
gchar **property_names;
};
@@ -169,6 +170,37 @@ offsets_tokenizer_func (void *data,
return SQLITE_OK;
}
+static gboolean
+ensure_fts_properties (TrackerTokenizerFunctionData *data)
+{
+ TrackerOntologies *ontologies;
+ TrackerProperty **properties;
+ GArray *property_names;
+ guint i, len;
+
+ if (data->property_names)
+ return data->property_names[0] != NULL;
+
+ ontologies = tracker_data_manager_get_ontologies (data->data_manager);
+
+ property_names = g_array_new (TRUE, FALSE, sizeof (gchar *));
+ properties = tracker_ontologies_get_properties (ontologies, &len);
+
+ for (i = 0; i < len; i++) {
+ gchar *column;
+
+ if (!tracker_property_get_fulltext_indexed (properties[i]))
+ continue;
+
+ column = g_strdup (tracker_property_get_name (properties[i]));
+ g_array_append_val (property_names, column);
+ }
+
+ data->property_names = (gchar **) g_array_free (property_names, FALSE);
+
+ return data->property_names[0] != NULL;
+}
+
static void
tracker_offsets_function (const Fts5ExtensionApi *api,
Fts5Context *fts_ctx,
@@ -189,6 +221,12 @@ tracker_offsets_function (const Fts5ExtensionApi *api,
}
data = api->xUserData (fts_ctx);
+
+ if (!ensure_fts_properties (data)) {
+ sqlite3_result_null (ctx);
+ return;
+ }
+
rc = api->xInstCount (fts_ctx, &n_hits);
if (rc != SQLITE_OK) {
@@ -296,14 +334,14 @@ error:
}
static TrackerTokenizerFunctionData *
-tracker_tokenizer_function_data_new (TrackerDBInterface *interface,
- const gchar **property_names)
+tracker_tokenizer_function_data_new (TrackerDBInterface *interface,
+ TrackerDataManager *data_manager)
{
TrackerTokenizerFunctionData *data;
data = g_new0 (TrackerTokenizerFunctionData, 1);
data->interface = interface;
- data->property_names = g_strdupv ((gchar **) property_names);
+ data->data_manager = data_manager;
return data;
}
@@ -319,7 +357,7 @@ gboolean
tracker_tokenizer_initialize (sqlite3 *db,
TrackerDBInterface *interface,
TrackerDBManagerFlags flags,
- const gchar **property_names,
+ TrackerDataManager *data_manager,
GError **error)
{
TrackerTokenizerData *data;
@@ -338,7 +376,7 @@ tracker_tokenizer_initialize (sqlite3 *db,
tracker_tokenizer_data_free);
/* Offsets */
- func_data = tracker_tokenizer_function_data_new (interface, property_names);
+ func_data = tracker_tokenizer_function_data_new (interface, data_manager);
api->xCreateFunction (api, "tracker_offsets", func_data,
&tracker_offsets_function,
(GDestroyNotify) tracker_tokenizer_function_data_free);
diff --git a/src/libtracker-sparql/core/tracker-fts-tokenizer.h b/src/libtracker-sparql/core/tracker-fts-tokenizer.h
index 57bca46a56..76e0bbcbb9 100644
--- a/src/libtracker-sparql/core/tracker-fts-tokenizer.h
+++ b/src/libtracker-sparql/core/tracker-fts-tokenizer.h
@@ -22,7 +22,7 @@
#include <sqlite3.h>
#include <glib.h>
-#include "tracker-db-manager.h"
+#include "tracker-data-manager.h"
#ifndef __TRACKER_FTS_TOKENIZER_H__
#define __TRACKER_FTS_TOKENIZER_H__
@@ -30,7 +30,7 @@
gboolean tracker_tokenizer_initialize (sqlite3 *db,
TrackerDBInterface *interface,
TrackerDBManagerFlags flags,
- const gchar **property_names,
+ TrackerDataManager *data_manager,
GError **error);
#endif /* __TRACKER_FTS_TOKENIZER_H__ */
diff --git a/src/libtracker-sparql/core/tracker-fts.c b/src/libtracker-sparql/core/tracker-fts.c
index 96ec9e9e76..f622855ee4 100644
--- a/src/libtracker-sparql/core/tracker-fts.c
+++ b/src/libtracker-sparql/core/tracker-fts.c
@@ -43,46 +43,6 @@ has_fts_properties (TrackerOntologies *ontologies)
return FALSE;
}
-static gchar **
-get_fts_properties (TrackerOntologies *ontologies)
-{
- TrackerProperty **properties;
- GArray *property_names;
- guint i, len;
-
- property_names = g_array_new (TRUE, FALSE, sizeof (gchar *));
- properties = tracker_ontologies_get_properties (ontologies, &len);
-
- for (i = 0; i < len; i++) {
- gchar *column;
-
- if (!tracker_property_get_fulltext_indexed (properties[i]))
- continue;
-
- column = g_strdup (tracker_property_get_name (properties[i]));
- g_array_append_val (property_names, column);
- }
-
- return (gchar **) g_array_free (property_names, FALSE);
-}
-
-gboolean
-tracker_fts_init_db (sqlite3 *db,
- TrackerDBInterface *interface,
- TrackerDBManagerFlags flags,
- TrackerOntologies *ontologies,
- GError **error)
-{
- gchar **property_names;
- gboolean retval;
-
- property_names = get_fts_properties (ontologies);
- retval = tracker_tokenizer_initialize (db, interface, flags, (const gchar **) property_names, error);
- g_strfreev (property_names);
-
- return retval;
-}
-
gboolean
tracker_fts_create_table (sqlite3 *db,
const gchar *database,
diff --git a/src/libtracker-sparql/core/tracker-fts.h b/src/libtracker-sparql/core/tracker-fts.h
index 4370d3f667..cf3e1d9cbd 100644
--- a/src/libtracker-sparql/core/tracker-fts.h
+++ b/src/libtracker-sparql/core/tracker-fts.h
@@ -30,11 +30,6 @@
G_BEGIN_DECLS
-gboolean tracker_fts_init_db (sqlite3 *db,
- TrackerDBInterface *interface,
- TrackerDBManagerFlags flags,
- TrackerOntologies *ontologies,
- GError **error);
gboolean tracker_fts_create_table (sqlite3 *db,
const gchar *database,
gchar *table_name,
--
GitLab

View File

@ -0,0 +1,49 @@
From 373535883c5b89fa1b3cd958274c36bdaf543db6 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Thu, 7 Dec 2023 10:16:16 +0100
Subject: [PATCH] libtracker-sparql: Move FTS initialization to an earlier
stage
With SQLite >= 3.44.x, the check_integrity pragma may involve existing
virtual tables and their xIntegrity vmethod. This includes FTS5 tables,
so we need to set up the FTS5 tokenizer at an earlier stage, so that
possible integrity checks happening on startup have everything set up.
Closes: https://gitlab.gnome.org/GNOME/tracker/-/issues/418
---
src/libtracker-sparql/core/tracker-data-manager.c | 2 --
src/libtracker-sparql/core/tracker-db-manager.c | 5 +++++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/libtracker-sparql/core/tracker-data-manager.c b/src/libtracker-sparql/core/tracker-data-manager.c
index f0797d642d..dff6b66542 100644
--- a/src/libtracker-sparql/core/tracker-data-manager.c
+++ b/src/libtracker-sparql/core/tracker-data-manager.c
@@ -3863,8 +3863,6 @@ tracker_data_manager_init_fts (TrackerDataManager *manager,
gboolean create,
GError **error)
{
- if (!tracker_db_interface_sqlite_fts_init (iface, manager->flags, error))
- return FALSE;
if (!create)
return TRUE;
return tracker_db_interface_sqlite_fts_create_table (iface,
diff --git a/src/libtracker-sparql/core/tracker-db-manager.c b/src/libtracker-sparql/core/tracker-db-manager.c
index 6952af082b..8427ed71b7 100644
--- a/src/libtracker-sparql/core/tracker-db-manager.c
+++ b/src/libtracker-sparql/core/tracker-db-manager.c
@@ -783,6 +783,11 @@ tracker_db_manager_create_db_interface (TrackerDBManager *db_manager,
return NULL;
}
+ if (!tracker_db_interface_sqlite_fts_init (connection,
+ db_manager->flags,
+ error))
+ return FALSE;
+
tracker_db_interface_set_max_stmt_cache_size (connection,
TRACKER_DB_STATEMENT_CACHE_TYPE_SELECT,
db_manager->s_cache_size);
--
GitLab

BIN
tracker-3.5.1.tar.xz (Stored with Git LFS)

Binary file not shown.

BIN
tracker-3.6.0.tar.xz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,3 +1,86 @@
-------------------------------------------------------------------
Wed Mar 6 10:50:26 UTC 2024 - Yifan Jiang <yfjiang@suse.com>
- Add patches to adapt SQLite 3.44 (glgo#GNOME/tracker#418):
+ 0001-decouple-fts-initialization-from-ontologies.patch
+ 0002-early-fts-initialization.patch
-------------------------------------------------------------------
Mon Sep 18 11:50:17 UTC 2023 - Marcus Meissner <meissner@suse.com>
- use pkgconfig(icu-i18n) to use the current libicu. (jsc#PED-6193)
-------------------------------------------------------------------
Sat Sep 16 15:35:51 UTC 2023 - Bjørn Lie <bjorn.lie@gmail.com>
- Update to version 3.6.0:
+ Use BM25 as ranking algorithm.
+ Better and more cohesive documentation.
+ Add tracker_batch_add_rdf() API call to insert RDF data as part
of an update batch.
+ Updated translations.
-------------------------------------------------------------------
Wed Sep 6 03:34:06 UTC 2023 - Luciano Santos <luc14n0@opensuse.org>
- Update to version 3.6.rc:
+ Updated documentation.
+ Updated translations.
-------------------------------------------------------------------
Fri Aug 11 10:54:43 UTC 2023 - Bjørn Lie <bjorn.lie@gmail.com>
- Update to version 3.6.beta:
+ Use BM25 as FTS ranking algorithm.
+ Add tracker_batch_add_rdf() call to add RDF as a batch
operation.
+ Fix warnings with newer glib.
+ Adapt tests to SQLite >= 3.42.
+ Build improvements.
+ Updated translations.
-------------------------------------------------------------------
Fri Jul 7 19:07:51 UTC 2023 - Bjørn Lie <bjorn.lie@gmail.com>
- Update to version 3.6.alpha:
+ Improved threading guarantees of TrackerNotifier signal
callbacks.
+ Add tracker-await-file tool to trackertestutils.
+ A number of build system fixes.
-------------------------------------------------------------------
Thu Jun 1 14:24:22 UTC 2023 - Bjørn Lie <bjorn.lie@gmail.com>
- Update to version 3.5.3:
+ Build fixes around strftime() bug workarounds on some
architectures/platforms.
+ Improved compatibility of JSON cursor readers.
+ Leaks plugged.
- Drop 63ea8f1a.patch: Fixed upstream.
-------------------------------------------------------------------
Thu May 18 05:18:39 UTC 2023 - Luciano Santos <luc14n0@opensuse.org>
- Drop %systemd_user_postun_with_restart macro from the %postun
directive. It's been deprecated and emptied (expands to nil) on
both Tumbleweed and Leap already.
- Comment unneded "/usr/bin/env python3" shebang line on utils/
trackertestutils/__main__.py Python script.
- Change tracker-data-files package's architecture to noarch, as it
doesn't contain any binaries.
-------------------------------------------------------------------
Sat May 13 11:23:38 UTC 2023 - Bjørn Lie <bjorn.lie@gmail.com>
- Update to version 3.5.2:
+ Fix several possible crashers.
+ Fix bashisms in doc generation scripts.
+ Fix ISO8601 date strings in cursors on Darwin.
+ Plug leak.
- Add 63ea8f1a.patch: Revert build: Detect appropriate strftime()
year modifier at build time. Revert upstream commit for now as it
breaks build for i586.
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Apr 25 16:34:18 UTC 2023 - Bjørn Lie <bjorn.lie@gmail.com> Tue Apr 25 16:34:18 UTC 2023 - Bjørn Lie <bjorn.lie@gmail.com>

View File

@ -1,7 +1,7 @@
# #
# spec file for package tracker # spec file for package tracker
# #
# Copyright (c) 2023 SUSE LLC # Copyright (c) 2024 SUSE LLC
# Copyright (c) 2010 Luis Medinas, Portugal # Copyright (c) 2010 Luis Medinas, Portugal
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
@ -21,13 +21,17 @@
%define RPMTrackerAPI 3_0 %define RPMTrackerAPI 3_0
Name: tracker Name: tracker
Version: 3.5.1 Version: 3.6.0
Release: 0 Release: 0
Summary: Object database, tag/metadata database, search tool and indexer Summary: Object database, tag/metadata database, search tool and indexer
License: GPL-2.0-or-later License: GPL-2.0-or-later
Group: Productivity/Other Group: Productivity/Other
URL: https://wiki.gnome.org/Projects/Tracker URL: https://wiki.gnome.org/Projects/Tracker
Source0: https://download.gnome.org/sources/tracker/3.5/%{name}-%{version}.tar.xz Source0: https://download.gnome.org/sources/tracker/3.6/%{name}-%{version}.tar.xz
# PATCH-FIX-UPSTREAM 0001-decouple-fts-initialization-from-ontologies.patch glgo#GNOME/tracker#418 yfjiang@suse.com -- Decouple FTS initialization from ongologies
Patch0: 0001-decouple-fts-initialization-from-ontologies.patch
# PATCH-FIX-UPSTREAM 0002-early-fts-initialization.patch glgo#GNOME/tracker#418 yfjiang@suse.com -- Move FTS initialization to an earlier stage
Patch1: 0002-early-fts-initialization.patch
BuildRequires: asciidoc BuildRequires: asciidoc
BuildRequires: fdupes BuildRequires: fdupes
@ -36,7 +40,6 @@ BuildRequires: glib2-devel >= 2.52.0
BuildRequires: gobject-introspection-devel BuildRequires: gobject-introspection-devel
BuildRequires: graphviz BuildRequires: graphviz
BuildRequires: intltool BuildRequires: intltool
BuildRequires: libicu-devel >= 4.8.1.1
BuildRequires: meson >= 0.53 BuildRequires: meson >= 0.53
BuildRequires: pkgconfig BuildRequires: pkgconfig
BuildRequires: python3 BuildRequires: python3
@ -47,6 +50,7 @@ BuildRequires: zlib-devel
BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(dbus-1)
BuildRequires: pkgconfig(gdk-pixbuf-2.0) BuildRequires: pkgconfig(gdk-pixbuf-2.0)
BuildRequires: pkgconfig(gi-docgen) BuildRequires: pkgconfig(gi-docgen)
BuildRequires: pkgconfig(icu-i18n) > 4.8.1.1
BuildRequires: pkgconfig(json-glib-1.0) >= 1.0 BuildRequires: pkgconfig(json-glib-1.0) >= 1.0
BuildRequires: pkgconfig(libseccomp) >= 2.0 BuildRequires: pkgconfig(libseccomp) >= 2.0
BuildRequires: pkgconfig(libsoup-3.0) >= 2.99.2 BuildRequires: pkgconfig(libsoup-3.0) >= 2.99.2
@ -124,6 +128,7 @@ This subpackage contains the headers to make use of its libraries.
%package -n tracker-data-files %package -n tracker-data-files
Summary: Data files for the Tracker Miners Summary: Data files for the Tracker Miners
Group: Productivity/Other Group: Productivity/Other
BuildArch: noarch
%description -n tracker-data-files %description -n tracker-data-files
Tracker is a desktop-neutral object database, tag/metadata database, Tracker is a desktop-neutral object database, tag/metadata database,
@ -135,6 +140,10 @@ This subpackage contains the data files for the Tracker miners.
%prep %prep
%autosetup -p1 %autosetup -p1
#
# Drop unneeded Python 3 shebang
#
sed -i '1s,#!/usr/bin/env python3,# &,' utils/trackertestutils/__main__.py
%build %build
%meson \ %meson \
@ -168,9 +177,6 @@ mkdir %{buildroot}%{_datadir}/tracker3/domain-ontologies
%preun %preun
%systemd_user_preun tracker-xdg-portal-3.service %systemd_user_preun tracker-xdg-portal-3.service
%postun
%systemd_user_postun_with_restart tracker-xdg-portal-3.service
%files %files
%license COPYING %license COPYING
%{_bindir}/tracker3 %{_bindir}/tracker3
@ -193,7 +199,6 @@ mkdir %{buildroot}%{_datadir}/tracker3/domain-ontologies
%files -n tracker-data-files %files -n tracker-data-files
%dir %{_datadir}/tracker3/domain-ontologies %dir %{_datadir}/tracker3/domain-ontologies
%{_datadir}/tracker3/ontologies/ %{_datadir}/tracker3/ontologies/
%{_datadir}/tracker3/stop-words/
%files -n libtracker-sparql-%{RPMTrackerAPI}-0 %files -n libtracker-sparql-%{RPMTrackerAPI}-0
%{_libdir}/libtracker-sparql*.so.* %{_libdir}/libtracker-sparql*.so.*