DbiSqlValPacket Class Reference

#include <DbiSqlValPacket.h>

List of all members.

Public Types

typedef enum DbiSqlValPacket::ECompResult CompResult_t
 kIdentical
 kUpdate
 kOutOfDate
 kConflict
enum  ECompResult { kIdentical, kUpdate, kOutOfDate, kConflict }

Public Member Functions

 DbiSqlValPacket ()
 DbiSqlValPacket (std::ifstream &is)
 DbiSqlValPacket (const DbiValidityRec &vrec)
virtual ~DbiSqlValPacket ()
Bool_t CanBeStored () const
CompResult_t Compare (const DbiSqlValPacket &that, Bool_t log=kFALSE, const Char_t *thisName="this", const Char_t *thatName="that") const
Bool_t CreateTable (UInt_t dbNo) const
UInt_t GetNumErrors () const
UInt_t GetNumSqlStmts () const
UInt_t GetSeqNo () const
VldTimeStamp GetCreationDate () const
string GetStmt (UInt_t stmtNo) const
std::vector< string > GetStmtValues (UInt_t stmtNo) const
const string & GetTableName () const
Bool_t IsEqual (const DbiSqlValPacket &that, Bool_t log=kFALSE, const Char_t *thisName="this", const Char_t *thatName="that") const
Bool_t Fill (std::ifstream &is)
Bool_t Store (UInt_t dbNo, Bool_t replace=kFALSE) const
Bool_t Write (std::ofstream &ios, Bool_t addMetadata=kFALSE) const
void Recreate (const string &tableName, const VldRange &vr, Int_t aggNo, Dbi::Task task=0, VldTimeStamp creationDate=VldTimeStamp())
Bool_t AddDataRow (const DbiTableProxy &tblProxy, const DbiValidityRec *vrec, const DbiTableRow &row)
void Clear ()
void SetCreationDate (VldTimeStamp ts)
void SetSeqNo (UInt_t seqno)
void Reset ()
virtual void Print (Option_t *option="") const

Private Member Functions

void AddRow (const string &row)
Bool_t AddRow (const DbiTableProxy &tblProxy, const DbiValidityRec *vrec, const DbiTableRow &row)
void Report (const char *msg, UInt_t line_num, const string &line)
void SetMetaData () const
void SetSeqNoOnRow (string &row, const string &seqno)
 DbiSqlValPacket (const DbiSqlValPacket &)

Private Attributes

UInt_t fNumErrors
 Number of error encountered while filling.
UInt_t fSeqNo
 Sequence number or 0 if not filled.
string fSqlMySqlMetaMain
 MySQL SQL to create main table. May be empty until needed.
string fSqlMySqlMetaVld
 As fSqlMySqlMetaMain but for aux. table.
std::list< string > fSqlStmts
 Set of SQL statements to generate packet.
UInt_t fNumStmts
 Number of statements.
string fTableName
 Table name or null if not filled.
VldTimeStamp fCreationDate
 Creation date, or object creation date if unfilled.

Static Private Attributes

static Bool_t fgLastMetaHadRowCounter = false


Detailed Description

Id
DbiSqlValPacket.h,v 1.20 2006/08/08 10:51:32 west Exp

Definition at line 43 of file DbiSqlValPacket.h.


Member Typedef Documentation

typedef enum DbiSqlValPacket::ECompResult DbiSqlValPacket::CompResult_t


Member Enumeration Documentation

enum DbiSqlValPacket::ECompResult

Enumerator:
kIdentical 
kUpdate 
kOutOfDate 
kConflict 

Definition at line 50 of file DbiSqlValPacket.h.

00050                            {
00051     kIdentical,
00052     kUpdate,
00053     kOutOfDate,
00054     kConflict 
00055   } CompResult_t;


Constructor & Destructor Documentation

DbiSqlValPacket::DbiSqlValPacket (  ) 

Definition at line 57 of file DbiSqlValPacket.cxx.

References Msg::kVerbose, LEA_CTOR, and MSG.

00057                                  :
00058 fNumErrors(0),
00059 fSeqNo(0),
00060 fNumStmts(0)
00061 {
00062 //
00063 //
00064 //  Purpose:  Default ctor.
00065 
00066   LEA_CTOR    //Leak Checker
00067 
00068   MSG("Dbi", Msg::kVerbose) << "Creating DbiSqlValPacket" << endl;
00069 }

DbiSqlValPacket::DbiSqlValPacket ( std::ifstream &  is  ) 

Definition at line 73 of file DbiSqlValPacket.cxx.

References Fill(), Msg::kVerbose, LEA_CTOR, and MSG.

00073                                                 :
00074 fNumErrors(0),
00075 fSeqNo(0),
00076 fNumStmts(0)
00077 {
00078 //
00079 //
00080 //  Purpose:  Constructor reading from input stream.
00081 //
00082 //  Arguments:
00083 //      is    in/out    Input stream.
00084 //
00085 //  Return:   n/a. 
00086 //
00087 //  Contact:   N. West
00088 //
00089 //  Specification:-
00090 //  =============
00091 //
00092 //  o  Create DbiSqlValPacket and fill from input stream.
00093 
00094 
00095 //  Program Notes:-
00096 //  =============
00097 
00098 //  None.
00099 
00100   LEA_CTOR    //Leak Checker
00101 
00102   MSG("Dbi", Msg::kVerbose) << "Creating DbiSqlValPacket" << endl;
00103 
00104   Fill(is);
00105 
00106 }
//.....................................................................

DbiSqlValPacket::DbiSqlValPacket ( const DbiValidityRec vrec  ) 

Definition at line 109 of file DbiSqlValPacket.cxx.

References AddRow(), DbiResultSet::FetchRow(), DbiValidityRec::GetDbNo(), DbiTableProxy::GetDBProxy(), DbiValidityRec::GetSeqNo(), DbiValidityRec::GetTableProxy(), DbiResultSet::IsExhausted(), Msg::kVerbose, LEA_CTOR, MSG, DbiDBProxy::QuerySeqNo(), and DbiResultSet::RowAsCsv().

