Re: possible problem on 64 bit machines with TMySQLStatement

From: Fons Rademakers <Fons.Rademakers_at_cern.ch>
Date: Thu, 26 Feb 2009 17:36:57 +0100


Hi Max,

  I'll fix this and let you know.

Cheers, Fons.

Maximilien Fechner wrote:
> Dear Rooters,
>
> I have identified what seems to be a bug in the TMySQLStatement code.
> In "TMySQLStatement::ConvertToString", I see the following lines (root
> 5.22 pro version):
>
> case MYSQL_TYPE_LONG:
> if (sig) snprintf(buf,100,"%ld",*((long*) addr));
> else snprintf(buf,100,"%lu",*((unsigned long*) addr));
> break;
> case MYSQL_TYPE_LONGLONG:
> if (sig) snprintf(buf,100,"%lld",*((long long*) addr)); else
> snprintf(buf,100,"%llu",*((unsigned long long*) addr));
>
> However, on my laptop (32 bits, Fedora10, gcc4.3), sizeof(long) is 4
> bytes, while on a 64 bit machine (SL4, gcc 3.4.6),
> sizeof(long) is 8 bytes.
> Hence the conversion from a "MYSQL_TYPE_LONG" to a string is quite
> different on 64 bit machines.
> I have tested this with a very simple script (attached) on both
> architectures, and I do get different answers... the code
> seems to be meaningful only on 32 bit machines.
> The data base I tested this with had 3 fields and only the third one was
> meaningful in my example.
> The call to GetString returns a wrong value for integers on the 64 bit
> machine I tested.
> I used root 5.22 in both places.
> Would it be possible for you to confirm this, and if confirmed, fix the
> problem ?
> The "GetString" code is heavily used in the software that I was given
> and this is causing many problems.
>
> Thanking you in advance,
> Maximilien Fechner
>

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers_at_cern.ch              Phone: +41 22 7679248
WWW:    http://fons.rademakers.org           Fax:   +41 22 7669640
Received on Thu Feb 26 2009 - 17:37:03 CET

This archive was generated by hypermail 2.2.0 : Fri Feb 27 2009 - 11:50:02 CET