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(),
|
||||
|
||||
Reference in New Issue
Block a user