27 auto const integrityWarning =
28 "reducing the data integrity guarantees from the "
29 "default [sqlite] behavior is not recommended for "
30 "nodes storing large amounts of history, because of the "
31 "difficulty inherent in rebuilding corrupted data.";
38 if (BEAST_EXPECT(s.globalPragma->size() == 3))
40 BEAST_EXPECT(s.globalPragma->at(0) ==
"PRAGMA journal_mode=wal;");
41 BEAST_EXPECT(s.globalPragma->at(1) ==
"PRAGMA synchronous=normal;");
42 BEAST_EXPECT(s.globalPragma->at(2) ==
"PRAGMA temp_store=file;");
53 auto& section = p->section(
"sqlite");
54 section.set(
"safety_level",
"high");
56 p->ledgerHistory = 100'000'000;
67 if (BEAST_EXPECT(s.globalPragma->size() == 3))
69 BEAST_EXPECT(s.globalPragma->at(0) ==
"PRAGMA journal_mode=wal;");
70 BEAST_EXPECT(s.globalPragma->at(1) ==
"PRAGMA synchronous=normal;");
71 BEAST_EXPECT(s.globalPragma->at(2) ==
"PRAGMA temp_store=file;");
82 auto& section = p->section(
"sqlite");
83 section.set(
"safety_level",
"low");
85 p->ledgerHistory = 100'000'000;
96 if (BEAST_EXPECT(s.globalPragma->size() == 3))
98 BEAST_EXPECT(s.globalPragma->at(0) ==
"PRAGMA journal_mode=memory;");
99 BEAST_EXPECT(s.globalPragma->at(1) ==
"PRAGMA synchronous=off;");
100 BEAST_EXPECT(s.globalPragma->at(2) ==
"PRAGMA temp_store=memory;");
111 auto& section = p->section(
"sqlite");
112 section.set(
"journal_mode",
"off");
113 section.set(
"synchronous",
"extra");
114 section.set(
"temp_store",
"default");
126 BEAST_EXPECT(!found);
128 if (BEAST_EXPECT(s.globalPragma->size() == 3))
130 BEAST_EXPECT(s.globalPragma->at(0) ==
"PRAGMA journal_mode=off;");
131 BEAST_EXPECT(s.globalPragma->at(1) ==
"PRAGMA synchronous=extra;");
132 BEAST_EXPECT(s.globalPragma->at(2) ==
"PRAGMA temp_store=default;");
143 auto& section = p->section(
"sqlite");
144 section.set(
"journal_mode",
"off");
145 section.set(
"synchronous",
"extra");
146 section.set(
"temp_store",
"default");
148 p->ledgerHistory = 50'000'000;
161 if (BEAST_EXPECT(s.globalPragma->size() == 3))
163 BEAST_EXPECT(s.globalPragma->at(0) ==
"PRAGMA journal_mode=off;");
164 BEAST_EXPECT(s.globalPragma->at(1) ==
"PRAGMA synchronous=extra;");
165 BEAST_EXPECT(s.globalPragma->at(2) ==
"PRAGMA temp_store=default;");
171 auto const expected =
172 "Failed to initialize SQL databases: "
173 "Configuration file may not define both \"safety_level\" and "
179 auto& section = p->section(
"sqlite");
180 section.set(
"safety_level",
"low");
181 section.set(
"journal_mode",
"off");
182 section.set(
"synchronous",
"extra");
183 section.set(
"temp_store",
"default");
203 auto const expected =
204 "Failed to initialize SQL databases: Configuration file may "
205 "not define both \"safety_level\" and \"journal_mode\"";
210 auto& section = p->section(
"sqlite");
211 section.set(
"safety_level",
"high");
212 section.set(
"journal_mode",
"off");
232 auto const expected =
233 "Failed to initialize SQL databases: Configuration file may "
234 "not define both \"safety_level\" and \"synchronous\"";
239 auto& section = p->section(
"sqlite");
240 section.set(
"safety_level",
"low");
241 section.set(
"synchronous",
"extra");
261 auto const expected =
262 "Failed to initialize SQL databases: Configuration file may "
263 "not define both \"safety_level\" and \"temp_store\"";
268 auto& section = p->section(
"sqlite");
269 section.set(
"safety_level",
"high");
270 section.set(
"temp_store",
"default");
290 auto const expected =
291 "Failed to initialize SQL databases: Invalid safety_level "
297 auto& section = p->section(
"sqlite");
298 section.set(
"safety_level",
"slow");
318 auto const expected =
319 "Failed to initialize SQL databases: Invalid journal_mode "
325 auto& section = p->section(
"sqlite");
326 section.set(
"journal_mode",
"fast");
346 auto const expected =
347 "Failed to initialize SQL databases: Invalid synchronous "
353 auto& section = p->section(
"sqlite");
354 section.set(
"synchronous",
"instant");
374 auto const expected =
375 "Failed to initialize SQL databases: Invalid temp_store "
381 auto& section = p->section(
"sqlite");
382 section.set(
"temp_store",
"network");
403 if (BEAST_EXPECT(s.txPragma.size() == 4))
405 BEAST_EXPECT(s.txPragma.at(0) ==
"PRAGMA page_size=4096;");
406 BEAST_EXPECT(s.txPragma.at(1) ==
"PRAGMA journal_size_limit=1582080;");
407 BEAST_EXPECT(s.txPragma.at(2) ==
"PRAGMA max_page_count=4294967294;");
408 BEAST_EXPECT(s.txPragma.at(3) ==
"PRAGMA mmap_size=17179869184;");
416 auto& section = p->section(
"sqlite");
417 section.set(
"page_size",
"512");
418 section.set(
"journal_size_limit",
"2582080");
420 return Env(*
this, std::move(p));
423 if (BEAST_EXPECT(s.txPragma.size() == 4))
425 BEAST_EXPECT(s.txPragma.at(0) ==
"PRAGMA page_size=512;");
426 BEAST_EXPECT(s.txPragma.at(1) ==
"PRAGMA journal_size_limit=2582080;");
427 BEAST_EXPECT(s.txPragma.at(2) ==
"PRAGMA max_page_count=4294967294;");
428 BEAST_EXPECT(s.txPragma.at(3) ==
"PRAGMA mmap_size=17179869184;");
433 auto const expected =
"Invalid page_size. Must be between 512 and 65536.";
437 auto& section = p->section(
"sqlite");
438 section.set(
"page_size",
"256");
456 auto const expected =
"Invalid page_size. Must be between 512 and 65536.";
460 auto& section = p->section(
"sqlite");
461 section.set(
"page_size",
"131072");
479 auto const expected =
"Invalid page_size. Must be a power of 2.";
483 auto& section = p->section(
"sqlite");
484 section.set(
"page_size",
"513");