00109                                                            :
00110 fNumErrors(0),
00111 fSeqNo(vrec.GetSeqNo()),
00112 fNumStmts(0),
00113 fTableName(vrec.GetTableProxy()->GetTableName()),
00114 fCreationDate(vrec.GetCreationDate())
00115 {
00116 //
00117 //
00118 //  Purpose:  Constructor from a DbiValidityRec.
00119 //
00120 //  Arguments:
00121 //      vrec  in   DbiValidityRec from which to create packet.     .
00122 //
00123 //  Return:   n/a. 
00124 //
00125 //  Contact:   N. West
00126 //
00127 //  Specification:-
00128 //  =============
00129 //
00130 //  o  Create DbiSqlValPacket from DbiValidityRec and associated data.
00131 
00132 
00133 //  Program Notes:-
00134 //  =============
00135 
00136 //  This member function uses DbiConfigSet as a generic concrete
00137 //  DbiTableRow that can be used to create SQL for any type of table.
00138 
00139   LEA_CTOR    //Leak Checker
00140 
00141   MSG("Dbi", Msg::kVerbose) << "Creating DbiSqlValPacket" << endl;
00142 
00143   const DbiTableProxy& tableProxy = *vrec.GetTableProxy();
00144   Int_t seqNo  = vrec.GetSeqNo();
00145   UInt_t dbNo  = vrec.GetDbNo();
00146 
00147   // Create the SQL for the DbiValidityRec itself.
00148   this->AddRow(tableProxy,0,vrec);
00149 
00150   // Create the SQL for the rows.
00151 
00152   const DbiDBProxy& dbProxy = tableProxy.GetDBProxy();
00153   DbiResultSet* rset = dbProxy.QuerySeqNo(seqNo,dbNo);
00154 
00155   
00156   for(; ! rset->IsExhausted(); rset->FetchRow()) {
00157     string str;
00158     rset->RowAsCsv(str);
00159     this->AddRow(str);
00160   }
00161   delete rset;
00162   rset = 0;
00163 }

DbiSqlValPacket::~DbiSqlValPacket (  )  [virtual]

Definition at line 167 of file DbiSqlValPacket.cxx.

References Clear(), Msg::kVerbose, LEA_DTOR, and MSG.

00167                                   {
00168 //
00169 //
00170 //  Purpose: Destructor
00171 //
00172 //  Arguments: 
00173 //    None.
00174 //
00175 //  Return:    n/a
00176 //
00177 //  Contact:   N. West
00178 //
00179 //  Specification:-
00180 //  =============
00181 //
00182 //  o  Destroy DbiSqlValPacket.
00183 
00184 
00185 //  Program Notes:-
00186 //  =============
00187 
00188 //  None.
00189 
00190   LEA_DTOR    //Leak Checker
00191 
00192   MSG("Dbi", Msg::kVerbose) << "Destroying DbiSqlValPacket" << endl;
00193 
00194   Clear();
00195 
00196 }

DbiSqlValPacket::DbiSqlValPacket ( const DbiSqlValPacket  )  [private]


Member Function Documentation

Bool_t DbiSqlValPacket::AddDataRow ( const DbiTableProxy tblProxy,
const DbiValidityRec vrec,
const DbiTableRow row 
)

Definition at line 200 of file DbiSqlValPacket.cxx.

References AddRow(), fNumErrors, Msg::kError, and MAXMSG.

Referenced by DbiWriter< T >::operator<<(), and DbiLogEntry::Write().

00202                                                           {
00203 //
00204 //
00205 //  Purpose: Add data row. 
00206 //
00207 
00208   if ( this->GetNumSqlStmts() == 0 ) {
00209     MAXMSG("Dbi",Msg::kError,20) 
00210       << "Cannot add data row - packet does not have a VLD row"  << endl;
00211     ++fNumErrors;
00212     return kFALSE;
00213   }
00214 
00215   return this->AddRow(tblProxy,vrec,row);
00216 
00217 }

Bool_t DbiSqlValPacket::AddRow ( const DbiTableProxy tblProxy,
const DbiValidityRec vrec,
const DbiTableRow row 
) [private]

Definition at line 241 of file DbiSqlValPacket.cxx.

References AddRow(), fNumErrors, fNumStmts, DbiTableProxy::GetMetaData(), DbiTableProxy::GetMetaValid(), GetNumSqlStmts(), DbiTableProxy::GetTableName(), DbiRowStream::HasRowCounter(), Msg::kError, MAXMSG, and DbiTableRow::Store().

00243                                                       {
00244 //
00245 //
00246 //  Purpose: Add row. 
00247 //
00248 
00249 
00250   bool isVld = this->GetNumSqlStmts() == 0;
00251   const DbiTableMetaData& meta = isVld ? tblProxy.GetMetaValid() : tblProxy.GetMetaData(); 
00252   DbiOutRowStream outRow(&meta);
00253 
00254 // Store dummy SEQNO, and, if necessary ROW_COUNTER, for data rows. 
00255   if ( ! isVld ) {
00256     outRow << 0;  // dummy SEQNO
00257     if ( outRow.HasRowCounter() )  outRow <<  fNumStmts; // ROW_COUNTER
00258   }
00259   row.Store(outRow,vrec);
00260   if ( ! outRow.HasGoodData() ) {
00261     if ( ! outRow.IsComplete() ) {
00262       MAXMSG("Dbi",Msg::kError,20)
00263         << "Incomplete data supplied for row " << this->GetNumSqlStmts()-1
00264         << " of table " 
00265         << tblProxy.GetTableName() << endl;
00266     }
00267     ++fNumErrors;
00268     return kFALSE;
00269   }
00270   this->AddRow(outRow.GetCSV());
00271   return kTRUE;
00272 }

void DbiSqlValPacket::AddRow ( const string &  row  )  [private]

Definition at line 221 of file DbiSqlValPacket.cxx.

References fNumStmts, fSqlStmts, GetSeqNo(), GetTableName(), and SetSeqNoOnRow().

Referenced by AddDataRow(), AddRow(), DbiSqlValPacket(), and Recreate().

00221                                               {
00222 //
00223 //
00224 //  Purpose: Add row. 
00225 //
00226 
00227   string sql("INSERT INTO ");
00228   sql += this->GetTableName();
00229   if ( this->GetNumSqlStmts() == 0 ) sql += "VLD";
00230   sql += " VALUES (" + row + ");";
00231   ostringstream seqno;
00232   seqno << this->GetSeqNo();
00233   this->SetSeqNoOnRow(sql,seqno.str());
00234   fSqlStmts.push_back(sql);
00235   ++fNumStmts;
00236 
00237 }

Bool_t DbiSqlValPacket::CanBeStored (  )  const [inline]

Definition at line 64 of file DbiSqlValPacket.h.

References fNumErrors, and fSeqNo.

Referenced by CreateTable(), DbmModule::Import(), Store(), and Write().

00064                                    { 
00065              return (fSeqNo > 0 && fNumErrors == 0 && this->GetNumSqlStmts()> 0)
00066             ? kTRUE : kFALSE; };

void DbiSqlValPacket::Clear (  )  [inline]

Definition at line 101 of file DbiSqlValPacket.h.

References fNumErrors, and Reset().

Referenced by DbiWriter< T >::Close(), Recreate(), DbiWriter< T >::Reset(), and ~DbiSqlValPacket().

00101 { this->Reset(); fNumErrors = 0; }

DbiSqlValPacket::CompResult_t DbiSqlValPacket::Compare ( const DbiSqlValPacket that,
Bool_t  log = kFALSE,
const Char_t *  thisName = "this",
const Char_t *  thatName = "that" 
) const

Definition at line 275 of file DbiSqlValPacket.cxx.

References fSeqNo, fTableName, GetStmtValues(), kConflict, kIdentical, Msg::kInfo, kOutOfDate, kUpdate, and MSG.

