330 fBasicTypes(mysql_BasicTypes),
331 fOtherTypes(mysql_OtherTypes),
338 ::Fatal(
"TFile::TFile",
"ROOT system not initialized");
342 SetTitle(
"TFile interface to SQL DB");
346 if (dbname && strstr(dbname,
"oracle://")!=0) {
390 if (!create && !recreate && !update && !read) {
395 if (!dbname || !dbname[0]) {
396 Error(
"TSQLFile",
"Database not specified");
405 Error(
"TSQLFile",
"Cannot connect to DB %s", dbname);
412 Error(
"TSQLFile",
"no write permission, DB %s locked", dbname);
422 Error(
"TSQLFile",
"DB tables already exists");
433 Error(
"TSQLFile",
"no write permission, DB %s locked", dbname);
440 Error(
"TSQLFile",
"DB %s tables not exist", dbname);
444 Error(
"TSQLFile",
"no read permission for DB %s tables", dbname);
451 if (create || update) {
480 fLogFile =
new std::ofstream(fname);
529 Error(
"SetUseSuffixes",
"Configurations already cannot be changed");
545 Error(
"SetArrayLimit",
"Configurations already cannot be changed");
559 Error(
"SetTablesType",
"Configurations already cannot be changed");
594 Error(
"SQLStartTransaction",
"Only allowed when SetUseTransactions(kUserTransactions) was configured");
608 Error(
"SQLCommit",
"Only allowed when SetUseTransactions(kUserTransactions) was configured");
622 Error(
"SQLRollback",
"Only allowed when SetUseTransactions(kUserTransactions) was configured");
644 Error(
"SetUseIndexes",
"Configurations already cannot be changed");
657 if (name==0)
return 0;
705 gROOT->GetListOfFiles()->Remove(
this);
754 if (opt !=
"READ" && opt !=
"UPDATE") {
755 Error(
"ReOpen",
"mode must be either READ or UPDATE, not %s", opt.
Data());
777 Error(
"ReOpen",
"Tables are locked, no write access");
796 return new TKeySQL(mother, obj, name);
804 return new TKeySQL(mother, obj, cl, name);
826 Info(
"WriteStreamerInfo",
"Saving streamer infos to database");
837 if (
gDebug>1)
Info(
"WriteStreamerInfo",
"Add %s",info->GetName());
857 if (obj==0)
return kTRUE;
882 if (key==0)
return obj;
910 Info(
"GetStreamerInfoList",
"Start reading of streamer infos");
915 if (list==0) {
delete obj; list =
new TList; }
939 if (dir==0)
return -1;
946 sqlcmd.
Form(
"SELECT * FROM %s%s%s WHERE %s%s%s=%lld",
949 if (specialkeyid>=0) {
957 if (res==0)
return -1;
963 while ((row = res->
Next()) != 0) {
969 const char* keyname = (*row)[3];
970 const char* keytitle = (*row)[4];
971 const char* keydatime = (*row)[5];
972 Int_t cycle = atoi((*row)[6]);
973 const char* classname = (*row)[7];
976 std::cout <<
" Reading keyid = " << keyid <<
" name = " << keyname << std::endl;
983 Error(
"StreamKeysForDirectory",
"Key with id %lld not exist in list", keyid);
986 if (key->
IsKeyModified(keyname, keytitle, keydatime, cycle, classname))
992 keydatime, cycle, classname);
994 { *specialkey = key; nkeys = 1; }
1005 Info(
"StreamKeysForDirectory",
"dir = %s numread = %d",dir->
GetName(), nkeys);
1018 Int_t len =
gROOT->GetListOfStreamerInfo()->GetSize()+1;
1019 if (len<5000) len = 5000;
1041 Error(
"InitSqlDatabase",
"Cannot detect proper tabled in database. Close.");
1053 gROOT->GetListOfFiles()->Add(
this);
1075 sqlcmd.
Form(
"SELECT * FROM %s%s%s",
1079 if (res==0)
return kFALSE;
1086 #define ReadIntCfg(name, target) \
1087 if ((field.CompareTo(name, TString::kIgnoreCase)==0)) \
1088 target = value.Atoi(); else
1090 #define ReadBoolCfg(name, target) \
1091 if ((field.CompareTo(name, TString::kIgnoreCase)==0)) \
1092 target = value.CompareTo(sqlio::True, TString::kIgnoreCase)==0; else
1094 #define ReadStrCfg(name, target) \
1095 if ((field.CompareTo(name, TString::kIgnoreCase)==0)) \
1096 target = value; else
1100 while ((row = res->
Next()) != 0) {
1116 Error(
"ReadConfigurations",
"Invalid configuration field %s", field.
Data());
1145 sqlcmd.
Form(
"CREATE TABLE %s%s%s (%s%s%s %s, %s%s%s %s)",
1150 sqlcmd +=
" ENGINE=";
1156 #define WrintCfg(name, type, value) \
1158 sqlcmd.Form("INSERT INTO %s%s%s VALUES (%s%s%s, %s" type "%s)", \
1159 quote, sqlio::ConfigTable, quote, \
1160 vquote, name, vquote, \
1161 vquote, value, vquote); \
1162 SQLQuery(sqlcmd.Data()); \
1182 sqlcmd.
Form(
"CREATE TABLE %s%s%s (%s%s%s %s, %s%s%s %s, %s%s%s %s, %s%s%s %s, %s%s%s %s, %s%s%s %s, %s%s%s %s, %s%s%s %s)",
1194 sqlcmd +=
" ENGINE=";
1201 sqlcmd.
Form(
"CREATE UNIQUE INDEX %s%s%s ON %s%s%s (%s%s%s)",
1218 Error(
"IncrementModifyCounter",
"Cannot update tables without write accsess");
1226 sqlcmd.
Form(
"UPDATE %s%s%s SET %s%s%s=%d WHERE %s%s%s=%s%s%s",
1248 if (sqlinfo==0)
return res;
1256 res.
Form(
"SELECT %s FROM %s", columns.Data(), tables.Data());
1271 if ((info==0) || (sqlinfo==0))
return kFALSE;
1278 table_syn.
Form(
"t%d", ++tablecnt);
1287 buf.
Form(
" LEFT JOIN %s AS %s USING(%s%s%s)",
1320 buf.
Form(
", %s.%s%s%s",table_syn.
Data(), quote, colname.
Data(), quote);
1326 TClass* parentcl = elem->GetClassPointer();
1329 columns, tables, tablecnt);
1334 for(
Int_t n=0;
n<elem->GetArrayLength();
n++) {
1336 buf.
Form(
", %s.%s%s%s",table_syn.
Data(), quote, colname.
Data(), quote);
1372 sqlcmd.
Form(
"UPDATE %s%s%s SET %s%s%s=%d WHERE %s%s%s=%s%s%s",
1389 sqlcmd.
Form(
"SELECT %s%s%s FROM %s%s%s WHERE %s%s%s=%s%s%s",
1397 TString field = (row==0) ?
"" : row->GetField(0);
1403 return field.
Atoi();
1432 if (
fSQL==0)
return 0;
1440 if (ok!=0) *ok = res;
1445 if (ok!=0) *ok = res!=0;
1446 if (res==0)
return 0;
1469 if (
fSQL==0)
return 0;
1474 Info(
"SQLStatement",
"%s", cmd);
1487 if (stmt==0)
return;
1505 while ((cmd=
iter())!=0) {
1535 if (
fSQL==0)
return -1;
1538 Info(
"SQLMaximumValue",
"Requests for %s column %s", tablename, columnname);
1543 query.
Form(
"SELECT MAX(%s%s%s) FROM %s%s%s",
1544 quote, columnname, quote,
1545 quote, tablename, quote);
1548 if (res==0)
return -1;
1561 Info(
"SQLMaximumValue",
"Result = %lld",maxid);;
1571 if (
fSQL==0)
return;
1574 if (tables==0)
return;
1581 while ((obj=
iter())!=0) {
1582 sqlcmd.
Form(
"DROP TABLE %s%s%s", quote, obj->
GetName(), quote);
1620 if (maxlen<10) maxlen = 10;
1636 sqlcmd.
Form(
"SELECT MIN(%s%s%s), MAX(%s%s%s) FROM %s%s%s WHERE %s%s%s=%lld",
1645 if ((row!=0) && (row->GetField(0)!=0) && (row->GetField(1)!=0)) {
1658 querymask.
Form(
"DELETE FROM %s%s%s WHERE %s%s%s BETWEEN %lld AND %lld",
1691 if (dir==0)
return 0;
1696 while ((obj =
next())!=0) {
1718 sqlcmd.
Form(
"INSERT INTO %s%s%s VALUES (%lld, %lld, %lld, %s%s%s, %s%s%s, %s%s%s, %d, %s%s%s)",
1721 valuequote, key->
GetName(), valuequote,
1722 valuequote, key->
GetTitle(), valuequote,
1755 sqlcmd.
Form(
"UPDATE %s%s%s SET %s%s%s=%s, %s%s%s=%s, %s%s%s=%s, %s%s%s=%d WHERE %s%s%s=%lld",
1798 if (strcmp(info->
GetName(), clname)==0)
1818 if (info!=0)
return info;
1820 if (
fSQL==0)
return 0;
1853 const char *suffix = rawtable ?
"_raw" :
"_ver";
1855 res.
Form(
"%s%s%d", clname, suffix, version);
1862 Int_t len = strlen(clname);
1864 if (cnt>100) cnt = 0;
1867 scnt.
Form(
"%d%s",cnt, suffix);
1869 if (numlen>=maxlen-2)
break;
1873 if (len + numlen > maxlen)
1874 res.
Resize(maxlen - numlen);
1882 }
while (cnt<10000);
1884 Error(
"DefineTableName",
"Cannot produce table name for class %s ver %d", clname, version);
1885 res.
Form(
"%s%s%d", clname, suffix, version);
1920 if (
fSQL==0)
return;
1929 sqlcmd.
Form(
"SELECT * FROM %s%s%s WHERE %s%s%s = %d ORDER BY %s%s%s",
1939 while ((row = res->
Next())!=0) {
1941 Int_t version = atoi(row->GetField(1));
1943 const char* classname = row->GetField(3);
1944 const char* classtable = row->GetField(4);
1961 sqlcmd.
Form(
"SELECT * FROM %s%s%s WHERE %s%s%s = %lld ORDER BY %s%s%s",
1970 while ((row = res->
Next())!=0) {
1972 Int_t typ = atoi(row->GetField(2));
1974 const char* fullname = row->GetField(3);
1975 const char* sqlname = row->GetField(4);
1976 const char* info2 = row->GetField(5);
1991 sqlcmd.
Form(
"SELECT * FROM %s%s%s WHERE %s%s%s = %d ORDER BY %s%s%s",
1999 while ((row = res->
Next())!=0) {
2001 Int_t version = atoi(row->GetField(1));
2003 const char* classname = row->GetField(3);
2004 const char* rawtable = row->GetField(4);
2029 const char*
name,
const char* sqlname,
const char* info)
2044 sqlcmd.
Form(
"CREATE TABLE %s%s%s (%s%s%s %s, %s%s%s %s, %s%s%s %s, %s%s%s %s, %s%s%s %s, %s%s%s %s)",
2053 sqlcmd +=
" ENGINE=";
2061 sqlcmd.
Form(
"INSERT INTO %s%s%s VALUES (%lld, %d, %d, %s%s%s, %s%s%s, %s%s%s)",
2063 tableid, subid, type,
2064 valuequote, name, valuequote,
2065 valuequote, sqlname, valuequote,
2066 valuequote, info, valuequote);
2076 if (sqlinfo==0)
return kFALSE;
2091 Info(
"CreateClassTable",
"cl:%s", sqlinfo->
GetName());
2100 "Main class table");
2103 sqlcmd.
Form(
"CREATE TABLE %s%s%s (",
2112 if (!first) sqlcmd+=
", ";
else first =
false;
2115 if ((strpbrk(colname,
"[:.]<>")!=0) || forcequote) {
2137 sqlcmd +=
" ENGINE=";
2150 sqlcmd.
Form(
"CREATE UNIQUE INDEX %s%s_I1%s ON %s%s%s (%s%s%s)",
2151 quote, indxname.
Data(), quote,
2165 if (sqlinfo==0)
return kFALSE;
2176 sqlcmd.
Form(
"CREATE TABLE %s%s%s (%s%s%s %s, %s%s%s %s, %s %s, %s %s)",
2184 sqlcmd +=
" ENGINE=";
2195 sqlcmd.
Form(
"CREATE UNIQUE INDEX %s%s_I2%s ON %s%s%s (%s%s%s, %s%s%s)",
2196 quote, indxname.
Data(), quote,
2208 "Raw data class table");
2226 sqlcmd.
Form(
"CREATE TABLE %s (%s%s%s %s, %s%s%s %s, %s %s)",
2233 sqlcmd +=
" ENGINE=";
2258 if (value==0)
return 0;
2263 if (*value++!=
' ')
return 0;
2265 if ((*value<
'1') || (*value>
'9'))
return 0;
2267 s_objid.
Append(*value++);
2268 }
while ((*value!=0) && (*value>=
'0') && (*value<=
'9'));
2270 if (*value++ !=
' ')
return 0;
2273 if (*value++!=
' ')
return 0;
2275 if ((*value<
'1') || (*value>
'9'))
return 0;
2277 s_strid.
Append(*value++);
2278 }
while ((*value!=0) && (*value>=
'0') && (*value<=
'9'));
2279 if (*value++!=
' ')
return 0;
2284 if (objid2!=objid)
return 0;
2286 return atoi(s_strid.
Data());
2299 cmd.
Form(
"SELECT %s FROM %s%s%s WHERE %s%s%s=%lld AND %s%s%s=%d",
2306 if (res==0)
return kFALSE;
2308 if (row==0) {
delete res;
return kFALSE; }
2324 if (
fSQL==0)
return -1;
2329 Info(
"VerifyObjectTable",
"Checks if object table is there");
2336 sqlcmd.
Form(
"CREATE TABLE %s%s%s (%s%s%s %s, %s%s%s %s, %s%s%s %s, %s%s%s %s)",
2344 sqlcmd +=
" ENGINE=";
2351 sqlcmd.
Form(
"CREATE UNIQUE INDEX %s%s%s ON %s%s%s (%s%s%s)",
2371 sqlcmd.
Form(
"SELECT %s%s%s, %s%s%s FROM %s%s%s WHERE %s%s%s=%lld",
2377 if (res==0)
return kFALSE;
2395 if (
fSQL==0)
return 0;
2399 sqlcmd.
Form(
"SELECT %s%s%s, %s%s%s, %s%s%s FROM %s%s%s WHERE %s%s%s=%lld ORDER BY %s%s%s",
2422 const char* clname = stmt->
GetString(1);
2435 if (res==0)
return 0;
2438 while ((row = res->
Next()) != 0) {
2440 const char* clname = row->
GetField(1);
2461 sqlcmd.
Form(
"SELECT * FROM %s%s%s WHERE %s%s%s=%lld",
2475 sqlcmd.
Form(
"SELECT * FROM %s%s%s WHERE %s%s%s BETWEEN %lld AND %lld ORDER BY %s%s%s",
2490 sqlcmd.
Form(
"SELECT %s, %s FROM %s%s%s WHERE %s%s%s=%lld ORDER BY %s%s%s",
2508 sqlcmd.
Form(
"SELECT %s, %s FROM %s%s%s WHERE %s%s%s=%lld ORDER BY %s%s%s",
2520 if (stmt==0)
return 0;
2534 if (
fSQL==0)
return -1;
2537 if (objid<=0) objid = 1;
else objid++;
2544 Error(
"StoreObjectInTables",
"Cannot convert object data to TSQLStructure");
2551 Error(
"StoreObjectInTables",
"Cannot convert to SQL statements");
2562 Error(
"StoreObject",
"Cannot correctly store object data in database");
2581 return (typ<0) || (typ>18) ? 0 :
fBasicTypes[typ];
2598 if (mother==0) mother =
this;
2634 if (sqlinfo==0)
return;
2643 TString timeC = fDatimeC.AsSQLString();
2646 TString timeM = fDatimeM.AsSQLString();
2654 TString col1name =
"CreateTime";
2655 TString col2name =
"ModifyTime";
2663 sqlcmd.
Form(
"UPDATE %s%s%s SET %s%s%s=%s, %s%s%s=%s, %s%s%s=%s WHERE %s%s%s=%lld",
2665 quote, col1name.
Data(), quote, timeC.
Data(),
2666 quote, col2name.
Data(), quote, timeM.
Data(),
2667 quote, col3name.
Data(), quote, uuid.
Data(),
2677 void TSQLFile::Streamer(
TBuffer &b)
2709 sbuf = fDatimeC.AsSQLString();
2714 sbuf = fDatimeM.AsSQLString();
2718 sbuf = fUUID.AsString();
virtual Bool_t Exec(const char *sql)
Execute sql query.
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
Int_t GetErrorFlag() const
virtual const char * GetTitle() const
Returns title of object.
TSQLResult * GetBlobClassData(Long64_t objid, TSQLClassInfo *sqlinfo)
Method return request results for specified objid from streamer classtable.
void * SqlReadAny(Long64_t keyid, Long64_t objid, TClass **cl, void *obj=0)
Recreate object from sql structure.
void SetClassTableName(const char *name)
double read(const std::string &file_name)
reading
static Int_t DefineElementColumnType(TStreamerElement *elem, TSQLFile *f)
defines which kind of column can be assigned for this element Possible cases kColSimple - basic data ...
const char ** fOtherTypes
! pointer on list of other SQL types like TEXT or blob
void StartLogFile(const char *fname)
start logging of all SQL statements in specified file
Char_t fUnits
Number of bytes for file pointers.
Bool_t fCanChangeConfig
! variable indicates can be basic configuration changed or not
Bool_t SQLApplyCommands(TObjArray *cmds)
supplies set of commands to server Commands is stored as array of TObjString
virtual void ClassBegin(const TClass *, Version_t=-1)=0
TString CodeLongString(Long64_t objid, Int_t strid)
Produces id which will be placed in column instead of string itself.
Long64_t SQLMaximumValue(const char *tablename, const char *columnname)
Returns maximum value, found in specified columnname of table tablename Column type should be numeric...
Int_t StreamKeysForDirectory(TDirectory *dir, Bool_t doupdate, Long64_t specialkeyid=-1, TKeySQL **specialkey=0)
read keys for specified directory (when update == kFALSE) or update value for modified keys when upda...
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
void InitSqlDatabase(Bool_t create)
initialize sql database and correspondent structures identical to TFile::Init() function ...
TObjArray * fProcessIDs
!Array of pointers to TProcessIDs
Info (classname, version) about object in database.
void StopLogFile()
close logging file
virtual Long64_t GetLong64(Int_t)
Bool_t SQLCommit()
Commit SQL transaction.
Long64_t fBytesWrite
Number of bytes written to this file.
Long64_t GetDBDirId() const
return sql id of parent directory
const char * GetRawTableName() const
virtual TList * GetListOfKeys() const
TSQLResult * GetNormalClassDataAll(Long64_t minobjid, Long64_t maxobjid, TSQLClassInfo *sqlinfo)
Return data for several objects from the range from normal class table.
Double_t fSumBuffer
Sum of buffer sizes of objects written so far.
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
void SetRawTableName(const char *name)
std::ofstream * fLogFile
! log file with SQL statements
virtual TClass * GetClass() const =0
Bool_t GetUseSuffixes() const
TSQLResult * GetNormalClassData(Long64_t objid, TSQLClassInfo *sqlinfo)
Method return request result for specified objid from normal classtable.
TArrayC * fClassIndex
!Index of TStreamerInfo classes written to this file
Int_t GetUseIndexes() const
virtual TSQLResult * Query(const char *sql)=0
static TSQLServer * Connect(const char *db, const char *uid, const char *pw)
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
Bool_t Rollback()
Rollback all operations, done after StartTransaction() call.
virtual Int_t ReOpen(Option_t *mode)
Reopen a file with a different access mode, like from READ to See TFile::Open() for details...
TSQLServer * fSQL
! interface to SQL database
TString & ReplaceAll(const TString &s1, const TString &s2)
TString fTablesType
! type, used in CREATE TABLE statements
TSQLFile()
default TSQLFile constructor
const char * cfg_UseTransactions
virtual void DirWriteHeader(TDirectory *)
Update dir header in the file.
Int_t fUseTransactions
! use transaction statements for writing data into the tables
Bool_t IsClassTableExist() const
Long64_t GetDBObjId() const
const char * SQLDirIdColumn() const
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Short_t GetCycle() const
Return cycle number associated to this key.
Bool_t SQLStartTransaction()
Start SQL transaction.
void ToUpper()
Change string to upper case.
Buffer base class used for serializing objects.
Bool_t IsODBC() const
checks, if ODBC driver used for database connection
void SQLDeleteStatement(TSQLStatement *stmt)
delete statement and decrease counter
#define ReadBoolCfg(name, target)
Int_t IsLongStringCode(Long64_t objid, const char *value)
Checks if this is long string code returns 0, if not or string id.
virtual Bool_t StartTransaction()
submit "START TRANSACTION" query to database return kTRUE, if successful
virtual Bool_t IsOpen() const
return kTRUE if file is opened and can be accessed
Contains information about tables specific to one class and version.
const char * cfg_LockingMode
virtual Bool_t StoreResult()=0
virtual const char * GetClassName() const
Bool_t UpdateKeyData(TKeySQL *key)
Updates (overwrites) key data in KeysTable.
void ToLower()
Change string to lower-case.
Long64_t StoreObjectInTables(Long64_t keyid, const void *obj, const TClass *cl)
Store object in database. Return stored object id or -1 if error.
R__EXTERN TVirtualMutex * gROOTMutex
const char * SQLIdentifierQuote() const
virtual TSQLStatement * Statement(const char *, Int_t=100)
TSQLClassInfo * RequestSQLClassInfo(const char *clname, Int_t version)
Search in database tables for specified class and return TSQLClassInfo object.
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
Int_t fStmtCounter
! count numbers of active statements
const char * SQLObjectIdColumn() const
void CreateBasicTables()
Creates initial tables in database This is table with configurations and table with keys Function cal...
Long64_t fSeekInfo
Location on disk of StreamerInfo record.
Bool_t ReadConfigurations()
read table configurations as special table
const char * cfg_UseIndexes
Bool_t IsMySQL() const
checks, if MySQL database
virtual const char * GetString(Int_t)
Int_t GetUseTransactions() const
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Bool_t HasTable(const char *name)
Test if table name exists.
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
Int_t fQuerisCounter
! how many query was applied
const char * GetDataBaseName() const
Return name of data base on the host For Oracle always return 0.
const char * Data() const
const char * StringsTable
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Long64_t atol64(const char *value)
Int_t fSQLIOversion
! version of SQL I/O which is stored in configurations
Int_t fNbytesInfo
Number of bytes for StreamerInfo record.
virtual void ClassMember(const char *, const char *=0, Int_t=-1, Int_t=-1)=0
Bool_t StartTransaction()
Start user transaction.
virtual const char * GetName() const
Returns name of object.
const char * oracle_OtherTypes[13]
Bool_t IsKeyModified(const char *keyname, const char *keytitle, const char *keydatime, Int_t cycle, const char *classname)
Compares keydata with provided and return kTRUE if key was modified Used in TFile::StreamKeysForDirec...
const char ** fBasicTypes
! pointer on list of basic types specific for currently connected SQL server
const char * ObjectsTableIndex
virtual void SetCompressionLevel(Int_t level=1)
See comments for function SetCompressionSettings.
void SetLocking(Int_t mode)
Set locking mode for current database.
TString fRealName
Effective real file name (not original url)
const char * SQLDefaultTableType() const
Bool_t ProduceClassSelectQuery(TVirtualStreamerInfo *info, TSQLClassInfo *sqlinfo, TString &columns, TString &tables, Int_t &tablecnt)
used by MakeClassSelectQuery method to add columns from table of class, specified by TVirtualStreamer...
virtual Bool_t Rollback()
submit "ROLLBACK" query to database return kTRUE, if successful
std::map< std::string, std::string >::const_iterator iter
TSQLResult * SQLQuery(const char *cmd, Int_t flag=0, Bool_t *res=0)
Submits query to SQL server.
This is hierarhical structure, which is created when data is written by TBufferSQL2.
const char * oracle_BasicTypes[21]
virtual Long64_t GetSeekDir() const
TString & Append(const char *cs)
Int_t fModifyCounter
! indicates how many changes was done with database tables
Bool_t CreateClassTable(TSQLClassInfo *sqlinfo, TObjArray *colinfos)
Create normal class table if required.
Bool_t IsWritable() const
Int_t Atoi() const
Return integer value of string.
TSQLStatement * SQLStatement(const char *cmd, Int_t bufsize=1000)
Produces SQL statement for currently conected DB server.
Int_t GetClassVersion() const
Book space in a file, create I/O buffers, to fill them, (un)compress them.
A TProcessID identifies a ROOT job in a unique way in time and space.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Long64_t fSeekDir
Location of directory on file.
const char * cfg_TablesType
Bool_t IsTablesExists()
Checks if main keys table is existing.
virtual void DirWriteKeys(TDirectory *)
Write directory keys list to database.
virtual Bool_t NextResultRow()=0
Long64_t GetClassId() const
void IncrementModifyCounter()
Update value of modify counter in config table Modify counter used to indicate that something was cha...
Bool_t SQLCanStatement()
Test if DB support statement and number of open statements is not exceeded.
Long64_t DefineNextKeyId()
Returns next possible key identifier.
Bool_t GetLongString(Long64_t objid, Int_t strid, TString &value)
Returns value of string, extracted from special table, where long strings are stored.
virtual const char * GetName() const
Returns name of object.
virtual const char * GetTitle() const
Returns title (title can contain 32x32 xpm thumbnail/icon).
Bool_t WriteKeyData(TKeySQL *key)
Add entry into keys table.
void ReadSQLClassInfos()
Read all class infos from IdsTable.
static TString DefineElementColumnName(TStreamerElement *elem, TSQLFile *f, Int_t indx=0)
returns name of the column in class table for that element
void AddIdEntry(Long64_t tableid, Int_t subid, Int_t type, const char *name, const char *sqlname, const char *info)
Add entry into IdsTable, where all tables names and columns names are listed.
const char * KeysTableIndex
virtual TKey * CreateKey(TDirectory *mother, const TObject *obj, const char *name, Int_t bufsize)
create SQL key, which will store object in data base
TString DefineTableName(const char *clname, Int_t version, Bool_t rawtable)
Proposes table name for class.
virtual ~TSQLFile()
destructor of TSQLFile object
const char * SQLSmallTextType() const
Access an SQL db via the TFile interface.
const char * SQLRawIdColumn() const
TList * fKeys
Pointer to keys list in memory.
const char * SQLIntType() const
return SQL integer type
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist...
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
#define ReadStrCfg(name, target)
const char * SQLDatetimeType() const
Bool_t Commit()
Commit transaction, started by StartTransaction() call.
void SetRawExist(Bool_t on)
virtual const char * ClassName() const
Returns name of class to which the object belongs.
TSQLClassInfo * FindSQLClassInfo(const char *clname, Int_t version)
Return (if exists) TSQLClassInfo for specified class name and version.
TSQLStatement * GetBlobClassDataStmt(Long64_t objid, TSQLClassInfo *sqlinfo)
Method return request results for specified objid from streamer classtable Data returned in form of s...
virtual Int_t GetMaxIdentifierLength()
const char * GetSQLType() const
const char * GetSQLName() const
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
virtual TList * GetStreamerInfoList()
Read back streamer infos from database List of streamer infos is always stored with key:id 0...
Bool_t SQLRollback()
Rollback all SQL operations, done after start transaction.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Int_t DecrementCount()
The reference fCount is used to delete the TProcessID in the TFile destructor when fCount = 0...
virtual Bool_t Commit()
submit "COMMIT" query to database return kTRUE, if successful
const char * AsString() const
Return UUID as string. Copy string immediately since it will be reused.
const char * LongStrPrefix
virtual const char * GetField(Int_t field)=0
virtual const char * GetName() const
Returns name of object.
TObjArray * SQLObjectsInfo(Long64_t keyid)
Produce array of TSQLObjectInfo objects for all objects, belong to that key Array should be deleted b...
The ROOT global object gROOT contains a list of all defined classes.
virtual Int_t GetInt(Int_t)
void SetUseIndexes(Int_t use_type=kIndexesBasic)
Specify usage of indexes for data tables Index Description kIndexesNone = 0 no indexes are used kInd...
void operator=(const TSQLFile &)
make private to exclude copy operator
TString MakeSelectQuery(TClass *cl)
Produce SELECT statement which can be used to get all data of class cl in one SELECT statement...
void Build(TFile *motherFile=0, TDirectory *motherDir=0)
Initialise directory to defaults.
Version_t GetClassVersion() const
const char * TObjectUniqueId
Bool_t fWritable
True if directory is writable.
void DeleteKeyFromDB(Long64_t keyid)
Remove key with specified id from keys table also removes all objects data, related to this table...
Bool_t IsOracle() const
checks, if Oracle database
void SetArrayLimit(Int_t limit=20)
Defines maximum number of columns for array representation If array size bigger than limit...
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
const char * mysql_BasicTypes[21]
virtual void ReadStreamerInfo()
Read the list of StreamerInfo from this file.
Double_t fSum2Buffer
Sum of squares of buffer sizes of objects written so far.
Converts data to SQL statements or read data from SQL tables.
TList * fFree
Free segments linked list table.
#define WrintCfg(name, type, value)
TFile * fFile
Pointer to current file in memory.
#define ReadIntCfg(name, target)
virtual Int_t GetSize() const
Bool_t CreateRawTable(TSQLClassInfo *sqlinfo)
Create the raw table.
Int_t GetLocking()
Return current locking mode for that file.
virtual void SetName(const char *newname)
Set the name for directory If the directory name is changed after the directory was written once...
virtual const char * GetName() const
Returns name of object.
const char * GetClassTableName() const
virtual TObjArray * GetElements() const =0
const Int_t Ids_StreamerInfos
const char * TObjectProcessId
Describe directory structure in memory.
virtual Int_t GetNumber() const =0
virtual void Clear(Option_t *option="")
delete the TObjArray pointing to referenced objects this function is called by TFile::Close("R") ...
void SetWritable(Bool_t writable=kTRUE)
Set the new value of fWritable recursively.
static void AddStrBrackets(TString &s, const char *quote)
adds quotes arround string value and replaces some special symbols
#define R__LOCKGUARD(mutex)
Bool_t SQLTestTable(const char *tablename)
Test, if table of specified name exists.
TString fOption
File options.
static TProcessID * GetSessionProcessID()
static function returning the pointer to the session TProcessID
virtual void Close(Option_t *option="")
Delete all objects from memory and directory structure itself.
const char * cfg_ArrayLimit
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
virtual TDirectory * GetMotherDir() const
const char * SQLStrIdColumn() const
Mother of all ROOT objects.
Bool_t WriteSpecialObject(Long64_t keyid, TObject *obj, const char *name, const char *title)
write special kind of object like streamer infos or file itself keys for that objects should exist in...
void SaveToDatabase()
save data which is not yet in Database Typically this is streamerinfos structures or ...
void SetTablesType(const char *table_type)
Defines tables type, which is used in CREATE TABLE statements Now is only used for MySQL database...
void SetUseTransactions(Int_t mode=kTransactionsAuto)
Defines usage of transactions statements for writing objects data to database.
Bool_t fIdsTableExists
! indicate if IdsTable exists
const char * SQLValueQuote() const
typedef void((*Func_t)())
virtual TList * GetTablesList(const char *wild=0)
Return list of user tables Parameter wild specifies wildcard for table names.
virtual void Add(TObject *obj)
Bool_t SQLObjectInfo(Long64_t objid, TString &clname, Version_t &version)
Read from objects table data for specified objectid.
virtual void WriteStreamerInfo()
Store all TVirtualStreamerInfo, used in file, in sql database.
virtual void ClassEnd(const TClass *)=0
Bool_t VerifyLongStringTable()
Checks that table for big strings is exists If not, will be created.
const char * ObjectsTable
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual Bool_t HasStatement() const
virtual Long64_t DirCreateEntry(TDirectory *)
Create entry for directory in database.
Int_t fNProcessIDs
Number of TProcessID written to this file.
TKeySQL represents metainforamtion about object, which was written to SQL database.
TObject * ReadSpecialObject(Long64_t keyid, TObject *obj=0)
Read data of special kind of objects.
virtual Bool_t Process()=0
virtual void WriteHeader()
Write file info like configurations, title, UUID and other.
Long64_t GetDBKeyId() const
Bool_t IsReadAccess()
dummy, in future should check about read access to database
Int_t fVersion
File format version.
TKeySQL * FindSQLKey(TDirectory *dir, Long64_t keyid)
Search for TKeySQL object with specified keyid.
virtual Bool_t HasTable(const char *tablename)
Tests if table of that name exists in database Return kTRUE, if table exists.
Bool_t fUseSuffixes
! use suffixes in column names like fValue:Int_t or fObject:pointer
TList * fSQLClassInfos
! list of SQL class infos
Int_t fWritten
Number of objects written so far.
TSQLStructure * SqlWriteAny(const void *obj, const TClass *cl, Long64_t objid)
Convert object of any class to sql structures Return pointer on created TSQLStructure TSQLStructure o...
void SQLDeleteAllTables()
Delete all tables in database.
Bool_t ConvertToTables(TSQLFile *f, Long64_t keyid, TObjArray *cmds)
Convert structure to sql statements This function is called immidiately after TBufferSQL2 produces th...
void SetUseSuffixes(Bool_t on=kTRUE)
enable/disable uasge of suffixes in columns names can be changed before first object is saved into fi...
const TDatime & GetDatime() const
Abstract Interface class describing Streamer information for one class.
Int_t SQLMaxIdentifierLength()
returns maximum allowed length of identifiers
const char * SQLBigTextType() const
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
virtual Int_t DirReadKeys(TDirectory *)
Read directory list of keys from database.
Int_t fUseIndexes
! use indexes for tables: 0 - off, 1 - only for basic tables, 2 + normal class tables, 3 - all tables
Int_t fArrayLimit
! limit for array size. when array bigger, its content converted to raw format
const char * SQLCompatibleType(Int_t typ) const
Returns sql type name which is most closer to ROOT basic type.
Bool_t IsRawTableExist() const
const char * SQLKeyIdColumn() const
const char * mysql_OtherTypes[13]
Long64_t fBytesRead
Number of bytes read from this file.
virtual void Close(Option_t *option="")
Close a SQL file For more comments see TFile::Close() function.
const char * AsSQLString() const
Return the date & time in SQL compatible string format, like: 1997-01-15 20:16:28.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
Bool_t IsWriteAccess()
Checkis, if lock is free in configuration tables.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
void SetColumns(TObjArray *columns)
assigns new list of columns
Long64_t VerifyObjectTable()
Checks that objects table is exists If not, table will be created Returns maximum value for existing ...
const char * cfg_UseSufixes
virtual TSQLRow * Next()=0
Array of chars or bytes (8 bits per element).
const char * cfg_ModifyCounter