GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/reflog_sql.h
Date: 2025-06-22 02:36:02
Exec Total Coverage
Lines: 2 4 50.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #ifndef CVMFS_REFLOG_SQL_H_
6 #define CVMFS_REFLOG_SQL_H_
7
8 #include <string>
9
10 #include "crypto/hash.h"
11 #include "sql.h"
12
13 class ReflogDatabase : public sqlite::Database<ReflogDatabase> {
14 public:
15 static const float kLatestSchema;
16 static const float kLatestSupportedSchema;
17 // backwards-compatible schema changes
18 static const unsigned kLatestSchemaRevision;
19
20 static const std::string kFqrnKey;
21
22 bool CreateEmptyDatabase();
23
24 bool CheckSchemaCompatibility();
25 bool LiveSchemaUpgradeIfNecessary();
26 bool CompactDatabase() const {
27 return true;
28 } // no implementation specific
29 // database compaction.
30
31 bool InsertInitialValues(const std::string &repo_name);
32
33 protected:
34 // TODO(rmeusel): C++11 - constructor inheritance
35 friend class sqlite::Database<ReflogDatabase>;
36 769 ReflogDatabase(const std::string &filename, const OpenMode open_mode)
37 769 : sqlite::Database<ReflogDatabase>(filename, open_mode) { }
38 };
39
40
41 //------------------------------------------------------------------------------
42
43
44 class SqlReflog : public sqlite::Sql {
45 public:
46 enum ReferenceType {
47 kRefCatalog,
48 kRefCertificate,
49 kRefHistory,
50 kRefMetainfo
51 };
52
53 static shash::Suffix ToSuffix(const ReferenceType type);
54 };
55
56
57 class SqlInsertReference : public SqlReflog {
58 public:
59 explicit SqlInsertReference(const ReflogDatabase *database);
60 bool BindReference(const shash::Any &reference_hash,
61 const ReferenceType type);
62 };
63
64
65 class SqlCountReferences : public SqlReflog {
66 public:
67 explicit SqlCountReferences(const ReflogDatabase *database);
68 uint64_t RetrieveCount();
69 };
70
71
72 class SqlListReferences : public SqlReflog {
73 public:
74 explicit SqlListReferences(const ReflogDatabase *database);
75 bool BindType(const ReferenceType type);
76 bool BindOlderThan(const uint64_t timestamp);
77 shash::Any RetrieveHash() const;
78 };
79
80
81 class SqlRemoveReference : public SqlReflog {
82 public:
83 explicit SqlRemoveReference(const ReflogDatabase *database);
84 bool BindReference(const shash::Any &reference_hash,
85 const ReferenceType type);
86 };
87
88
89 class SqlContainsReference : public SqlReflog {
90 public:
91 explicit SqlContainsReference(const ReflogDatabase *database);
92 bool BindReference(const shash::Any &reference_hash,
93 const ReferenceType type);
94 bool RetrieveAnswer();
95 };
96
97
98 class SqlGetTimestamp : public SqlReflog {
99 public:
100 explicit SqlGetTimestamp(const ReflogDatabase *database);
101 bool BindReference(const shash::Any &reference_hash,
102 const ReferenceType type);
103 uint64_t RetrieveTimestamp();
104 };
105
106 #endif // CVMFS_REFLOG_SQL_H_
107