00279                                                                {
00280 //
00281 //
00282 //  Purpose:  Compare to another DbiSqlValPacket
00283 //
00284 //  Arguments: 
00285 //    that         in    The other DbiSqlValPacket to be compared.
00286 //    log          in    If true list differences to MSG("Dbi",kInfo)
00287 //    thisName     in    Optional name for this packet (default: this)
00288 //    thatName     in    Optional name for that packet (default: that)
00289 //
00290 //  Return:    kIdentical   if identical (apart from InsertDate)
00291 //             kUpdate      "that" is more up to date
00292 //             kOutOfDate   "that" is out of date
00293 //             kConflict    records are incompatible
00294 //
00295 //  Contact:   N. West
00296 //
00297 
00298   if ( this->IsEqual(that,log,thisName,thatName ) ) return kIdentical;
00299 
00300   if (    fSeqNo           != that.fSeqNo
00301        || fTableName       != that.fTableName     ) return kConflict;
00302 
00303   std::vector<std::string> valuesThis = this->GetStmtValues(0);
00304   std::vector<std::string> valuesThat = that.GetStmtValues(0);
00305 
00306   // Assume CreationDate is the 7th element (counting from 0).
00307   int comp = valuesThis[7].compare(valuesThat[7]);
00308 
00309   if ( comp < 0 ) {
00310     if ( log ) {
00311       MSG("Dbi",Msg::kInfo) 
00312         << "  Difference classified as Update" << endl;;
00313     }
00314     return kUpdate;
00315   }
00316   else if ( comp > 0 ) {
00317     if ( log ) {
00318       MSG("Dbi",Msg::kInfo) 
00319         << "  Difference classified as OutOfDate" << endl;
00320     }
00321     return kOutOfDate;
00322   }
00323   return kConflict;
00324 
00325 }

Bool_t DbiSqlValPacket::CreateTable ( UInt_t  dbNo  )  const

Definition at line 330 of file DbiSqlValPacket.cxx.

References CanBeStored(), fSqlMySqlMetaMain, fSqlMySqlMetaVld, fTableName, DbiTableProxyRegistry::Instance(), Msg::kWarning, MSG, and DbiTableProxyRegistry::RefreshMetaData().

Referenced by DTFtest(), and DbmModule::Import().

00330                                                      {
00331 //
00332 //
00333 //  Purpose:  Create table in specified database.
00334 //
00335 //  Arguments: 
00336 //    dbNo         in    Number of database in the cascade.
00337 //
00338 //  Return:    kTRUE if successfully created.
00339 //
00340 //  Contact:   N. West
00341 //
00342 //  Specification:-
00343 //  =============
00344 //
00345 //  o If SQL to create tables is available, use it to create 
00346 //    the main and auxiliary tables and refresh the corresponding 
00347 //    DbiTableProxy.
00348 
00349 //  Program Notes:-
00350 //  =============
00351 
00352 //  None.
00353 
00354   if ( ! CanBeStored() ) return kFALSE; 
00355 
00356   // Locate required DbiStatement.
00357   auto_ptr<DbiStatement> stmtDb(DbiTableProxyRegistry::Instance()
00358                                .GetCascader()
00359                                .CreateStatement(dbNo));
00360   if ( ! stmtDb.get() ) {
00361     MSG("Dbi",Msg::kWarning) 
00362       << "Attempting to write to non-existant cascade entry " << dbNo
00363       << endl;
00364     return kFALSE;
00365   }
00366   if ( fSqlMySqlMetaMain == "" || fSqlMySqlMetaVld  == "" ) {
00367     MSG("Dbi",Msg::kWarning) 
00368       << "No SQL available to create table " << fTableName
00369       << " in cascade entry: " << dbNo << endl;
00370     return kFALSE;
00371   }
00372 
00373   stmtDb->ExecuteUpdate(fSqlMySqlMetaVld.c_str());
00374   if ( stmtDb->PrintExceptions() ) return kFALSE;
00375   stmtDb->ExecuteUpdate(fSqlMySqlMetaMain.c_str());
00376   if ( stmtDb->PrintExceptions() ) return kFALSE;
00377 
00378   DbiTableProxyRegistry::Instance().RefreshMetaData(this->GetTableName());
00379 
00380   return kTRUE;
00381 
00382 }

Bool_t DbiSqlValPacket::Fill ( std::ifstream &  is  ) 

Definition at line 386 of file DbiSqlValPacket.cxx.

References fCreationDate, fgLastMetaHadRowCounter, fNumStmts, fSeqNo, fSqlMySqlMetaMain, fSqlMySqlMetaVld, fSqlStmts, fTableName, GetNumSqlStmts(), GetStmtValues(), Dbi::kMAXTABLENAMELEN, Msg::kWarning, Dbi::MakeTimeStamp(), MSG, Report(), Reset(), and UtilString::StringTok().

Referenced by DbiSqlValPacket(), and DbmModule::Import().

