aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2022-03-06 11:50:10 +0100
committerGitHub <noreply@github.com>2022-03-06 11:50:10 +0100
commit7809d6e5f7cb40490516b91d3f9b603a7d367e4c (patch)
tree321be08faa5769ad124679d6ee9a53238462864e
parentf6780951cace8c589c2131baf98cf68b3bebb9c0 (diff)
parentbd2326210253cce5bf60626825d60da52f24cc53 (diff)
downloadPROJ-7809d6e5f7cb40490516b91d3f9b603a7d367e4c.tar.gz
PROJ-7809d6e5f7cb40490516b91d3f9b603a7d367e4c.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.cpp21
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 &parameters = 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,