Dear Steve,

Thanks for a using the facilities with DBD::Informix to report this problem
- it is a pleasure to have the information I need immediately at hand, and
a working reproduction of the problem too.  Thanks again!

And anyone else reporting problems with DBD::Informix please take this as
an excellent example of how to do it!

This is a genuine bug in DBD::Informix.  Here's a quick-fix patch.  Note
that the test code you provide will still fail because when you supply the
$large_value in the $sth->execute($large_value); call, you override the
good work done with bind_param - and the value is passed as an INT not an
INT8.  When I replace that code with $sth->execute (and the patched
DBD::Informix), then I get the correct result.

I have a feeling that this is a second (bigger, unfixed) bug in
DBD::Informix - once bound via bind_param, the type is supposed to be
sticky in some form.  This patch certainly does not attempt to handle that.

(See attached file: int8.fix)

--
Jonathan Leffler ([EMAIL PROTECTED])
STSM, Informix Database Engineering, IBM Data Management
4100 Bohannon Drive, Menlo Park, CA 94025
Tel: +1 650-926-6921   Tie-Line: 630-6921
      "I don't suffer from insanity; I enjoy every minute of it!"




|---------+---------------------------->
|         |           Jonathan Leffler |
|         |           <[EMAIL PROTECTED]|
|         |           nk.net>          |
|         |                            |
|         |           07/01/2003 08:28 |
|         |           AM               |
|         |                            |
|---------+---------------------------->
  
>---------------------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                    
                                                         |
  |       To:       Jonathan Leffler/Menlo Park/[EMAIL PROTECTED]                      
                                                                 |
  |       cc:                                                                          
                                                         |
  |       Subject:  [Fwd: DBD::Informix Issue with int8 field.]                        
                                                         |
  |                                                                                    
                                                         |
  
>---------------------------------------------------------------------------------------------------------------------------------------------|





--
Jonathan Leffler ([EMAIL PROTECTED], [EMAIL PROTECTED])
#include <disclaimer.h>
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/

----- Message from Steve Vornbrock <[EMAIL PROTECTED]> on Tue, 01 Jul 2003
10:22:57 -0500 -----
                                     
      To: [EMAIL PROTECTED]         
                                     
 Subject: DBD::Informix Issue with   
          int8 field.                
                                     

Hello,

I am running into an issue with the insert of a number into an INT8
field when that number is larger than the max value of an INTEGER. I
have included the test script, output and additional configuration of
the machine.  Any help would be appreciated.

Thanks,
Steve

This is running on a Sun machine with Solaris 8 and IDS 9.40FC1.
-------------------------
Output
-------------------------
Perl Version 5.008
DBI Version 1.37
DBD::Informix Version 2003.04
IBM Informix CSDK Version 2.81, IBM Informix-ESQL Version 9.53.UC1
# DBI->connect('dbi:Informix:test_db', '', '');
#       Connect Attribute: RaiseError => 1
#       Connect Attribute: ChopBlanks => 1
large_number => 4278190080
inserted_value => -16777216
-------------------------
Script.
-------------------------

use strict;
use warnings;
use DBI;
use DBD::Informix::TestHarness;
use DBD::Informix::TechSupport;
use DBD::Informix qw(:ix_types);

print_versions("Perl DBI DBD::Informix ESQL/C");
my $large_number = 4278190080;
my $table = "test_table";
my $inserted_value;

my $dbh = connect_to_test_database({RaiseError => 1});
$dbh->do(qq%CREATE TEMP TABLE $table (id INT8)%);
my $sth = $dbh->prepare(qq%INSERT INTO $table VALUES(?)%);
$sth->bind_param(1,$large_number, {ix_type => IX_INT8});

$sth->execute($large_number);

$sth = $dbh->prepare(qq%SELECT id FROM $table%);
$sth->bind_columns(\$inserted_value);
$sth->execute;
$sth->fetch;
$sth->finish;

print "large_number => $large_number\n";
print "inserted_value => $inserted_value\n";

exit 0;




Attachment: int8.fix
Description: Binary data

Reply via email to