From 8da626250d59c375c578b6fe0d0fc77ad9b1e45e Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Tue, 31 Jan 2017 18:28:16 +0100 Subject: [PATCH] Make sure to register the regexp function when creating a new database DB4S comes with its own default implementation for the REGEXP function. This function, however, needs to be registered in order for SQLite to use it. We did that when opening a database file but not when creating a new database file, so regular expressions wouldn't work for newly created databases like they did for existing ones. This is fixed by this commit. --- src/sqlitedb.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 45c712dc..2de17164 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -384,6 +384,10 @@ bool DBBrowserDB::create ( const QString & db) // Enable extension loading sqlite3_enable_load_extension(_db, 1); + // Register REGEXP function + if(Settings::getSettingsValue("extensions", "disableregex").toBool() == false) + sqlite3_create_function(_db, "REGEXP", 2, SQLITE_UTF8, NULL, regexp, NULL, NULL); + // force sqlite3 do write proper file header // if we don't create and drop the table we might end up // with a 0 byte file, if the user cancels the create table dialog