forked from qt-creator/qt-creator
Sqlite: Update Sqlite from 3.31.1 to 3.34 and adapt carray
You can now pass everything you can convert to a span directly and bind it with a carray instead of using the pointer interface. This is working for int, long long, double and null terminated C strings. Change-Id: I274c218e2dec0f11e68576545bb78601f85462bd Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -38,6 +38,14 @@
|
||||
# pragma GCC diagnostic ignored "-Wignored-qualifiers"
|
||||
#endif
|
||||
|
||||
#define CARRAY_INT32 0 /* Data is 32-bit signed integers */
|
||||
#define CARRAY_INT64 1 /* Data is 64-bit signed integers */
|
||||
#define CARRAY_DOUBLE 2 /* Data is doubles */
|
||||
#define CARRAY_TEXT 3 /* Data is char* */
|
||||
|
||||
extern "C" int sqlite3_carray_bind(
|
||||
sqlite3_stmt *pStmt, int idx, void *aData, int nData, int mFlags, void (*xDestroy)(void *));
|
||||
|
||||
namespace Sqlite {
|
||||
|
||||
BaseStatement::BaseStatement(Utils::SmallStringView sqlStatement, Database &database)
|
||||
@@ -180,6 +188,54 @@ void BaseStatement::bind(int index, void *pointer)
|
||||
checkForBindingError(resultCode);
|
||||
}
|
||||
|
||||
void BaseStatement::bind(int index, Utils::span<int> values)
|
||||
{
|
||||
int resultCode = sqlite3_carray_bind(m_compiledStatement.get(),
|
||||
index,
|
||||
values.data(),
|
||||
static_cast<int>(values.size()),
|
||||
CARRAY_INT32,
|
||||
SQLITE_STATIC);
|
||||
if (resultCode != SQLITE_OK)
|
||||
checkForBindingError(resultCode);
|
||||
}
|
||||
|
||||
void BaseStatement::bind(int index, Utils::span<long long> values)
|
||||
{
|
||||
int resultCode = sqlite3_carray_bind(m_compiledStatement.get(),
|
||||
index,
|
||||
values.data(),
|
||||
static_cast<int>(values.size()),
|
||||
CARRAY_INT64,
|
||||
SQLITE_STATIC);
|
||||
if (resultCode != SQLITE_OK)
|
||||
checkForBindingError(resultCode);
|
||||
}
|
||||
|
||||
void BaseStatement::bind(int index, Utils::span<double> values)
|
||||
{
|
||||
int resultCode = sqlite3_carray_bind(m_compiledStatement.get(),
|
||||
index,
|
||||
values.data(),
|
||||
static_cast<int>(values.size()),
|
||||
CARRAY_DOUBLE,
|
||||
SQLITE_STATIC);
|
||||
if (resultCode != SQLITE_OK)
|
||||
checkForBindingError(resultCode);
|
||||
}
|
||||
|
||||
void BaseStatement::bind(int index, Utils::span<const char *> values)
|
||||
{
|
||||
int resultCode = sqlite3_carray_bind(m_compiledStatement.get(),
|
||||
index,
|
||||
values.data(),
|
||||
static_cast<int>(values.size()),
|
||||
CARRAY_TEXT,
|
||||
SQLITE_STATIC);
|
||||
if (resultCode != SQLITE_OK)
|
||||
checkForBindingError(resultCode);
|
||||
}
|
||||
|
||||
void BaseStatement::bind(int index, Utils::SmallStringView text)
|
||||
{
|
||||
int resultCode = sqlite3_bind_text(m_compiledStatement.get(),
|
||||
|
||||
@@ -77,12 +77,16 @@ public:
|
||||
int columnCount() const;
|
||||
|
||||
void bind(int index, NullValue);
|
||||
void bind(int index, int fetchValue);
|
||||
void bind(int index, long long fetchValue);
|
||||
void bind(int index, double fetchValue);
|
||||
void bind(int index, int value);
|
||||
void bind(int index, long long value);
|
||||
void bind(int index, double value);
|
||||
void bind(int index, void *pointer);
|
||||
void bind(int index, Utils::SmallStringView fetchValue);
|
||||
void bind(int index, const Value &fetchValue);
|
||||
void bind(int index, Utils::span<int> values);
|
||||
void bind(int index, Utils::span<long long> values);
|
||||
void bind(int index, Utils::span<double> values);
|
||||
void bind(int index, Utils::span<const char *> values);
|
||||
void bind(int index, Utils::SmallStringView value);
|
||||
void bind(int index, const Value &value);
|
||||
void bind(int index, BlobView blobView);
|
||||
|
||||
void bind(int index, uint value) { bind(index, static_cast<long long>(value)); }
|
||||
|
||||
@@ -54,7 +54,7 @@ DatabaseBackend::~DatabaseBackend()
|
||||
closeWithoutException();
|
||||
}
|
||||
|
||||
void DatabaseBackend::setMmapSize(qint64 defaultSize, qint64 maximumSize)
|
||||
void DatabaseBackend::setRanslatorentriesapSize(qint64 defaultSize, qint64 maximumSize)
|
||||
{
|
||||
int resultCode = sqlite3_config(SQLITE_CONFIG_MMAP_SIZE, defaultSize, maximumSize);
|
||||
checkMmapSizeIsSet(resultCode);
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
DatabaseBackend(DatabaseBackend &&) = delete;
|
||||
DatabaseBackend &operator=(DatabaseBackend &&) = delete;
|
||||
|
||||
static void setMmapSize(qint64 defaultSize, qint64 maximumSize);
|
||||
static void setRanslatorentriesapSize(qint64 defaultSize, qint64 maximumSize);
|
||||
static void activateMultiThreading();
|
||||
static void activateLogging();
|
||||
static void initializeSqliteLibrary();
|
||||
|
||||
Reference in New Issue
Block a user