Sqlite: Optimize the initialization

https: //www.sqlite.org/compile.html#omit_autoinit

Change-Id: Iaa91203be21f01a19235a9401cb4fa412eca8276
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2021-04-09 17:44:03 +02:00
parent 8edbdd78ad
commit 81a36ac0ef
6 changed files with 104 additions and 6 deletions

View File

@@ -10,7 +10,7 @@ add_qtc_library(Sqlite
SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_UTF16 SQLITE_DQS=0
SQLITE_ENABLE_STAT4 HAVE_ISNAN HAVE_FDATASYNC HAVE_MALLOC_USABLE_SIZE
SQLITE_DEFAULT_MMAP_SIZE=268435456 SQLITE_CORE SQLITE_ENABLE_SESSION SQLITE_ENABLE_PREUPDATE_HOOK
SQLITE_LIKE_DOESNT_MATCH_BLOBS
SQLITE_LIKE_DOESNT_MATCH_BLOBS SQLITE_OMIT_AUTOINIT
DEPENDS Qt5::Core Threads::Threads ${CMAKE_DL_LIBS}
PUBLIC_INCLUDES
"${CMAKE_CURRENT_LIST_DIR}"
@@ -46,4 +46,5 @@ add_qtc_library(Sqlite
utf8stringvector.cpp utf8stringvector.h
sqliteblob.h
sqlitetimestamp.h
sqlitelibraryinitializer.cpp sqlitelibraryinitializer.h
)

View File

@@ -15,6 +15,7 @@ SOURCES += \
$$PWD/sqlitedatabasebackend.cpp \
$$PWD/sqliteexception.cpp \
$$PWD/sqliteglobal.cpp \
$$PWD/sqlitelibraryinitializer.cpp \
$$PWD/sqlitesessionchangeset.cpp \
$$PWD/sqlitesessions.cpp \
$$PWD/sqlstatementbuilder.cpp \
@@ -25,6 +26,7 @@ SOURCES += \
HEADERS += \
$$PWD/constraints.h \
$$PWD/sqliteblob.h \
$$PWD/sqlitelibraryinitializer.h \
$$PWD/sqlitetimestamp.h \
$$PWD/tableconstraints.h \
$$PWD/createtablesqlstatementbuilder.h \
@@ -59,7 +61,7 @@ DEFINES += SQLITE_THREADSAFE=2 SQLITE_ENABLE_FTS5 SQLITE_ENABLE_UNLOCK_NOTIFY \
SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_UTF16 SQLITE_DQS=0 \
SQLITE_ENABLE_STAT4 HAVE_ISNAN HAVE_FDATASYNC HAVE_MALLOC_USABLE_SIZE \
SQLITE_DEFAULT_MMAP_SIZE=268435456 SQLITE_CORE SQLITE_ENABLE_SESSION SQLITE_ENABLE_PREUPDATE_HOOK \
SQLITE_LIKE_DOESNT_MATCH_BLOBS
SQLITE_LIKE_DOESNT_MATCH_BLOBS SQLITE_OMIT_AUTOINIT
CONFIG(debug, debug|release): DEFINES += SQLITE_ENABLE_API_ARMOR

View File

@@ -0,0 +1,47 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "sqlitelibraryinitializer.h"
#include "sqlitedatabasebackend.h"
namespace Sqlite {
void LibraryInitializer::initialize()
{
static LibraryInitializer initializer;
}
LibraryInitializer::LibraryInitializer()
{
DatabaseBackend::initializeSqliteLibrary();
}
LibraryInitializer::~LibraryInitializer()
{
DatabaseBackend::shutdownSqliteLibrary();
}
} // namespace Sqlite

View File

@@ -0,0 +1,42 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "sqliteglobal.h"
namespace Sqlite {
class LibraryInitializer
{
public:
SQLITE_EXPORT static void initialize();
private:
LibraryInitializer();
~LibraryInitializer();
};
} // namespace Sqlite