From ea52bbf3e29194ba34de41f9368ae480ce6f6b33 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Mon, 21 Jun 2010 12:38:24 +0000 Subject: [PATCH] Register the FTS3 tokenizer with a QSqlQuery, so it works even if we couldn't resolve the sqlite symbols. --- src/core/database.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/core/database.cpp b/src/core/database.cpp index 4abed97ef..863e72048 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -394,6 +394,14 @@ QSqlDatabase Database::Connect() { // Find Sqlite3 functions in the Qt plugin. StaticInit(); + QSqlQuery set_fts_tokenizer("SELECT fts3_tokenizer(:name, :pointer)", db); + set_fts_tokenizer.bindValue(":name", "unicode"); + set_fts_tokenizer.bindValue(":pointer", QByteArray( + reinterpret_cast(&sFTSTokenizer), sizeof(sFTSTokenizer))); + if (!set_fts_tokenizer.exec()) { + qWarning() << "Couldn't register FTS3 tokenizer"; + } + // We want Unicode aware LIKE clauses and FTS if possible. if (sLoadedSqliteSymbols) { QVariant v = db.driver()->handle(); @@ -408,17 +416,6 @@ QSqlDatabase Database::Connect() { this, // Custom data available via sqlite3_user_data(). &Database::SqliteLike, // Our function :-) NULL, NULL); - - sqlite3_stmt* statement; - const char* sql = "SELECT fts3_tokenizer(?, ?)"; - int rc = _sqlite3_prepare_v2(handle, sql, -1, &statement, 0); - if (rc == SQLITE_OK) { - _sqlite3_bind_text(statement, 1, "unicode", -1, SQLITE_STATIC); - _sqlite3_bind_blob(statement, 2, &sFTSTokenizer, sizeof(sFTSTokenizer), SQLITE_STATIC); - _sqlite3_step(statement); - - _sqlite3_finalize(statement); - } } } }