On Sat, Sep 5, 2015 at 6:42 PM, Darin Adler <darin at apple.com> wrote:
> Michael is planning a workaround in WebKit that will call > sqlite3_initialize manually exactly once before WebKit uses sqlite, using > std::once to deal with the thread safety issue. > This reminds me ... I was recently working on a patch which used sqlite3_config(), which needs to run before sqlite3_initialize(). Since we were already calling sqlite3_initialize(), I put it in the obvious place. Then I found a case where someone was making a sqlite3_*() call before calling into the normal code path. That worked fine for lazy initialization, but caused my sqlite3_config() to start failing depending on what happened in which order. It would be modestly interesting to have a macro SQLITE_REQUIRE_INIT (or similar) which caused SQLite to throw errors if an API is being called before sqlite3_initialize(). My pencil implementation would probably piggyback on SQLITE_OMIT_AUTOINIT, changing those callsites from sqlite3_initialize() to sqlite3Initialize(), then having that implementation look something like: #ifndef SQLITE_OMIT_AUTOINIT int sqlite3Initialize() { #ifdef SQLITE_REQUIRE_INIT return sqlite3GlobalConfig.isInit ? SQLITE_OK : SQLITE_MISUSE; #else return sqlite3_initialize(); #endif } #endif Mostly I'd want this in debug and testing builds, so that I could have confidence in setting SQLITE_OMIT_AUTOINIT for release builds. Thanks, scott