Commit f0206c36 authored by Jürg Billeter's avatar Jürg Billeter

Link to tracker-fts instead of loading it at runtime

parent 3fc413be
......@@ -598,8 +598,6 @@ AC_CHECK_HEADERS([sys/inotify.h])
SQLITE_REQUIRED=3.5
PKG_CHECK_MODULES(SQLITE3, [sqlite3 >= $SQLITE_REQUIRED])
AC_CHECK_LIB([sqlite3], [sqlite3_enable_load_extension], [:],
[AC_MSG_ERROR([SQLite must be configured with --enable-load-extension.])])
AC_SUBST(SQLITE3_CFLAGS)
AC_SUBST(SQLITE3_LIBS)
......
......@@ -82,13 +82,6 @@ Makes any errors fatal, i.e. forces abortion of
This switch is only useful for debugging.
.SH ENVIRONMENT
.TP
.B TRACKER_DB_MODULES_DIR
This is the directory which the SQLite modules will be loaded from. At
the moment this is only the tracker-fts module. If unset it will
default to the correct place. This is used mainly for testing
purposes.
.TP
.B TRACKER_DB_SQL_DIR
This is the directory which tracker uses to load the .sql files from.
......
......@@ -4,10 +4,10 @@ SUBDIRS = \
libstemmer \
libinotify \
libtracker-common \
tracker-fts \
libtracker-db \
libtracker-data \
libtracker \
tracker-fts \
plugins \
tracker-store \
tracker-utils \
......@@ -38,10 +38,10 @@ DIST_SUBDIRS = \
libstemmer \
libinotify \
libtracker-common \
tracker-fts \
libtracker-db \
libtracker-data \
libtracker \
tracker-fts \
tracker-store \
tracker-utils \
tracker-explorer \
......
......@@ -32,6 +32,7 @@ libtracker_db_la_LDFLAGS = \
libtracker_db_la_LIBADD = \
$(top_builddir)/src/libtracker-common/libtracker-common.la \
$(top_builddir)/src/tracker-fts/libtracker-fts.la \
$(SQLITE3_LIBS) \
$(DBUS_LIBS) \
$(GCOV_LIBS) \
......
......@@ -24,6 +24,8 @@
#include <sqlite3.h>
#include <stdlib.h>
#include <tracker-fts/tracker-fts.h>
#include "tracker-db-interface-sqlite.h"
#define TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_DB_INTERFACE_SQLITE, TrackerDBInterfaceSqlitePrivate))
......@@ -128,25 +130,10 @@ tracker_db_interface_sqlite_constructor (GType type,
sqlite3_extended_result_codes (priv->db, 0);
sqlite3_busy_timeout (priv->db, 100000);
sqlite3_enable_load_extension (priv->db, 1);
env_path = g_getenv ("TRACKER_DB_MODULES_DIR");
if (G_LIKELY (!env_path)) {
sqlite3_load_extension (priv->db, PKGLIBDIR "/tracker-fts.so", NULL, &err_msg);
} else {
gchar *filename;
filename = g_build_filename (env_path, "tracker-fts.so", NULL);
sqlite3_load_extension (priv->db, filename, NULL, &err_msg);
g_free (filename);
}
if (err_msg) {
g_critical ("Could not load tracker-fts extension:'%s'", err_msg);
sqlite3_free (err_msg);
if (sqlite3Fts3Init (priv->db) != SQLITE_OK) {
g_critical ("Could not initialize tracker-fts extension");
} else {
g_message ("Loaded tracker fts extension");
g_message ("Initialized tracker fts extension");
}
return object;
......
......@@ -10,12 +10,10 @@ INCLUDES = \
$(PANGO_CFLAGS) \
$(SQLITE3_CFLAGS)
module_flags = -module -avoid-version -no-undefined
tracker_fts_modulesdir = $(libdir)/tracker-$(TRACKER_API_VERSION)
tracker_fts_modules_LTLIBRARIES = tracker-fts.la
tracker_fts_modules_LTLIBRARIES = libtracker-fts.la
tracker_fts_la_SOURCES = \
libtracker_fts_la_SOURCES = \
tracker-fts.c \
tracker-fts.h \
tracker-fts-config.c \
......@@ -23,10 +21,10 @@ tracker_fts_la_SOURCES = \
tracker-fts-hash.c \
tracker-fts-hash.h
tracker_fts_la_LDFLAGS = $(module_flags)
libtracker_fts_la_LDFLAGS = \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
tracker_fts_la_LIBADD = \
$(top_builddir)/src/libtracker-db/libtracker-db.la \
libtracker_fts_la_LIBADD = \
$(SQLITE3_LIBS) \
$(GTHREAD_LIBS) \
$(GCOV_LIBS) \
......
......@@ -277,7 +277,7 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <sqlite3ext.h>
#include <sqlite3.h>
#include <libtracker-common/tracker-common.h>
#include <libtracker-db/tracker-db-manager.h>
......@@ -286,8 +286,6 @@
#include "tracker-fts-config.h"
#include "tracker-fts-hash.h"
SQLITE_EXTENSION_INIT1
/* TODO(shess) MAN, this thing needs some refactoring. At minimum, it
** would be nice to order the file better, perhaps something along the
** lines of:
......@@ -429,12 +427,6 @@ static int safe_isalnum(char c){
return (c&0x80)==0 ? isalnum(c) : 0;
}
int sqlite3_extension_init(
sqlite3 *db,
char **pzErrMsg,
const sqlite3_api_routines *pApi
);
typedef enum DocListType {
......@@ -7805,10 +7797,6 @@ int sqlite3Fts3InitHashTable(sqlite3 *, fts3Hash *, const char *);
int sqlite3Fts3Init(sqlite3 *db){
int rc = SQLITE_OK;
g_type_init ();
if (!g_thread_supported ())
g_thread_init (NULL);
/* Create the virtual table wrapper around the hash-table and overload
** the two scalar functions. If this is successful, register the
** module with sqlite.
......@@ -7834,13 +7822,3 @@ int sqlite3Fts3Init(sqlite3 *db){
return rc;
}
int sqlite3_extension_init(
sqlite3 *db,
char **pzErrMsg,
const sqlite3_api_routines *pApi
){
SQLITE_EXTENSION_INIT2(pApi)
return sqlite3Fts3Init(db);
}
......@@ -230,7 +230,6 @@ main (int argc, char **argv)
g_setenv ("XDG_DATA_HOME", current_dir, TRUE);
g_setenv ("XDG_CACHE_HOME", current_dir, TRUE);
g_setenv ("TRACKER_DB_MODULES_DIR", TOP_BUILDDIR "/src/tracker-fts/.libs/", TRUE);
g_setenv ("TRACKER_DB_SQL_DIR", TOP_SRCDIR "/data/db/", TRUE);
g_setenv ("TRACKER_DB_ONTOLOGIES_DIR", TOP_SRCDIR "/data/ontologies/", TRUE);
......
......@@ -254,7 +254,6 @@ main (int argc, char **argv)
g_setenv ("XDG_DATA_HOME", current_dir, TRUE);
g_setenv ("XDG_CACHE_HOME", current_dir, TRUE);
g_setenv ("TRACKER_DB_MODULES_DIR", TOP_BUILDDIR "/src/tracker-fts/.libs/", TRUE);
g_setenv ("TRACKER_DB_SQL_DIR", TOP_SRCDIR "/data/db/", TRUE);
g_setenv ("TRACKER_DB_ONTOLOGIES_DIR", TOP_SRCDIR "/data/ontologies/", TRUE);
......
......@@ -17,6 +17,7 @@ tracker_fts_test_SOURCES = \
tracker_fts_test_LDADD = \
$(top_builddir)/src/libtracker-common/libtracker-common.la \
$(top_builddir)/src/tracker-fts/libtracker-fts.la \
$(SQLITE3_LIBS) \
$(GTHREAD_LIBS) \
$(PANGO_LIBS) \
......
......@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <sqlite3.h>
#include <tracker-fts/tracker-fts.h>
#include <glib.h>
#include <glib/gstdio.h>
......@@ -66,7 +67,6 @@ main (int argc, char **argv)
sqlite3 *db;
gint rc;
gboolean db_exists = FALSE;
gchar *st = NULL;
gchar *sql;
g_type_init ();
......@@ -87,13 +87,9 @@ main (int argc, char **argv)
sqlite3_close(db);
return EXIT_FAILURE;
}
sqlite3_enable_load_extension (db, 1);
sqlite3_load_extension (db, PKGLIBDIR "/tracker-fts.so", NULL, &st);
if (st) {
fprintf(stderr, "SQL error: %s\n", st);
sqlite3_free(st);
if (sqlite3Fts3Init (db) != SQLITE_OK) {
fprintf(stderr, "SQL error\n");
}
if (!db_exists) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment