6#include "../../Api.hpp"
7#include "../../SqlBindingTypes.hpp"
8#include "../../SqlConnectInfo.hpp"
9#include "../../SqlError.hpp"
10#include "../../SqlServerType.hpp"
13#include "SqlOdbcPrelude.hpp"
17#include <source_location>
34namespace Lightweight::Driver::Odbc
60[[nodiscard]] LIGHTWEIGHT_API std::expected<void, SqlErrorInfo>
Close(
Connection& connection,
61 CloseDiagnostic diagnostic)
noexcept;
85 return connection.dbc != SQL_NULL_HDBC;
172 std::source_location sourceLocation)
174 return detail::CheckOdbcConnectionCall(std::to_underlying(result), connection.
dbc, sourceLocation);
198[[nodiscard]] LIGHTWEIGHT_API ::Lightweight::detail::NarrowTextBinding NarrowTextBinding(
Connection const& connection,
199 SqlServerType serverType,
221 std::source_location location);
238 std::source_location location);
bool IsAllocated(ConnectionHandle const &connection) noexcept
Tells whether connection holds a driver connection (connected or not).
std::string ServerVersion(ConnectionHandle const &connection)
The version of the DBMS the connection is connected to.
std::expected< void, SqlErrorInfo > Connect(ConnectionHandle &handle, Info const &info, std::source_location location)
Connects handle from info through the enabled driver that connects from it.
bool TransactionActive(ConnectionHandle const &connection) noexcept
Tells whether a transaction is open, i.e. autocommit is off.
void Allocate(ConnectionHandle &connection) noexcept
Allocates the driver's connection resources, unless the connection already holds them.
SqlResult SetAutoCommit(ConnectionHandle &connection, bool enabled) noexcept
Switches autocommit mode on or off.
bool ReadsBoundColumnsAgain(ConnectionHandle const &connection) noexcept
Tells whether the connection's driver can read a bound output column again, so that a bound value lon...
std::string ServerName(ConnectionHandle const &connection)
The name of the DBMS the connection is connected to.
std::string DriverNameOf(ConnectionHandle const &connection, SqlConnectionString const &connectionString)
Names the driver a connect from connectionString reaches, without connecting (see ServerTypeFromDrive...
SqlResult SetIsolation(ConnectionHandle &connection, SqlIsolationMode mode) noexcept
Sets the transaction isolation level of the connection.
bool RollbackOpenTransaction(ConnectionHandle &connection) noexcept
Rolls back the open transaction and switches autocommit back on.
SqlErrorInfo LastError(ConnectionHandle const &connection)
Reads the connection's diagnostics: the first record its last failed call left.
SqlResult Disconnect(ConnectionHandle &connection) noexcept
Ends the connection's session, keeping its driver resources for the next connect.
SqlResult Commit(ConnectionHandle &connection) noexcept
Commits the open transaction.
std::string DriverName(ConnectionHandle const &connection)
The name of the driver (library) the connection runs on.
void RegisterTextEntry(ConnectionHandle const &connection, bool acceptsWideQueryText) noexcept
Records whether the connection's driver takes text through its wide entry points, where the driver ha...
std::string UserName(ConnectionHandle const &connection)
The name of the user the connection is logged in as.
std::expected< void, SqlErrorInfo > Close(ConnectionHandle &connection, CloseDiagnostic diagnostic) noexcept
Closes the connection: disconnects it, frees its driver resources and leaves connection empty,...
SqlResult Rollback(ConnectionHandle &connection) noexcept
Rolls back the open transaction.
bool AcceptsWideQueryText(ConnectionHandle const &connection) noexcept
Tells whether the connection's driver receives wide (UTF-16) query text unchanged.
bool TransactionsAllowed(ConnectionHandle const &connection) noexcept
Tells whether the data source supports transactions.
std::string DatabaseName(ConnectionHandle const &connection)
The name of the database in use.
CallOutcome CheckResult(StatementHandle const &statement, SqlResult result, std::source_location location)
The non-throwing, fault-seam-aware verdict on result.
bool IsAlive(ConnectionHandle const &connection) noexcept
Tells whether the driver still considers the connection alive.
LIGHTWEIGHT_API void RememberTextEntry(SqlConnectionString const &connectionString, bool acceptsWideQueryText) noexcept
Records, process-wide, whether the driver a connection string names accepts wide text,...
LIGHTWEIGHT_API SqlResult RestoreAutoCommitAfterRollback(Connection &connection) noexcept
Switches autocommit back on after SqlConnection::RollbackOpenTransaction() rolled back.
A database driver the library can be built with.
std::variant< SqlConnectionDataSource, SqlConnectionString, SqliteConnectInfo > SqlConnectInfo
What a connection is opened from: an ODBC data source, an ODBC connection string, or a SQLite databas...
Verdict of a non-throwing checked driver call, carrying the diagnostic that justifies a failure verdi...
The ODBC driver's connection handle struct.
SQLHDBC dbc
The native ODBC connection handle.
Represents a SQL error as reported by the database driver.