7 successful_prepare(
int const rc,
8 std::string
const& filename,
9 std::string
const& statement)
14 <<
"Error in preparing statement for getting contributors.\n" 15 <<
"File: " << filename <<
'\n' 16 <<
"Preparation statement: " << statement <<
'\n';
20 successful_step(
int const rc,
21 std::string
const& sqlErrMsg,
22 std::string
const& filename)
24 if (rc == SQLITE_DONE)
27 <<
"Unexpected status from table read: " << sqlErrMsg <<
" (" << rc
29 <<
"File: " << filename <<
'\n';
33 successful_finalize(
int const rc,
34 std::string
const& sqlErrMsg,
35 std::string
const& filename)
40 <<
"Unexpected status from DB status cleanup: " << sqlErrMsg <<
" (" << rc
42 <<
"File: " << filename <<
'\n';
51 std::string
const& filename,
53 unsigned const rangeSetID,
58 return RangeSetInfo::invalid();
60 sqlite3_stmt* stmt{
nullptr};
61 std::string
const run_ddl{
64 auto rc = sqlite3_prepare_v2(db, run_ddl.c_str(), -1, &stmt,
nullptr);
65 successful_prepare(rc, filename, run_ddl);
67 rc = sqlite3_step(stmt);
68 auto const r =
static_cast<RunNumber_t>(sqlite3_column_int(stmt, 0));
69 rc = sqlite3_finalize(stmt);
70 successful_finalize(rc, sqlite3_errmsg(db), filename);
72 std::string
const result_column_begin{compact ?
"min(begin)" :
"begin"};
73 std::string
const result_column_end{compact ?
"max(end)" :
"end"};
74 std::string
const maybe_suffix{compact ?
" GROUP BY SubRun" :
""};
75 std::string
const ddl{
76 "SELECT SubRun," + result_column_begin +
',' + result_column_end +
77 " FROM EventRanges WHERE rowid IN" 78 "(SELECT EventRangesID FROM " +
81 rc = sqlite3_prepare_v2(db, ddl.c_str(), -1, &stmt,
nullptr);
82 successful_prepare(rc, filename, ddl);
84 std::vector<EventRange> ranges;
85 while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) {
86 ranges.emplace_back(sqlite3_column_int(stmt, 0),
87 sqlite3_column_int(stmt, 1),
88 sqlite3_column_int(stmt, 2));
90 successful_step(rc, sqlite3_errmsg(db), filename);
92 rc = sqlite3_finalize(stmt);
93 successful_finalize(rc, sqlite3_errmsg(db), filename);
102 return RangeSet::invalid();
109 std::string
const& filename,
111 unsigned const rangeSetID,
RangeSetInfo resolveRangeSetInfo(sqlite3 *, std::string const &filename, BranchType, unsigned RangeSetID, bool compact)
std::vector< EventRange > ranges
RangeSet resolveRangeSet(RangeSetInfo const &rs)
std::string const & BranchTypeToString(BranchType const bt)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
IDNumber_t< Level::Run > RunNumber_t