|
Lightweight 0.20261105.1
|
#include "../../Api.hpp"#include "../../SqlBindingTypes.hpp"#include "../../SqlError.hpp"#include "../Concept.hpp"#include "Connection.hpp"#include "Handles.hpp"#include <chrono>#include <concepts>#include <cstddef>#include <cstdint>#include <expected>#include <optional>#include <source_location>#include <span>#include <string>#include <string_view>#include <type_traits>Go to the source code of this file.
Typedefs | |
| using | Lightweight::Driver::Sqlite3::OutputReader = SqlResult(*)(Statement &stmt, SqlColumnIndex column, void *target, SqlIndicator *indicator) |
| A registered reader: reads one column of the current row into the bound target. | |
Enumerations | |
| enum class | Lightweight::Driver::Sqlite3::StorageClass : std::uint8_t { Null , Integer , Float , Text , Blob } |
| The storage class of a SQLite value. More... | |
Functions | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::Allocate (Connection const &connection, Statement &stmt) noexcept |
Creates a statement state registered with connection's state. | |
| LIGHTWEIGHT_API void | Lightweight::Driver::Sqlite3::Free (Statement &stmt) noexcept |
Finalizes the prepared statement, unregisters the state from its connection and destroys it; leaves stmt empty. An orphaned state (its connection closed) is just destroyed; an empty stmt is left alone. | |
| LIGHTWEIGHT_API void | Lightweight::Driver::Sqlite3::Abandon (Statement &stmt) noexcept |
Gives up a statement whose connection session ended (the connection was closed or connected again), and leaves stmt empty. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::Prepare (Statement &stmt, std::string_view query, bool wideQueryText) |
Prepares query (sqlite3_prepare_v3), finalizing what the statement held before. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::Execute (Statement &stmt) noexcept |
| Executes the prepared statement with the bound parameters. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::ExecuteDirect (Statement &stmt, std::string_view query, bool wideQueryText) |
Runs the statements of query in order, each prepared and executed as Prepare and Execute do. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::Fetch (Statement &stmt) noexcept |
| Makes the next row the current one and runs the registered readers on it in column order. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::MoreResults (Statement &stmt) noexcept |
Moves to the next result set of an ExecuteDirect text: closes the current one and runs the pending rest of the text as ExecuteDirect runs a text. | |
| LIGHTWEIGHT_API void | Lightweight::Driver::Sqlite3::CloseCursor (Statement &stmt) noexcept |
Closes the cursor: resets the statement (bindings stay). The pending rest of an ExecuteDirect text stays pending, for MoreResults. Nothing on an orphaned statement. | |
| LIGHTWEIGHT_API void | Lightweight::Driver::Sqlite3::DiscardResults (Statement &stmt) noexcept |
Discards the pending results: resets the statement (bindings stay) and runs the pending rest of an ExecuteDirect text to its end or its first failing statement, dropping that failure (Diagnose keeps reporting what it reported before). Nothing on an orphaned statement, whose pending text was dropped unrun. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::UnbindColumns (Statement &stmt) noexcept |
Forgets every registered output reader (RegisterOutputReader). | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::ResetParameters (Statement &stmt) noexcept |
Clears the parameter bindings (sqlite3_clear_bindings): every parameter is NULL until bound again. | |
| LIGHTWEIGHT_API void | Lightweight::Driver::Sqlite3::ResetParameterArrays (Statement &stmt) noexcept |
| Nothing: this driver has no parameter arrays. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::NumResultColumns (Statement const &stmt, std::int16_t &count) noexcept |
The number of result columns of the prepared statement (sqlite3_column_count). | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::NumParameters (Statement const &stmt, std::int16_t &count) noexcept |
The number of parameters of the prepared statement (sqlite3_bind_parameter_count). | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::NumRowsAffected (Statement const &stmt, std::ptrdiff_t &count) noexcept |
| The number of rows the statement's last execution changed, known once that execution completed. | |
| LIGHTWEIGHT_API std::expected< SqlResultColumnType, SqlErrorInfo > | Lightweight::Driver::Sqlite3::ColumnType (Statement const &stmt, SqlColumnIndex column) |
The type of result column column. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::SetQueryTimeout (Statement &stmt, std::chrono::seconds timeout) noexcept |
| Accepts a query timeout and stores nothing: as on the ODBC SQLite path it is not enforced. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::QueryTimeout (Statement const &stmt, std::chrono::seconds &timeout) noexcept |
| The query timeout: always none. | |
| LIGHTWEIGHT_API SqlErrorInfo | Lightweight::Driver::Sqlite3::Diagnose (Statement const &stmt) |
| The diagnostics of the statement's last failure, captured in its state when the failing call returned (never read later from the connection, where another statement may have replaced it). | |
| LIGHTWEIGHT_API void | Lightweight::Driver::Sqlite3::RequireSuccess (Statement const &stmt, SqlResult result, std::source_location location=std::source_location::current()) |
Throws unless result is a success, as Driver::ClassifyResult decides from Diagnose: std::invalid_argument for 07009, SqlException for any other failure. | |
| ::Lightweight::Driver::CallOutcome | Lightweight::Driver::Sqlite3::CheckResult (Statement const &stmt, SqlResult result, std::source_location location) noexcept |
The non-throwing verdict on result; this driver has no fault seam, so nothing is ever injected. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::OpenCatalog (Statement const &stmt, SqlCatalogRequest const &request) noexcept |
Fails: this driver has no catalog functions (SqlSchema reads its catalog with the SQL of SqlQueryFormatter::CatalogQueries()). | |
| constexpr SqlResultColumnType | Lightweight::Driver::Sqlite3::CatalogColumnType (Statement const &stmt, int dataType) noexcept |
The type a catalog DATA_TYPE code stands for: none, since this driver opens no catalog result set. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::DescribeColumn (Statement const &stmt, SqlColumnIndex column, SqlColumnDescription &description) |
Describes result column column: its type as ColumnType reports it, and no column size (SQLite does not bound a column's values). | |
| constexpr std::optional< std::int16_t > | Lightweight::Driver::Sqlite3::DescribeResultColumnSqlType (Statement const &stmt, SqlColumnIndex column) noexcept |
The driver's SQL type code of result column column: none, since this driver's leaf binders read the storage class of the value instead and never ask. | |
| LIGHTWEIGHT_API std::size_t | Lightweight::Driver::Sqlite3::DeclaredBoundColumnSize (Statement const &stmt, SqlColumnIndex column, SqlOutputColumnLength length) noexcept |
The bound buffer size the declared length of result column column asks for: the default, since this driver fills a bound column afresh for every row and so never cuts a value off. | |
| LIGHTWEIGHT_API void | Lightweight::Driver::Sqlite3::ResetRowArrayAttributes (Statement &stmt) noexcept |
| Nothing: this driver has no row arrays. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::BindUtf16TextParameter (Statement &stmt, std::uint16_t parameter, char16_t *text, std::size_t columnSize, SqlIndicator &lengthIndicator) noexcept |
Binds UTF-16 text to parameter (as BindText16), read from text for lengthIndicator bytes. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::Fail (Statement &stmt, std::string_view sqlState, std::string_view message) noexcept |
| Records a failure the driver did not produce itself (a leaf binder's conversion error) as the statement's diagnostic, native error code 0. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::BindNull (Statement &stmt, SqlColumnIndex parameter) noexcept |
Binds SQL NULL to parameter; it counts as bound for Execute (bind unused numbered parameters this way). | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::BindInt64 (Statement &stmt, SqlColumnIndex parameter, std::int64_t value) noexcept |
Binds an integer to parameter, by value. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::BindDouble (Statement &stmt, SqlColumnIndex parameter, double value) noexcept |
Binds a floating-point number to parameter, by value. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::BindText (Statement &stmt, SqlColumnIndex parameter, std::string_view utf8) noexcept |
Binds UTF-8 text to parameter; an empty view binds empty text, never NULL. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::BindText16 (Statement &stmt, SqlColumnIndex parameter, std::u16string_view utf16) noexcept |
Binds UTF-16 text (native byte order) to parameter; referenced or copied as by BindText. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::BindBlob (Statement &stmt, SqlColumnIndex parameter, std::span< std::byte const > bytes) noexcept |
Binds bytes to parameter; referenced or copied as by BindText. Empty bytes bind an empty blob, never NULL. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::ReadInt64 (Statement &stmt, SqlColumnIndex column, std::int64_t &value, SqlIndicator *indicator) noexcept |
Reads result column column of the current row as an integer (SQLite converts other storage classes). | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::ReadDouble (Statement &stmt, SqlColumnIndex column, double &value, SqlIndicator *indicator) noexcept |
Reads result column column of the current row as a floating-point number; as ReadInt64. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::ReadText (Statement &stmt, SqlColumnIndex column, std::string_view &utf8, SqlIndicator *indicator) noexcept |
Reads result column column of the current row as UTF-8 text, without copying it. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::ReadText16 (Statement &stmt, SqlColumnIndex column, std::u16string_view &utf16, SqlIndicator *indicator) noexcept |
Reads result column column of the current row as UTF-16 text (native byte order), without copying it. | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::ReadBlob (Statement &stmt, SqlColumnIndex column, std::span< std::byte const > &bytes, SqlIndicator *indicator) noexcept |
Reads result column column of the current row as bytes, without copying them. | |
| constexpr SqlResultColumnType | Lightweight::Driver::Sqlite3::TypeOfStorageClass (StorageClass storageClass) noexcept |
The driver-neutral type of a value of storageClass, as ColumnType reports a column whose declared type does not name one: Integer is BigInt, Float Double, Text VarChar, Blob VarBinary, Null Unknown. | |
| LIGHTWEIGHT_API StorageClass | Lightweight::Driver::Sqlite3::ColumnStorageClass (Statement const &stmt, SqlColumnIndex column) noexcept |
The storage class of result column column's value in the row at hand (the pending or the current one). | |
| LIGHTWEIGHT_API std::string | Lightweight::Driver::Sqlite3::ExpandedSql (Statement const &stmt) |
The prepared SQL text with the values currently bound in place of the parameters (sqlite3_expanded_sql); unbound parameters read NULL. | |
| LIGHTWEIGHT_API std::string_view | Lightweight::Driver::Sqlite3::ColumnDeclaredType (Statement const &stmt, SqlColumnIndex column) noexcept |
The type result column column is declared with (sqlite3_column_decltype). | |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::RegisterOutputReader (Statement &stmt, SqlColumnIndex column, OutputReader reader, void *target, SqlIndicator *indicator) noexcept |
Registers reader as the reader of column, run on every row Fetch makes current. | |
| LIGHTWEIGHT_API SqlDataBinderCallback const & | Lightweight::Driver::Sqlite3::OutputReaderCallback () noexcept |
The binder callback the readers of RegisterOutputColumn hand to SqlDataBinder<T>::GetColumn. | |
| template<typename T > | |
| SqlResult | Lightweight::Driver::Sqlite3::RegisterOutputColumn (Statement &stmt, SqlColumnIndex column, T *result, SqlIndicator *indicator) noexcept |
Registers SqlDataBinder<T>::GetColumn as the reader of column, filling result on every row (what every leaf binder's OutputColumn calls). A NULL row leaves result holding T{} (for a type that has one: a disengaged optional, a NULL SqlVariant, 0, an empty string), never the previous row's value. | |
The statement operations of the SQLite3 driver: the statement half of the Lightweight::Driver::SqlDriver concept, and the typed bind and read functions the leaf data binders call instead of SQLite's own.
A Lightweight::Driver::Sqlite3::Statement is one pointer to a driver-owned StatementState (private State.hpp), registered with its connection's state. SQLite yields the first row on the first step; the driver hides that: Lightweight::Driver::Sqlite3::Execute keeps that row pending and the first Lightweight::Driver::Sqlite3::Fetch hands it out.
Every failure is captured in the statement's state when it happens, so Lightweight::Driver::Sqlite3::Diagnose reports the statement's own failure even after another statement of the same connection succeeded. A statement whose connection is closed (or not open yet) answers Error with SQLSTATE 08003 to every operation that returns a Lightweight::SqlResult.
Parameters and columns are 1-based throughout.
Definition in file Statement.hpp.
| using Lightweight::Driver::Sqlite3::OutputReader = typedef SqlResult (*)(Statement& stmt, SqlColumnIndex column, void* target, SqlIndicator* indicator) |
A registered reader: reads one column of the current row into the bound target.
Called by Fetch with the statement, the column, and the target and indicator it was registered with. It must store no pointer to anything but its target: the statement owning the handle may move.
Definition at line 541 of file Statement.hpp.
|
strong |
The storage class of a SQLite value.
| Enumerator | |
|---|---|
| Null | SQL NULL. |
| Integer | A signed integer of up to 8 bytes. |
| Float | An 8-byte IEEE floating-point number. |
| Text | Text. |
| Blob | Bytes, stored as given. |
Definition at line 467 of file Statement.hpp.
|
noexcept |
Creates a statement state registered with connection's state.
Works on a connection that is allocated but not connected yet: the statement then answers Error 08003 to everything until the connection is open. A stmt that already has a state keeps its memory, but is reset to a new statement's state — prepared statement finalized, readers, bindings, error and row forgotten — and registered with connection instead.
| connection | The connection; it must be allocated. |
| stmt | Receives the state. |
Success; Error when connection has no state or memory ran out (stmt is then unchanged). References Lightweight::Driver::Allocate().
|
noexcept |
Finalizes the prepared statement, unregisters the state from its connection and destroys it; leaves stmt empty. An orphaned state (its connection closed) is just destroyed; an empty stmt is left alone.
Statements of an ExecuteDirect text still pending are run first, as DiscardResults does, so freeing a statement whose text is not exhausted runs the rest of it rather than dropping it. A statement of it that fails stops the text; its diagnostics are reported to the SqlLogger (OnError), since this function returns nothing.
| stmt | The statement. |
References Lightweight::Driver::Free().
|
noexcept |
Gives up a statement whose connection session ended (the connection was closed or connected again), and leaves stmt empty.
Usually ending the session finalized the native statement and orphaned the state, which the statement still owns. The state may also still be attached to an open database (that of a moved-from SqlConnection, now owned by another): this is Free without running a pending ExecuteDirect text — the rest is dropped unrun, so nothing of the connection is touched.
| stmt | The statement; may be empty. |
References Lightweight::Driver::Abandon().
| LIGHTWEIGHT_API SqlResult Lightweight::Driver::Sqlite3::Prepare | ( | Statement & | stmt, |
| std::string_view | query, | ||
| bool | wideQueryText | ||
| ) |
Prepares query (sqlite3_prepare_v3), finalizing what the statement held before.
Statements of an earlier ExecuteDirect text still pending are run first, as DiscardResults does. Prepares exactly one statement, since a prepared statement has one parameter set: text holding a further statement after the first is Error 42000 ("Prepare() takes one statement"); blanks, comments and semicolons after it are not one. Text holding no statement at all prepares nothing and succeeds. SQLite stops parsing at a NUL character: text left after one is Error 42000 ("the SQL text holds a NUL character"). A statement with more than 32767 parameters or result columns (what the std::int16_t counts can report) is Error HY000. Registered output-column readers survive it, as SQLBindCol bindings do: the owner unbinds them (UnbindColumns).
| stmt | The statement. |
| query | The SQL text, UTF-8. |
| wideQueryText | Ignored: SQLite takes UTF-8. |
Success, or Error with the failure captured for Diagnose.
|
noexcept |
Executes the prepared statement with the bound parameters.
Resets a statement that was stepped, then steps once. A statement with result columns keeps the first row pending, for Fetch to hand out first. A statement without result columns runs to completion, records its change count (NumRowsAffected) and is reset.
Every parameter must have been bound since the bindings were last cleared, else Error 07002 naming the first unbound one (an unbound parameter is never a silent NULL; BindNull binds NULL on purpose). The bindings stay across executions, as on ODBC, until ResetParameters or the next prepare: a statement bound once executes again with the same values, and binding one parameter again changes only that one. The text and blob bytes bound to a statement without result columns are referenced, so they must stay alive and unchanged as long as the binding is executed; a statement with result columns copied them. A bind that fails leaves its parameter unbound. With numbered parameters SQLite counts up to the largest index (?5 alone is 5 parameters): every index up to it must be bound, gaps included (to NULL, say).
| stmt | The statement. |
Success (never NoData), or Error with the failure captured for Diagnose. | LIGHTWEIGHT_API SqlResult Lightweight::Driver::Sqlite3::ExecuteDirect | ( | Statement & | stmt, |
| std::string_view | query, | ||
| bool | wideQueryText | ||
| ) |
Runs the statements of query in order, each prepared and executed as Prepare and Execute do.
Statements of an earlier text still pending are run first, as DiscardResults does. A statement without result columns runs to completion at once; the first with result columns becomes the current result set and the rest of the text is kept (a copy the statement owns) for MoreResults. A failing statement stops the text: its error is returned and the statements after it do not run. The text takes no parameters: a statement of it that has some fails with 07002. Text holding no statement succeeds without executing anything. Text holding a NUL character fails with 42000 before any of it runs.
| stmt | The statement. |
| query | The SQL text, UTF-8: any number of statements. |
| wideQueryText | Ignored: SQLite takes UTF-8. |
Success, or Error with the failure captured for Diagnose.
|
noexcept |
Makes the next row the current one and runs the registered readers on it in column order.
The row Execute left pending comes first. A reader that fails stops the row: the result is Error, Diagnose reports the reader's diagnostic, and the row stays current, so its columns can still be read. A reader that throws (a binder running out of memory, a user's binder refusing a value) fails the same way: the exception is caught and kept as the diagnostic — a SqlException's own, HY001 for std::bad_alloc, HY000 with the message of any other exception — and the statement stays usable.
| stmt | The statement. |
Success on a row; NoData past the last row (and again on every further call); Error with 24000 when the statement has no result set, else with the failure captured for Diagnose.
|
noexcept |
Moves to the next result set of an ExecuteDirect text: closes the current one and runs the pending rest of the text as ExecuteDirect runs a text.
| stmt | The statement. |
Success when a further statement with result columns became current; NoData when the text is exhausted; Error when a statement of it failed (the statements after it do not run), and Error 08003 on a statement whose connection is closed. References Lightweight::Driver::MoreResults().
|
noexcept |
Closes the cursor: resets the statement (bindings stay). The pending rest of an ExecuteDirect text stays pending, for MoreResults. Nothing on an orphaned statement.
| stmt | The statement. |
References Lightweight::Driver::CloseCursor().
|
noexcept |
Discards the pending results: resets the statement (bindings stay) and runs the pending rest of an ExecuteDirect text to its end or its first failing statement, dropping that failure (Diagnose keeps reporting what it reported before). Nothing on an orphaned statement, whose pending text was dropped unrun.
| stmt | The statement. |
References Lightweight::Driver::DiscardResults().
|
noexcept |
Forgets every registered output reader (RegisterOutputReader).
| stmt | The statement. |
Success; Error 08003 on a statement whose connection is closed. References Lightweight::Driver::UnbindColumns().
|
noexcept |
Clears the parameter bindings (sqlite3_clear_bindings): every parameter is NULL until bound again.
| stmt | The statement. |
Success; Error 08003 on a statement whose connection is closed. References Lightweight::Driver::ResetParameters().
|
noexcept |
Nothing: this driver has no parameter arrays.
| stmt | The statement. |
References Lightweight::Driver::ResetParameterArrays().
|
noexcept |
The number of result columns of the prepared statement (sqlite3_column_count).
| stmt | The statement. |
| count | Receives the count; 0 when nothing is prepared. SQLite caps it at 32767. |
Success; Error 08003 on a statement whose connection is closed. References Lightweight::Driver::NumResultColumns().
|
noexcept |
The number of parameters of the prepared statement (sqlite3_bind_parameter_count).
| stmt | The statement. |
| count | Receives the count (the largest parameter index); 0 when nothing is prepared. Prepare refuses a statement with more than 32767 parameters, so it always fits. |
Success; Error 08003 on a statement whose connection is closed. References Lightweight::Driver::NumParameters().
|
noexcept |
The number of rows the statement's last execution changed, known once that execution completed.
A statement without result columns completes inside Execute. A statement with result columns completes when Execute or Fetch steps past its last row: an INSERT / UPDATE / DELETE with RETURNING has written all its rows on the first step, but SQLite reports the count only at completion, so it reads 0 until Fetch returned NoData. The count is sqlite3_changes64 when the connection's total change count moved during the execution, else 0: a DDL statement, transaction control, a PRAGMA or a SELECT reads 0, not the count of an earlier statement. After an ExecuteDirect text of several statements (and after MoreResults) it is the count of the last statement of the text that completed, also when a later statement of it failed.
| stmt | The statement. |
| count | Receives the count; 0 before the execution completed. |
Success; Error 08003 on a statement whose connection is closed. References Lightweight::Driver::NumRowsAffected().
| LIGHTWEIGHT_API std::expected< SqlResultColumnType, SqlErrorInfo > Lightweight::Driver::Sqlite3::ColumnType | ( | Statement const & | stmt, |
| SqlColumnIndex | column | ||
| ) |
The type of result column column.
A column declared with a type name the SQLite formatter emits has the type the SQLite ODBC driver reports for that name (the name is matched in any case, without its "(size)"; DECIMAL, GUID and the character types report WVarChar, TEXT WLongVarChar, REAL Double, BLOB Binary). Any other column (an expression, or a type name the table lacks) has the type of the storage class of its value in the row at hand (the pending or the current one): Integer is BigInt, Float Double, Text VarChar, Blob VarBinary, and Null (or no row at hand) Unknown.
| stmt | The statement. |
| column | The column. |
07009) or a closed connection (08003). References Lightweight::Driver::ColumnType().
|
noexcept |
Accepts a query timeout and stores nothing: as on the ODBC SQLite path it is not enforced.
| stmt | The statement. |
| timeout | The timeout. |
Success; Error 08003 on a statement whose connection is closed. References Lightweight::Driver::SetQueryTimeout().
|
noexcept |
The query timeout: always none.
| stmt | The statement. |
| timeout | Receives 0. |
Success; Error 08003 on a statement whose connection is closed. References Lightweight::Driver::QueryTimeout().
| LIGHTWEIGHT_API SqlErrorInfo Lightweight::Driver::Sqlite3::Diagnose | ( | Statement const & | stmt | ) |
The diagnostics of the statement's last failure, captured in its state when the failing call returned (never read later from the connection, where another statement may have replaced it).
| stmt | The statement. |
Prepare; 08003 for a statement without state. References Lightweight::Driver::Diagnose().
| LIGHTWEIGHT_API void Lightweight::Driver::Sqlite3::RequireSuccess | ( | Statement const & | stmt, |
| SqlResult | result, | ||
| std::source_location | location = std::source_location::current() |
||
| ) |
Throws unless result is a success, as Driver::ClassifyResult decides from Diagnose: std::invalid_argument for 07009, SqlException for any other failure.
| stmt | The statement result came from. |
| result | The result to check. |
| location | Where the check originated, for the message of std::invalid_argument. |
References Lightweight::Driver::RequireSuccess().
|
inlinenoexcept |
The non-throwing verdict on result; this driver has no fault seam, so nothing is ever injected.
| stmt | The statement result came from. |
| result | The result to check. |
| location | Where the check originated (unused). |
{ Succeeded(result), std::nullopt }. Definition at line 259 of file Statement.hpp.
References Lightweight::Driver::CheckResult(), and Lightweight::Driver::CallOutcome::succeeded.
|
noexcept |
Fails: this driver has no catalog functions (SqlSchema reads its catalog with the SQL of SqlQueryFormatter::CatalogQueries()).
| stmt | The statement. |
| request | The catalog function asked for (unused). |
Error, with the statement's diagnostics NotSupportedByDriver(SqlDriverId::Sqlite3, "catalog access") (SQLSTATE IM001); Error 08003 on a statement whose connection is closed. References Lightweight::Driver::OpenCatalog().
|
constexprnoexcept |
The type a catalog DATA_TYPE code stands for: none, since this driver opens no catalog result set.
| stmt | The statement (unused). |
| dataType | The code (unused). |
SqlResultColumnType::Unknown. Definition at line 278 of file Statement.hpp.
References Lightweight::Driver::CatalogColumnType().
| LIGHTWEIGHT_API SqlResult Lightweight::Driver::Sqlite3::DescribeColumn | ( | Statement const & | stmt, |
| SqlColumnIndex | column, | ||
| SqlColumnDescription & | description | ||
| ) |
Describes result column column: its type as ColumnType reports it, and no column size (SQLite does not bound a column's values).
| stmt | The statement. |
| column | The column. |
| description | Receives the description; left unchanged on failure. |
Success; Error with the diagnostics of ColumnType (07009, 08003). References Lightweight::Driver::DescribeColumn().
|
constexprnoexcept |
The driver's SQL type code of result column column: none, since this driver's leaf binders read the storage class of the value instead and never ask.
| stmt | The statement (unused). |
| column | The column (unused). |
std::nullopt. Definition at line 299 of file Statement.hpp.
References Lightweight::Driver::DescribeResultColumnSqlType().
|
noexcept |
The bound buffer size the declared length of result column column asks for: the default, since this driver fills a bound column afresh for every row and so never cuts a value off.
| stmt | The statement (unused). |
| column | The column (unused). |
| length | Which declared length (unused). |
detail::DefaultBoundColumnSize. References Lightweight::Driver::DeclaredBoundColumnSize().
|
noexcept |
Nothing: this driver has no row arrays.
| stmt | The statement. |
References Lightweight::Driver::ResetRowArrayAttributes().
|
noexcept |
Binds UTF-16 text to parameter (as BindText16), read from text for lengthIndicator bytes.
| stmt | The statement. |
| parameter | The parameter. |
| text | The text; must stay alive and unchanged as long as the binding is executed (see BindText). |
| columnSize | The declared column size (unused: SQLite does not bound a parameter's value). |
| lengthIndicator | The byte length of text, >= 0 only: ODBC's special lengths (SqlNullData, a NUL-terminated length) mean nothing here. |
BindText16; Error with SQLSTATE HY090 for a negative lengthIndicator, nothing bound.
|
noexcept |
Records a failure the driver did not produce itself (a leaf binder's conversion error) as the statement's diagnostic, native error code 0.
| stmt | The statement. |
| sqlState | The SQLSTATE. |
| message | The message. |
Error, so a binder can return Fail(stmt, "22003", "numeric value out of range");. References Lightweight::Driver::Sqlite3::Fail().
Referenced by Lightweight::Driver::Sqlite3::Fail().
|
noexcept |
Binds SQL NULL to parameter; it counts as bound for Execute (bind unused numbered parameters this way).
| stmt | The statement. |
| parameter | The parameter. |
Success, or Error (07009 for an out-of-range parameter) with the failure captured. References Lightweight::Driver::Sqlite3::BindNull().
Referenced by Lightweight::Driver::Sqlite3::BindNull().
|
noexcept |
Binds an integer to parameter, by value.
| stmt | The statement. |
| parameter | The parameter. |
| value | The value. |
Success, or Error (07009 for an out-of-range parameter) with the failure captured. References Lightweight::Driver::Sqlite3::BindInt64().
Referenced by Lightweight::Driver::Sqlite3::BindInt64().
|
noexcept |
Binds a floating-point number to parameter, by value.
| stmt | The statement. |
| parameter | The parameter. |
| value | The value. |
Success, or Error (07009 for an out-of-range parameter) with the failure captured. References Lightweight::Driver::Sqlite3::BindDouble().
Referenced by Lightweight::Driver::Sqlite3::BindDouble().
|
noexcept |
Binds UTF-8 text to parameter; an empty view binds empty text, never NULL.
On a statement without result columns the bytes are referenced, not copied: they must stay alive and unchanged as long as the binding is executed (until the parameter is bound again, ResetParameters or the next prepare). On a statement with result columns they are copied.
| stmt | The statement. |
| parameter | The parameter. |
| utf8 | The text; embedded NULs are kept. |
Success, or Error (07009 for an out-of-range parameter) with the failure captured. References Lightweight::Driver::Sqlite3::BindText().
Referenced by Lightweight::Driver::Sqlite3::BindText().
|
noexcept |
Binds UTF-16 text (native byte order) to parameter; referenced or copied as by BindText.
| stmt | The statement. |
| parameter | The parameter. |
| utf16 | The text; embedded NULs are kept. |
Success, or Error (07009 for an out-of-range parameter) with the failure captured. References Lightweight::Driver::Sqlite3::BindText16().
Referenced by Lightweight::Driver::Sqlite3::BindText16().
|
noexcept |
Binds bytes to parameter; referenced or copied as by BindText. Empty bytes bind an empty blob, never NULL.
| stmt | The statement. |
| parameter | The parameter. |
| bytes | The bytes. |
Success, or Error (07009 for an out-of-range parameter) with the failure captured. References Lightweight::Driver::Sqlite3::BindBlob().
Referenced by Lightweight::Driver::Sqlite3::BindBlob().
|
noexcept |
Reads result column column of the current row as an integer (SQLite converts other storage classes).
| stmt | The statement. |
| column | The column. |
| value | Receives the value; untouched for NULL. |
| indicator | Receives the byte length of the value, or SqlNullData for NULL; may be null unless the value is NULL. |
Success; Error with 07009 (column out of range), 24000 (no current row) or 22002 (NULL, but indicator is null). References Lightweight::Driver::Sqlite3::ReadInt64().
Referenced by Lightweight::Driver::Sqlite3::ReadInt64().
|
noexcept |
Reads result column column of the current row as a floating-point number; as ReadInt64.
| stmt | The statement. |
| column | The column. |
| value | Receives the value; untouched for NULL. |
| indicator | As for ReadInt64. |
ReadInt64. References Lightweight::Driver::Sqlite3::ReadDouble().
Referenced by Lightweight::Driver::Sqlite3::ReadDouble().
|
noexcept |
Reads result column column of the current row as UTF-8 text, without copying it.
The view points into SQLite's buffer: it stays valid until the statement is stepped (Fetch), reset (Execute, CloseCursor, ...) or finalized, or the same column is read as UTF-16 or as a blob.
| stmt | The statement. |
| column | The column. |
| utf8 | Receives the text, with its full length (embedded NULs kept); untouched for NULL. |
| indicator | As for ReadInt64; the byte length. |
ReadInt64; also Error HY001 when SQLite runs out of memory converting the value. References Lightweight::Driver::Sqlite3::ReadText().
Referenced by Lightweight::Driver::Sqlite3::ReadText().
|
noexcept |
Reads result column column of the current row as UTF-16 text (native byte order), without copying it.
The view points into SQLite's buffer, valid as long as that of ReadText (reading the column as UTF-8 ends it).
| stmt | The statement. |
| column | The column. |
| utf16 | Receives the text; untouched for NULL. |
| indicator | As for ReadInt64; the byte length (twice the code units). |
ReadText. References Lightweight::Driver::Sqlite3::ReadText16().
Referenced by Lightweight::Driver::Sqlite3::ReadText16().
|
noexcept |
Reads result column column of the current row as bytes, without copying them.
The span points into SQLite's buffer, valid as long as that of ReadText (reading the column as text ends it).
| stmt | The statement. |
| column | The column. |
| bytes | Receives the bytes; untouched for NULL. |
| indicator | As for ReadInt64; the byte length. |
ReadText. References Lightweight::Driver::Sqlite3::ReadBlob().
Referenced by Lightweight::Driver::Sqlite3::ReadBlob().
|
constexprnoexcept |
The driver-neutral type of a value of storageClass, as ColumnType reports a column whose declared type does not name one: Integer is BigInt, Float Double, Text VarChar, Blob VarBinary, Null Unknown.
| storageClass | The storage class. |
Definition at line 486 of file Statement.hpp.
References Lightweight::Driver::Sqlite3::TypeOfStorageClass().
Referenced by Lightweight::Driver::Sqlite3::TypeOfStorageClass().
|
noexcept |
The storage class of result column column's value in the row at hand (the pending or the current one).
| stmt | The statement. |
| column | The column. |
Null when there is no row at hand, the column is out of range or the connection is closed. References Lightweight::Driver::Sqlite3::ColumnStorageClass().
Referenced by Lightweight::Driver::Sqlite3::ColumnStorageClass().
| LIGHTWEIGHT_API std::string Lightweight::Driver::Sqlite3::ExpandedSql | ( | Statement const & | stmt | ) |
The prepared SQL text with the values currently bound in place of the parameters (sqlite3_expanded_sql); unbound parameters read NULL.
It reads every value currently bound. A parameter stays bound across executions until it is bound again, ResetParameters runs or another query is prepared, and on a statement without result columns text and blobs are bound by reference: every currently bound value must still be alive when this is called. That includes values bound by an SqlStatement::Execute(args...) or a batch, which may be gone once that call returned (the statement resets them only at the next bind by hand). A statement with result columns copied its values when they were bound. For tests of the driver; library code must not use it for logging (it would read the caller's values at a moment the caller does not control).
| stmt | The statement. |
References Lightweight::Driver::Sqlite3::ExpandedSql().
Referenced by Lightweight::Driver::Sqlite3::ExpandedSql().
|
noexcept |
The type result column column is declared with (sqlite3_column_decltype).
The view stays valid until the statement is stepped again (SQLite re-prepares a statement whose schema changed on its next step), prepared again or freed.
| stmt | The statement. |
| column | The column. |
References Lightweight::Driver::Sqlite3::ColumnDeclaredType().
Referenced by Lightweight::Driver::Sqlite3::ColumnDeclaredType().
|
noexcept |
Registers reader as the reader of column, run on every row Fetch makes current.
Registering a column again replaces its reader. The reader table grows here, never during a fetch.
| stmt | The statement. |
| column | The column; it is not checked against the prepared statement (a reader of a column the result set lacks fails when it reads, with 07009). |
| reader | The reader; null unregisters the column. |
| target | Handed to reader on every row. |
| indicator | Handed to reader on every row. |
Success; Error with 07009 for column 0, HY001 when memory ran out, 08003 on a statement whose connection is closed. References Lightweight::Driver::Sqlite3::RegisterOutputReader().
Referenced by Lightweight::Driver::Sqlite3::RegisterOutputColumn(), and Lightweight::Driver::Sqlite3::RegisterOutputReader().
|
noexcept |
The binder callback the readers of RegisterOutputColumn hand to SqlDataBinder<T>::GetColumn.
Answers ServerType() with SqlServerType::SQLITE and DriverName() with "sqlite3-native"; it refers to no statement.
References Lightweight::Driver::Sqlite3::OutputReaderCallback().
Referenced by Lightweight::Driver::Sqlite3::OutputReaderCallback().
|
noexcept |
Registers SqlDataBinder<T>::GetColumn as the reader of column, filling result on every row (what every leaf binder's OutputColumn calls). A NULL row leaves result holding T{} (for a type that has one: a disengaged optional, a NULL SqlVariant, 0, an empty string), never the previous row's value.
| stmt | The statement. |
| column | The column. |
| result | The bound target. |
| indicator | The bound indicator. |
RegisterOutputReader. Definition at line 598 of file Statement.hpp.
References Lightweight::Driver::Sqlite3::RegisterOutputColumn(), and Lightweight::Driver::Sqlite3::RegisterOutputReader().
Referenced by Lightweight::Driver::Sqlite3::RegisterOutputColumn().