Lightweight 0.20261105.1
Loading...
Searching...
No Matches
Lightweight::Driver::Sqlite3::ConnectionState Struct Reference

The driver-owned state of one SQLite connection: everything mutable behind a Connection. More...

#include <State.hpp>

Public Attributes

::sqlite3 * database {}
 The open database; null before a successful Connect and after a failed one.
 
bool transactionBegun = false
 
std::string databaseName {}
 The database the connection was opened on (SqliteConnectInfo::database), as DatabaseName reports it.
 
std::optional< SqlErrorInfo > lastError {}
 
StatementState * firstStatement {}
 

Detailed Description

The driver-owned state of one SQLite connection: everything mutable behind a Connection.

Created by Allocate(Connection&) with std::make_unique and released into the handle struct, so the handle is its only owner; Close(Connection&) re-adopts it into a std::unique_ptr and destroys it. A connection and its statements are used by one thread at a time, their destruction included (the public contract, stated on Driver::Sqlite3::Connection), so the state carries no lock.

Definition at line 146 of file State.hpp.

Member Data Documentation

◆ database

::sqlite3* Lightweight::Driver::Sqlite3::ConnectionState::database {}

The open database; null before a successful Connect and after a failed one.

Definition at line 149 of file State.hpp.

◆ transactionBegun

bool Lightweight::Driver::Sqlite3::ConnectionState::transactionBegun = false

Whether SetAutoCommit(false) began (or adopted) a transaction that no Commit, Rollback or SetAutoCommit(true) has ended yet. SQLite rolls a transaction back by itself on some failures (ON CONFLICT ROLLBACK, RAISE(ROLLBACK, ...), a full disk); this flag is how Commit tells that case (fails with 25000) from a commit with no transaction begun (succeeds).

Definition at line 155 of file State.hpp.

◆ databaseName

std::string Lightweight::Driver::Sqlite3::ConnectionState::databaseName {}

The database the connection was opened on (SqliteConnectInfo::database), as DatabaseName reports it.

Definition at line 158 of file State.hpp.

◆ lastError

std::optional<SqlErrorInfo> Lightweight::Driver::Sqlite3::ConnectionState::lastError {}

The last failure of a connection-level call, kept so that LastError reports it even when the native connection it came from is gone (a failed open closes it). Disengaged until something failed.

Definition at line 162 of file State.hpp.

◆ firstStatement

StatementState* Lightweight::Driver::Sqlite3::ConnectionState::firstStatement {}

The first of the statements allocated on this connection and not yet freed; an intrusive list through StatementState::nextOfConnection, so attaching and detaching are O(1) and never allocate.

Definition at line 166 of file State.hpp.


The documentation for this struct was generated from the following file: