libdballe  9.11
db/v7/db.h
1 #ifndef DBA_DB_V7_H
2 #define DBA_DB_V7_H
3 
4 #include <dballe/fwd.h>
5 #include <dballe/sql/fwd.h>
6 #include <dballe/db/db.h>
7 #include <dballe/db/v7/trace.h>
8 #include <dballe/db/v7/fwd.h>
9 #include <wreport/varinfo.h>
10 #include <string>
11 #include <memory>
12 
13 namespace dballe {
14 namespace db {
15 namespace v7 {
16 
20 class DB : public dballe::db::DB
21 {
22 public:
24  std::shared_ptr<dballe::sql::Connection> conn;
26  Trace* trace = nullptr;
28  bool explain_queries = false;
29 
30 protected:
33 
34  void init_after_connect();
35 
36 public:
37  DB(std::shared_ptr<dballe::sql::Connection> conn);
38  virtual ~DB();
39 
40  db::Format format() const override { return Format::V7; }
41 
43  v7::Driver& driver();
44 
45  std::shared_ptr<dballe::Transaction> transaction(bool readonly=false) override;
46  std::shared_ptr<dballe::db::Transaction> test_transaction(bool readonly=false) override;
47 
48  void disappear() override;
49 
61  void reset(const char* repinfo_file = 0) override;
62 
66  void delete_tables();
67 
77  void vacuum() override;
78 
79  friend class dballe::DB;
80  friend class dballe::db::v7::Transaction;
81 };
82 
83 }
84 }
85 }
86 #endif
Forward declarations for public dballe/sql names.
std::shared_ptr< dballe::db::Transaction > test_transaction(bool readonly=false) override
Same as transaction(), but the resulting transaction will throw an exception if commit is called...
std::shared_ptr< dballe::Transaction > transaction(bool readonly=false) override
Begin a transaction on this database, and return a Transaction object that can be used to commit it...
std::shared_ptr< dballe::sql::Connection > conn
Database connection.
Definition: db/v7/db.h:24
void disappear() override
Remove all our traces from the database, if applicable.
void reset(const char *repinfo_file=0) override
Reset the database, removing all existing DBALLE tables and re-creating them empty.
Definition: db/v7/trace.h:194
Functions used to connect to DB-All.e and insert, query and delete data.
Definition: cmdline.h:18
db::Format format() const override
Return the format of this DB.
Definition: db/v7/db.h:40
Definition: db/db.h:252
Definition: transaction.h:15
void delete_tables()
Delete all the DB-ALLe tables from the database.
v7::Driver & driver()
Access the backend DB driver.
bool explain_queries
True if we print an EXPLAIN trace of all queries to stderr.
Definition: db/v7/db.h:28
Definition: db.h:296
DB-ALLe database connection for database format V7.
Definition: db/v7/db.h:20
v7::Driver * m_driver
SQL driver backend.
Definition: db/v7/db.h:32
void vacuum() override
Remove orphan values from the database.
Definition: driver.h:19
Trace * trace
Database query tracing.
Definition: db/v7/db.h:26