8#include "../../SqlBindingTypes.hpp"
9#include "../../SqlError.hpp"
22namespace Lightweight::Driver::Sqlite3
26inline constexpr std::string_view ConnectionNotOpenState =
"08003";
29inline constexpr std::string_view NativeDriverName =
"sqlite3-native";
35template <
typename MakeError>
36void KeepError(std::optional<SqlErrorInfo>& lastError, MakeError
const& makeError)
noexcept
40 lastError = makeError();
42 catch (std::exception
const&)
49enum class StatementPhase : std::uint8_t
173inline void DetachStatement(StatementState& statement)
noexcept
175 if (!statement.connection)
177 statement.pendingTail.clear();
178 if (statement.previousOfConnection)
179 statement.previousOfConnection->nextOfConnection = statement.nextOfConnection;
181 statement.connection->firstStatement = statement.nextOfConnection;
182 if (statement.nextOfConnection)
183 statement.nextOfConnection->previousOfConnection = statement.previousOfConnection;
184 statement.connection =
nullptr;
185 statement.previousOfConnection =
nullptr;
186 statement.nextOfConnection =
nullptr;
193inline void AttachStatement(ConnectionState& connection, StatementState& statement)
noexcept
195 DetachStatement(statement);
196 statement.connection = &connection;
197 statement.previousOfConnection =
nullptr;
198 statement.nextOfConnection = connection.firstStatement;
199 if (connection.firstStatement)
200 connection.firstStatement->previousOfConnection = &statement;
201 connection.firstStatement = &statement;
207[[nodiscard]] SqlErrorInfo ErrorInfoOf(::sqlite3* database);
SqlResult(*)(Statement &stmt, SqlColumnIndex column, void *target, SqlIndicator *indicator) OutputReader
A registered reader: reads one column of the current row into the bound target.
One registered output reader: what Fetch runs for one result column on every row.
void * target
The target handed to reader.
SqlIndicator * indicator
The indicator handed to reader.
OutputReader reader
The reader; null for a column without one.
The driver-owned state of one SQLite connection: everything mutable behind a Connection.
std::optional< SqlErrorInfo > lastError
std::string databaseName
The database the connection was opened on (SqliteConnectInfo::database), as DatabaseName reports it.
::sqlite3 * database
The open database; null before a successful Connect and after a failed one.
StatementState * firstStatement
The driver-owned state of one SQLite statement: everything mutable behind a Statement.
std::vector< BoundColumn > boundColumns
The registered output readers, indexed by column - 1; grown by RegisterOutputReader only.
ConnectionState * connection
The connection the statement belongs to; null once orphaned by that connection's Close.
std::optional< SqlErrorInfo > lastError
std::int64_t rowsAffected
The change count of the statement's last completed execution (see NumRowsAffected); 0 until it comple...
int boundParameterCount
The number of true entries of boundParameters, so the check before every execution is one compare.
std::vector< bool > boundParameters
std::int64_t totalChangesAtExecute
StatementPhase phase
Where the statement stands in its result set.
StatementState * previousOfConnection
The previous statement in the connection's statement list; null for the first one.
StatementState * nextOfConnection
The next statement in the connection's statement list; null for the last one.
::sqlite3_stmt * native
The prepared statement; null when nothing is prepared, and after the connection closed.