-
Notifications
You must be signed in to change notification settings - Fork 785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cannot open proj.db with memvfs #3887
Labels
Comments
gaoyuanning
changed the title
cannot open proj.db in memvfs
cannot open proj.db with memvfs
Sep 8, 2023
I found if I add // proj-9.3.0/src/iso19111/factory.cpp
std::shared_ptr<SQLiteHandle> SQLiteHandle::open(PJ_CONTEXT *ctx,
const std::string &path) {
const int sqlite3VersionNumber = sqlite3_libversion_number();
// Minimum version for correct performance: 3.11
if (sqlite3VersionNumber < 3 * 1000000 + 11 * 1000) {
pj_log(ctx, PJ_LOG_ERROR,
"SQLite3 version is %s, whereas at least 3.11 should be used",
sqlite3_libversion());
}
std::string vfsName;
#ifdef ENABLE_CUSTOM_LOCKLESS_VFS
std::unique_ptr<SQLite3VFS> vfs;
if (ctx->custom_sqlite3_vfs_name.empty()) {
vfs = SQLite3VFS::create(false, true, true);
if (vfs == nullptr) {
throw FactoryException("Open of " + path + " failed");
}
vfsName = vfs->name();
} else
#endif
{
vfsName = ctx->custom_sqlite3_vfs_name;
}
sqlite3 *sqlite_handle = nullptr;
// SQLITE_OPEN_FULLMUTEX as this will be used from concurrent threads
if (sqlite3_open_v2(path.c_str(), &sqlite_handle,
SQLITE_OPEN_READONLY | SQLITE_OPEN_FULLMUTEX,
vfsName.empty() ? nullptr : vfsName.c_str()) !=
SQLITE_OK ||
!sqlite_handle) {
if (sqlite_handle != nullptr) {
sqlite3_close(sqlite_handle);
}
throw FactoryException("Open of " + path + " failed");
}
auto handle =
std::shared_ptr<SQLiteHandle>(new SQLiteHandle(sqlite_handle, true));
#ifdef ENABLE_CUSTOM_LOCKLESS_VFS
handle->vfs_ = std::move(vfs);
#endif
handle->initialize();
handle->checkDatabaseLayout(path, path, std::string());
return handle;
} |
rouault
added a commit
that referenced
this issue
Sep 13, 2023
proj.db opening: allow opening with a URI (typically for memvfs) (fixes #3887)
rouault
added a commit
that referenced
this issue
Sep 13, 2023
rouault
added a commit
that referenced
this issue
Sep 14, 2023
[Backport 9.3] proj.db opening: allow opening with a URI (typically for memvfs) (fixes #3887)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi I try to use the proj to load the proj.db in memory format. To do this, I use char proj_db[] to store the proj.db in binary format, and load it by memvfs. But when I run the code, I get the error of open file. I wonder if there something wrong in my codes?
Here is my code:
The text was updated successfully, but these errors were encountered: