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(?)

(Yes, this looks really ugly.)

Alexander

On 15.05.2009 22:17, Tod A. Sandman wrote:
I'm trying to use DBI and DBD::mysql with perl-5.8.8 on a 64bit Redhat
host:
  Linux host 2.6.9-67.0.20.ELsmp #1 SMP Wed Jun 18 12:35:02 EDT 2008 x86_64 
x86_64 x86_64 GNU/Linux


I need to do table lookups based on a column of type bigint.  I don't
generate or manipulate the bigint value myself - I actually read it in
from the database.  But when I turn around and try to select on the
bigint value, it is not found.

I scanned the web etc and have tried "use bigint", quoting the value,
forcing it to be string, etc.

Testing shows that defining a large int as a string and inserting it
into the database works fine (I pass $query to prepare() and $token to
execute()):

  my $token = "18288286186892797895";
  $query = "insert into table (uid, token) VALUES (9, ?)";
But I cannot figure out a way to turn around and select on that same
token.  For instance, these do nothing:

  $query = "UPDATE table set uid = 8 where (uid = 9) and (token = ?)";
OR
  $query = "SELECT * from table where (uid = 9) and (token = ?)";


If I try a smaller number for token, everything works as expected.



Tod Sandman
Sr. Systems Administrator
Middleware Development & Integration
Rice University
Voice: 713.348.5816


--
Alexander Foken
mailto:[email protected]  http://www.foken.de/alexander/

Reply via email to