|
KiCad PCB EDA Suite
|
A read-only source of tables. More...
#include <database_backend.h>
Public Member Functions | |
| virtual | ~DATABASE_BACKEND ()=default |
| virtual bool | Connect ()=0 |
| virtual void | Disconnect ()=0 |
| virtual bool | IsConnected () const =0 |
| virtual bool | ListTables (std::vector< std::string > &aTables)=0 |
| Lists the tables and views, sorted by name. | |
| virtual std::optional< DB_TABLE_INFO > | DescribeTable (const std::string &aTable)=0 |
| virtual bool | ListColumns (const std::string &aTable, std::vector< std::string > &aColumns) |
| Lists the column names of a table as the catalog reports them, empty if it has none, false if the catalog failed. | |
| virtual bool | ReadTable (const DB_TABLE_INFO &aTable, const std::vector< std::string > &aColumns, size_t aMaxRows, std::vector< std::string > &aLabels, const DB_ROW_SINK &aSink)=0 |
| Reads rows of a table, handing each to aSink. | |
| virtual bool | ReadAllRows (const DB_TABLE_INFO &aTable, const std::vector< std::string > &aColumns, std::vector< std::string > &aLabels, const DB_ROW_SINK &aSink, const DB_RESTART_SINK &aRestart) |
| Reads every row of a table for a caller that keeps them, handing each to aSink. | |
| virtual void | BeginLoadCycle (const DB_STOP_CHECK &aStopped) |
| Brackets a load cycle, in which the caller reads each table once. | |
| virtual void | EndLoadCycle () |
| virtual std::optional< bool > | ReadRow (const DB_TABLE_INFO &aTable, const std::vector< std::string > &aColumns, const std::string &aKeyColumn, const std::string &aKey, std::vector< std::string > &aLabels, std::vector< DB_VALUE > &aRow) |
| Reads the one row whose key column equals aKey, using an indexed lookup if the backend has one. | |
| virtual std::string | GetLastError () const =0 |
| virtual DB_FAILURE | GetLastFailure () const =0 |
Static Public Member Functions | |
| static DB_BACKEND_RESULT | Create (const DATABASE_SOURCE &aSource, const wxString &aBasePath) |
| Builds the backend for a source. | |
Static Public Attributes | |
| static constexpr size_t | ALL_ROWS = std::numeric_limits<size_t>::max() |
| Passed as ReadTable()'s row limit to read every row. | |
A read-only source of tables.
DATABASE_CONNECTION owns one and supplies the locking, row cache, column matching and conversion to text, so a backend only talks to its database. A backend is never called from two threads at once.
Definition at line 102 of file database_backend.h.
|
virtualdefault |
|
inlinevirtual |
Brackets a load cycle, in which the caller reads each table once.
A backend may keep what it opens for the cycle's reads until the cycle ends. Cycles may nest, and only the outermost begin and end count. Nesting is backend-wide and may cross threads, as when a lookup on one thread reads a table while a refresh on another has a cycle open. The nested read keeps the stop check and sessions of the outermost cycle.
| aStopped | may be empty; a backend that retries a read gives up when it returns true |
Reimplemented in ACE_BACKEND.
Definition at line 161 of file database_backend.h.
|
pure virtual |
Implemented in ACE_BACKEND, ODBC_BACKEND, and SQLITE_BACKEND.
|
static |
Builds the backend for a source.
| aSource | the source as configured; ${CWD} is expanded in its connection string and path |
| aBasePath | the directory ${CWD} stands for |
Definition at line 34 of file database_backend.cpp.
References _, ACCESS, DATABASE_SOURCE::Expanded(), INVALID, INVALID_TYPE, ACE_BACKEND::MISSING, NOT_SUPPORTED_ON_PLATFORM, ODBC, PROVIDER_MISSING, ACE_BACKEND::ProviderMissingMessage(), ACE_BACKEND::ProviderState(), source, SQLITE, UNKNOWN, and utf8().
Referenced by SCH_IO_DATABASE::connectOnce(), and SCH_IO_DATABASE::CreateConnection().
|
pure virtual |
Implemented in ACE_BACKEND, ODBC_BACKEND, and SQLITE_BACKEND.
Referenced by ListColumns().
|
pure virtual |
Implemented in ACE_BACKEND, ODBC_BACKEND, and SQLITE_BACKEND.
|
inlinevirtual |
Reimplemented in ACE_BACKEND.
Definition at line 163 of file database_backend.h.
|
pure virtual |
Implemented in ACE_BACKEND, ODBC_BACKEND, and SQLITE_BACKEND.
Referenced by ListColumns().
|
pure virtual |
Implemented in ACE_BACKEND, ODBC_BACKEND, and SQLITE_BACKEND.
|
pure virtual |
Implemented in ACE_BACKEND, ODBC_BACKEND, and SQLITE_BACKEND.
|
virtual |
Lists the column names of a table as the catalog reports them, empty if it has none, false if the catalog failed.
Reimplemented in ODBC_BACKEND.
Definition at line 71 of file database_backend.cpp.
References DescribeTable(), GetLastError(), info, and DB_COLUMN::name.
|
pure virtual |
Lists the tables and views, sorted by name.
Implemented in ACE_BACKEND, ODBC_BACKEND, and SQLITE_BACKEND.
|
inlinevirtual |
Reads every row of a table for a caller that keeps them, handing each to aSink.
A backend that checks one read against another may deliver the table more than once, and calls aRestart before every delivery after the first, so the caller drops the rows it already took. The default reads once.
| aLabels | is filled with the result-column labels before each delivery's first call to aSink |
Reimplemented in ACE_BACKEND.
Definition at line 146 of file database_backend.h.
References ALL_ROWS, and ReadTable().
|
inlinevirtual |
Reads the one row whose key column equals aKey, using an indexed lookup if the backend has one.
Reimplemented in ODBC_BACKEND.
Definition at line 170 of file database_backend.h.
|
pure virtual |
Reads rows of a table, handing each to aSink.
| aColumns | the columns to read; empty reads all of them |
| aMaxRows | stops after this many rows; zero fills aLabels and fetches no rows. A bounded read is ordered by the first column where the backend can. |
| aLabels | is filled with the result-column labels as the source spells them, before the first call to aSink |
Implemented in ACE_BACKEND, ODBC_BACKEND, and SQLITE_BACKEND.
Referenced by ReadAllRows().
|
staticconstexpr |
Passed as ReadTable()'s row limit to read every row.
Definition at line 106 of file database_backend.h.
Referenced by ReadAllRows(), ACE_BACKEND::ReadTable(), ODBC_BACKEND::ReadTable(), SQLITE_BACKEND::ReadTable(), and ACE_BACKEND::readVerified().