Everett
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
everett::catalog_detail Namespace Reference

Classes

struct  outcome_reader
 
struct  statement
 

Typedefs

using bytes = std::vector< std::byte >
 

Functions

void number (bytes &out, std::uint64_t value)
 
void field (bytes &out, std::string_view value)
 
void identity (bytes &out, object_id const &value)
 
void pair (bytes &out, blob_identity const &value)
 
void timeline (bytes &out, catalog_timeline_head const &value)
 
void binary (bytes &out, std::span< std::byte const > value)
 
void auxiliary (bytes &out, catalog_auxiliary_roots const &value)
 
catalog_auxiliary_roots canonical_auxiliary (catalog_auxiliary_roots value, blob_identity const &primary)
 
void session (bytes &out, catalog_session_head const &value)
 
void name (std::string_view value)
 
std::int64_t integer (std::uint64_t value)
 
bool storage_error (int code) noexcept
 
void fail (sqlite3 *db, int code)
 
void exec (sqlite3 *db, char const *sql)
 
std::string schema_for (unsigned version)
 

Variables

constexpr char schema []
 
constexpr char native_merges_schema []
 
constexpr char private_scopes_schema []
 
constexpr char private_attempts_schema []
 
constexpr char released_private_scopes_schema []
 
constexpr char live_owner_objects_schema []
 
constexpr char live_owner_roots_schema []
 

Typedef Documentation

◆ bytes

using everett::catalog_detail::bytes = typedef std::vector<std::byte>

Function Documentation

◆ auxiliary()

void everett::catalog_detail::auxiliary ( bytes &  out,
catalog_auxiliary_roots const &  value 
)
inline

◆ binary()

void everett::catalog_detail::binary ( bytes &  out,
std::span< std::byte const >  value 
)
inline

◆ canonical_auxiliary()

catalog_auxiliary_roots everett::catalog_detail::canonical_auxiliary ( catalog_auxiliary_roots  value,
blob_identity const &  primary 
)
inline

◆ exec()

void everett::catalog_detail::exec ( sqlite3 *  db,
char const *  sql 
)
inline

◆ fail()

void everett::catalog_detail::fail ( sqlite3 *  db,
int  code 
)
inline

◆ field()

void everett::catalog_detail::field ( bytes &  out,
std::string_view  value 
)
inline

◆ identity()

void everett::catalog_detail::identity ( bytes &  out,
object_id const &  value 
)
inline

◆ integer()

std::int64_t everett::catalog_detail::integer ( std::uint64_t  value)
inline

◆ name()

void everett::catalog_detail::name ( std::string_view  value)
inline

◆ number()

void everett::catalog_detail::number ( bytes &  out,
std::uint64_t  value 
)
inline

◆ pair()

void everett::catalog_detail::pair ( bytes &  out,
blob_identity const &  value 
)
inline

◆ schema_for()

std::string everett::catalog_detail::schema_for ( unsigned  version)
inline

◆ session()

void everett::catalog_detail::session ( bytes &  out,
catalog_session_head const &  value 
)
inline

◆ storage_error()

bool everett::catalog_detail::storage_error ( int  code)
inlinenoexcept

◆ timeline()

void everett::catalog_detail::timeline ( bytes &  out,
catalog_timeline_head const &  value 
)
inline

Variable Documentation

◆ live_owner_objects_schema

constexpr char everett::catalog_detail::live_owner_objects_schema[]
inlineconstexpr
Initial value:
=
"CREATE VIEW live_owner_objects AS SELECT p.* FROM owner_objects p WHERE p.owner_kind<>'attempt' OR NOT EXISTS(SELECT 1 FROM attempts a JOIN private_attempts s ON s.attempt=a.id JOIN released_private_scopes r ON r.scope=s.scope WHERE a.owner=p.owner_id)"

◆ live_owner_roots_schema

constexpr char everett::catalog_detail::live_owner_roots_schema[]
inlineconstexpr
Initial value:
=
"CREATE VIEW live_owner_roots AS SELECT p.* FROM owner_roots p WHERE p.owner_kind<>'attempt' OR NOT EXISTS(SELECT 1 FROM attempts a JOIN private_attempts s ON s.attempt=a.id JOIN released_private_scopes r ON r.scope=s.scope WHERE a.owner=p.owner_id)"

◆ native_merges_schema

constexpr char everett::catalog_detail::native_merges_schema[]
inlineconstexpr
Initial value:
=
"CREATE TABLE completed_native_merges(domain BLOB NOT NULL,older TEXT NOT NULL REFERENCES objects(id),newer TEXT NOT NULL REFERENCES objects(id),output TEXT NOT NULL REFERENCES objects(id),owner_kind TEXT NOT NULL CHECK(owner_kind='reader'),owner_id BLOB NOT NULL UNIQUE,PRIMARY KEY(domain,older,newer),FOREIGN KEY(owner_kind,owner_id,output) REFERENCES owner_objects(owner_kind,owner_id,object_id)) STRICT"

