--- chewbacca/YodaProfiler/src/PamelaDBOperations.cpp 2013/03/06 10:12:36 1.34 +++ chewbacca/YodaProfiler/src/PamelaDBOperations.cpp 2014/04/04 14:11:24 1.37 @@ -226,7 +226,26 @@ qu.str(""); // qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<10000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<7200 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<40000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<40000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // relax conditions... 090112 [8RED: error -29] - qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<50000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<50000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // even more relaxed conditions... 091214 [9REDtest3: error -29] + qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< (float)chlastts <<")<50000 AND ABS(REAL_TIME_INIT-"<< atof(row2->GetField(10)) <<")<50000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // even more relaxed conditions... 091214 [9REDtest3: error -29] // 10RED MYSQL operators BUG: + /* + +mysql> select CAST(1322000646 AS UNSIGNED INTEGER)-1322017203.; ++--------------------------------------------------+ +| CAST(1322000646 AS UNSIGNED INTEGER)-1322017203. | ++--------------------------------------------------+ +| -16557 | ++--------------------------------------------------+ +1 row in set (0.06 sec) + +mysql> select CAST(1322000646 AS UNSIGNED INTEGER)-1322017203; ++-------------------------------------------------+ +| CAST(1322000646 AS UNSIGNED INTEGER)-1322017203 | ++-------------------------------------------------+ +| 18446744073709535059 | ++-------------------------------------------------+ +1 row in set (0.02 sec) + + */ if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); result3 = conn->Query(qu.str().c_str()); if ( result3 ){ @@ -2162,16 +2181,16 @@ UInt_t lowerts = tsync-(obt0/1000)-5; if ( chewbacca ){ oss.str(""); - oss << "select BOOT_NUMBER from ROOT_TABLE where LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)<" + oss << "select BOOT_NUMBER from ROOT_TABLE where CAST((LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)) AS SIGNED INT)<" // 10RED MYSQL OPERATORS BUG << upperts - << " AND LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)>" + << " AND CAST((LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)) AS SIGNED INT)>" // 10RED MYSQL OPERATORS BUG << lowerts << " AND BOOT_NUMBER>1;"; } else { oss.str(""); - oss << "select GL_RAW.BOOT_NUMBER from GL_TIMESYNC LEFT JOIN GL_RAW ON GL_RAW.ID = GL_TIMESYNC.ID_RAW where TIMESYNC-(OBT0/1000)<" + oss << "select GL_RAW.BOOT_NUMBER from GL_TIMESYNC LEFT JOIN GL_RAW ON GL_RAW.ID = GL_TIMESYNC.ID_RAW where CAST((TIMESYNC-(OBT0/1000)) AS SIGNED INT)<" // 10RED MYSQL OPERATORS BUG << upperts - << " AND TIMESYNC-(OBT0/1000)>" + << " AND CAST((TIMESYNC-(OBT0/1000)) AS SIGNED INT)>" // 10RED MYSQL OPERATORS BUG << lowerts << " AND GL_RAW.BOOT_NUMBER>0 GROUP BY GL_TIMESYNC.OBT0;"; }; @@ -2957,6 +2976,7 @@ if ( IsDebug() ) printf(" here firstev is %i lastev is %i \n",firstev,lastev); // glrun->SetEV_FROM(firstev); + glrun->SetEV_TO(lastev); // EM 10 RED ghost run bug glrun->SetNEVENTS(lastev-firstev+1); // glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME()); @@ -3152,6 +3172,7 @@ }; if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); // + glrun->SetEV_FROM(firstev); // EM 10RED ghost run bug glrun->SetEV_TO(lastev); glrun->SetNEVENTS(lastev-firstev+1); glrun->SetPKT_COUNTER(glrun1->GetPKT_COUNTER()); @@ -3994,6 +4015,7 @@ glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); // glrun->SetEV_FROM(firstev); + glrun->SetEV_TO(lastev); // 10 RED ghost run bug glrun->SetNEVENTS(lastev-firstev+1); // glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME()); @@ -5449,7 +5471,8 @@ if ( IsDebug() ) cout << endl << ">>>> TRY TO RECOVER TRACKER CALIBRATIONS <<<<"<Query(oss.str().c_str()); + rresult = conn->Query(oss.str().c_str()); if ( !result ) throw -4;; if ( IsDebug() ) cout <<"Rows: "<GetRowCount()<Next(); + row = rresult->Next(); if(!row)break; UInt_t id = (UInt_t)atoll(row->GetField(0)); @@ -5668,7 +5691,8 @@ if(FOUND)break; }while(1);//endl loop over root table entries - + + delete result2; // 10RED potential memory leak if(FOUND)break; }//end loop over tables @@ -5822,7 +5846,7 @@ }while(1);//end loop over calibrations - if( result )delete result; + if( rresult )delete rresult; // 10RED bug if( row )delete row; @@ -6154,7 +6178,7 @@ while ( anr ){ // oss.str(""); - oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE BOOT_NUMBER=" << mbo << " AND RUNHEADER_PKT=" << mrhp << "+1 AND ABS(RUNHEADER_TIME-"<< mrht <<")<=1 AND INSERT_TIME <= '" << clean_time->AsSQLString() << "' order BY RUNHEADER_TIME asc;"; + oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE BOOT_NUMBER=" << mbo << " AND RUNHEADER_PKT=" << mrhp << "+1 AND ABS(RUNHEADER_TIME-"<< (float)mrht <<")<=1 AND INSERT_TIME <= '" << clean_time->AsSQLString() << "' order BY RUNHEADER_TIME asc;"; // 10RED MYSQL OPERATOR BUG if ( IsDebug() ) printf(" In the loop searching for fragmented runs : query is \n %s \n",oss.str().c_str()); // nresult1 = conn->Query(oss.str().c_str());