00386                                             {
00387 //
00388 //
00389 //  Purpose:  Refill object from input string.
00390 //
00391 //  Arguments: 
00392 //      is    in/out    Input stream.
00393 //
00394 //  Return:   kTRUE is object has been refilled. 
00395 //
00396 //  Contact:   N. West
00397 //
00398 //  Specification:-
00399 //  =============
00400 //
00401 //  o Collect SQL statements, and possibly metadata (as SQL to
00402 //    create table) bracketed by >>>> ... <<<<< checking that
00403 //    the table name and SeqNos match.  Count and discard any data that
00404 //    looks bad. 
00405 
00406 //  Program Notes:-
00407 //  =============
00408 
00409 //  None.
00410 
00411 #ifdef IRIX6
00412   EFillState state = kLOOKING_FOR_HEADER;
00413 #else
00414   enum { kLOOKING_FOR_HEADER,
00415          kLOOKING_FOR_TRAILER } state = kLOOKING_FOR_HEADER;
00416 #endif
00417 
00418   enum { kMAXTABLENAMELEN        = Dbi::kMAXTABLENAMELEN,
00419          kHEADER_TRAILER_MAX_LEN = kMAXTABLENAMELEN + 20 };
00420 
00421   string nameHead;
00422   string nameTrail;
00423   UInt_t seqNoHead  = 0;
00424   UInt_t seqNoTrail = 0;
00425 
00426   string line;
00427   string msg;
00428   string sql;
00429   int lineNum = 0;
00430 
00431   this->Reset();
00432   //  Loop until EOF reading lines.
00433 
00434   while ( ! is.eof() ) {
00435     getline(is,line);
00436     ++lineNum;
00437     // Skip null lines.
00438     if (line.size() == 0 ) continue;
00439 
00440     // Look for header line
00441     if ( state == kLOOKING_FOR_HEADER ) {
00442       if ( line.substr(0,5) == ">>>>>" ) {
00443         if ( line.size() >= kHEADER_TRAILER_MAX_LEN ) {
00444           Report("Bad header",lineNum,line);
00445           continue;
00446         }
00447 
00448         // Look for optional metadata.
00449         if ( line.find("Metadata") != string::npos ) {
00450           getline(is,fSqlMySqlMetaVld);
00451           ++lineNum;
00452           getline(is,fSqlMySqlMetaMain);
00453           // Record whether or not table has a ROW_COUNTER column.
00454           fgLastMetaHadRowCounter = 
00455             fSqlMySqlMetaMain.find("ROW_COUNTER",fSqlMySqlMetaMain.find("(")) != string::npos;
00456           ++lineNum;
00457           getline(is,line);
00458           ++lineNum;
00459           if (   line.substr(0,5) != "<<<<<" 
00460               || line.find("Metadata") == string::npos ) {
00461             Report("Bad metadata",lineNum,line);
00462             continue;
00463           }
00464           getline(is,line);
00465           ++lineNum;
00466           if ( line.size() >= kHEADER_TRAILER_MAX_LEN ) {
00467             Report("Bad header",lineNum,line);
00468             continue;
00469           }
00470         }
00471           
00472         //  Collect table name and SeqNo.
00473         istringstream istr(line.substr(5));
00474         istr.width(kMAXTABLENAMELEN);
00475         istr >> nameHead >> seqNoHead;
00476         if ( ! istr.eof() ) {
00477           Report("Input error",lineNum,line);
00478           continue;
00479         }
00480 
00481         // Header looks good, start to collect SQL. 
00482         state = kLOOKING_FOR_TRAILER;
00483         sql = "";
00484       }
00485       else {
00486         Report("Not header",lineNum,line);
00487       }
00488     }
00489 
00490     //Look for trailer line.
00491 
00492     else {
00493       if ( line.substr(0,5) == "<<<<<" ) {
00494         if ( line.size() >= kHEADER_TRAILER_MAX_LEN 
00495            ) msg = "Bad trailer";
00496 
00497         else {
00498 
00499           //  Collect table name and SeqNo.
00500           istringstream istr(line.substr(5));
00501           istr.width(kMAXTABLENAMELEN);
00502           istr >> nameTrail >> seqNoTrail;
00503           if ( ! istr.eof() ) msg = "Input error";
00504 
00505           else if (    nameTrail != nameHead
00506                     || seqNoHead != seqNoTrail ) {
00507             msg = "Header/Trailer mismatch: Header: ";
00508             msg += istr.str();
00509           }
00510           else if ( GetNumSqlStmts() == 0 
00511                   ) msg = "No SQL statements between Header/Trailer";
00512           else {
00513 
00514             // Trailer looks good return with object filled. 
00515             fSeqNo     = seqNoHead;
00516             fTableName = nameHead;
00517 
00518             //Dig out the creation date from the first record.
00519             string date = this->GetStmtValues(0)[7];
00520             //Remove the quotes.
00521             date.erase(0,1);
00522             date.erase(date.size()-1,1);
00523             fCreationDate = Dbi::MakeTimeStamp(date);
00524             // Temporary hack: set for Agg No = -1 for DBUSUBRUNSUMMARY
00525             if ( fTableName  == "DBUSUBRUNSUMMARY" ) {
00526               std::vector<std::string> ls;
00527               UtilString::StringTok(ls,*fSqlStmts.begin(),",");
00528               // Agg. no is element 6.
00529               if (ls.size() >= 7 && ls[6] != "-1") {
00530                 static bool warnOnce = true;
00531                 if ( warnOnce ) {
00532                   MSG("Dbi",Msg::kWarning)
00533                    << "Setting aggregate number for DBUSUBRUNSUMMARY = -1\n"
00534                    << "  Expect this message once.  DBUSUBRUNSUMMARY needs to be "
00535                    << " fixed!" << endl;
00536                    warnOnce = false;
00537                 }
00538                 ls[6] = "-1";
00539                 sql = ls[0];
00540                 for (unsigned i=1; i<ls.size(); ++i ) sql += "," + ls[i];
00541                 fSqlStmts.pop_front();
00542                 fSqlStmts.push_front(sql);  
00543               }
00544             }
00545             return kTRUE;
00546 
00547           }
00548         }
00549 
00550         // Trailer bad, start again!
00551         Report(msg.c_str(),lineNum,line);
00552         state = kLOOKING_FOR_HEADER;
00553       }
00554 
00555       // Not a trailer line, must be SQL, collect and append lines
00556       // until a trailing ; found.
00557       else {
00558         sql += line;
00559         if ( sql[sql.size()-1] == ';') {
00560           fSqlStmts.push_back(sql);
00561           ++fNumStmts;
00562           sql = "";
00563         }
00564       } 
00565     }
00566 
00567   }
00568 
00569   if ( state != kLOOKING_FOR_HEADER 
00570      ) Report("Unexpected EOF",lineNum,"EOF");
00571   this->Reset();
00572   return kFALSE;
00573 
00574 }

VldTimeStamp DbiSqlValPacket::GetCreationDate (  )  const [inline]

Definition at line 75 of file DbiSqlValPacket.h.

References fCreationDate.

Referenced by DbmModule::Import().

00075 { return fCreationDate; }

UInt_t DbiSqlValPacket::GetNumErrors (  )  const [inline]

Definition at line 72 of file DbiSqlValPacket.h.

References fNumErrors.

Referenced by DbmModule::Import().

00072 { return fNumErrors; }

UInt_t DbiSqlValPacket::GetNumSqlStmts (  )  const [inline]

Definition at line 73 of file DbiSqlValPacket.h.

References fNumStmts.

Referenced by AddRow(), DbiWriter< T >::CanOutput(), Fill(), DbiWriter< T >::IsOpen(), and Print().

00073 { return fNumStmts; }

UInt_t DbiSqlValPacket::GetSeqNo (  )  const [inline]

Definition at line 74 of file DbiSqlValPacket.h.

References fSeqNo.

Referenced by AddRow(), DbmModule::Import(), and Write().

00074 { return fSeqNo; }

string DbiSqlValPacket::GetStmt ( UInt_t  stmtNo  )  const

Definition at line 577 of file DbiSqlValPacket.cxx.

References fSqlStmts.

Referenced by DbiWriter< T >::CanOutput(), and GetStmtValues().

00577                                                    {
00578 //
00579 //
00580 //  Purpose:  Return a selected statment
00581 
00582   if ( stmtNo >= this->GetNumSqlStmts() ) return "";
00583 
00584   // Locate statement
00585   std::list<std::string>::const_iterator itr = fSqlStmts.begin();
00586   while ( stmtNo ) { ++itr; --stmtNo; }
00587 
00588   return *itr;
00589 
00590 }

std::vector< std::string > DbiSqlValPacket::GetStmtValues ( UInt_t  stmtNo  )  const

Definition at line 593 of file DbiSqlValPacket.cxx.

References GetStmt(), and UtilString::StringTok().

Referenced by Compare(), and Fill().

