GnuCash
5.6-150-g038405b370+
|
Public Member Functions | |
GncDbiBackend (GncSqlConnection *conn, QofBook *book) | |
void | session_begin (QofSession *, const char *, SessionOpenMode) override |
Open the file or connect to the server. More... | |
void | session_end () override |
void | load (QofBook *, QofBackendLoadType) override |
Load the minimal set of application data needed for the application to be operable at initial startup. More... | |
void | safe_sync (QofBook *) override |
Safely resave a database by renaming all of its tables, recreating everything, and then dropping the backup tables only if there were no errors. More... | |
bool | connected () const noexcept |
void | set_dbi_error (QofBackendError error, unsigned int repeat, bool retry) noexcept |
FIXME: Just a pass-through to m_conn: | |
void | retry_connection (const char *msg) const noexcept |
bool | exists () |
void | set_exists (bool exists) |
template<> | |
void | session_begin (QofSession *session, const char *new_uri, SessionOpenMode mode) |
Open the file or connect to the server. More... | |
template<> | |
void | safe_sync (QofBook *book) |
Perform a sync in a way that prevents data loss on a DBI backend. | |
Public Member Functions inherited from GncSqlBackend | |
GncSqlBackend (GncSqlConnection *conn, QofBook *book) | |
void | load (QofBook *, QofBackendLoadType) override |
Load the contents of an SQL database into a book. More... | |
void | sync (QofBook *) override |
Save the contents of a book to an SQL database. More... | |
void | begin (QofInstance *) override |
An object is about to be edited. More... | |
void | commit (QofInstance *) override |
Object editing is complete and the object should be saved. More... | |
void | rollback (QofInstance *) override |
Object editing has been cancelled. More... | |
void | connect (GncSqlConnection *conn) noexcept |
Connect the backend to a GncSqlConnection. More... | |
void | init_version_info () noexcept |
Initializes DB table version information. More... | |
bool | reset_version_info () noexcept |
Resets the version table information by removing all version table info. More... | |
void | finalize_version_info () noexcept |
Finalizes DB table version information. More... | |
GncSqlStatementPtr | create_statement_from_sql (const std::string &str) const noexcept |
GncSqlResultPtr | execute_select_statement (const GncSqlStatementPtr &stmt) const noexcept |
Executes an SQL SELECT statement and returns the result rows. More... | |
int | execute_nonselect_statement (const GncSqlStatementPtr &stmt) const noexcept |
std::string | quote_string (const std::string &) const noexcept |
bool | create_table (const std::string &table_name, const EntryVec &col_table) const noexcept |
Creates a table in the database. More... | |
bool | create_table (const std::string &table_name, int table_version, const EntryVec &col_table) noexcept |
Creates a table in the database and sets its version. More... | |
void | create_tables () noexcept |
Create/update all tables in the database. | |
bool | create_index (const std::string &index_name, const std::string &table_name, const EntryVec &col_table) const noexcept |
Creates an index in the database. More... | |
bool | add_columns_to_table (const std::string &table_name, const EntryVec &col_table) const noexcept |
Adds one or more columns to an existing table. More... | |
void | upgrade_table (const std::string &table_name, const EntryVec &col_table) noexcept |
Upgrades a table to a new structure. More... | |
uint_t | get_table_version (const std::string &table_name) const noexcept |
Returns the version number for a DB table. More... | |
bool | set_table_version (const std::string &table_name, uint_t version) noexcept |
Registers the version for a table. More... | |
void | commodity_for_postload_processing (gnc_commodity *) |
Register a commodity to be committed after loading is complete. More... | |
GncSqlObjectBackendPtr | get_object_backend (const std::string &type) const noexcept |
Get the GncSqlObjectBackend for the indicated type. More... | |
bool | object_in_db (const char *table_name, QofIdTypeConst obj_name, const gpointer pObject, const EntryVec &table) const noexcept |
Checks whether an object is in the database or not. More... | |
bool | do_db_operation (E_DB_OPERATION op, const char *table_name, QofIdTypeConst obj_name, gpointer pObject, const EntryVec &table) const noexcept |
Performs an operation on the database. More... | |
bool | save_commodity (gnc_commodity *comm) noexcept |
Ensure that a commodity referenced in another object is in fact saved in the database. More... | |
QofBook * | book () const noexcept |
void | set_loading (bool loading) noexcept |
bool | pristine () const noexcept |
void | update_progress (double pct) const noexcept |
void | finish_progress () const noexcept |
Public Member Functions inherited from QofBackend | |
QofBackend (const QofBackend &)=delete | |
QofBackend (const QofBackend &&)=delete | |
virtual void | export_coa (QofBook *) |
Extract the chart of accounts from the current database and create a new database with it. More... | |
void | set_error (QofBackendError err) |
Set the error value only if there isn't already an error already. | |
QofBackendError | get_error () |
Retrieve the currently-stored error and clear it. | |
bool | check_error () |
Report if there is an error. | |
void | set_message (std::string &&) |
Set a descriptive message that can be displayed to the user when there's an error. | |
const std::string && | get_message () |
Retrieve and clear the stored error message. | |
void | set_percentage (QofBePercentageFunc pctfn) |
Store and retrieve a backend-specific function for determining the progress in completing a long operation, for use with a progress meter. | |
QofBePercentageFunc | get_percentage () |
const std::string & | get_uri () |
Retrieve the backend's storage URI. | |
Additional Inherited Members | |
Static Public Member Functions inherited from QofBackend | |
static bool | register_backend (const char *, const char *) |
Class methods for dynamically loading the several backends and for freeing them at shutdown. | |
static void | release_backends () |
Protected Attributes inherited from GncSqlBackend | |
GncSqlConnection * | m_conn = nullptr |
SQL connection. | |
QofBook * | m_book = nullptr |
The primary, main open book. | |
bool | m_loading |
We are performing an initial load. | |
bool | m_in_query |
We are processing a query. | |
bool | m_is_pristine_db |
Are we saving to a new pristine db? | |
const char * | m_time_format = nullptr |
Server-specific date-time string format. | |
VersionVec | m_versions |
Version number for each table. | |
Protected Attributes inherited from QofBackend | |
QofBePercentageFunc | m_percentage |
std::string | m_fullpath |
Each backend resolves a fully-qualified file path. More... | |
Definition at line 88 of file gnc-backend-dbi.hpp.
|
overridevirtual |
Load the minimal set of application data needed for the application to be operable at initial startup.
It is assumed that the application will perform a 'run_query()' to obtain any additional data that it needs. For file-based backends, it is acceptable for the backend to return all data at load time; for SQL-based backends, it is acceptable for the backend to return no data.
Thus, for example, the old GnuCash postgres backend returned the account tree, all currencies, and the pricedb, as these were needed at startup. It did not have to return any transactions whatsoever, as these were obtained at a later stage when a user opened a register, resulting in a query being sent to the backend. The current DBI backend on the other hand loads the entire database into memory.
(Its OK to send over entities at this point, but one should be careful of the network load; also, its possible that whatever is sent is not what the user wanted anyway, which is why its better to wait for the query).
Implements QofBackend.
Definition at line 862 of file gnc-backend-dbi.cpp.
|
overridevirtual |
Safely resave a database by renaming all of its tables, recreating everything, and then dropping the backup tables only if there were no errors.
If there are errors, drop the new tables and restore the originals.
book | QofBook to be saved in the database. |
Implements QofBackend.
Definition at line 946 of file gnc-backend-dbi.cpp.
|
overridevirtual |
Open the file or connect to the server.
session | The QofSession that will control the backend. |
new_uri | The location of the data store that the backend will use. |
mode | The session open mode. See qof_session_begin(). |
Implements QofBackend.
Definition at line 637 of file gnc-backend-dbi.cpp.
|
virtual |
Open the file or connect to the server.
session | The QofSession that will control the backend. |
new_uri | The location of the data store that the backend will use. |
mode | The session open mode. See qof_session_begin(). |
Implements QofBackend.
Definition at line 356 of file gnc-backend-dbi.cpp.