Sqlite: Export interface

Change-Id: I17fffdb2d6ca43e5f0897c0c86dd461b0d844699
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2020-05-16 15:24:01 +02:00
committed by Tim Jenssen
parent 6ae30941d2
commit 36711dab34
4 changed files with 27 additions and 16 deletions

View File

@@ -75,6 +75,11 @@ Database::Database(Utils::PathString &&databaseFilePath,
Database::~Database() = default;
void Database::activateLogging()
{
DatabaseBackend::activateLogging();
}
void Database::open()
{
m_databaseBackend.open(m_databaseFilePath, m_openMode);

View File

@@ -66,6 +66,8 @@ public:
Database(const Database &) = delete;
Database &operator=(const Database &) = delete;
static void activateLogging();
void open();
void open(Utils::PathString &&databaseFilePath);
void close();

View File

@@ -68,7 +68,7 @@ void DatabaseBackend::activateMultiThreading()
static void sqliteLog(void*,int errorCode,const char *errorMessage)
{
qWarning() << sqlite3_errstr(errorCode) << errorMessage;
std::cout << "Sqlite " << sqlite3_errstr(errorCode) << ": " << errorMessage << std::endl;
}
void DatabaseBackend::activateLogging()
@@ -285,31 +285,35 @@ void DatabaseBackend::checkDatabaseHandleIsNotNull() const
void DatabaseBackend::checkIfMultithreadingIsActivated(int resultCode)
{
if (resultCode != SQLITE_OK)
throwException("SqliteDatabaseBackend::activateMultiThreading: multithreading can't be activated!");
throwExceptionStatic(
"SqliteDatabaseBackend::activateMultiThreading: multithreading can't be activated!");
}
void DatabaseBackend::checkIfLoogingIsActivated(int resultCode)
{
if (resultCode != SQLITE_OK)
throwException("SqliteDatabaseBackend::activateLogging: logging can't be activated!");
throwExceptionStatic("SqliteDatabaseBackend::activateLogging: logging can't be activated!");
}
void DatabaseBackend::checkMmapSizeIsSet(int resultCode)
{
if (resultCode != SQLITE_OK)
throwException("SqliteDatabaseBackend::checkMmapSizeIsSet: mmap size can't be changed!");
throwExceptionStatic(
"SqliteDatabaseBackend::checkMmapSizeIsSet: mmap size can't be changed!");
}
void DatabaseBackend::checkInitializeSqliteLibraryWasSuccesful(int resultCode)
{
if (resultCode != SQLITE_OK)
throwException("SqliteDatabaseBackend::initializeSqliteLibrary: SqliteLibrary cannot initialized!");
throwExceptionStatic(
"SqliteDatabaseBackend::initializeSqliteLibrary: SqliteLibrary cannot initialized!");
}
void DatabaseBackend::checkShutdownSqliteLibraryWasSuccesful(int resultCode)
{
if (resultCode != SQLITE_OK)
throwException("SqliteDatabaseBackend::shutdownSqliteLibrary: SqliteLibrary cannot be shutdowned!");
throwExceptionStatic(
"SqliteDatabaseBackend::shutdownSqliteLibrary: SqliteLibrary cannot be shutdowned!");
}
void DatabaseBackend::checkIfLogCouldBeCheckpointed(int resultCode)

View File

@@ -52,11 +52,11 @@ public:
DatabaseBackend(DatabaseBackend &&) = delete;
DatabaseBackend &operator=(DatabaseBackend &&) = delete;
void setMmapSize(qint64 defaultSize, qint64 maximumSize);
void activateMultiThreading();
void activateLogging();
void initializeSqliteLibrary();
void shutdownSqliteLibrary();
static void setMmapSize(qint64 defaultSize, qint64 maximumSize);
static void activateMultiThreading();
static void activateLogging();
static void initializeSqliteLibrary();
static void shutdownSqliteLibrary();
void checkpointFullWalLog();
void open(Utils::SmallStringView databaseFilePath, OpenMode openMode);
@@ -107,11 +107,11 @@ protected:
void checkCarrayCannotBeIntialized(int resultCode);
void checkPragmaValue(Utils::SmallStringView databaseValue, Utils::SmallStringView expectedValue);
void checkDatabaseHandleIsNotNull() const;
void checkIfMultithreadingIsActivated(int resultCode);
void checkIfLoogingIsActivated(int resultCode);
void checkMmapSizeIsSet(int resultCode);
void checkInitializeSqliteLibraryWasSuccesful(int resultCode);
void checkShutdownSqliteLibraryWasSuccesful(int resultCode);
static void checkIfMultithreadingIsActivated(int resultCode);
static void checkIfLoogingIsActivated(int resultCode);
static void checkMmapSizeIsSet(int resultCode);
static void checkInitializeSqliteLibraryWasSuccesful(int resultCode);
static void checkShutdownSqliteLibraryWasSuccesful(int resultCode);
void checkIfLogCouldBeCheckpointed(int resultCode);
void checkIfBusyTimeoutWasSet(int resultCode);