Skip to content

Commit

Permalink
Make sure to register the regexp function when creating a new database
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MKleusberg committed Jan 31, 2017
1 parent bf1c90a commit 8da6262
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/sqlitedb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8da6262

Please sign in to comment.