commit 695de191d4e4228bb0e6105ed1057bfb3435f7aa
parent aa7f136af6f67c2030db0c570137cc5761936960
Author: JohnMcPMS <johnmcp@microsoft.com>
Date: Tue, 12 May 2020 18:07:31 -0700
Swithc to sqlite3_prepare_v2 as we didn't really need v3 and it is not on RS3 (#134)
v3 is not available on Windows 10 (16299), and we don't really need or use the persistent statements in a meaningful way. Fall back to v2 and remove the persistent statement support.
Diffstat:
4 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/AppInstallerRepositoryCore/SQLiteStatementBuilder.cpp b/src/AppInstallerRepositoryCore/SQLiteStatementBuilder.cpp
@@ -689,9 +689,9 @@ namespace AppInstaller::Repository::SQLite::Builder
return *this;
}
- Statement StatementBuilder::Prepare(Connection& connection, bool persistent)
+ Statement StatementBuilder::Prepare(Connection& connection)
{
- Statement result = Statement::Create(connection, m_stream.str(), persistent);
+ Statement result = Statement::Create(connection, m_stream.str());
for (const auto& f : m_binders)
{
f(result);
diff --git a/src/AppInstallerRepositoryCore/SQLiteStatementBuilder.h b/src/AppInstallerRepositoryCore/SQLiteStatementBuilder.h
@@ -334,7 +334,7 @@ namespace AppInstaller::Repository::SQLite::Builder
int GetLastBindIndex() const { return m_bindIndex - 1; }
// Prepares and returns the statement, applying any bindings that were requested.
- Statement Prepare(Connection& connection, bool persistent = false);
+ Statement Prepare(Connection& connection);
// A convenience function that prepares, binds, and then executes a statement that does not return rows.
void Execute(Connection& connection);
diff --git a/src/AppInstallerRepositoryCore/SQLiteWrapper.cpp b/src/AppInstallerRepositoryCore/SQLiteWrapper.cpp
@@ -122,29 +122,29 @@ namespace AppInstaller::Repository::SQLite
return sqlite3_changes(m_dbconn.get());
}
- Statement::Statement(Connection& connection, std::string_view sql, bool persistent)
+ Statement::Statement(Connection& connection, std::string_view sql)
{
m_id = GetNextStatementId();
AICLI_LOG(SQL, Verbose, << "Preparing statement #" << m_id << ": " << sql);
// SQL string size should include the null terminator (https://www.sqlite.org/c3ref/prepare.html)
assert(sql.data()[sql.size()] == '\0');
- THROW_IF_SQLITE_FAILED(sqlite3_prepare_v3(connection, sql.data(), static_cast<int>(sql.size() + 1), (persistent ? SQLITE_PREPARE_PERSISTENT : 0), &m_stmt, nullptr));
+ THROW_IF_SQLITE_FAILED(sqlite3_prepare_v2(connection, sql.data(), static_cast<int>(sql.size() + 1), &m_stmt, nullptr));
}
- Statement Statement::Create(Connection& connection, const std::string& sql, bool persistent)
+ Statement Statement::Create(Connection& connection, const std::string& sql)
{
- return { connection, { sql.c_str(), sql.size() }, persistent };
+ return { connection, { sql.c_str(), sql.size() } };
}
- Statement Statement::Create(Connection& connection, std::string_view sql, bool persistent)
+ Statement Statement::Create(Connection& connection, std::string_view sql)
{
// We need the statement to be null terminated, and the only way to guarantee that with a string_view is to construct a string copy.
- return Create(connection, std::string(sql), persistent);
+ return Create(connection, std::string(sql));
}
- Statement Statement::Create(Connection& connection, char const* const sql, bool persistent)
+ Statement Statement::Create(Connection& connection, char const* const sql)
{
- return { connection, sql, persistent };
+ return { connection, sql };
}
bool Statement::Step(bool failFastOnError)
@@ -203,8 +203,8 @@ namespace AppInstaller::Repository::SQLite
using namespace std::string_literals;
Statement begin = Statement::Create(connection, "SAVEPOINT ["s + m_name + "]");
- m_rollbackTo = Statement::Create(connection, "ROLLBACK TO ["s + m_name + "]", true);
- m_release = Statement::Create(connection, "RELEASE ["s + m_name + "]", true);
+ m_rollbackTo = Statement::Create(connection, "ROLLBACK TO ["s + m_name + "]");
+ m_release = Statement::Create(connection, "RELEASE ["s + m_name + "]");
AICLI_LOG(SQL, Info, << "Begin savepoint: " << m_name);
begin.Step();
diff --git a/src/AppInstallerRepositoryCore/SQLiteWrapper.h b/src/AppInstallerRepositoryCore/SQLiteWrapper.h
@@ -155,9 +155,9 @@ namespace AppInstaller::Repository::SQLite
// A SQL statement.
struct Statement
{
- static Statement Create(Connection& connection, const std::string& sql, bool persistent = false);
- static Statement Create(Connection& connection, std::string_view sql, bool persistent = false);
- static Statement Create(Connection& connection, char const* const sql, bool persistent = false);
+ static Statement Create(Connection& connection, const std::string& sql);
+ static Statement Create(Connection& connection, std::string_view sql);
+ static Statement Create(Connection& connection, char const* const sql);
Statement() = default;
@@ -231,7 +231,7 @@ namespace AppInstaller::Repository::SQLite
operator bool() const { return static_cast<bool>(m_stmt); }
private:
- Statement(Connection& connection, std::string_view sql, bool persistent);
+ Statement(Connection& connection, std::string_view sql);
// Helper to receive the integer sequence from the public function.
// This is equivalent to calling: