Don't call sqlite3_config() unless explicitly required to do so #284
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
GRDB calls the SQLite sqlite3_config function in order to configure the global error log.
Any call to sqlite3_config must happen before any connection to any database. In other words, changing the SQLite configuration after a connection has been opened is a misuse of SQLite .
Bug
GRDB was calling sqlite3_config() once, before opening its first database connection. But issue #283 has revealed that this GRDB practice could conflict with other pieces of code that also open database connections. When GRDB opens its first connection after another part of the program has already opened a connection, this sqlite3_config() invocation is a misuse.
Fix
This PR fixes this, by only calling sqlite3_config() when the GRDB user configures the error log:
This also mean that the user is now responsible for setting the
Database.logError
before any other piece of code would open a connection.