Lightweight 0.20261105.1
Loading...
Searching...
No Matches
Concept.hpp
1// SPDX-License-Identifier: Apache-2.0
2
3#pragma once
4
5#include "../Api.hpp"
6#include "../SqlBindingTypes.hpp"
7#include "../SqlError.hpp"
8
9#include <chrono>
10#include <concepts>
11#include <cstddef>
12#include <cstdint>
13#include <expected>
14#include <optional>
15#include <source_location>
16#include <string>
17#include <string_view>
18#include <type_traits>
19
20namespace Lightweight
21{
22
23/// @brief Identifies one of the database drivers the library knows.
24///
25/// There is one enumerator per known driver, in every build: an id names a driver whether or not the build
26/// contains it (see the @c LIGHTWEIGHT_DRIVER_* compile definitions and @c Driver::IsEnabled), so code that
27/// merely identifies a driver needs no conditional compilation. Each has an explicit, fixed value, so a
28/// driver's id never depends on which drivers the build enables.
29enum class SqlDriverId : std::uint8_t
30{
31 /// The ODBC driver: every DBMS reached through an ODBC driver manager.
32 Odbc = 0,
33
34 /// The native SQLite3 driver: SQLite linked into the library, no ODBC driver manager involved.
35 Sqlite3 = 1,
36};
37
38/// @brief The SQLSTATE of an operation the driver a handle is bound to does not provide.
39///
40/// It is the state an ODBC driver manager reports for a function its driver lacks ("driver does not
41/// support this function"), so one check covers both (see @c IsNotSupportedByDriverError).
42inline constexpr std::string_view SqlStateNotSupportedByDriver = "IM001";
43
44/// @brief The parameter type code a driver reports for a parameter whose declared SQL type it cannot tell
45/// (see @c Driver::DescribeParameterTypes).
46///
47/// It is ODBC's @c SQL_UNKNOWN_TYPE, so the ODBC driver's codes need no translation; a driver that cannot
48/// describe parameters at all reports no codes rather than this one.
49inline constexpr std::int16_t SqlUnknownParameterType = 0;
50
51} // namespace Lightweight
52
53namespace Lightweight::Driver
54{
55
56/// @brief Whether closing a connection reads the driver's diagnostic of a disconnect it refuses.
57enum class CloseDiagnostic : std::uint8_t
58{
59 /// Read it: the connection was opened, so a refused disconnect leaves a session the caller reports.
60 Read,
61 /// Do not read it: the connection was never opened, and its refused disconnect only says so (ODBC's 08003
62 /// "connection not open"), which nobody reports.
63 Skip,
64};
65
66/// @brief Verdict of a non-throwing checked driver call, carrying the diagnostic that justifies a
67/// failure verdict whenever that failure was injected rather than real.
68///
69/// A bare @c bool is not enough here. When an installed fault source overrides a real success into a
70/// failure, the underlying driver call genuinely succeeded, so the handle holds no diagnostic records at
71/// all: a caller that recovers by *inspecting* the error (rather than merely branching on it) would read
72/// an empty or stale diagnostic off the handle and take the wrong recovery arm. Carrying the injected
73/// error alongside the verdict is what makes such an arm reachable from a test, which is the whole point
74/// of the seam.
76{
77 /// Whether the checked call should be treated as having succeeded.
78 bool succeeded {};
79
80 /// The injected diagnostic, engaged only when a fault source turned a real success into a failure.
81 /// Never engaged for a genuine failure — that one's diagnostic is on the handle, where the caller can
82 /// read it. Prefer @ref EffectiveError over branching on this directly.
83 std::optional<SqlErrorInfo> injectedError {};
84
85 /// @return @ref succeeded, so an outcome can be tested directly in an `if`.
86 [[nodiscard]] explicit constexpr operator bool() const noexcept
87 {
88 return succeeded;
89 }
90
91 /// @brief The diagnostic describing this failure, from whichever source actually has one.
92 ///
93 /// @param readFromHandle Invoked only when the failure was not injected, to read the real
94 /// handle's diagnostic (e.g. @c Driver::Diagnose or
95 /// @c SqlConnection::LastError). Deliberately lazy: reading
96 /// diagnostics off a handle is a driver round-trip, and there is
97 /// nothing to read when the failure was injected.
98 /// @return The injected diagnostic when there is one, otherwise @p readFromHandle's result.
99 template <typename ReadFromHandle>
100 requires std::is_invocable_r_v<SqlErrorInfo, ReadFromHandle const&>
101 [[nodiscard]] SqlErrorInfo EffectiveError(ReadFromHandle const& readFromHandle) const
102 {
103 return injectedError.has_value() ? *injectedError : readFromHandle();
104 }
105};
106
107/// @brief The error of an operation the driver a handle is bound to does not provide.
108/// @param driver The driver lacking the operation.
109/// @param operation The name of the operation, as the message shows it.
110/// @return SQLSTATE @ref SqlStateNotSupportedByDriver, native error code 0, and the message
111/// "<operation> is not supported by the <driver name> driver".
112[[nodiscard]] LIGHTWEIGHT_API SqlErrorInfo NotSupportedByDriver(SqlDriverId driver, std::string_view operation);
113
114/// @brief Decides how a failed result should surface, given the diagnostics already retrieved from the
115/// driver.
116///
117/// This is the error-handling *policy* of the library, split out from @c RequireSuccess so it can be
118/// exercised without a database: it performs no I/O and touches no handle, so a test drives it by
119/// constructing a @ref SqlErrorInfo - the approach `SqlErrorDetectionTests.cpp` already uses for the
120/// error-classification helpers.
121///
122/// @param result The result being classified.
123/// @param errorInfo The diagnostics corresponding to @p result.
124/// @return The action the caller should take.
125///
126/// @note Deliberately not @c constexpr: @ref SqlErrorInfo holds @c std::string members, so a call
127/// can never be a constant expression, and the keyword would only mislead.
128[[nodiscard]] LIGHTWEIGHT_API SqlFailureAction ClassifyResult(SqlResult result, SqlErrorInfo const& errorInfo) noexcept;
129
130/// @brief What a catalog call asks for: the ODBC catalog function and its arguments, in driver-neutral terms.
131///
132/// The result set a driver opens for it has the layout the ODBC specification gives that catalog function;
133/// a driver without catalog functions (@c HasCatalogFunctions is @c false) opens none and fails the call
134/// (see @ref OpenCatalog).
136{
137 /// @brief The catalog function.
138 enum class Kind : std::uint8_t
139 {
140 Tables, //!< the tables of a catalog and schema, narrowed to a table name search pattern
141 Columns, //!< every column of a table
142 PrimaryKeys, //!< the primary key of a table
143 ForeignKeys, //!< the foreign keys between a primary-key table and a foreign-key table
144 Statistics, //!< the indexes of a table
145 };
146
147 /// The catalog function to open.
149 /// The catalog (database) name; empty for none. For @c ForeignKeys: of the primary-key table.
150 std::string_view catalog;
151 /// The schema name, or for @c Tables and @c Columns a search pattern; empty for none. For @c ForeignKeys: of the
152 /// primary-key table.
153 std::string_view schema;
154 /// The table name, or for @c Tables and @c Columns a search pattern; empty for all tables (@c Tables) or for an
155 /// open side (@c ForeignKeys). For @c ForeignKeys: the primary-key table.
156 std::string_view table;
157 /// @c ForeignKeys only: the catalog name of the foreign-key table; empty for none.
158 std::string_view foreignCatalog;
159 /// @c ForeignKeys only: the schema name of the foreign-key table; empty for none.
160 std::string_view foreignSchema;
161 /// @c ForeignKeys only: the name of the foreign-key table; empty for any.
162 std::string_view foreignTable;
163 /// @c Statistics only: whether to report the unique indexes only.
164 bool uniqueOnly = false;
165 /// Whether the driver is to receive the text as UTF-16 (see SqlConnection::AcceptsWideQueryText()); a driver
166 /// taking UTF-8 only ignores it.
167 bool wideText = false;
168};
169
170/// @brief What a driver reports about a result column (see @ref DescribeColumn).
172{
173 /// The column's type, @c SqlResultColumnType::Unknown for one without an enumerator.
174 SqlResultColumnType type = SqlResultColumnType::Unknown;
175
176 /// The column size (maximum character count for character columns); 0 when the driver cannot bound it.
177 std::size_t columnSize = 0;
178};
179
180/// @brief A per-driver handle struct: plain data the tagged handles store verbatim.
181///
182/// A driver handle struct is a handle: it is trivially copyable, copies alias one native resource, and every
183/// piece of mutable driver state lives behind the native handle, never in the struct. That is what makes the
184/// copies the library takes correct — deferred binder callbacks capture the struct by value (a reference would
185/// dangle once the owning @c SqlStatement is moved), and a cursor keeps its own copy — while the owning
186/// @c SqlStatement / @c SqlConnection, which frees the native resource, is never copied. A driver that cached
187/// state in the struct would see each copy diverge.
188///
189/// It is trivially copyable, so storing and moving it costs no more than its bytes, and equality
190/// comparable, so a handle can tell whether it holds anything: a value-initialized struct holds nothing.
191template <typename H>
193 std::default_initializable<H> && std::is_trivially_copyable_v<H> && std::equality_comparable<H>;
194
195/// @brief The statement operations a driver provides, as free functions found by argument-dependent
196/// lookup on its statement handle struct.
197///
198/// Each returns the driver's result code rather than throwing, so the caller decides how to check it;
199/// @c Diagnose, @c RequireSuccess and @c CheckResult are the driver's ways of checking one.
200///
201/// Catalog access is part of it, so that the schema reader compiles against every driver without naming one:
202/// @c OpenCatalog opens the result set of a @ref Lightweight::Driver::SqlCatalogRequest in ODBC's catalog layout, and
203/// @c CatalogColumnType reads that layout's type codes. A driver without catalog functions
204/// (@c HasCatalogFunctions is @c false) implements both with the one "not supported by this driver" error
205/// (SQLSTATE @c IM001) and the type @c Unknown; SqlSchema never calls them on it, since it reads that driver's
206/// catalog with the SQL of @c SqlQueryFormatter::CatalogQueries(). Likewise each operation a driver has no data
207/// for answers with that error or the stated neutral value (no SQL type code, the default bound size, nothing
208/// to reset), never by being absent: shared code calls every operation unconditionally.
209template <typename D>
210concept SqlDriverStatementOperations = requires(D::Statement& stmt,
211 D::Statement const& constStmt,
212 D::Connection const& connection,
213 std::string_view query,
214 bool wideQueryText,
215 SqlColumnIndex column,
216 std::int16_t& count,
217 std::ptrdiff_t& rowCount,
218 std::chrono::seconds timeout,
219 std::chrono::seconds& timeoutOut,
220 SqlResult result,
221 std::source_location location,
222 SqlCatalogRequest const& catalogRequest,
223 int catalogDataType,
224 SqlColumnDescription& description,
225 SqlOutputColumnLength length,
226 std::uint16_t parameter,
227 char16_t* utf16Text,
228 std::size_t columnSize,
229 SqlIndicator& lengthIndicator) {
230 { Allocate(connection, stmt) } -> std::same_as<SqlResult>;
231 { Free(stmt) } -> std::same_as<void>;
232 { Abandon(stmt) } -> std::same_as<void>;
233 { Prepare(stmt, query, wideQueryText) } -> std::same_as<SqlResult>;
234 { Execute(stmt) } -> std::same_as<SqlResult>;
235 { ExecuteDirect(stmt, query, wideQueryText) } -> std::same_as<SqlResult>;
236 { Fetch(stmt) } -> std::same_as<SqlResult>;
237 { MoreResults(stmt) } -> std::same_as<SqlResult>;
238 { CloseCursor(stmt) } -> std::same_as<void>;
239 { DiscardResults(stmt) } -> std::same_as<void>;
240 { UnbindColumns(stmt) } -> std::same_as<SqlResult>;
241 { ResetParameters(stmt) } -> std::same_as<SqlResult>;
242 { ResetParameterArrays(stmt) } -> std::same_as<void>;
243 { NumResultColumns(constStmt, count) } -> std::same_as<SqlResult>;
244 { NumParameters(constStmt, count) } -> std::same_as<SqlResult>;
245 { NumRowsAffected(constStmt, rowCount) } -> std::same_as<SqlResult>;
246 { ColumnType(constStmt, column) } -> std::same_as<std::expected<SqlResultColumnType, SqlErrorInfo>>;
247 { SetQueryTimeout(stmt, timeout) } -> std::same_as<SqlResult>;
248 { QueryTimeout(constStmt, timeoutOut) } -> std::same_as<SqlResult>;
249 { Diagnose(constStmt) } -> std::same_as<SqlErrorInfo>;
250 { RequireSuccess(constStmt, result, location) } -> std::same_as<void>;
251 { CheckResult(constStmt, result, location) } -> std::same_as<CallOutcome>;
252 { OpenCatalog(constStmt, catalogRequest) } -> std::same_as<SqlResult>;
253 { CatalogColumnType(constStmt, catalogDataType) } -> std::same_as<SqlResultColumnType>;
254 { DescribeColumn(constStmt, column, description) } -> std::same_as<SqlResult>;
255 { DescribeResultColumnSqlType(constStmt, column) } -> std::same_as<std::optional<std::int16_t>>;
256 { DeclaredBoundColumnSize(constStmt, column, length) } -> std::same_as<std::size_t>;
257 { ResetRowArrayAttributes(stmt) } -> std::same_as<void>;
258 { BindUtf16TextParameter(stmt, parameter, utf16Text, columnSize, lengthIndicator) } -> std::same_as<SqlResult>;
259};
260
261/// @brief The connection and transaction operations a driver provides, as free functions found by
262/// argument-dependent lookup on its connection handle struct.
263///
264/// Establishing a connection is not part of it: what a connection is opened from differs per driver.
265/// Operations that can fail return the driver's result code rather than throwing, so the caller decides
266/// how to check it.
267template <typename D>
268concept SqlDriverConnectionOperations = requires(D::Connection& connection,
269 D::Connection const& constConnection,
270 bool enabled,
271 SqlIsolationMode isolationMode,
272 CloseDiagnostic closeDiagnostic,
273 SqlResult result,
274 std::source_location location) {
275 { Allocate(connection) } -> std::same_as<void>;
276 { Close(connection, closeDiagnostic) } -> std::same_as<std::expected<void, SqlErrorInfo>>;
277 { Disconnect(connection) } -> std::same_as<SqlResult>;
278 { IsAllocated(constConnection) } -> std::same_as<bool>;
279 { IsAlive(constConnection) } -> std::same_as<bool>;
280 { LastError(constConnection) } -> std::same_as<SqlErrorInfo>;
281 { ServerName(constConnection) } -> std::same_as<std::string>;
282 { ServerVersion(constConnection) } -> std::same_as<std::string>;
283 { DriverName(constConnection) } -> std::same_as<std::string>;
284 { DatabaseName(constConnection) } -> std::same_as<std::string>;
285 { UserName(constConnection) } -> std::same_as<std::string>;
286 { TransactionActive(constConnection) } -> std::same_as<bool>;
287 { TransactionsAllowed(constConnection) } -> std::same_as<bool>;
288 { SetAutoCommit(connection, enabled) } -> std::same_as<SqlResult>;
289 { Commit(connection) } -> std::same_as<SqlResult>;
290 { Rollback(connection) } -> std::same_as<SqlResult>;
291 { SetIsolation(connection, isolationMode) } -> std::same_as<SqlResult>;
292 { RollbackOpenTransaction(connection) } -> std::same_as<bool>;
293 { CheckResult(constConnection, result, location) } -> std::same_as<CallOutcome>;
294 { SearchPatternEscape(constConnection) } -> std::same_as<std::expected<std::string, SqlErrorInfo>>;
295};
296
297/// @brief A database driver the library can be built with.
298///
299/// A driver names its statement and connection handle structs, its @c SqlDriverId, its display
300/// @c Name (as error messages show it) and its capabilities, and provides the
301/// @c SqlDriverStatementOperations and the @c SqlDriverConnectionOperations. The capabilities are
302/// compile-time constants:
303/// - @c SupportsParameterArrays: whether a statement can execute a whole column-major or row-wise parameter
304/// array in one call (native batch execution).
305/// - @c SupportsRowArrayFetch: whether a statement can fetch a block of rows into array-bound columns in one
306/// call (block fetch and transparent prefetch).
307/// - @c StatementsDieWithConnection: whether closing a connection destroys its statement handles, so that they
308/// must not be freed afterwards.
309/// - @c TranscodesNarrowText: whether the driver may pass narrow text through a client codepage, so that
310/// whether narrow text round-trips byte-exact depends on the backend (see
311/// @c SqlConnection::RoundTripsNarrowTextByteExact); a driver exchanging narrow text as UTF-8 says @c false.
312/// - @c HasCatalogFunctions: whether the driver reads a database's catalog with catalog functions of its own (ODBC's
313/// @c SQLTables, @c SQLColumns, ...); a driver without says @c false, and SqlSchema reads the catalog with the SQL
314/// of @c SqlQueryFormatter::CatalogQueries().
315template <typename D>
316concept SqlDriver =
317 requires {
318 typename D::Statement;
319 typename D::Connection;
320 { D::Id } -> std::convertible_to<SqlDriverId>;
321 { D::Name } -> std::convertible_to<std::string_view>;
322 { D::SupportsParameterArrays } -> std::convertible_to<bool>;
323 { D::SupportsRowArrayFetch } -> std::convertible_to<bool>;
324 { D::StatementsDieWithConnection } -> std::convertible_to<bool>;
325 { D::TranscodesNarrowText } -> std::convertible_to<bool>;
326 { D::HasCatalogFunctions } -> std::convertible_to<bool>;
329
330} // namespace Lightweight::Driver
bool IsAllocated(ConnectionHandle const &connection) noexcept
Tells whether connection holds a driver connection (connected or not).
Definition Dispatch.hpp:597
std::string ServerVersion(ConnectionHandle const &connection)
The version of the DBMS the connection is connected to.
Definition Dispatch.hpp:641
void ResetParameterArrays(StatementHandle &statement) noexcept
Restores single-row parameter binding after a parameter-array execution. Not reported.
Definition Dispatch.hpp:402
void CloseCursor(StatementHandle &statement) noexcept
Closes the cursor of a result set that was read to its end. Pending result sets are left alone.
Definition Dispatch.hpp:371
SqlResult UnbindColumns(StatementHandle &statement) noexcept
Unbinds every bound result column.
Definition Dispatch.hpp:387
bool TransactionActive(ConnectionHandle const &connection) noexcept
Tells whether a transaction is open, i.e. autocommit is off.
Definition Dispatch.hpp:673
std::optional< std::int16_t > DescribeResultColumnSqlType(StatementHandle const &statement, SqlColumnIndex column) noexcept
The driver's own SQL type code of a result column, as the driver's leaf binders read it (see SqlDataB...
Definition Dispatch.hpp:535
void Allocate(ConnectionHandle &connection) noexcept
Allocates the driver's connection resources, unless the connection already holds them.
Definition Dispatch.hpp:569
void RequireSuccess(StatementHandle const &statement, SqlResult result, std::source_location location=std::source_location::current())
Throws unless result indicates success: std::invalid_argument for a soft failure the caller is expect...
Definition Dispatch.hpp:477
SqlResult SetAutoCommit(ConnectionHandle &connection, bool enabled) noexcept
Switches autocommit mode on or off.
Definition Dispatch.hpp:690
SqlResult NumResultColumns(StatementHandle const &statement, std::int16_t &count) noexcept
Reports the number of columns of the current result set.
Definition Dispatch.hpp:411
std::string ServerName(ConnectionHandle const &connection)
The name of the DBMS the connection is connected to.
Definition Dispatch.hpp:633
SqlResult SetQueryTimeout(StatementHandle &statement, std::chrono::seconds timeout) noexcept
Sets the query timeout of the statement.
Definition Dispatch.hpp:449
void DiscardResults(StatementHandle &statement) noexcept
Drains every pending result set and closes the cursor, so the handle can run another query....
Definition Dispatch.hpp:379
void Free(StatementHandle &statement) noexcept
Frees the statement's driver handle and leaves statement empty, bound to the same driver.
Definition Dispatch.hpp:285
SqlResult OpenCatalog(StatementHandle const &statement, SqlCatalogRequest const &request)
Opens the catalog result set request names on statement, in the layout the ODBC specification gives t...
Definition Dispatch.hpp:502
SqlResult NumParameters(StatementHandle const &statement, std::int16_t &count) noexcept
Reports the number of parameters of the prepared statement.
Definition Dispatch.hpp:420
SqlResultColumnType CatalogColumnType(StatementHandle const &statement, int dataType) noexcept
The type a DATA_TYPE code of the driver's catalog result sets (see OpenCatalog) stands for.
Definition Dispatch.hpp:512
SqlResult SetIsolation(ConnectionHandle &connection, SqlIsolationMode mode) noexcept
Sets the transaction isolation level of the connection.
Definition Dispatch.hpp:715
SqlResult QueryTimeout(StatementHandle const &statement, std::chrono::seconds &timeout) noexcept
Reports the query timeout of the statement.
Definition Dispatch.hpp:458
void ResetRowArrayAttributes(StatementHandle &statement) noexcept
Restores single-row fetching after a row-array fetch. Not reported; nothing for a driver without row ...
Definition Dispatch.hpp:558
SqlResult NumRowsAffected(StatementHandle const &statement, std::ptrdiff_t &count) noexcept
Reports the number of rows the last executed statement affected.
Definition Dispatch.hpp:429
void Abandon(StatementHandle &statement) noexcept
Gives up the statement's driver handle after its connection session ended, and leaves statement empty...
Definition Dispatch.hpp:294
bool RollbackOpenTransaction(ConnectionHandle &connection) noexcept
Rolls back the open transaction and switches autocommit back on.
Definition Dispatch.hpp:723
SqlErrorInfo LastError(ConnectionHandle const &connection)
Reads the connection's diagnostics: the first record its last failed call left.
Definition Dispatch.hpp:613
std::size_t DeclaredBoundColumnSize(StatementHandle const &statement, SqlColumnIndex column, SqlOutputColumnLength length) noexcept
The declared length of a result column as a bound buffer size (see SqlDataBinderCallback::MinimumOutp...
Definition Dispatch.hpp:548
SqlResult Disconnect(ConnectionHandle &connection) noexcept
Ends the connection's session, keeping its driver resources for the next connect.
Definition Dispatch.hpp:589
SqlResult Commit(ConnectionHandle &connection) noexcept
Commits the open transaction.
Definition Dispatch.hpp:698
SqlErrorInfo Diagnose(StatementHandle const &statement)
Reads the statement's diagnostics: the first record its last failed call left.
Definition Dispatch.hpp:466
std::string DriverName(ConnectionHandle const &connection)
The name of the driver (library) the connection runs on.
Definition Dispatch.hpp:649
SqlResult DescribeColumn(StatementHandle const &statement, SqlColumnIndex column, SqlColumnDescription &description)
Describes a result column: its type and its size.
Definition Dispatch.hpp:522
SqlResult ResetParameters(StatementHandle &statement) noexcept
Drops every parameter binding.
Definition Dispatch.hpp:395
std::expected< SqlResultColumnType, SqlErrorInfo > ColumnType(StatementHandle const &statement, SqlColumnIndex column)
The SQL data type of a result column, as the driver describes it.
Definition Dispatch.hpp:439
std::string UserName(ConnectionHandle const &connection)
The name of the user the connection is logged in as.
Definition Dispatch.hpp:665
std::expected< void, SqlErrorInfo > Close(ConnectionHandle &connection, CloseDiagnostic diagnostic) noexcept
Closes the connection: disconnects it, frees its driver resources and leaves connection empty,...
Definition Dispatch.hpp:580
SqlResult Rollback(ConnectionHandle &connection) noexcept
Rolls back the open transaction.
Definition Dispatch.hpp:706
SqlResult MoreResults(StatementHandle &statement) noexcept
Advances to the next pending result set.
Definition Dispatch.hpp:364
bool TransactionsAllowed(ConnectionHandle const &connection) noexcept
Tells whether the data source supports transactions.
Definition Dispatch.hpp:681
std::string DatabaseName(ConnectionHandle const &connection)
The name of the database in use.
Definition Dispatch.hpp:657
CallOutcome CheckResult(StatementHandle const &statement, SqlResult result, std::source_location location)
The non-throwing, fault-seam-aware verdict on result.
Definition Dispatch.hpp:489
bool IsAlive(ConnectionHandle const &connection) noexcept
Tells whether the driver still considers the connection alive.
Definition Dispatch.hpp:605
The connection and transaction operations a driver provides, as free functions found by argument-depe...
Definition Concept.hpp:268
A per-driver handle struct: plain data the tagged handles store verbatim.
Definition Concept.hpp:192
The statement operations a driver provides, as free functions found by argument-dependent lookup on i...
Definition Concept.hpp:210
A database driver the library can be built with.
Definition Concept.hpp:316
@ Execute
The execution of a prepared statement (SqlStatement::Execute).
@ ExecuteDirect
The execution of a one-shot statement (SqlStatement::ExecuteDirect).
@ Prepare
The preparation of a statement (SqlStatement::Prepare).
Verdict of a non-throwing checked driver call, carrying the diagnostic that justifies a failure verdi...
Definition Concept.hpp:76
SqlErrorInfo EffectiveError(ReadFromHandle const &readFromHandle) const
The diagnostic describing this failure, from whichever source actually has one.
Definition Concept.hpp:101
std::optional< SqlErrorInfo > injectedError
Definition Concept.hpp:83
bool succeeded
Whether the checked call should be treated as having succeeded.
Definition Concept.hpp:78
What a catalog call asks for: the ODBC catalog function and its arguments, in driver-neutral terms.
Definition Concept.hpp:136
@ Tables
the tables of a catalog and schema, narrowed to a table name search pattern
@ PrimaryKeys
the primary key of a table
@ ForeignKeys
the foreign keys between a primary-key table and a foreign-key table
std::string_view foreignTable
ForeignKeys only: the name of the foreign-key table; empty for any.
Definition Concept.hpp:162
Kind kind
The catalog function to open.
Definition Concept.hpp:148
std::string_view catalog
The catalog (database) name; empty for none. For ForeignKeys: of the primary-key table.
Definition Concept.hpp:150
std::string_view foreignCatalog
ForeignKeys only: the catalog name of the foreign-key table; empty for none.
Definition Concept.hpp:158
bool uniqueOnly
Statistics only: whether to report the unique indexes only.
Definition Concept.hpp:164
std::string_view foreignSchema
ForeignKeys only: the schema name of the foreign-key table; empty for none.
Definition Concept.hpp:160
What a driver reports about a result column (see DescribeColumn).
Definition Concept.hpp:172
std::size_t columnSize
The column size (maximum character count for character columns); 0 when the driver cannot bound it.
Definition Concept.hpp:177
SqlResultColumnType type
The column's type, SqlResultColumnType::Unknown for one without an enumerator.
Definition Concept.hpp:174
Represents a SQL error as reported by the database driver.
Definition SqlError.hpp:29