|
| LIGHTWEIGHT_API void | Lightweight::Driver::Sqlite3::Allocate (Connection &connection) noexcept |
| | Creates the connection's state, holding no database yet, unless connection already has one.
|
| |
| LIGHTWEIGHT_API std::expected< void, SqlErrorInfo > | Lightweight::Driver::Sqlite3::Close (Connection &connection, CloseDiagnostic diagnostic) noexcept |
| | Closes the connection and leaves connection empty; safe on an empty one.
|
| |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::Disconnect (Connection &connection) noexcept |
| | Ends the session of the connection, keeping its state for the next connect: finalizes the native statement of every statement still allocated on it, orphaning their states (they then fail with 08003), and closes the database.
|
| |
| bool | Lightweight::Driver::Sqlite3::IsAllocated (Connection const &connection) noexcept |
| | Tells whether connection has its state (connected or not).
|
| |
| LIGHTWEIGHT_API bool | Lightweight::Driver::Sqlite3::IsAlive (Connection const &connection) noexcept |
| | Tells whether a database is open; a native connection never dies on its own.
|
| |
| LIGHTWEIGHT_API SqlErrorInfo | Lightweight::Driver::Sqlite3::LastError (Connection const &connection) |
| | The last failure of a connection-level call.
|
| |
| LIGHTWEIGHT_API std::string | Lightweight::Driver::Sqlite3::ServerName (Connection const &connection) |
| | The name of the DBMS.
|
| |
| LIGHTWEIGHT_API std::string | Lightweight::Driver::Sqlite3::ServerVersion (Connection const &connection) |
| | The version of the DBMS: the SQLite library the driver is linked against.
|
| |
| LIGHTWEIGHT_API std::string | Lightweight::Driver::Sqlite3::DriverName (Connection const &connection) |
| | The name of the driver the connection runs on, as SqlConnection::DriverName() reports it (for ODBC, the driver library the driver manager loaded). Not Driver::Name ("SQLite3"), the kind of driver that error messages name.
|
| |
| LIGHTWEIGHT_API std::string | Lightweight::Driver::Sqlite3::DatabaseName (Connection const &connection) |
| | The database the connection was opened on.
|
| |
| LIGHTWEIGHT_API std::string | Lightweight::Driver::Sqlite3::UserName (Connection const &connection) |
| | The user the connection is logged in as; SQLite has no users.
|
| |
| LIGHTWEIGHT_API bool | Lightweight::Driver::Sqlite3::TransactionActive (Connection const &connection) noexcept |
| | Tells whether a transaction is open (sqlite3_get_autocommit is 0).
|
| |
| LIGHTWEIGHT_API bool | Lightweight::Driver::Sqlite3::TransactionsAllowed (Connection const &connection) noexcept |
| | Tells whether the data source supports transactions; SQLite always does.
|
| |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::SetAutoCommit (Connection &connection, bool enabled) noexcept |
| | Switches autocommit mode on or off: off begins a transaction (BEGIN, or adopts one that is open already), on commits it as Commit does.
|
| |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::Commit (Connection &connection) noexcept |
| | Commits the transaction SetAutoCommit began (COMMIT); nothing to do when none was begun.
|
| |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::Rollback (Connection &connection) noexcept |
| | Rolls back the open transaction (ROLLBACK); nothing to do when none is open, also when SQLite already rolled back the transaction SetAutoCommit began (see Commit). Ends the begun transaction either way.
|
| |
| LIGHTWEIGHT_API SqlResult | Lightweight::Driver::Sqlite3::SetIsolation (Connection &connection, SqlIsolationMode mode) noexcept |
| | Sets the transaction isolation level: SQLite transactions are serializable, which satisfies every standard level, so a valid one is accepted and nothing is issued.
|
| |
| LIGHTWEIGHT_API bool | Lightweight::Driver::Sqlite3::RollbackOpenTransaction (Connection &connection) noexcept |
| | Rolls back the open transaction (ROLLBACK), if one is open.
|
| |
| ::Lightweight::Driver::CallOutcome | Lightweight::Driver::Sqlite3::CheckResult (Connection const &connection, SqlResult result, std::source_location location) noexcept |
| | The non-throwing verdict on result of a call on connection; this driver has no fault seam, so nothing is ever injected.
|
| |
| LIGHTWEIGHT_API std::expected< std::string, SqlErrorInfo > | Lightweight::Driver::Sqlite3::SearchPatternEscape (Connection const &connection) |
| | Fails: this driver has no catalog functions, so no search pattern of theirs to escape (the dialect's SqlCatalogQueries::searchPatternEscape states the escape of the SQL catalog, see SqlQueryFormatter::CatalogQueries()).
|
| |
| LIGHTWEIGHT_API std::expected< void, SqlErrorInfo > | Lightweight::Driver::Sqlite3::Connect (Connection &connection, SqliteConnectInfo const &info, std::source_location location) |
| | Opens the database info names (sqlite3_open_v2), with extended result codes on.
|
| |
The connection and transaction operations of the SQLite3 driver: the connection half of the Lightweight::Driver::SqlDriver concept, plus connecting from a Lightweight::SqliteConnectInfo.
A Lightweight::Driver::Sqlite3::Connection is one pointer to a driver-owned ConnectionState (private State.hpp). Every failure of a connection-level call is kept in that state, as the diagnostics Lightweight::Driver::Sqlite3::LastError reports.
Definition in file Connection.hpp.
| LIGHTWEIGHT_API SqlResult Lightweight::Driver::Sqlite3::Commit |
( |
Connection & |
connection | ) |
|
|
noexcept |
Commits the transaction SetAutoCommit began (COMMIT); nothing to do when none was begun.
SQLite rolls a transaction back by itself when a statement in it fails with a conflict resolution of ROLLBACK (ON CONFLICT ROLLBACK, RAISE(ROLLBACK, ...) in a trigger) or with a full disk or an I/O error; the statements run after that run in autocommit mode, each committed on its own. A transaction that was begun but is not open any more is therefore not committed silently: Error with SQLSTATE 25000 ("invalid transaction state", which the retry classifiers take as permanent, as they take the SQLite ODBC driver's failure of that commit). Only a successful COMMIT ends the begun transaction: after any failed commit (this one, a busy database, a deferred foreign key) it stays begun, so a retried commit fails again instead of reporting success; Rollback ends it.
- Parameters
-
| connection | The connection. |
- Returns
Success, or Error with the failure kept for LastError; 08003 when the connection is not open.
References Lightweight::Driver::Commit().
| LIGHTWEIGHT_API std::expected< void, SqlErrorInfo > Lightweight::Driver::Sqlite3::Connect |
( |
Connection & |
connection, |
|
|
SqliteConnectInfo const & |
info, |
|
|
std::source_location |
location |
|
) |
| |
Opens the database info names (sqlite3_open_v2), with extended result codes on.
Closes a database the connection still has open first (as Close does, keeping the state: its statements are orphaned), and allocates the state if connection has none. Statements allocated while the connection was not open stay registered and become usable. The open flags map one to one onto SQLite's; a combination SQLite does not define (no access flag, both ReadOnly and ReadWrite, Create with ReadOnly, an unknown flag) is rejected with SQLSTATE HY024 before anything is opened, and so is any connect with HY000 when the SQLite library is built single-threaded (SQLITE_THREADSAFE=0). The SQLite settings of info (busy timeout, journal mode) are not applied here — SqlConnection applies them through the query formatter once connected, as it does on the ODBC path.
- Parameters
-
| connection | The connection. |
| info | The database and how to open it. |
| location | Where the connect originated (unused by this driver; the ODBC driver's fault seam needs it). |
- Returns
- Nothing on success; else the diagnostics of the failed open, which are also kept in the state so
LastError reports them after the failed native connection is closed.
References Lightweight::Driver::Connect().