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.
This commit is contained in:
Martin Kleusberg
2017-01-31 18:28:16 +01:00
parent bf1c90a896
commit 8da626250d
+4
View File
@@ -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