Re: float bug? perl 5.8, DBI and oracle 10.2.0



On Wed, Jul 18, 2007 at 03:23:50PM +0200, Erwan Lemonnier wrote:

sub showbin {
print "bin: ".unpack("B70",reverse pack("d",$_[0]))."\n";
}

my $v1 = "1.73696";
showbin($v1);

print "connecting\n";
my $DBC = DBI->connect("dbi:Oracle:$ORASID",$ORAUSR,$ORAPWD,
{ PrintError=>0, AutoCommit=>0 } );

my $v2 = "1.73696";
showbin($v2);

This code simply opens a connection toward an oracle database. And
shows the binary representation of the string "1.73696" converted into
a native float (NV) before and after we opened the connection.

When I run it with perl 5.6.2, DBI 1.38 and DBD::Oracle 1.17, it says:

[HEAD] ~/HEAD/test/t> !967$ /opt/perl-5.6.2/bin/perl 04_test1.t
bin: 0011111111111011110010101001011010010001101001110101110011010001
connecting
bin: 0011111111111011110010101001011010010001101001110101110011010001

When I run it with perl 5.8.8, DBI 1.58 and DBD::Oracle 1.19, it says:

[HEAD] ~/HEAD/test/t> !969$ /opt/perl-5.8.8/bin/perl 04_test1.t
bin: 0011111111111011110010101001011010010001101001110101110011010001
connecting
bin: 0011111111111011110010101001011010010001101001110101110011010000

Ah, now it's getting interesting! :)

Are the two versions of DBD::Oracle built against the same Oracle
version/installation?

What differences are there in the configuration of the two perl versions?
Take a look at the source for the Perl_sv_2nv() function in sv.c
in the two distributions. Also check for differences in the perl config
items that impact that code.

See how the least significant bit (last one on the right) changes in
the last run?
There we have it. It is what caused the problems I have been spamming
you all with for the last few days :)

Try it with:

my $v1 = "1.73696";
showbin($v1);
require DBD::Oracle;
my $v2 = "1.73696";
showbin($v2);

Conclusion: on my host (perl 5.8 etc.), the line:

my $DBC = DBI->connect("dbi:Oracle:$ORASID",$ORAUSR,$ORAPWD,
{ PrintError=>0, AutoCommit=>0 } );

seems to alter the way perl parses the string "1.73696". This later
resulted in arithmetic errors that looked like floating point related
issues but were not.

Has anyone any idea of what's happening here????

I know that on Solaris the act of loading the Oracle library (e.g.
libclntsh.so) could suck in other libraries which would cause
subtle side effects.

The particular case I (vagely) recall related to alarm(). Loading the
Oracle library caused the threaded version of alarm() to be loaded and
take precedence. So alarm(0) after loading DBD::Oracle wouldn't cancel
the alarm($timeout) set before loading it. Fun. I don't recall now
if/how that got resolved.

Anyway, I mention it because it seems like this is a similar issue.

Tim.
.



Relevant Pages

  • RE: Identify PID for remote database handle--CLARIFICATION...
    ... This is somewhat off topic as it has nothing to do with DBI nor Perl. ... When a connection request is made to an Oracle database instance, ... If you need more information on these views, see the Oracle docs and/or ...
    (perl.dbi.users)
  • Re: problem with DBD::Oracle - timeout ?
    ... I need to run an Oracle stored proc from perl. ... The problem is that I'm using a db link in the Oracle stored proc. ... I can run it successfully from Toad and sqlplus, but I'm having issue when run from perl. ... I've monitored the Oracle connection and I can see that the procedure is called, and connected with the same user I'm using under sqlplus, and no error is return ...
    (perl.dbi.users)
  • RE: Oracle: Embedded Perl & 7/8 bit character sets
    ... after several days of investigations we found out that using the non-standard character set US7ASCII also affected the C++ programs. ... I did not use any specific DBI connect routine such as telling DBD to share the connection. ... It seems to be that the Oracle client libraries provides the result in a way that the Perl driver cannot decode. ...
    (perl.dbi.users)
  • Re: float bug? perl 5.8, DBI and oracle 10.2.0
    ... The one used by perl 5.6.2 was built against an oracle 9.2.1.0 (unsure ... So alarmafter loading DBD::Oracle wouldn't cancel ...
    (perl.dbi.users)
  • Re: float bug? perl 5.8, DBI and oracle 10.2.0
    ... The one used by perl 5.6.2 was built against an oracle 9.2.1.0 (unsure ... So alarmafter loading DBD::Oracle wouldn't cancel ...
    (perl.dbi.users)