perlquestion
cLive ;-)
<p>So, we're migrating servers, and another dev noticed a minor bug in yasql, which I've traced back to DBD::Oracle.</p>
<p>What is happening is when you <code>DESC TABLENAME</code> is that the precision of VARCHAR2 fields are coming back as being 4 times what it should be. I've narrowed it down to an error in the values in <code>$sth->{PRECISION}</code>.</p>
<p>What I can't work out though is where this is set. I have a feeling the issue might be in DBD::Oracle::st::_prepare call, but I'm not quite sure what's going on.</p>
<p>Using Data::Dumper, $sth looks like an empty hashref. If that's the case though, why does <code>$sth->{PRECISION}</code> return an arrayref of numbers? Is the hashref call overloaded in DBI as a method or something? I've not seen that before.</p>
<p><strike>For DBD::Oracle, version 1.64 appears to be working correctly, but version 1.74 is not. Oracle Version is 11.2.0.4</strike> - this was on different machines. When run on the same machine, results were the same for both modules.</p>
<p>This code demonstrates the issue:</p>
<code>
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $dbh = DBI->connect(...connect args to oracle db...);
$dbh->do("CREATE TABLE test__table(testfield VARCHAR2(10))")
or die "Can't create table: $DBI::errstr";
my $sth= $dbh->prepare("SELECT * FROM test__table");
print $sth->{PRECISION}->[0].$/;
$dbh->do("DROP TABLE test__table");
</code>
<p>When run under v1.64, output is 10. When run under v1.74, output is 40.</p>
<p>Thoughts? DBD::Oracle bug to report?</p>
<p>Edit: I've <a href="https://github.com/pythian/DBD-Oracle/issues/33">reported the bug</a>, but still welcome insights on how the hashref call turns into a method call (I hate these magic bits of code sometimes :D)</p>
<p><b>FINAL EDIT:</b> We worked out the issue, at last. When migrating servers, the DBAs accidentally added a new environment variable to the <code>/oracle/#VERSION#/CLIENT.env</code> file that set <code>NLS_LANG</code> to <code>AMERICAN_AMERICA.UTF8</code>. The database, however, is a legacy DB that uses <code>WE8ISO8859P1</code>. So, yasql was expecting UTF8, but the DB wasn't supplying it.</p>