diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2022-03-06 11:50:10 +0100 |
|---|---|---|
| committer | github-actions[bot] <github-actions[bot]@users.noreply.github.com> | 2022-03-06 10:50:33 +0000 |
| commit | 486da786aca5e5c40f88028eba6b90c60b829ba6 (patch) | |
| tree | 1754a11cfbce3e0c479a81da3dd1c17c8b5692df | |
| parent | 8ea73006ce82c66c259f9a8b1ad3430879216b01 (diff) | |
| download | PROJ-486da786aca5e5c40f88028eba6b90c60b829ba6.tar.gz PROJ-486da786aca5e5c40f88028eba6b90c60b829ba6.zip | |
Merge pull request #3089 from rouault/fix_3077
Fix wrong results with SQLite 3.38.0 (fixes #3077)
| -rw-r--r-- | src/iso19111/factory.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp index 52c3f82b..a5162ab2 100644 --- a/src/iso19111/factory.cpp +++ b/src/iso19111/factory.cpp @@ -252,7 +252,7 @@ class SQLiteHandle { } // cppcheck-suppress functionStatic - void registerFunctions(); + void initialize(); SQLResultSet run(const std::string &sql, const ListOfParams ¶meters = ListOfParams(), @@ -344,7 +344,7 @@ std::shared_ptr<SQLiteHandle> SQLiteHandle::open(PJ_CONTEXT *ctx, #ifdef ENABLE_CUSTOM_LOCKLESS_VFS handle->vfs_ = std::move(vfs); #endif - handle->registerFunctions(); + handle->initialize(); handle->checkDatabaseLayout(path, path, std::string()); return handle; } @@ -359,7 +359,7 @@ SQLiteHandle::initFromExisting(sqlite3 *sqlite_handle, bool close_handle, new SQLiteHandle(sqlite_handle, close_handle)); handle->nLayoutVersionMajor_ = nLayoutVersionMajor; handle->nLayoutVersionMinor_ = nLayoutVersionMinor; - handle->registerFunctions(); + handle->initialize(); return handle; } @@ -370,7 +370,7 @@ SQLiteHandle::initFromExistingUniquePtr(sqlite3 *sqlite_handle, bool close_handle) { auto handle = std::unique_ptr<SQLiteHandle>( new SQLiteHandle(sqlite_handle, close_handle)); - handle->registerFunctions(); + handle->initialize(); return handle; } @@ -547,7 +547,18 @@ void SQLiteHandle::checkDatabaseLayout(const std::string &mainDbPath, #define SQLITE_DETERMINISTIC 0 #endif -void SQLiteHandle::registerFunctions() { +void SQLiteHandle::initialize() { + + // There is a bug in sqlite 3.38.0 with some complex queries. + // Cf https://github.com/OSGeo/PROJ/issues/3077 + // Disabling Bloom-filter pull-down optimization as suggested in + // https://sqlite.org/forum/forumpost/7d3a75438c + const int sqlite3VersionNumber = sqlite3_libversion_number(); + if (sqlite3VersionNumber == 3 * 1000000 + 38 * 1000) { + sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite_handle_, + 0x100000); + } + sqlite3_create_function(sqlite_handle_, "pseudo_area_from_swne", 4, SQLITE_UTF8 | SQLITE_DETERMINISTIC, nullptr, PROJ_SQLITE_pseudo_area_from_swne, nullptr, |
