-------- Original Message --------
Subject: Re: selecting a bigint
Date: Mon, 18 May 2009 08:42:56 -0500
From: Tod A. Sandman <[email protected]>
To: Alexander Foken <[email protected]>
References: <[email protected]>
<[email protected]>
On Sat, May 16, 2009 at 06:07:05PM +0200, Alexander Foken wrote:
Perl silently converts Integers to Floats to prevent integer overflow.
Unless you have a perl with 64 Bit integers (see perl -V), this may bite
you here: You get the usual floating point rounding issues. If you
explicitly convert the bigint to a string already in the database, so
that perl reads and writes a string, the problem should disappear.
Something like
SELECT TOCHAR(token) FROM table WHERE foo=?
and
SELECT bar,baz FROM table WHERE TOCHAR(token)=?
or
SELECT bar,baz FROM table WHERE token=TOBIGINT(?)
Thanks.
I tried using "TOCHAR" verbatim (I'm ultra weak in sql), but I got a
mysql syntax error (I'm using mysql-4.1.22). But using
"SELECT CONVERT(token, CHAR) seems to work fine:
$query = "SELECT CONVERT(token, CHAR),spam_hits,innocent_hits
from dspam_token_data where uid = $uid";
..........
$query = "UPDATE dspam_token_data set spam_hits = ?,
innocent_hits = ? where (uid = $uid) and
(CONVERT(token, CHAR) = ?)";
Tod Sandman
Sr. Systems Administrator
Middleware Development & Integration
Rice University
Voice: 713.348.5816
--
Alexander Foken
mailto:[email protected] http://www.foken.de/alexander/