@@ -170,11 +170,13 @@ int mu2e::DbTool::printCalibration() {
170170 args[" user" ] = " " ;
171171 args[" cid" ] = " " ;
172172 args[" ctime" ] = " " ;
173+ args[" hash" ] = " " ;
173174 if ((rc = getArgs (args))) return rc;
174175 std::string name = args[" name" ];
175176 std::string user = args[" user" ];
176177 std::vector<int > cids = intList (args[" cid" ]);
177178 timeInterval tint = parseInterval (args[" ctime" ]);
179+ std::string chash = args[" hash" ];
178180
179181 // if this is a val table, just exit - there is no summary line
180182 if (name.substr (0 , 3 ) == " Val" ) {
@@ -202,7 +204,9 @@ int mu2e::DbTool::printCalibration() {
202204 if (tid < 0 || cc.tid () == tid) {
203205 if (user.empty () || user == cc.create_user ()) {
204206 if (tint.start == 0 || inTime (tint, cc.create_time ())) {
205- cids.push_back (cc.cid ());
207+ if (chash.empty () || chash == cc.chash () ) {
208+ cids.push_back (cc.cid ());
209+ }
206210 }
207211 }
208212 }
@@ -764,9 +768,9 @@ int mu2e::DbTool::printCIDLine(int cid, int indent) {
764768 auto name = tids.row (cr.tid ()).name ();
765769
766770 std::stringstream ss;
767- ss << " CID " << std::setw (5 + 4 * std::max (indent, 0 )) << cid << std::setw (20 )
768- << name << std::setw (12 ) << cr.create_user () << std::setw ( 35 )
769- << cr.create_time () << std::endl;
771+ ss << " CID " << std::setw (5 + 4 * std::max (indent, 0 )) << cid << std::setw (22 )
772+ << name << std::setw (12 ) << cr.create_user ()
773+ << std::setw ( 35 ) << cr.create_time () << std::endl;
770774 _result.append (ss.str ());
771775
772776 return 0 ;
@@ -1037,13 +1041,21 @@ int mu2e::DbTool::commitCalibrationList(DbTableCollection& coll, bool qai,
10371041
10381042 liveTable.setTid (tid);
10391043
1044+ if (ptr->hash ().empty ()) {
1045+ std::cout
1046+ << " DbTool::commitCalibrationList found empty hash summary for table named "
1047+ << liveTable.table ().name () << std::endl;
1048+ return 1 ;
1049+ }
1050+
10401051 command = " SET ROLE val_role;" ;
10411052 rc = _sql.execute (command, result);
10421053 if (rc != 0 ) return rc;
10431054
10441055 command =
1045- " INSERT INTO val.calibrations (tid,create_time,create_user) VALUES (" +
1046- std::to_string (tid) + " ,CURRENT_TIMESTAMP,SESSION_USER) RETURNING cid;" ;
1056+ " INSERT INTO val.calibrations (tid,chash,create_time,create_user) VALUES (" +
1057+ std::to_string (tid) + " ,'" + ptr->hash () +
1058+ " ',CURRENT_TIMESTAMP,SESSION_USER) RETURNING cid;" ;
10471059 rc = _sql.execute (command, result);
10481060 if (rc != 0 ) return rc;
10491061
@@ -2747,6 +2759,7 @@ int mu2e::DbTool::help() {
27472759 " [OPTIONS]\n "
27482760 " --name NAME : name of the table\n "
27492761 " --user USERNAME : only print tables committed by this user \n "
2762+ " --hash HASH : only print table with this content hash \n "
27502763 " --ctime TIME/TIME : only print contents created in this "
27512764 " interval \n "
27522765 " --cid INT or INT LIST : only print this cid \n "
0 commit comments