00593                                                                        {
00594 //
00595 //
00596 //  Purpose:  Return all the values associated with a selected statment
00597 //
00598 //  Arguments: 
00599 //    stmtNo       in    The statement number (starting at 0)
00600 //
00601 //  Return:              vector of string values.  
00602 //                       Empty vector if stmt does not exits. 
00603 //
00604 //  Contact:   N. West
00605 
00606   std::vector<std::string> vec;
00607   if ( stmtNo >= this->GetNumSqlStmts() ) return vec;
00608 
00609   // Locate statement
00610   std::string str = this->GetStmt(stmtNo);
00611 
00612   // Extract ...(list-of-values)... and parse it into tokens.
00613   std::string::size_type pos = str.find('(');
00614   ++pos;
00615   std::string::size_type n = str.find(')') - pos;
00616   UtilString::StringTok(vec,str.substr(pos,n),",");
00617 
00618   return vec;
00619 
00620 }

const string& DbiSqlValPacket::GetTableName (  )  const [inline]

Definition at line 78 of file DbiSqlValPacket.h.

References fTableName.

Referenced by AddRow(), DbmModule::Import(), and Write().

00078 { return fTableName; }

Bool_t DbiSqlValPacket::IsEqual ( const DbiSqlValPacket that,
Bool_t  log = kFALSE,
const Char_t *  thisName = "this",
const Char_t *  thatName = "that" 
) const

Definition at line 624 of file DbiSqlValPacket.cxx.

References compStringPtrs(), fNumStmts, fSeqNo, fSqlStmts, fTableName, Msg::kInfo, and MSG.

00627                                                                {
00628 //
00629 //
00630 //  Purpose:  Test for equality to another DbiSqlValPacket
00631 //
00632 //  Arguments: 
00633 //    that         in    The other DbiSqlValPacket to be compared.
00634 //    log          in    If true list differences to MSG("Dbi",kInfo)
00635 //    thisName     in    Optional name for this packet (default: this)
00636 //    thatName     in    Optional name for that packet (default: that)
00637 //
00638 //  Return:    kTRUE if identical (apart from InsertDate).
00639 //
00640 //  Contact:   N. West
00641 //
00642 //  Specification:-
00643 //  =============
00644 //
00645 //  o Compare to another DbiSqlValPacket.
00646 
00647 //  Program Notes:-
00648 //  =============
00649 
00650 //  The InsertDate reflects the date when the data was written into the
00651 // local database so has to be excluded from the comparison.
00652 
00653   if (    fSeqNo           != that.fSeqNo
00654        || fTableName       != that.fTableName
00655        || fNumStmts != that.fNumStmts ) {
00656     if ( log ) {
00657       MSG("Dbi",Msg::kInfo) 
00658         << "Conflict found:"
00659         << " for : " << thisName << " , " << thatName << " :-\n"
00660         << "  SeqNo " << fSeqNo << "," << that.fSeqNo 
00661         << "\n  TableName " << fTableName << "," << that.fTableName
00662         << "\n  Size " << fNumStmts << "," 
00663         << that.fNumStmts << endl;
00664     }
00665     return kFALSE;
00666   }
00667 
00668   list<string>::const_iterator itrThisBegin = fSqlStmts.begin();
00669   list<string>::const_iterator itrThisEnd   = fSqlStmts.end();
00670   list<string>::const_iterator itrThatBegin = that.fSqlStmts.begin();
00671   list<string>::const_iterator itrThatEnd   = that.fSqlStmts.end();
00672 
00673   list<string>::const_iterator itrThis = itrThisBegin;
00674   list<string>::const_iterator itrThat = itrThatBegin;
00675 
00676   Bool_t isEqual = kTRUE;
00677 
00678   // Strip off InsertDate from first statement (assume its
00679   // the last parameter in list).
00680 
00681   string strThis = (*itrThis).substr(0,(*itrThis).rfind(','));
00682   string strThat = (*itrThat).substr(0,(*itrThat).rfind(','));
00683   if ( strThis != strThat ) {
00684   if ( ! log ) return kFALSE;
00685   isEqual = kFALSE;
00686   MSG("Dbi",Msg::kInfo) 
00687       << "Difference on VLD record " << ":-\n"
00688       << "  " << thisName << ": " << strThis  << endl
00689       << "  " << thatName << ": " << strThat  << endl;
00690   }
00691 
00692   // Rows can come in any order (after the first) so we have
00693   // to sort before comparing.  However, if we are lucky, they
00694   // may be in the same order or inverse order so do a quick 
00695   // test to see if there are no conflicts assuming these 
00696   // relative orderings.
00697 
00698   ++itrThis;
00699   ++itrThat;
00700   while ( itrThis != itrThisEnd && (*itrThis) == (*itrThat) ) {
00701 //     cout << "Debug: trying forward compare ..." << *itrThis 
00702 //       << "::" << *itrThat << endl;
00703     ++itrThis;
00704     ++itrThat;
00705   }
00706   if ( itrThis == itrThisEnd ) return isEqual;
00707 
00708   itrThis = itrThisBegin;
00709   itrThat = itrThatEnd;
00710   ++itrThis;
00711   --itrThat;
00712 
00713   while ( itrThis != itrThisEnd &&  (*itrThis) == (*itrThat) ) {
00714 //   cout << "Debug: trying reverse compare ..." << *itrThis 
00715 //       << "::" << *itrThat << endl;
00716     ++itrThis;
00717     --itrThat;
00718   }
00719   if ( itrThis == itrThisEnd ) return isEqual;
00720 
00721   // O.K., we are out of luck so set up pointers to both sets
00722   // and sort these.
00723 
00724   typedef vector<const string*>      shadow_list_t;
00725   typedef shadow_list_t::iterator  shadow_list_itr_t;
00726 
00727   shadow_list_t shadowThis;
00728   shadow_list_t shadowThat;
00729 
00730   itrThis = itrThisBegin;
00731   itrThat = itrThatBegin;
00732   ++itrThis;
00733   ++itrThat;
00734 
00735   while ( itrThis != itrThisEnd ) {
00736     shadowThis.push_back(&(*itrThis));
00737     shadowThat.push_back(&(*itrThat));
00738     ++itrThis;
00739     ++itrThat;
00740   }
00741 
00742   shadow_list_itr_t shadowThisItr    = shadowThis.begin();
00743   shadow_list_itr_t shadowThisItrEnd = shadowThis.end();
00744   shadow_list_itr_t shadowThatItr    = shadowThat.begin();
00745   shadow_list_itr_t shadowThatItrEnd = shadowThat.end();
00746 
00747   sort(shadowThisItr,shadowThisItrEnd,compStringPtrs);
00748   sort(shadowThatItr,shadowThatItrEnd,compStringPtrs);
00749 
00750   while ( shadowThisItr != shadowThisItrEnd ) {
00751     if ( (**shadowThisItr) != (**shadowThatItr) ){
00752       if ( ! log ) return kFALSE;
00753       isEqual = kFALSE;
00754       MSG("Dbi",Msg::kInfo) << "Difference on data record "
00755          << ":-\n"
00756          << "  " << thisName << ": " << **shadowThisItr  << endl
00757          << "  " << thatName << ": " << **shadowThatItr  << endl;
00758     }
00759    ++shadowThisItr;
00760    ++shadowThatItr;
00761   }
00762 
00763   return isEqual;
00764 
00765 }