◆ private_attempts_schema

constexpr char everett::catalog_detail::private_attempts_schema[]
inlineconstexpr
Initial value:
=
"CREATE TABLE private_attempts(attempt TEXT PRIMARY KEY REFERENCES attempts(id),scope TEXT NOT NULL REFERENCES private_scopes(id)) STRICT"

◆ private_scopes_schema

constexpr char everett::catalog_detail::private_scopes_schema[]
inlineconstexpr
Initial value:
=
"CREATE TABLE private_scopes(id TEXT PRIMARY KEY CHECK(length(id)=32)) STRICT"

◆ released_private_scopes_schema

constexpr char everett::catalog_detail::released_private_scopes_schema[]
inlineconstexpr
Initial value:
=
"CREATE TABLE released_private_scopes(scope TEXT PRIMARY KEY REFERENCES private_scopes(id)) STRICT"

◆ schema

constexpr char everett::catalog_detail::schema[]
inlineconstexpr
Initial value:
= R"sql(
CREATE TABLE catalog_info(singleton INTEGER PRIMARY KEY CHECK(singleton=1), version INTEGER NOT NULL CHECK(version=1), identity TEXT NOT NULL CHECK(length(identity)=32), policy BLOB NOT NULL) STRICT;
CREATE TABLE operations(id BLOB PRIMARY KEY, kind TEXT NOT NULL, request BLOB NOT NULL, outcome BLOB NOT NULL) STRICT;
CREATE TABLE owners(kind TEXT NOT NULL CHECK(kind IN('attempt','save','reader')), id BLOB NOT NULL, PRIMARY KEY(kind,id)) STRICT;
CREATE TABLE attempts(id TEXT PRIMARY KEY CHECK(length(id)=32), owner BLOB NOT NULL UNIQUE) STRICT;
CREATE TABLE objects(id TEXT PRIMARY KEY CHECK(length(id)=32), kind INTEGER NOT NULL CHECK(kind IN(0,1)), attempt TEXT NOT NULL REFERENCES attempts(id), bytes INTEGER, crc INTEGER, barrier INTEGER,
CHECK((bytes IS NULL AND crc IS NULL AND barrier IS NULL) OR (bytes IS NOT NULL AND crc IS NOT NULL AND barrier IS NOT NULL AND bytes>=96 AND crc>=0 AND crc<=4294967295 AND barrier IN(0,1)))) STRICT;
CREATE TABLE pairs(index_id TEXT PRIMARY KEY REFERENCES objects(id), native_id TEXT NOT NULL REFERENCES objects(id), target_native TEXT, target_index TEXT, native_count INTEGER NOT NULL CHECK(native_count>=0), borrowed_count INTEGER NOT NULL CHECK(borrowed_count>=0), virtual_count INTEGER NOT NULL CHECK(virtual_count>=0),
UNIQUE(native_id,index_id), FOREIGN KEY(target_native,target_index) REFERENCES pairs(native_id,index_id), CHECK((target_native IS NULL)=(target_index IS NULL)), CHECK(native_count<=virtual_count AND borrowed_count=virtual_count-native_count)) STRICT;
CREATE TABLE owner_objects(owner_kind TEXT NOT NULL, owner_id BLOB NOT NULL, object_id TEXT NOT NULL REFERENCES objects(id), PRIMARY KEY(owner_kind,owner_id,object_id), FOREIGN KEY(owner_kind,owner_id) REFERENCES owners(kind,id)) STRICT;
CREATE TABLE owner_roots(owner_kind TEXT NOT NULL, owner_id BLOB NOT NULL, native_id TEXT NOT NULL, index_id TEXT NOT NULL, PRIMARY KEY(owner_kind,owner_id,native_id,index_id), FOREIGN KEY(owner_kind,owner_id) REFERENCES owners(kind,id), FOREIGN KEY(native_id,index_id) REFERENCES pairs(native_id,index_id)) STRICT;
CREATE TABLE saves(name BLOB PRIMARY KEY, native_id TEXT NOT NULL, index_id TEXT NOT NULL, FOREIGN KEY(native_id,index_id) REFERENCES pairs(native_id,index_id)) STRICT;
CREATE TRIGGER sealed_immutable BEFORE UPDATE ON objects WHEN OLD.bytes IS NOT NULL OR NEW.id<>OLD.id OR NEW.kind<>OLD.kind OR NEW.attempt<>OLD.attempt BEGIN SELECT RAISE(ABORT,'immutable object'); END;
)sql"