Good evening.
Please, correct another bugs in the TPgSQLStatement class.
- TPgSQLStatement::SetBinary(Int_t npar, void* mem, Long_t size, Long_t maxsize) function works only with string values. If ‘mem’ variable points to not string (e.g. int or double), it contains arbitrary symbols which will cause errors, e.g.:
I propose the following corrected function which works well:
[code]Bool_t TPgSQLStatement::SetBinary(Int_t npar, void* mem, Long_t size, Long_t maxsize)
{
// Set parameter value as binary data.
size_t sz = size, mxsz;
unsigned char* escape_ptr = PQescapeBytea((const unsigned char*)mem, sz, &mxsz);
unsigned char* binary_ptr = PQunescapeBytea((const unsigned char*)escape_ptr, &mxsz);
PQfreemem(escape_ptr);
delete [] fBind[npar];
fBind[npar] = new char[mxsz+1];
fBind[npar][mxsz] = ‘\0’;
memcpy(fBind[npar], binary_ptr, mxsz);
PQfreemem(binary_ptr);
return kTRUE;
}[/code]
- Please, add checking ‘npar’ to be in the correct range in TPgSQLStatement.cxx in
Bool_t TPgSQLStatement::SetNull(Int_t npar) function:
if ((npar >= 0) && (npar < fNumBuffers))
fBind[npar] = 0;
Thank you.