69const char *
Bool =
"Bool_t";
70const char *
Char =
"Char_t";
72const char *
Int =
"Int_t";
73const char *
Long =
"Long_t";
79const char *
UInt =
"UInt_t";
219 v->SetBit(
BIT(20), numeric);
234 Int_t maxlen =
fFile->SQLMaxIdentifierLength();
246 scnt.
Form(
"%d", cnt);
251 if (
len + numlen > maxlen)
252 res.
Resize(maxlen - numlen);
262 }
while (cnt < 10000);
264 Error(
"DefineSQLName",
"Cannot find reasonable column name for field %s", fullname);
280 if (strcmp(colname, sqlname) == 0)
361 fValue.Form(
"%lld", refid);
371 fValue.Form(
"%lld", ptrid);
383 fValue.Form(
"%d", version);
581 child->SetParent(
this);
624 curr = recursive ? curr->
GetParent() :
nullptr;
644 child->SetObjectData(objdata);
677 case 0: std::cout <<
"Undefined type";
break;
687 std::cout <<
"Class: " << info->
GetName();
693 std::cout <<
"Member: " << elem->
GetName();
697 std::cout <<
"Value: " <<
fValue;
701 std::cout <<
" type = " << (
const char *)
fPointer;
705 std::cout <<
"Array ";
707 std::cout <<
" sz = " <<
fValue;
712 std::cout <<
"CustomClass: " << cl->
GetName() <<
" ver = " <<
fValue;
715 default: std::cout <<
"Unknown type";
717 std::cout << std::endl;
846 fPool.DeleteValues();
869 fPool.Add(sqlinfo, buf);
880 if ((values.
GetLast() < 0) || !tablename)
885 Int_t maxsize = 50000;
888 const char *quote =
fFile->SQLIdentifierQuote();
892 while ((cmd = iter()) !=
nullptr) {
894 if (sqlcmd.Length() == 0)
895 sqlcmd.Form(
"INSERT INTO %s%s%s VALUES (%s)", quote, tablename, quote, cmd->
GetName());
902 if (!canbelong || (sqlcmd.Length() > maxsize * 0.9)) {
908 if (sqlcmd.Length() > 0)
923 fFile->CreateRawTable(sqlinfo);
941 Error(
"AddRegCmd",
"Something wrong with objid = %lld", objid);
947 const char *quote =
fFile->SQLIdentifierQuote();
950 const char *pars =
fFile->IsOracle() ?
":1, :2, :3, :4" :
"?, ?, ?, ?";
965 const char *valuequote =
fFile->SQLValueQuote();
977 fFile->VerifyLongStringTable();
980 const char *valuequote =
fFile->SQLValueQuote();
1000 if (!
fFile->SQLCanStatement())
1003 const char *quote =
fFile->SQLIdentifierQuote();
1009 if (
fFile->IsOracle()) {
1017 stmt =
fFile->SQLStatement(sqlcmd.
Data(), 1000);
1025 Int_t sizelimit =
fFile->SQLSmallTextTypeLimit();
1045 const char *valuequote =
fFile->SQLValueQuote();
1093 if (stmt &&
fFile->IsOracle()) {
1102 void AddLine(
const char *
name,
const char *
value,
const char *topname =
nullptr,
const char *ns =
nullptr)
1111 maketmt = !
fCmdBuf->fBlobStmt &&
fFile->SQLCanStatement();
1117 const char *quote =
fFile->SQLIdentifierQuote();
1119 const char *params =
fFile->IsOracle() ?
":1, :2, :3, :4" :
"?, ?, ?, ?";
1120 sqlcmd.
Form(
"INSERT INTO %s%s%s VALUES (%s)", quote,
fInfo->GetRawTableName(), quote, params);
1127 const char *fullname =
name;
1128 if (topname && ns) {
1132 fullname = buf.
Data();
1203 reg.ConvertPoolValues();
1216 const char *ns =
reg->fFile->SQLNameSeparator();
1238 Error(
"PerformConversion",
"version without class");
1257 sobjid.
Form(
"%lld", objid);
1278 const char *tname = (
const char *)
fPointer;
1297 if (
size >
reg->fFile->SQLSmallTextTypeLimit()) {
1299 buf =
reg->fFile->CodeLongString(
reg->fCurrentObjId, strid);
1314 child->PerformConversion(
reg, blobs, topname, useblob);
1328 if (!cl || (objid < 0))
1332 std::cout <<
"Store object " << objid <<
" cl = " << cl->
GetName() << std::endl;
1342 reg->fCurrentObjId = objid;
1343 reg->fCurrentObjClass = cl;
1362 std::cout <<
"Store object " << objid <<
" of class " << cl->
GetName() <<
" normal = " << normstore
1363 <<
" sqltype = " <<
GetType() << std::endl;
1374 child->PerformConversion(
reg, &rawdata,
nullptr );
1381 reg->AddRegCmd(objid, cl);
1383 reg->fCurrentObjId = oldid;
1384 reg->fCurrentObjClass = oldcl;
1431 columns.
AddColumn(
reg->fFile->SQLObjectIdColumn(),
reg->fCurrentObjId);
1438 Error(
"StoreClassInNormalForm",
"CAN NOT BE");
1442 if (
child->StoreElementInNormalForm(
reg, &columns))
1447 Error(
"StoreClassInNormalForm",
"Element %s typ=%d has problem with normal store ", elem->
GetName(),
1457 if (
child->TryConvertObjectArray(
reg, &rawdata))
1463 if (blobid == rawdata.
fRawId)
1474 if (
reg->fFile->GetUseSuffixes())
1482 reg->InsertToNormalTable(&columns, sqlinfo);
1500 buf.
Form(
"%s%d%s",
"[", ix,
"]");
1520 std::cout <<
"Element " << elem->
GetName() <<
" type = " << typ <<
" column = " << columntyp << std::endl;
1531 Int_t sizelimit =
reg->fFile->SQLSmallTextTypeLimit();
1533 const char *stype =
reg->fFile->SQLSmallTextType();
1535 if (
len <= sizelimit)
1539 TString buf =
reg->fFile->CodeLongString(
reg->fCurrentObjId, strid);
1565 if (!
child->StoreObject(
reg, objid,
child->GetObjectClass()))
1577 objid =
reg->GetNextObjId();
1603 normal =
child->StoreObject(
reg, objid,
child->GetObjectClass());
1609 Error(
"kColNormObject",
"child->StoreObject fails");
1631 normal =
child->StoreObject(
reg, objid,
child->GetObjectClass());
1655 normal =
child->StoreObject(
reg, objid,
child->GetObjectClass());
1669 Error(
"StoreElementInNormalForm",
"Unexpected number %d for simple element %s",
NumChilds(), elem->
GetName());
1681 const char *sqltype =
reg->fFile->SQLCompatibleType(typ);
1692 Error(
"StoreElementInNormalForm",
"In fixed array %s only array node should be", elem->
GetName());
1697 const char *sqltype =
reg->fFile->SQLCompatibleType(typ % 20);
1711 while (
index < last) {
1748 const char *ns =
reg->fFile->SQLNameSeparator();
1762 sobjid.
Form(
"%lld", objid);
1781 TClass *info_cl =
nullptr;
1786 if (!ver_cl || !info_cl || (ver_cl != info_cl) || (ver_cl->
GetClassVersion() != info_ver))
1826 columns.
AddColumn(
reg->fFile->SQLObjectIdColumn(),
reg->fCurrentObjId);
1834 reg->InsertToNormalTable(&columns, sqlinfo);
1845 const char *
value =
nullptr;
1855 columns.
AddColumn(
reg->fFile->SQLObjectIdColumn(),
reg->fCurrentObjId);
1860 reg->InsertToNormalTable(&columns, sqlinfo);
1900 if (lenbig && !chars)
1904 value = chars->GetValue();
1934 if ((
f->GetArrayLimit() < 0) || (elem->
GetArrayLength() <=
f->GetArrayLimit()))
2022 const char *elemname = elem->
GetName();
2027 if (
f->GetUseSuffixes()) {
2028 colname +=
f->SQLNameSeparator();
2042 if (
f->GetUseSuffixes())
2049 if (
f->GetUseSuffixes())
2057 if (
f->GetUseSuffixes())
2064 if (
f->GetUseSuffixes())
2071 if (
f->GetUseSuffixes())
2078 if (
f->GetUseSuffixes())
2085 if (
f->GetUseSuffixes())
2092 if (
f->GetUseSuffixes())
2113 std::cout <<
"TSQLStructure::LocateElementColumn " << elem->
GetName() <<
" coltyp = " << coltype <<
" : "
2119 const char *elemname = elem->
GetName();
2125 std::cout <<
" colname = " << colname <<
" in " <<
data->GetInfo()->GetClassTableName() << std::endl;
2129 located =
data->LocateColumn(colname.
Data());
2134 located =
data->LocateColumn(colname);
2139 located =
data->LocateColumn(colname.
Data());
2144 const char *clname = elemname;
2182 located =
data->LocateColumn(colname.
Data());
2186 const char *strobjid =
data->GetValue();
2232 located =
data->LocateColumn(colname.
Data());
2241 located =
data->LocateColumn(colname.
Data());
2246 located =
data->LocateColumn(colname.
Data());
2251 located =
data->LocateColumn(colname);
2263 if (
f->GetLongString(objid, strid, buf2))
2367 if (strcmp(quote,
"\"") == 0)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Boolean (0=false, 1=true) (bool).
int Int_t
Signed integer 4 bytes (int).
short Version_t
Class version identifier (short).
long long Long64_t
Portable signed long integer 8 bytes.
const char Option_t
Option string (const char).
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void reg
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Converts data to SQL statements or read data from SQL tables.
Bool_t SqlObjectInfo(Long64_t objid, TString &clname, Version_t &version)
Returns object info like classname and version Should be taken from buffer, which is produced in the ...
TSQLObjectData * SqlObjectData(Long64_t objid, TSQLClassInfo *sqlinfo)
Creates TSQLObjectData for specified object id and specified class.
TClass instances represent classes, structs and namespaces in the ROOT type system.
Version_t GetClassVersion() const
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
const char * GetName() const override
Returns name of object.
Int_t GetLast() const override
Return index of last object in array.
Collectable string class.
virtual const char * GetName() const
Returns name of object.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TObject()
TObject constructor.
const char * GetSQLName() const
Contains information about tables specific to one class and version.
Bool_t IsClassTableExist() const
const char * GetClassTableName() const
const char * GetRawTableName() const
TString fName
! name of the table column
TString fValue
! value of the table column
TSQLColumnData(const char *name, const char *sqltype, const char *value, Bool_t numeric)
normal constructor of TSQLColumnData class specifies name, type and value for one column
Bool_t fNumeric
! for numeric quotes (double quotes) are not required
TString fType
! type of the table column
Access an SQL db via the TFile interface.
TSQLObjectData is used in TBufferSQL2 class in reading procedure.
Bool_t LocateColumn(const char *colname, Bool_t isblob=kFALSE)
locate column of that name in results
void ShiftToNextValue()
shift to next column or next row in blob data
const char * GetValue() const
Bool_t PrepareForRawData()
prepare to read data from raw table
virtual Bool_t NextIteration()=0
virtual Bool_t SetString(Int_t, const char *, Int_t=256)
virtual Bool_t Process()=0
virtual Bool_t SetInt(Int_t, Int_t)
virtual Bool_t SetLong64(Int_t, Long64_t)
Bool_t RecognizeTString(const char *&value)
prove that structure contains TString data
TSQLStructure * GetParent() const
Int_t LocateElementColumn(TSQLFile *f, TBufferSQL2 *buf, TSQLObjectData *data)
find column in TSQLObjectData object, which correspond to current element
TClass * GetObjectClass() const
return object class if type kSqlObject
void SetValue(const char *value, const char *tname=nullptr)
set structure type as kSqlValue
Bool_t TryConvertObjectArray(TSqlRegistry *reg, TSqlRawBuffer *blobs)
tries to write array of objects as list of object references in streamer table, while objects itself ...
static void AddStrBrackets(TString &s, const char *quote)
adds quotes around string value and replaces some special symbols
void Add(TSQLStructure *child)
Add child structure.
void AddVersion(const TClass *cl, Int_t version=-100)
add child as version
void SetVersion(const TClass *cl, Int_t version=-100)
set structure type as kSqlVersion
void SetObjectPointer(Long64_t ptrid)
set structure type as kSqlPointer
void SetArray(Int_t sz=-1)
Set structure as array element.
static Bool_t IsNumericType(Int_t typ)
defines if value is numeric and not requires quotes when writing
Int_t GetElementNumber() const
returns number of TStremerElement in TStreamerInfo
TSQLObjectData * GetObjectData(Bool_t search=false)
searches for objects data
TStreamerInfo * GetStreamerInfo() const
return TStreamerInfo* if type is kSqlStreamerInfo
void PerformConversion(TSqlRegistry *reg, TSqlRawBuffer *blobs, const char *topname, Bool_t useblob=kFALSE)
perform conversion of structure to sql statements first tries convert it to normal form if fails,...
Bool_t StoreTObject(TSqlRegistry *reg)
store data of TObject in special table workaround custom TObject streamer
TSQLStructure * GetChild(Int_t n) const
return child structure of index n
Bool_t GetClassInfo(TClass *&cl, Version_t &version)
provides class info if structure kSqlStreamerInfo or kSqlCustomClass
void SetCustomClass(const TClass *cl, Version_t version)
set structure type as kSqlCustomClass
const char * GetValue() const
returns value for different structure kinds has different sense For kSqlVersion it version,...
static Bool_t UnpackTString(TSQLFile *f, TBufferSQL2 *buf, TSQLObjectData *data, Long64_t objid, Int_t clversion)
Unpack TString data in form, accepted by custom TString streamer.
static Int_t DefineElementColumnType(TStreamerElement *elem, TSQLFile *f)
defines which kind of column can be assigned for this element Possible cases kColSimple - basic data ...
Long64_t FindMaxObjectId()
define maximum reference id, used for objects
void AddValue(const char *value, const char *tname=nullptr)
Add child structure as value.
Bool_t StoreObjectInNormalForm(TSqlRegistry *reg)
this function verify object child elements and calls transformation to class table
void SetStreamerInfo(const TStreamerInfo *info)
set structure type as kSqlStreamerInfo
void AddObjectData(TSQLObjectData *objdata)
add element with pointer to object data
void SetArrayIndex(Int_t indx, Int_t cnt=1)
set array index for this structure
Bool_t StoreClassInNormalForm(TSqlRegistry *reg)
produces data for complete class table where not possible, raw data for some elements are created
static TString MakeArrayIndex(TStreamerElement *elem, Int_t n)
produce string with complete index like [1][2][0]
Version_t GetCustomClassVersion() const
return custom class version if structures is kSqlCustomClass
static Bool_t UnpackTObject(TSQLFile *f, TBufferSQL2 *buf, TSQLObjectData *data, Long64_t objid, Int_t clversion)
Unpack TObject data in form, accepted by custom TObject streamer.
Bool_t StoreObject(TSqlRegistry *reg, Long64_t objid, TClass *cl, Bool_t registerobj=kTRUE)
convert object data to sql statements if normal (column-wise) representation is not possible,...
void ChangeValueOnly(const char *value)
change value of this structure used as "workaround" to keep object id in kSqlElement node
Bool_t ConvertToTables(TSQLFile *f, Long64_t keyid, TObjArray *cmds)
Convert structure to sql statements This function is called immediately after TBufferSQL2 produces th...
void Print(Option_t *option="") const override
print content of complete structure
void SetCustomElement(TStreamerElement *elem)
set structure type as kSqlCustomElement
const char * GetValueType() const
return value type if structure is kSqlValue
static TString DefineElementColumnName(TStreamerElement *elem, TSQLFile *f, Int_t indx=0)
returns name of the column in class table for that element
void SetObjectData(TSQLObjectData *objdata)
set element to be used for object data
void SetObjectRef(Long64_t refid, const TClass *cl)
set structure type as kSqlObject
Long64_t DefineObjectId(Bool_t recursive=kTRUE)
defines current object id, to which this structure belong make life complicated, because some objects...
TStreamerElement * GetElement() const
return TStremerElement* if type is kSqlElement
TClass * GetVersionClass() const
return class for version tag if type is kSqlVersion
void PrintLevel(Int_t level) const
print content of current structure
static const char * GetSimpleTypeName(Int_t typ)
provides name for basic types used as suffix for column name or field suffix in raw table
Bool_t StoreElementInNormalForm(TSqlRegistry *reg, TSQLTableData *columns)
tries to store element data in column
Bool_t CheckNormalClassPair(TSQLStructure *vers, TSQLStructure *info)
check if pair of two element corresponds to start of object, stored in normal form
Int_t NumChilds() const
number of child structures
TClass * GetCustomClass() const
return element custom class if structures is kSqlCustomClass
~TSQLStructure() override
destructor
Bool_t StoreTString(TSqlRegistry *reg)
store data of TString in special table it is required when TString stored as pointer and reference to...
void SetClassStreamer(const TClass *cl)
set structure type as kSqlClassStreamer
void SetStreamerElement(const TStreamerElement *elem, Int_t number)
set structure type as kSqlElement
void ChildArrayIndex(Int_t index, Int_t cnt=1)
set array index for last child element if (cnt<=1) return;
void AddColumn(const char *name, Long64_t value)
Add INT column to list of columns.
TString DefineSQLName(const char *fullname)
produce suitable name for column, taking into account length limitation
~TSQLTableData() override
destructor
Bool_t HasSQLName(const char *sqlname)
checks if columns list already has that sql name
const char * GetColumn(Int_t n)
return column value
Bool_t IsNumeric(Int_t n)
identifies if column has numeric value
TObjArray fColumns
! collection of columns
Int_t GetNumColumns()
returns number of columns in provided set
TObjArray * fColInfos
! array with TSQLClassColumnInfo, used later for TSQLClassInfo
TSQLTableData(TSQLFile *f=nullptr, TSQLClassInfo *info=nullptr)
normal constructor
TObjArray * TakeColInfos()
take ownership over colinfos
TSQLStatement * fBlobStmt
TSQLStatement * fNormStmt
~TSqlCmdsBuffer() override
TSqlCmdsBuffer(TSQLFile *f, TSQLClassInfo *info)
void AddValues(Bool_t isnorm, const char *values)
~TSqlRawBuffer() override
TSqlRawBuffer(TSqlRegistry *reg, TSQLClassInfo *sqlinfo)
void AddLine(const char *name, const char *value, const char *topname=nullptr, const char *ns=nullptr)
Bool_t InsertToNormalTableOracle(TSQLTableData *columns, TSQLClassInfo *sqlinfo)
TSqlCmdsBuffer * GetCmdsBuffer(TSQLClassInfo *sqlinfo)
TClass * fCurrentObjClass
void InsertToNormalTable(TSQLTableData *columns, TSQLClassInfo *sqlinfo)
void AddRegCmd(Long64_t objid, TClass *cl)
void AddSqlCmd(const char *query)
void ConvertSqlValues(TObjArray &values, const char *tablename)
Int_t AddLongString(const char *strvalue)
Describe one element (data member) to be Streamed.
virtual TClass * GetClassPointer() const
Returns a pointer to the TClass of this element and updates fClassObject.
Int_t GetArrayDim() const
TMemberStreamer * GetStreamer() const
Return the local streamer object.
Int_t GetArrayLength() const
Int_t GetMaxIndex(Int_t i) const
Describes a persistent version of a class.
Int_t GetClassVersion() const override
TClass * GetClass() const override
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
void Resize(Ssiz_t n)
Resize the string. Truncate or add blanks as necessary.
TString & Prepend(const char *cs)
TString & Append(const char *cs)
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Long64_t Atoll() const
Return long long value of string.
@ kUChar
Equal to TDataType's kchar.
const char * cfg_UseIndexes
const char * StringsTable
const char * ObjectsTableIndex
const char * ObjectSuffix
const char * KeysTableIndex
Long64_t atol64(const char *value)
const char * TStringValue
const char * cfg_TablesType
const Int_t Ids_FirstObject
const char * ObjectRef_Arr
const Int_t Ids_StreamerInfos
const char * ParentSuffix
const char * cfg_ArrayLimit
const char * TObjectProcessId
const char * PointerSuffix
const char * IdsTableIndex
const char * cfg_UseTransactions
const char * cfg_LockingMode
const char * cfg_UseSufixes
const char * ObjectsTable
const char * cfg_ModifyCounter
const char * TObjectUniqueId
const char * LongStrPrefix