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

The driver-owned state of one SQLite statement: everything mutable behind a Statement. More...

#include <State.hpp>

Public Attributes

ConnectionState * connection {}
 The connection the statement belongs to; null once orphaned by that connection's Close.
 
::sqlite3_stmt * native {}
 The prepared statement; null when nothing is prepared, and after the connection closed.
 
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.
 
int columnCount {}
 
int parameterCount {}
 
StatementPhase phase {}
 Where the statement stands in its result set.
 
bool readOnly = true
 
std::vector< bool > boundParameters {}
 
int boundParameterCount {}
 The number of true entries of boundParameters, so the check before every execution is one compare.
 
std::int64_t rowsAffected {}
 The change count of the statement's last completed execution (see NumRowsAffected); 0 until it completed.
 
std::int64_t totalChangesAtExecute {}
 
std::vector< BoundColumn > boundColumns {}
 The registered output readers, indexed by column - 1; grown by RegisterOutputReader only.
 
std::optional< SqlErrorInfo > lastError {}
 
std::string pendingTail {}
 

Detailed Description

The driver-owned state of one SQLite statement: everything mutable behind a Statement.

Created by the statement's Allocate with std::make_unique, released into its handle struct and registered with its connection's state (AttachStatement); destroyed only by the statement's Free, which finalizes native, unregisters it and re-adopts it. Its connection never destroys it: closing the connection (or connecting it again) finalizes native and orphans the state (connection becomes null), so a statement or cursor destroyed after its connection still touches valid memory.

Invariant: native is non-null only while connection is non-null and has an open database, so a non-null native is all a per-row operation needs to check.

Definition at line 82 of file State.hpp.

Member Data Documentation

◆ connection

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

The connection the statement belongs to; null once orphaned by that connection's Close.

Definition at line 85 of file State.hpp.

◆ native

::sqlite3_stmt* Lightweight::Driver::Sqlite3::StatementState::native {}

The prepared statement; null when nothing is prepared, and after the connection closed.

Definition at line 88 of file State.hpp.

◆ previousOfConnection

StatementState* Lightweight::Driver::Sqlite3::StatementState::previousOfConnection {}

The previous statement in the connection's statement list; null for the first one.

Definition at line 91 of file State.hpp.

◆ nextOfConnection

StatementState* Lightweight::Driver::Sqlite3::StatementState::nextOfConnection {}

The next statement in the connection's statement list; null for the last one.

Definition at line 94 of file State.hpp.

◆ columnCount

int Lightweight::Driver::Sqlite3::StatementState::columnCount {}

The number of result columns of native, cached at prepare and refreshed by each Execute (SQLite may re-prepare a statement whose schema changed). It decides whether bound text is referenced or copied.

Definition at line 98 of file State.hpp.

◆ parameterCount

int Lightweight::Driver::Sqlite3::StatementState::parameterCount {}

The number of parameters of native, cached at prepare. Kept as wide as SQLite reports it (a build may allow 250000); Prepare refuses a statement whose counts do not fit the std::int16_t the concept uses.

Definition at line 102 of file State.hpp.

◆ phase

StatementPhase Lightweight::Driver::Sqlite3::StatementState::phase {}

Where the statement stands in its result set.

Definition at line 105 of file State.hpp.

◆ readOnly

bool Lightweight::Driver::Sqlite3::StatementState::readOnly = true

Whether native writes nothing (sqlite3_stmt_readonly), cached at prepare: such a statement reports no changed rows, whatever another statement of the connection wrote meanwhile.

Definition at line 109 of file State.hpp.

◆ boundParameters

std::vector<bool> Lightweight::Driver::Sqlite3::StatementState::boundParameters {}

Which parameters (index - 1) were bound since the bindings were last cleared; sized at prepare, so binding never allocates. Execute refuses (07002) while any is unbound, rather than writing NULL for it.

Definition at line 113 of file State.hpp.

◆ boundParameterCount

int Lightweight::Driver::Sqlite3::StatementState::boundParameterCount {}

The number of true entries of boundParameters, so the check before every execution is one compare.

Definition at line 116 of file State.hpp.

◆ rowsAffected

std::int64_t Lightweight::Driver::Sqlite3::StatementState::rowsAffected {}

The change count of the statement's last completed execution (see NumRowsAffected); 0 until it completed.

Definition at line 119 of file State.hpp.

◆ totalChangesAtExecute

std::int64_t Lightweight::Driver::Sqlite3::StatementState::totalChangesAtExecute {}

The connection's total change count (sqlite3_total_changes64) when Execute started; a completed statement that did not move it changed no rows, whatever sqlite3_changes64 still reports.

Definition at line 123 of file State.hpp.

◆ boundColumns

std::vector<BoundColumn> Lightweight::Driver::Sqlite3::StatementState::boundColumns {}

The registered output readers, indexed by column - 1; grown by RegisterOutputReader only.

Definition at line 126 of file State.hpp.

◆ lastError

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

The statement's last failure, captured when the failing call returned. Disengaged until something failed since the last prepare.

Definition at line 130 of file State.hpp.

◆ pendingTail

std::string Lightweight::Driver::Sqlite3::StatementState::pendingTail {}

The statements of an ExecuteDirect text not run yet: the text after the statement whose result set is current. A copy owned here (the caller's text dies when ExecuteDirect returns), run by MoreResults, DiscardResults, Prepare and ExecuteDirect; empty when nothing is pending. Orphaning the statement (DetachStatement) drops it unrun. Only one sqlite3_stmt of the text exists at any time, in native.

Definition at line 137 of file State.hpp.


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