void DbiSqlValPacket::Print ( Option_t *  option = ""  )  const [virtual]

Definition at line 769 of file DbiSqlValPacket.cxx.

References fCreationDate, fNumErrors, fSeqNo, fSqlMySqlMetaMain, fSqlMySqlMetaVld, fSqlStmts, fTableName, GetNumSqlStmts(), Msg::kInfo, and MSG.

Referenced by DbiWriter< T >::CanOutput().

00769                                                          {
00770 //
00771 //
00772 //  Purpose:  Print the current state.
00773 
00774   MSG("Dbi",Msg::kInfo) 
00775     << "DbiSQLValPacket:"
00776     << " table \"" << fTableName << "\" "
00777     << " SeqNo " << fSeqNo
00778     << " NumErrors " << fNumErrors
00779     << endl
00780     << "   CreationDate " << fCreationDate
00781     << endl;
00782 
00783   MSG("Dbi",Msg::kInfo) 
00784     << "   MySQL Main table creation: \"" << fSqlMySqlMetaMain << "\"" << endl;
00785 
00786   MSG("Dbi",Msg::kInfo) 
00787     << "   MySQL VLD table creation: \"" << fSqlMySqlMetaVld << "\"" << endl;
00788 
00789   if ( GetNumSqlStmts() > 0 ) {
00790     std::list<string>::const_iterator itr    = fSqlStmts.begin();
00791     std::list<string>::const_iterator itrEnd = fSqlStmts.end();
00792     for (; itr != itrEnd; ++itr) 
00793       MSG("Dbi",Msg::kInfo) 
00794         << "   SqlStmt \"" << *itr << "\"" << endl;
00795   }
00796   else {
00797     MSG("Dbi",Msg::kInfo) << "   No SqlStmts." << endl;
00798   }
00799 
00800 }

void DbiSqlValPacket::Recreate ( const string &  tableName,
const VldRange vr,
Int_t  aggNo,
Dbi::Task  task = 0,
VldTimeStamp  creationDate = VldTimeStamp() 
)

Definition at line 805 of file DbiSqlValPacket.cxx.

References AddRow(), Clear(), dummy, fNumErrors, fTableName, DbiTableProxyRegistry::GetCascader(), DbiOutRowStream::GetCSV(), DbiTableProxy::GetMetaValid(), DbiTableProxyRegistry::GetTableProxy(), DbiTableProxyRegistry::Instance(), Msg::kError, MAXMSG, SetCreationDate(), DbiValidityRec::Store(), and DbiCascader::TableExists().

Referenced by DbiWriter< T >::CompleteOpen(), and DbiLogEntry::Write().

00808                                                                     : 0 */
00809                                VldTimeStamp creationDate   /*  Default: now */ 
00810                                ) {
00811 //
00812 //
00813 //  Purpose:  Recreate and define first row (VLD - the validity record).
00814 
00815 
00816   this->Clear();
00817 
00818   DbiTableProxyRegistry& tablePR = DbiTableProxyRegistry::Instance();
00819   if ( ! tablePR.GetCascader().TableExists(tableName) ) {
00820     MAXMSG("Dbi",Msg::kError,20) << "Cannot create packet - table " << tableName
00821                            << " does not exist." << endl;
00822     fNumErrors = 1;
00823     return;
00824   }
00825 
00826   fTableName = tableName;
00827 
00828 
00829   // Create a DbiValidityRec from the supplied data.
00830   DbiValidityRec vrec(vr,task,aggNo,0);
00831 
00832   //  Create a DbiOutRowStream that can serialise this validity record
00833   DbiConfigSet dummy;     // For validity row any DbiTableRow will do.
00834   const DbiTableMetaData&  metaValid = tablePR.GetTableProxy(tableName,&dummy)
00835                                               .GetMetaValid();
00836   DbiOutRowStream buff(&metaValid);
00837 
00838   vrec.Store(buff,0);
00839   this->AddRow(buff.GetCSV());
00840   this->SetCreationDate(creationDate);
00841 
00842 }  

void DbiSqlValPacket::Report ( const char *  msg,
UInt_t  line_num,
const string &  line 
) [private]

Definition at line 846 of file DbiSqlValPacket.cxx.

References fNumErrors, Msg::kError, MAXMSG, and Reset().

Referenced by Fill().

00848                                                  {
00849 //
00850 //
00851 //  Purpose:  Report and count errors.
00852 //
00853 //  Arguments: 
00854 //    msg          in    Message to be reported.
00855 //    lineNum      in    Line number.
00856 //    line         in    Input line causing error.
00857 //
00858 //  Return:    
00859 //
00860 //  Contact:   N. West
00861 //
00862 //  Specification:-
00863 //  =============
00864 //
00865 //  o Reset object, report and count errors.
00866 
00867 //  Program Notes:-
00868 //  =============
00869 
00870 //  None.
00871 
00872   MAXMSG("Dbi",Msg::kError,20) << msg << " on line " << lineNum
00873                          <<":- \n  " << line << endl;
00874   this->Reset();
00875   ++fNumErrors;
00876 
00877 }

void DbiSqlValPacket::Reset (  ) 

Definition at line 880 of file DbiSqlValPacket.cxx.

References fNumStmts, fSeqNo, fSqlMySqlMetaMain, fSqlMySqlMetaVld, fSqlStmts, and fTableName.

Referenced by Clear(), Fill(), and Report().

00880                             {
00881 //
00882 //
00883 //  Purpose:  Clear out back to unfilled status except for fNumErrors.
00884 
00885   fSeqNo       = 0;
00886   fSqlMySqlMetaMain = "";
00887   fSqlMySqlMetaVld  = "";
00888   fSqlStmts.clear();
00889   fNumStmts    = 0;
00890   fTableName   = "";
00891 
00892 }

void DbiSqlValPacket::SetCreationDate ( VldTimeStamp  ts  ) 

Definition at line 895 of file DbiSqlValPacket.cxx.

References VldTimeStamp::AsString(), fCreationDate, and fSqlStmts.

Referenced by DbiWriter< T >::Close(), and Recreate().

00895                                                      {
00896 //
00897 //
00898 //  Purpose:  Set creation date.
00899 
00900   fCreationDate = ts;
00901 
00902   //  Update the validity row assuming:  "...,'creationdate',insertdate);"
00903   if ( this->GetNumSqlStmts() == 0 ) return;
00904 
00905   string& vldRow = *fSqlStmts.begin();
00906   string::size_type locEnd = vldRow.rfind(',');
00907   if ( locEnd == string::npos ) return;
00908   locEnd -=2;
00909   string::size_type locStart = vldRow.rfind(',',locEnd);
00910   if ( locStart == string::npos ) return;
00911   locStart+=2;
00912   vldRow.replace(locStart,locEnd-locStart+1,ts.AsString("s"));
00913 
00914 }

