![]() |
Bitcoin Core 30.99.0
P2P Digital Currency
|
An instance of this class represents one SQLite3 database. More...
#include <sqlite.h>
Public Member Functions | |
| SQLiteDatabase ()=delete | |
| SQLiteDatabase (const fs::path &dir_path, const fs::path &file_path, const DatabaseOptions &options, bool mock=false) | |
| Create DB handle to real database. More... | |
| ~SQLiteDatabase () | |
| bool | Verify (bilingual_str &error) |
| void | Open () override |
| Open the database if it is not already opened. More... | |
| void | Close () override |
| Close the database. More... | |
| bool | Rewrite () override |
| Rewrite the entire database on disk. More... | |
| bool | Backup (const std::string &dest) const override |
| Back up the entire database to a file. More... | |
| std::string | Filename () override |
| Return path to main database file for logs and error messages. More... | |
| std::vector< fs::path > | Files () override |
| Return paths to all database created files. More... | |
| std::string | Format () override |
| std::unique_ptr< DatabaseBatch > | MakeBatch () override |
| Make a SQLiteBatch connected to this database. More... | |
| bool | HasActiveTxn () |
| Return true if there is an on-going txn in this connection. More... | |
Public Member Functions inherited from wallet::WalletDatabase | |
| WalletDatabase ()=default | |
| Create dummy DB handle. More... | |
| virtual | ~WalletDatabase ()=default |
| virtual void | Open ()=0 |
| Open the database if it is not already opened. More... | |
| virtual bool | Rewrite ()=0 |
| Rewrite the entire database on disk. More... | |
| virtual bool | Backup (const std::string &strDest) const =0 |
| Back up the entire database to a file. More... | |
| virtual void | Close ()=0 |
| Flush to the database file and close the database. More... | |
| virtual std::string | Filename ()=0 |
| Return path to main database file for logs and error messages. More... | |
| virtual std::vector< fs::path > | Files ()=0 |
| Return paths to all database created files. More... | |
| virtual std::string | Format ()=0 |
| virtual std::unique_ptr< DatabaseBatch > | MakeBatch ()=0 |
| Make a DatabaseBatch connected to this database. More... | |
Public Attributes | |
| std::binary_semaphore | m_write_semaphore |
| sqlite3 * | m_db {nullptr} |
| bool | m_use_unsafe_sync |
Public Attributes inherited from wallet::WalletDatabase | |
| std::atomic< int > | m_refcount {0} |
| Counts the number of active database users to be sure that the database is not closed while someone is using it. More... | |
Private Member Functions | |
| void | Cleanup () noexcept EXCLUSIVE_LOCKS_REQUIRED(!g_sqlite_mutex) |
Static Private Member Functions | |
| static int g_sqlite_count | GUARDED_BY (g_sqlite_mutex) |
Private Attributes | |
| const bool | m_mock {false} |
| const fs::path | m_dir_path |
| const std::string | m_file_path |
Static Private Attributes | |
| static Mutex | g_sqlite_mutex |
| This mutex protects SQLite initialization and shutdown. More... | |
|
delete |
| wallet::SQLiteDatabase::SQLiteDatabase | ( | const fs::path & | dir_path, |
| const fs::path & | file_path, | ||
| const DatabaseOptions & | options, | ||
| bool | mock = false |
||
| ) |
Create DB handle to real database.
Definition at line 114 of file sqlite.cpp.
| wallet::SQLiteDatabase::~SQLiteDatabase | ( | ) |
|
overridevirtual |
Back up the entire database to a file.
Implements wallet::WalletDatabase.
Definition at line 343 of file sqlite.cpp.
|
privatenoexcept |
Definition at line 172 of file sqlite.cpp.
|
overridevirtual |
Close the database.
Implements wallet::WalletDatabase.
Definition at line 370 of file sqlite.cpp.
|
inlineoverridevirtual |
Return path to main database file for logs and error messages.
Implements wallet::WalletDatabase.
Definition at line 149 of file sqlite.h.
|
inlineoverridevirtual |
Return paths to all database created files.
Implements wallet::WalletDatabase.
Definition at line 151 of file sqlite.h.
|
inlineoverridevirtual |
Implements wallet::WalletDatabase.
|
staticprivate |
| bool wallet::SQLiteDatabase::HasActiveTxn | ( | ) |
Return true if there is an on-going txn in this connection.
Definition at line 379 of file sqlite.cpp.
|
overridevirtual |
Make a SQLiteBatch connected to this database.
Implements wallet::WalletDatabase.
Definition at line 390 of file sqlite.cpp.
|
overridevirtual |
Open the database if it is not already opened.
Implements wallet::WalletDatabase.
Definition at line 244 of file sqlite.cpp.
|
overridevirtual |
Rewrite the entire database on disk.
Implements wallet::WalletDatabase.
Definition at line 336 of file sqlite.cpp.
| bool wallet::SQLiteDatabase::Verify | ( | bilingual_str & | error | ) |
|
staticprivate |
This mutex protects SQLite initialization and shutdown.
sqlite3_config() and sqlite3_shutdown() are not thread-safe (sqlite3_initialize() is). Concurrent threads that execute SQLiteDatabase::SQLiteDatabase() should have just one of them do the init and the rest wait for it to complete before all can proceed.
|
private |
| std::binary_semaphore wallet::SQLiteDatabase::m_write_semaphore |