48#if MYSQL_VERSION_ID >= 40100 
   82      mysql_stmt_close(
fStmt);
 
   91#define CheckStmt(method, res)                          \ 
   95         SetError(-1,"Statement handle is 0",method);   \
 
  101#define CheckErrNo(method, force, res)                  \ 
  103      unsigned int stmterrno = mysql_stmt_errno(fStmt);     \ 
  104      if ((stmterrno!=0) || force) {                        \ 
  105         const char* stmterrmsg = mysql_stmt_error(fStmt);  \ 
  106         if (stmterrno==0) { stmterrno = 11111; stmterrmsg = "MySQL statement error"; } \
 
  107         SetError(stmterrno, stmterrmsg, method);               \
 
  114#define CheckGetField(method, res)                      \ 
  117      if (!IsResultSetMode()) {                         \ 
  118         SetError(-1,"Cannot get statement parameters",method); \
 
  121      if ((npar<0) || (npar>=fNumBuffers)) {            \
 
  122         SetError(-1,Form("Invalid parameter number %d", npar),method); \
 
  144   if (mysql_stmt_execute(
fStmt))
 
  157   my_ulonglong res = mysql_stmt_affected_rows(
fStmt);
 
  159   if (res == (my_ulonglong) -1)
 
  187      SetError(-1,
"Cannot store result for that statement",
"StoreResult");
 
  191   if (mysql_stmt_store_result(
fStmt))
 
  195   MYSQL_RES* meta = mysql_stmt_result_metadata(
fStmt);
 
  197      int count = mysql_num_fields(meta);
 
  201      MYSQL_FIELD *fields = mysql_fetch_fields(meta);
 
  203      for (
int n=0;
n<count;
n++) {
 
  209      mysql_free_result(meta);
 
  268      SetError(-1,
"Cannot call for that statement",
"NextIteration");
 
  282   if (mysql_stmt_execute(
fStmt))
 
  314   if (numpars<=0) 
return;
 
  348   if ((
fBind[npar].buffer_type==MYSQL_TYPE_STRING) ||
 
  349      (
fBind[npar].buffer_type==MYSQL_TYPE_VAR_STRING))
 
  350      return (
const char *) addr;
 
  352   constexpr int kSize = 100;
 
  356   switch(
fBind[npar].buffer_type) {
 
  357      case MYSQL_TYPE_LONG:
 
  361      case MYSQL_TYPE_LONGLONG:
 
  365      case MYSQL_TYPE_SHORT:
 
  369      case MYSQL_TYPE_TINY:
 
  373      case MYSQL_TYPE_FLOAT:
 
  376      case MYSQL_TYPE_DOUBLE:
 
  379      case MYSQL_TYPE_DATETIME:
 
  380      case MYSQL_TYPE_TIMESTAMP: {
 
  381         MYSQL_TIME* tm = (MYSQL_TIME*) addr;
 
  383                            tm->year, tm->month,  tm->day,
 
  384                            tm->hour, tm->minute, tm->second);
 
  387      case MYSQL_TYPE_TIME: {
 
  388         MYSQL_TIME* tm = (MYSQL_TIME*) addr;
 
  390                             tm->hour, tm->minute, tm->second);
 
  393      case MYSQL_TYPE_DATE: {
 
  394         MYSQL_TIME* tm = (MYSQL_TIME*) addr;
 
  396                             tm->year, tm->month,  tm->day);
 
  404      SetError(-1, 
Form(
"Cannot convert param %d into string - buffer too small", npar));
 
  416   if (
fBuffer[npar].fResNull) 
return 0;
 
  421   if (addr==0) 
return 0;
 
  423   switch(
fBind[npar].buffer_type) {
 
  424      case MYSQL_TYPE_LONG:
 
  425         if (sig) 
return *((
int*) addr); 
else 
  426                  return *((
unsigned int*) addr);
 
  428      case MYSQL_TYPE_LONGLONG:
 
  429         if (sig) 
return *((
Long64_t*) addr); 
else 
  432      case MYSQL_TYPE_SHORT:
 
  433         if (sig) 
return *((
short*) addr); 
else 
  434                  return *((
unsigned short*) addr);
 
  436      case MYSQL_TYPE_TINY:
 
  437         if (sig) 
return *((
char*) addr); 
else 
  438                  return *((
unsigned char*) addr);
 
  440      case MYSQL_TYPE_FLOAT:
 
  441         return *((
float*) addr);
 
  443      case MYSQL_TYPE_DOUBLE:
 
  444         return *((
double*) addr);
 
  446#if MYSQL_VERSION_ID >= 50022 
  447      case MYSQL_TYPE_NEWDECIMAL :
 
  449      case MYSQL_TYPE_STRING:
 
  450      case MYSQL_TYPE_VAR_STRING:
 
  451      case MYSQL_TYPE_BLOB: {
 
  452         char* str = (
char*) addr;
 
  454         if ((str==0) || (*str==0) || (
len==0)) 
return 0;
 
  461         sscanf(str,
"%Lf",&buf);
 
  465      case MYSQL_TYPE_DATETIME:
 
  466      case MYSQL_TYPE_TIMESTAMP: {
 
  467         MYSQL_TIME* tm = (MYSQL_TIME*) addr;
 
  468         TDatime rtm(tm->year, tm->month,  tm->day,
 
  469                  tm->hour, tm->minute, tm->second);
 
  473      case MYSQL_TYPE_DATE: {
 
  474         MYSQL_TIME* tm = (MYSQL_TIME*) addr;
 
  475         TDatime rtm(tm->year, tm->month,  tm->day, 0, 0, 0);
 
  476         return rtm.GetDate();
 
  479      case MYSQL_TYPE_TIME: {
 
  480         MYSQL_TIME* tm = (MYSQL_TIME*) addr;
 
  481         TDatime rtm(2000, 1, 1, tm->hour, tm->minute, tm->second);
 
  482         return rtm.GetTime();
 
  508   if ((
fBuffer[npar].fSqlType==MYSQL_TYPE_LONG) && 
fBuffer[npar].fSign)
 
  521   if ((
fBuffer[npar].fSqlType==MYSQL_TYPE_LONG) && !
fBuffer[npar].fSign)
 
  534   if ((
fBuffer[npar].fSqlType==MYSQL_TYPE_LONG) && 
fBuffer[npar].fSign)
 
  547   if ((
fBuffer[npar].fSqlType==MYSQL_TYPE_LONGLONG) && 
fBuffer[npar].fSign)
 
  560   if ((
fBuffer[npar].fSqlType==MYSQL_TYPE_LONGLONG) && !
fBuffer[npar].fSign)
 
  573   if (
fBuffer[npar].fSqlType==MYSQL_TYPE_DOUBLE)
 
  586   if ((
fBind[npar].buffer_type==MYSQL_TYPE_STRING)
 
  587      || (
fBind[npar].buffer_type==MYSQL_TYPE_BLOB)
 
  588      || (
fBind[npar].buffer_type==MYSQL_TYPE_VAR_STRING)
 
  589#
if MYSQL_VERSION_ID >= 50022
 
  590      || (
fBuffer[npar].fSqlType==MYSQL_TYPE_NEWDECIMAL)
 
  593         if (
fBuffer[npar].fResNull) 
return nullptr;
 
  594         char *str = (
char *) 
fBuffer[npar].fMem;
 
  615   if ((
fBind[npar].buffer_type==MYSQL_TYPE_STRING) ||
 
  616       (
fBind[npar].buffer_type==MYSQL_TYPE_VAR_STRING) ||
 
  617       (
fBind[npar].buffer_type==MYSQL_TYPE_BLOB) ||
 
  618       (
fBind[npar].buffer_type==MYSQL_TYPE_TINY_BLOB) ||
 
  619       (
fBind[npar].buffer_type==MYSQL_TYPE_MEDIUM_BLOB) ||
 
  620       (
fBind[npar].buffer_type==MYSQL_TYPE_LONG_BLOB)) {
 
  639   switch(
fBind[npar].buffer_type) {
 
  640      case MYSQL_TYPE_DATETIME:
 
  641      case MYSQL_TYPE_TIMESTAMP:
 
  642      case MYSQL_TYPE_DATE: {
 
  643         MYSQL_TIME* tm = (MYSQL_TIME*) 
fBuffer[npar].fMem;
 
  665   switch(
fBind[npar].buffer_type) {
 
  666      case MYSQL_TYPE_DATETIME:
 
  667      case MYSQL_TYPE_TIMESTAMP:
 
  668      case MYSQL_TYPE_TIME: {
 
  669         MYSQL_TIME* tm = (MYSQL_TIME*) 
fBuffer[npar].fMem;
 
  691   switch(
fBind[npar].buffer_type) {
 
  692      case MYSQL_TYPE_DATETIME:
 
  693      case MYSQL_TYPE_TIMESTAMP: {
 
  694         MYSQL_TIME* tm = (MYSQL_TIME*) 
fBuffer[npar].fMem;
 
  719   switch(
fBind[npar].buffer_type) {
 
  720      case MYSQL_TYPE_DATETIME:
 
  721      case MYSQL_TYPE_TIMESTAMP: {
 
  722         MYSQL_TIME* tm = (MYSQL_TIME*) 
fBuffer[npar].fMem;
 
  759      case MYSQL_TYPE_LONG:     allocsize = 
sizeof(
int);  
break;
 
  760      case MYSQL_TYPE_LONGLONG: allocsize = 
sizeof(
Long64_t); 
break;
 
  761      case MYSQL_TYPE_SHORT:    allocsize = 
sizeof(short); 
break;
 
  762      case MYSQL_TYPE_TINY:     allocsize = 
sizeof(char); 
break;
 
  763      case MYSQL_TYPE_FLOAT:    allocsize = 
sizeof(float); 
break;
 
  764      case MYSQL_TYPE_DOUBLE:   allocsize = 
sizeof(
double); 
break;
 
  765#if MYSQL_VERSION_ID >= 50022 
  766      case MYSQL_TYPE_NEWDECIMAL :
 
  768      case MYSQL_TYPE_STRING:   allocsize = sqlsize > 256 ? sqlsize : 256; 
break;
 
  769      case MYSQL_TYPE_VAR_STRING: allocsize = sqlsize > 256 ? sqlsize : 256; 
break;
 
  770      case MYSQL_TYPE_MEDIUM_BLOB:
 
  771      case MYSQL_TYPE_LONG_BLOB:
 
  772      case MYSQL_TYPE_BLOB:     allocsize = sqlsize >= 65525 ? sqlsize : 65535; 
break;
 
  773      case MYSQL_TYPE_TINY_BLOB:   allocsize = sqlsize > 255 ? sqlsize : 255; 
break;
 
  774      case MYSQL_TYPE_TIME:
 
  775      case MYSQL_TYPE_DATE:
 
  776      case MYSQL_TYPE_TIMESTAMP:
 
  777      case MYSQL_TYPE_DATETIME: allocsize = 
sizeof(MYSQL_TIME); doreset = 
true; 
break;
 
  778      default: 
SetError(-1, 
Form(
"SQL type not supported: %d", sqltype),
"SetSQLParamType"); 
return kFALSE;
 
  791   if (
fBuffer[npar].fMem && doreset)
 
  792      memset(
fBuffer[npar].fMem, 0, allocsize);
 
  794   fBind[npar].buffer_type = enum_field_types(sqltype);
 
  796   fBind[npar].buffer_length = allocsize;
 
  799   fBind[npar].is_unsigned = !sig;
 
  813      SetError(-1,
"Cannot set parameter for statement", method);
 
  818      SetError(-1,
Form(
"Invalid parameter number %d",npar), method);
 
  824         SetError(-1,
"Cannot initialize parameter buffer", method);
 
  828   if ((
fBuffer[npar].fSqlType!=sqltype) ||
 
  829      (
fBuffer[npar].fSign != sig)) 
return 0;
 
  847   void* addr = 
BeforeSet(
"SetNull", npar, MYSQL_TYPE_LONG);
 
  863   void* addr = 
BeforeSet(
"SetInt", npar, MYSQL_TYPE_LONG);
 
  866      *((
int*) addr) = 
value;
 
  879      *((
unsigned int*) addr) = 
value;
 
  889   void* addr = 
BeforeSet(
"SetLong", npar, MYSQL_TYPE_LONG);
 
  892      *((
int*) addr) = 
value;
 
  902   void* addr = 
BeforeSet(
"SetLong64", npar, MYSQL_TYPE_LONGLONG);
 
  915   void* addr = 
BeforeSet(
"SetULong64", npar, MYSQL_TYPE_LONGLONG, 
kFALSE);
 
  931      *((
double*) addr) = 
value;
 
  943   void *addr = 
BeforeSet(
"SetString", npar, MYSQL_TYPE_STRING, 
true, maxsize);
 
  963      ((
char *)addr)[0] = 0;
 
  975   if (
size>=maxsize) maxsize = 
size + 1;
 
  977   int bin_type = MYSQL_TYPE_BLOB;
 
  978   if (maxsize > 65525) bin_type = MYSQL_TYPE_MEDIUM_BLOB;
 
  979   if (maxsize > 16777205) bin_type = MYSQL_TYPE_LONG_BLOB;
 
  981   void* addr = 
BeforeSet(
"SetBinary", npar, bin_type, 
true, maxsize);
 
  983   if (addr==0) 
return kFALSE;
 
  998   memcpy(addr, mem, 
size);
 
 1010   MYSQL_TIME* addr = (MYSQL_TIME*) 
BeforeSet(
"SetDate", npar, MYSQL_TYPE_DATE);
 
 1014      addr->month = month;
 
 1026   MYSQL_TIME* addr = (MYSQL_TIME*) 
BeforeSet(
"SetTime", npar, MYSQL_TYPE_TIME);
 
 1042   MYSQL_TIME* addr = (MYSQL_TIME*) 
BeforeSet(
"SetDatime", npar, MYSQL_TYPE_DATETIME);
 
 1046      addr->month = month;
 
 1061   MYSQL_TIME* addr = (MYSQL_TIME*) 
BeforeSet(
"SetTimestamp", npar, MYSQL_TYPE_TIMESTAMP);
 
 1065      addr->month = month;
 
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
 
unsigned long long ULong64_t
 
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 length
 
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 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 type
 
#define CheckErrNo(method, force, res)
 
#define CheckGetField(method, defres)
 
#define CheckStmt(method, res)
 
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
 
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
 
static ULong64_t fgAllocSizeLimit
 
void SetBuffersNumber(Int_t n)
Allocate buffers for statement parameters/ result fields.
 
Bool_t SetInt(Int_t npar, Int_t value) final
Set parameter value as integer.
 
void * BeforeSet(const char *method, Int_t npar, Int_t sqltype, Bool_t sig=kTRUE, ULong_t size=0)
Check boundary condition before setting value of parameter.
 
Bool_t GetTimestamp(Int_t npar, Int_t &year, Int_t &month, Int_t &day, Int_t &hour, Int_t &min, Int_t &sec, Int_t &) final
Return field value as time stamp.
 
UInt_t GetUInt(Int_t npar) final
Return field value as unsigned integer.
 
Bool_t NextIteration() final
Increment iteration counter for statement, where parameter can be set.
 
Double_t GetDouble(Int_t npar) final
Return field value as double.
 
Bool_t GetDatime(Int_t npar, Int_t &year, Int_t &month, Int_t &day, Int_t &hour, Int_t &min, Int_t &sec) final
Return field value as date & time.
 
Bool_t IsSetParsMode() const
indicates when parameters bind should be called
 
const char * ConvertToString(Int_t npar)
Convert field value to string.
 
Bool_t GetDate(Int_t npar, Int_t &year, Int_t &month, Int_t &day) final
Return field value as date.
 
Bool_t SetDouble(Int_t npar, Double_t value) final
Set parameter value as double.
 
Bool_t SetUInt(Int_t npar, UInt_t value) final
Set parameter value as unsigned integer.
 
Bool_t SetTimestamp(Int_t npar, Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec, Int_t frac=0) final
Set parameter value as timestamp.
 
Bool_t GetTime(Int_t npar, Int_t &hour, Int_t &min, Int_t &sec) final
Return field value as time.
 
Bool_t Process() final
Process statement.
 
Bool_t SetBinary(Int_t npar, void *mem, Long_t size, Long_t maxsize=0x1000) final
Set parameter value as binary data.
 
static void SetAllocSizeLimit(ULong_t sz)
Set limit for maximal allocated memory for single parameter.
 
void Close(Option_t *="") final
Close statement.
 
Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec) final
Set parameter value as time.
 
Int_t fWorkingMode
parameter definition structures
 
Int_t GetNumParameters() final
Return number of statement parameters.
 
void FreeBuffers()
Release all buffers, used by statement.
 
Bool_t IsNull(Int_t npar) final
Checks if field value is null.
 
Int_t fIterationCount
1 - setting parameters, 2 - retrieving results
 
ULong64_t GetULong64(Int_t npar) final
Return field value as unsigned 64-bit integer.
 
Long64_t GetLong64(Int_t npar) final
Return field value as 64-bit integer.
 
static ULong_t GetAllocSizeLimit()
Return limit for maximal allocated memory for single parameter.
 
Bool_t IsResultSetMode() const
 
virtual ~TMySQLStatement()
Destructor.
 
const char * GetFieldName(Int_t nfield) final
Returns field name in result set.
 
Bool_t SetSQLParamType(Int_t npar, int sqltype, Bool_t sig, ULong_t sqlsize=0)
Set parameter type to be used as buffer.
 
Int_t GetInt(Int_t npar) final
Return field value as integer.
 
TParamData * fBuffer
array of bind data
 
Int_t GetNumFields() final
Return number of fields in result set.
 
Bool_t fNeedParBind
number of iteration
 
Bool_t SetLong(Int_t npar, Long_t value) final
Set parameter value as long integer.
 
Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day) final
Set parameter value as date.
 
Bool_t StoreResult() final
Store result of statement processing to access them via GetInt(), GetDouble() and so on methods.
 
Int_t fNumBuffers
executed statement
 
Bool_t SetString(Int_t npar, const char *value, Int_t maxsize=256) final
Set parameter value as string.
 
Long_t GetLong(Int_t npar) final
Return field value as long integer.
 
TMySQLStatement(const TMySQLStatement &)=delete
 
Bool_t SetLong64(Int_t npar, Long64_t value) final
Set parameter value as 64-bit integer.
 
Int_t GetNumAffectedRows() final
Return number of affected rows after statement is processed.
 
Bool_t GetBinary(Int_t npar, void *&mem, Long_t &size) final
Return field value as binary array.
 
Bool_t SetDatime(Int_t npar, Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec) final
Set parameter value as date & time.
 
long double ConvertToNumeric(Int_t npar)
Convert field to numeric value.
 
const char * GetString(Int_t npar) final
Return field value as string.
 
Bool_t SetNull(Int_t npar) final
Set NULL as parameter value.
 
Bool_t SetULong64(Int_t npar, ULong64_t value) final
Set parameter value as unsigned 64-bit integer.
 
Bool_t NextResultRow() final
Shift cursor to nect row in result set.
 
MYSQL_BIND * fBind
number of statement parameters
 
static const char * GetFloatFormat()
return current printf format for float/double members, default "%e"
 
void SetError(Int_t code, const char *msg, const char *method=nullptr)
set new values for error fields if method specified, displays error message
 
void ClearError()
reset error fields
 
Bool_t fSign
sqltype of parameter
 
std::string fFieldName
special buffer to be used for string conversions
 
ULong_t fResLength
signed - not signed type
 
Int_t fSize
allocated data buffer
 
my_bool fResNull
length argument
 
std::string fStrBuffer
indicates if argument is null
 
Int_t fSqlType
size of allocated data