MXS-2480 Fix creating of the in memory sqlite3 databases in PAMAuth

SQLITE_OPEN_URI flag was missing causing the databases to be created in
disk instead of in memory. Also added info level log message from created
database in clustrixmonitor.
This commit is contained in:
Marko 2019-05-15 12:51:30 +03:00
parent b212307fea
commit 004e8e638f
3 changed files with 5 additions and 2 deletions

View File

@ -121,6 +121,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
static bool open_instance_database(const char* path, sqlite3** handle)
{
// This only opens database in memory if path is exactly ":memory:"
// To use the URI filename SQLITE_OPEN_URI flag needs to be used.
int rc = sqlite3_open_v2(path, handle, db_flags, NULL);
if (rc != SQLITE_OK)

View File

@ -93,7 +93,8 @@ PamClientSession* PamClientSession::create(const PamInstance& inst)
{
// This handle is only used from one thread, can define no_mutex.
sqlite3* dbhandle = NULL;
int db_flags = SQLITE_OPEN_READONLY | SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_NOMUTEX;
int db_flags = SQLITE_OPEN_READONLY | SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_NOMUTEX
| SQLITE_OPEN_URI;
if (sqlite3_open_v2(inst.m_dbname.c_str(), &dbhandle, db_flags, NULL) == SQLITE_OK)
{
sqlite3_busy_timeout(dbhandle, 1000);

View File

@ -56,7 +56,7 @@ PamInstance* PamInstance::create(char** options)
/* This handle may be used from multiple threads, set full mutex. */
sqlite3* dbhandle = NULL;
int db_flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
| SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_FULLMUTEX;
| SQLITE_OPEN_SHAREDCACHE | SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_URI;
if (sqlite3_open_v2(pam_db_name.c_str(), &dbhandle, db_flags, NULL) != SQLITE_OK)
{
MXS_ERROR("Failed to open SQLite3 handle.");