23#include "Writable_Database.h"
24#include "joedb/concurrency/Writable_Client.h"
39 Client_Data(joedb::Buffered_File &file): db(file, false)
47 protected detail::Client_Data,
48 public joedb::Writable_Client
50 friend class Client_Lock;
53 int64_t schema_checkpoint;
56 void read_journal() override
59 if (schema_checkpoint)
61 if (db.schema_journal.get_checkpoint() > schema_checkpoint)
62 Database::throw_exception("Can't upgrade schema during pull");
63 db.check_single_row();
70 joedb::Buffered_File &file,
71 joedb::Connection &connection,
72 joedb::Content_Check content_check = joedb::Content_Check::quick
74 detail::Client_Data(file),
75 joedb::Writable_Client(db.journal, connection, content_check),
78 if (get_checkpoint_difference() > 0)
81 db.play_journal(); // makes transaction shorter if db is big
82 joedb::Writable_Client::transaction([this](){
86 schema_checkpoint = db.schema_journal.get_checkpoint();
89 const Database &get_database() const
105 template<typename F> auto transaction
110 return joedb::Writable_Client::transaction([&]()
112 return transaction(db);
122 class Client_Lock: public joedb::Client_Lock
125 Client_Lock(Client &client): joedb::Client_Lock(client)
129 Writable_Database &get_database()
131 JOEDB_DEBUG_ASSERT(locked);
132 return static_cast<Client &>(client).db;