VSQLite++
0.3
Toggle main menu visibility
Loading...
Searching...
No Matches
include
sqlite
snapshot.hpp
Go to the documentation of this file.
1
/*##############################################################################
2
VSQLite++ - virtuosic bytes SQLite3 C++ wrapper
3
4
Copyright (c) 2006-2024 Vinzenz Feenstra
5
and contributors
6
All rights reserved.
7
8
Redistribution and use in source and binary forms, with or without modification,
9
are permitted provided that the following conditions are met:
10
11
* Redistributions of source code must retain the above copyright notice,
12
this list of conditions and the following disclaimer.
13
* Redistributions in binary form must reproduce the above copyright notice,
14
this list of conditions and the following disclaimer in the documentation
15
and/or other materials provided with the distribution.
16
* Neither the name of virtuosic bytes nor the names of its contributors may
17
be used to endorse or promote products derived from this software without
18
specific prior written permission.
19
20
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
POSSIBILITY OF SUCH DAMAGE.
31
32
##############################################################################*/
33
#ifndef GUARD_SQLITE_SNAPSHOT_HPP_INCLUDED
34
#define GUARD_SQLITE_SNAPSHOT_HPP_INCLUDED
35
36
#include <string>
37
#include <string_view>
38
39
struct
sqlite3_snapshot;
40
48
namespace
sqlite
{
49
inline
namespace
v2
{
50
struct
connection
;
51
52
enum class
wal_mode
{
53
rollback
,
54
truncate
,
55
persist
,
56
memory
,
57
wal
,
58
wal2
59
};
60
62
struct
snapshot
{
63
snapshot
() =
default
;
64
~snapshot
();
65
66
snapshot
(
snapshot
const
&) =
delete
;
67
snapshot
&
operator=
(
snapshot
const
&) =
delete
;
68
69
snapshot
(
snapshot
&&other)
noexcept
;
70
snapshot
&
operator=
(
snapshot
&&other)
noexcept
;
71
72
bool
valid
() const noexcept {
73
return
handle_
!=
nullptr
;
74
}
75
explicit
operator
bool() const noexcept {
76
return
valid
();
77
}
78
80
void
reset
() noexcept;
81
83
static
snapshot
take
(
connection
&con, std::string_view schema =
"main"
);
84
86
void
open
(
connection
&con, std::string_view schema =
"main"
) const;
87
88
sqlite3_snapshot *
native_handle
() const noexcept {
89
return
handle_
;
90
}
91
92
private
:
93
explicit
snapshot
(sqlite3_snapshot *handle);
94
sqlite3_snapshot *
handle_
=
nullptr
;
95
};
96
98
wal_mode
set_wal_mode
(
connection
&con,
wal_mode
mode);
99
101
wal_mode
enable_wal
(
connection
&con,
bool
prefer_wal2 =
false
);
102
104
wal_mode
get_wal_mode
(
connection
&con);
105
107
std::string_view
to_string
(
wal_mode
mode);
108
110
bool
snapshots_supported
() noexcept;
111
}
// namespace v2
112
}
// namespace sqlite
113
114
#endif
// GUARD_SQLITE_SNAPSHOT_HPP_INCLUDED
sqlite::v2
Definition
backup.hpp:18
sqlite::v2::set_wal_mode
wal_mode set_wal_mode(connection &con, wal_mode mode)
Force a specific WAL journal mode.
sqlite::v2::get_wal_mode
wal_mode get_wal_mode(connection &con)
Query the current journal mode for a connection.
sqlite::v2::to_string
std::string_view to_string(wal_mode mode)
Convert wal_mode to the corresponding PRAGMA token.
sqlite::v2::enable_wal
wal_mode enable_wal(connection &con, bool prefer_wal2=false)
Enable WAL, optionally preferring WAL2 with transparent fallback.
sqlite::v2::snapshots_supported
bool snapshots_supported() noexcept
Check if the linked SQLite library exposes snapshot helpers.
sqlite::v2::wal_mode
wal_mode
Definition
snapshot.hpp:52
sqlite::v2::wal_mode::truncate
@ truncate
Definition
snapshot.hpp:54
sqlite::v2::wal_mode::wal
@ wal
Definition
snapshot.hpp:57
sqlite::v2::wal_mode::persist
@ persist
Definition
snapshot.hpp:55
sqlite::v2::wal_mode::memory
@ memory
Definition
snapshot.hpp:56
sqlite::v2::wal_mode::wal2
@ wal2
Definition
snapshot.hpp:58
sqlite::v2::wal_mode::rollback
@ rollback
DELETE/legacy rollback journal.
Definition
snapshot.hpp:53
sqlite
Definition
backup.hpp:17
sqlite::v2::connection
connection is used to open, close, attach and detach a database. Further it has to be passed to all c...
Definition
connection.hpp:64
sqlite::snapshot
RAII wrapper around sqlite3_snapshot.
Definition
snapshot.hpp:62
sqlite::v2::snapshot::handle_
sqlite3_snapshot * handle_
Definition
snapshot.hpp:94
sqlite::v2::snapshot::operator=
snapshot & operator=(snapshot const &)=delete
sqlite::v2::snapshot::snapshot
snapshot(snapshot const &)=delete
sqlite::v2::snapshot::snapshot
snapshot()=default
sqlite::v2::snapshot::snapshot
snapshot(sqlite3_snapshot *handle)
sqlite::v2::snapshot::snapshot
snapshot(snapshot &&other) noexcept
sqlite::v2::snapshot::native_handle
sqlite3_snapshot * native_handle() const noexcept
Definition
snapshot.hpp:88
sqlite::v2::snapshot::take
static snapshot take(connection &con, std::string_view schema="main")
Capture a snapshot for the provided connection/schema.
sqlite::v2::snapshot::operator=
snapshot & operator=(snapshot &&other) noexcept
sqlite::v2::snapshot::~snapshot
~snapshot()
sqlite::v2::snapshot::open
void open(connection &con, std::string_view schema="main") const
Rewind an open read transaction to this snapshot.
sqlite::v2::snapshot::valid
bool valid() const noexcept
Definition
snapshot.hpp:72
sqlite::v2::snapshot::reset
void reset() noexcept
Release the managed sqlite3_snapshot (if owned).
Generated by
1.17.0