void DbiSqlValPacket::SetMetaData (  )  const [private]

Definition at line 918 of file DbiSqlValPacket.cxx.

References dummy, fSqlMySqlMetaMain, fSqlMySqlMetaVld, DbiTableProxyRegistry::GetCascader(), DbiCascader::GetTableDbNo(), DbiTableProxyRegistry::GetTableProxy(), DbiTableProxyRegistry::Instance(), and DbiTableMetaData::Sql().

00918                                         {
00919 //
00920 //
00921 //  Purpose:  Set up meta-data as SQL table creation statements.
00922 
00923   DbiTableProxyRegistry& tbprxreg = DbiTableProxyRegistry::Instance();
00924 
00925   //  Locate the table in the cascade.
00926   DbiCascader& cas = tbprxreg.GetCascader();
00927   Int_t dbNo = cas.GetTableDbNo(this->GetTableName());
00928   if ( dbNo < 0 ) return;
00929 
00930   //  Any table proxy will do to get the meta-data so use the one for a 
00931   //  DbiConfigSet;
00932   DbiConfigSet dummy;
00933   const DbiTableMetaData & metaVld =  tbprxreg.GetTableProxy(this->GetTableName(),&dummy)
00934                                      .GetMetaValid();
00935   const DbiTableMetaData & metaMain = tbprxreg.GetTableProxy(this->GetTableName(),&dummy)
00936                                      .GetMetaData();
00937   fSqlMySqlMetaVld   = metaVld.Sql();
00938   fSqlMySqlMetaMain  = metaMain.Sql();
00939 
00940 }

void DbiSqlValPacket::SetSeqNo ( UInt_t  seqno  ) 

Definition at line 944 of file DbiSqlValPacket.cxx.

References fSeqNo, fSqlStmts, and SetSeqNoOnRow().

Referenced by DbiWriter< T >::Close(), and DbiLogEntry::Write().

00944                                            {
00945 //
00946 //
00947 //  Purpose:  Set Sequence number.
00948 
00949   fSeqNo = seqno;
00950 
00951   //  Update all rows 
00952   if ( this->GetNumSqlStmts() == 0 ) return;
00953 
00954   ostringstream tmp;
00955   tmp << seqno;
00956   const string seqnoStr = tmp.str();
00957 
00958   std::list<string>::iterator itr    = fSqlStmts.begin();
00959   std::list<string>::iterator itrEnd = fSqlStmts.end();
00960   for (; itr != itrEnd; ++itr) SetSeqNoOnRow(*itr,seqnoStr);
00961 
00962 
00963 }

void DbiSqlValPacket::SetSeqNoOnRow ( string &  row,
const string &  seqno 
) [private]

Definition at line 967 of file DbiSqlValPacket.cxx.

Referenced by AddRow(), and SetSeqNo().

00967                                                                    {
00968 //
00969 //
00970 //  Purpose:  Set Sequence number on supplied row
00971 
00972 //  Update row assuming:  "...(seqno, ...."
00973   
00974   string::size_type locStart = row.find('(');
00975   if ( locStart == string::npos ) return;
00976   ++locStart;
00977   string::size_type locEnd = row.find(',',locStart);
00978   if ( locEnd == string::npos ) return;
00979   row.replace(locStart,locEnd-locStart,seqno);
00980 
00981 }

Bool_t DbiSqlValPacket::Store ( UInt_t  dbNo,
Bool_t  replace = kFALSE 
) const

Definition at line 985 of file DbiSqlValPacket.cxx.

References CanBeStored(), fgLastMetaHadRowCounter, fSqlStmts, DbiTableProxy::GetDBProxy(), DbiTableProxy::GetMetaData(), DbiTableProxyRegistry::GetTableProxy(), DbiTableMetaData::HasRowCounter(), DbiTableProxyRegistry::Instance(), Msg::kError, Dbi::kOracle, Msg::kWarning, Dbi::MakeDateTimeString(), MAXMSG, MSG, and DbiDBProxy::RemoveSeqNo().

Referenced by DbiWriter< T >::Close(), DTFtest(), DbmModule::Import(), and DbiLogEntry::Write().

00985                                                                {
00986 //
00987 //
00988 //  Purpose:  Output validity packet to specified database.
00989 //
00990 //  Arguments: 
00991 //    dbNo         in    Number of database in the cascade.
00992 //    replace      in    If true replace existing SeqNo (default: kFALSE).
00993 //
00994 //  Return:    kTRUE if successfully stored.
00995 //
00996 //  Contact:   N. West
00997 //
00998 //  Specification:-
00999 //  =============
01000 //
01001 //  o Output validity packet to specified database modifying
01002 //    InsertDate to be current date.
01003 
01004   if ( ! CanBeStored() ) return kFALSE; 
01005 
01006   //Just use any old table row object just to get a DbiDBProxy.
01007   DbiConfigSet pet;
01008   DbiTableProxy& tp =  DbiTableProxyRegistry::Instance()
01009                       .GetTableProxy(this->GetTableName(),&pet);
01010   if ( replace ) {
01011     const DbiDBProxy & proxy = tp.GetDBProxy();
01012     if ( ! proxy.RemoveSeqNo(this->GetSeqNo(),dbNo) ) return kFALSE;
01013   }
01014 
01015   // Locate required DbiStatement.
01016   auto_ptr<DbiStatement> stmtDb(DbiTableProxyRegistry::Instance()
01017                                .GetCascader()
01018                                .CreateStatement(dbNo));
01019   if ( ! stmtDb.get() ) {
01020     MSG("Dbi",Msg::kWarning) 
01021       << "Attempting to write to non-existant cascade entry " << dbNo
01022       << endl;
01023     return kFALSE;
01024   }
01025 
01026   // Decide if ROW_COUNTER column has to be removed i.e. Master
01027   // DB exported with ROW_COUNTER but Slave still has old table form
01028   // without ROW_COUNTER.
01029 
01030   bool removeRowCounter =    fgLastMetaHadRowCounter 
01031                           && ! tp.GetMetaData().HasRowCounter();
01032 
01033   // Loop processing all SQL statements
01034   Bool_t first = kTRUE;
01035   int combineInserts = 0;
01036   // Cannot group ORACLE inserts.
01037   int maxInserts = stmtDb->GetDBType() == Dbi::kOracle ? 1 : 20;  
01038   string sqlInserts;
01039 
01040   for (list<string>::const_iterator itr = fSqlStmts.begin();
01041        itr != fSqlStmts.end();
01042        ++itr) {
01043     if ( first ) {
01044 //    On first statement replace InsertDate by current datetime.
01045       string sql = *itr;
01046       list<string>::size_type locDate = sql.rfind(",\'");
01047       if ( locDate !=  string::npos ) {
01048         VldTimeStamp now;
01049         sql.replace(locDate+2,19,Dbi::MakeDateTimeString(now));
01050       }
01051       stmtDb->ExecuteUpdate(sql.c_str());
01052       if ( stmtDb->PrintExceptions() ) return kFALSE;
01053       first = kFALSE;
01054       continue;
01055     }
01056 
01057     string sql = *itr;
01058 
01059 //  On other statements remove the second (ROW_COUNTER) column if required.
01060     if (removeRowCounter) {
01061       list<string>::size_type locStart  = sql.find(',');
01062       ++locStart;
01063       list<string>::size_type locEnd    = sql.find(',',locStart);
01064       if ( locEnd !=  string::npos ) {
01065         list<string>::size_type numChars = locEnd - locStart + 1;
01066         sql.erase(locStart,numChars);
01067       }
01068     }
01069 
01070 //  Reduce database I/O by combining groups of insert commands.
01071 
01072     string::size_type insertIndex = sql.find("VALUES (");
01073     if ( insertIndex == string::npos) {
01074       MAXMSG("Dbi",Msg::kError,20) << "Unexpected SQL : " << sql
01075                              << "\n  should be of form INSERT INTO ... VALUES (...);" << endl;
01076       return kFALSE;
01077     }
01078     ++combineInserts;
01079     if ( combineInserts == 1 ) sqlInserts = sql;
01080     else {
01081       sqlInserts[sqlInserts.size()-1] = ',';
01082       sqlInserts += sql.substr(insertIndex+7);
01083     }
01084     if ( combineInserts >= maxInserts ) {
01085       stmtDb->ExecuteUpdate(sqlInserts.c_str());
01086       if ( stmtDb->PrintExceptions() ) return kFALSE;
01087       combineInserts = 0;
01088     }
01089   }
01090 
01091 // Deal with last group of inserts.
01092   if ( combineInserts ) {
01093     stmtDb->ExecuteUpdate(sqlInserts.c_str());
01094     combineInserts = 0;
01095     if ( stmtDb->PrintExceptions() ) return kFALSE;
01096   }
01097 
01098   return kTRUE;
01099 
01100 }

Bool_t DbiSqlValPacket::Write ( std::ofstream &  ios,
Bool_t  addMetadata = kFALSE 
) const

Definition at line 1103 of file DbiSqlValPacket.cxx.

References CanBeStored(), fSqlMySqlMetaMain, fSqlMySqlMetaVld, fSqlStmts, GetSeqNo(), GetTableName(), Msg::kWarning, and MSG.

Referenced by DbiWriter< T >::Close().

01104                                                         {
01105 //
01106 //
01107 //  Purpose:  Export to an iostream.
01108 //
01109 //  Arguments: 
01110 //     ios          in/out    Output stream.
01111 //     addMetadata  in        if kTRUE, output SQL metadata (in form
01112 //                            of a create table SQL)
01113 //
01114 //  Return:    kTRUE is I/O successful.
01115 //
01116 //  Contact:   N. West
01117 //
01118 //  Specification:-
01119 //  =============
01120 //
01121 //  o Export to an iostream.
01122 
01123 //  Program Notes:-
01124 //  =============
01125 
01126 //  None.
01127 
01128   if ( ! CanBeStored() ) return kFALSE;
01129   if ( addMetadata ) {
01130     if ( fSqlMySqlMetaMain.size() == 0 ) this->SetMetaData();
01131     if ( fSqlMySqlMetaMain.size() == 0 ) {    
01132       MSG("Dbi",Msg::kWarning) 
01133       << "Cannot write metadata; no associated DbiTableProxy "
01134       << endl;
01135     }
01136     else {
01137 
01138 
01139       ios << ">>>>>" << GetTableName() << " Metadata [MySQL]" << endl;
01140       ios << fSqlMySqlMetaVld   << endl;
01141       ios << fSqlMySqlMetaMain  << endl;
01142       ios << "<<<<<" << GetTableName() << " Metadata" << endl;
01143     }
01144   }
01145 
01146   ios << ">>>>>" << GetTableName() << "  " << GetSeqNo() << endl;
01147 
01148   for ( list<string>::const_iterator itr = fSqlStmts.begin();
01149         itr != fSqlStmts.end();
01150         ++itr) ios << (*itr) << endl;
01151 
01152   ios << "<<<<<" << GetTableName() << "  " << GetSeqNo() << endl;    
01153 
01154   return kTRUE;
01155 
01156 }


Member Data Documentation

VldTimeStamp DbiSqlValPacket::fCreationDate [private]

Creation date, or object creation date if unfilled.

Definition at line 149 of file DbiSqlValPacket.h.

Referenced by Fill(), GetCreationDate(), Print(), and SetCreationDate().

Bool_t DbiSqlValPacket::fgLastMetaHadRowCounter = false [static, private]

Definition at line 121 of file DbiSqlValPacket.h.

Referenced by Fill(), and Store().

UInt_t DbiSqlValPacket::fNumErrors [private]

Number of error encountered while filling.

Definition at line 128 of file DbiSqlValPacket.h.

Referenced by AddDataRow(), AddRow(), CanBeStored(), Clear(), GetNumErrors(), Print(), Recreate(), and Report().

UInt_t DbiSqlValPacket::fNumStmts [private]

Number of statements.

Definition at line 143 of file DbiSqlValPacket.h.

Referenced by AddRow(), Fill(), GetNumSqlStmts(), IsEqual(), and Reset().

UInt_t DbiSqlValPacket::fSeqNo [private]

Sequence number or 0 if not filled.

Definition at line 131 of file DbiSqlValPacket.h.

Referenced by CanBeStored(), Compare(), Fill(), GetSeqNo(), IsEqual(), Print(), Reset(), and SetSeqNo().

string DbiSqlValPacket::fSqlMySqlMetaMain [mutable, private]

MySQL SQL to create main table. May be empty until needed.

Definition at line 134 of file DbiSqlValPacket.h.

Referenced by CreateTable(), Fill(), Print(), Reset(), SetMetaData(), and Write().

string DbiSqlValPacket::fSqlMySqlMetaVld [mutable, private]

As fSqlMySqlMetaMain but for aux. table.

Definition at line 137 of file DbiSqlValPacket.h.

Referenced by CreateTable(), Fill(), Print(), Reset(), SetMetaData(), and Write().

std::list<string> DbiSqlValPacket::fSqlStmts [private]

Set of SQL statements to generate packet.

Definition at line 140 of file DbiSqlValPacket.h.

Referenced by AddRow(), Fill(), GetStmt(), IsEqual(), Print(), Reset(), SetCreationDate(), SetSeqNo(), Store(), and Write().

string DbiSqlValPacket::fTableName [private]

Table name or null if not filled.

Definition at line 146 of file DbiSqlValPacket.h.

Referenced by Compare(), CreateTable(), Fill(), GetTableName(), IsEqual(), Print(), Recreate(), and Reset().


The documentation for this class was generated from the following files:
Generated on Fri Oct 10 22:45:31 2014 for loon by  doxygen 1.4.7