PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Avis, Ed" <avised at kbcfp dot com>
Subject: DBD::Sybase 1.05_01 test failure
Date: May 5 2005 4:17PM

I tested the current beta release 1.05_01 of DBD::Sybase.  The test
t/xblk.t failed because of

DBD::Sybase::db prepare warning: Server message number=4847 severity=16 state=1 line=1 server=IT_LN text=BCP insert operation is disabled when LONGCHAR capability is turned on and data size is changing between client and server character sets since BCP does not support LONGCHAR yet.

This is because my client (Linux RHEL 3) is using UTF-8.  It's fixed by
setting LC_ALL to C.

I also noticed that xblk.t doesn't cope very well when a statement
handle couldn't be prepared.  It goes on to try calling methods on the
undef value and crashes.  Better to fail lots of tests than to die.
Here's a patch that fixes both these things.

diff -wru DBD-Sybase-1.05_01/t/xblk.t DBD-Sybase-1.05_01-new/t/xblk.t
--- DBD-Sybase-1.05_01/t/xblk.t	2005-04-09 10:02:35.000000000 +0100
+++ DBD-Sybase-1.05_01-new/t/xblk.t	2005-05-05 17:16:58.000000000 +0100
@@ -33,6 +33,9 @@
 
 $SIG{__WARN__} = sub { print @_; };
 
+# Try to avoid charset problems.
+$ENV{LC_ALL} = 'C';
+
 DBD::Sybase::set_cslib_cb(\&cslib_cb);
 
 #DBI->trace(5);
@@ -79,18 +82,19 @@
   my $rc;
   my $i = 1;
   foreach (@data) {
+    my $test_name = "Send row $i - test 1";
+    fail($test_name), next if not $sth;
     $_->[8] = pack('H*', $_->[8]);
     $rc = $sth->execute(@$_);
-    ok(defined($rc), "Send row $i - test 1");
+    ok(defined($rc), $test_name);
     ++$i;
   }
 
   $rc = $dbh->commit();
   ok($rc, 'Commit test 1');
-  my $rows = $sth->rows();
-  ok($rows == 3, 'Rows test 1');
+  ok($sth && $sth->rows() == 3, 'Rows test 1');
 
-  $sth->finish;
+  $sth->finish if $sth;
 
 #  DBI->trace(0);
 }
@@ -115,18 +119,19 @@
   my $i = 1;
   my $rc;
   foreach (@data) {
+    my $test_name = "Execute row $i, test 2";
+    fail($test_name), next if not $sth;
     $_->[8] = pack('H*', $_->[8]);
     $rc = $sth->execute(@$_);
-    ok(!defined($rc), "Execute row $i, test 2");
+    ok(!defined($rc), $test_name);
     ++$i;
   }
   $rc = $dbh->commit;
   ok($rc, 'Commit test 2');
 
-  my $rows = $sth->rows;
-  ok($rows == 0, 'Rows, test 2');
+  ok($sth && $sth->rows == 0, 'Rows, test 2');
 
-  $sth->finish;
+  $sth->finish if $sth;
 }
 
 # Test explicit identity value inserts.
@@ -146,19 +151,20 @@
   my $i = 1;
   my $rc;
   foreach (@data) {
+    my $test_name = "Execute row $i, test 3";
+    fail($test_name), next if not $sth;
     $_->[8] = pack('H*', $_->[8]);
     $rc = $sth->execute(@$_);
-    ok(defined($rc), "Execute row $i, test 3");
+    ok(defined($rc), $test_name);
     ++$i;
   }
 
   $rc = $dbh->commit;
   ok($rc, 'Commit, test 3');
 
-  my $rows = $sth->rows;
-  ok($rows == 3, 'Rows, test 3');
+  ok($sth && $sth->rows == 3, 'Rows, test 3');
 
-  $sth->finish;
+  $sth->finish if $sth;
 }
 
 # Test for prepare failures
@@ -203,14 +209,16 @@
   my $rc;
   my $i = 1;
   foreach (@data) {
+    my $test_name = "Send row $i - test 5";
+    fail($test_name), next if not $sth;
     $_->[8] = pack('H*', $_->[8]);
     $rc = $sth->execute(@$_);
-    ok(defined($rc), "Send row $i - test 5");
+    ok(defined($rc), $test_name);
     ++$i;
   }
 
   local $^W = 0;
-  $sth->finish;
+  $sth->finish if $sth;
 }
 
 # Test for rollback.
@@ -233,25 +241,32 @@
   my $rc;
   my $i = 1;
   foreach (@data) {
+    my $test_name = "Send row $i - test 6";
+    fail($test_name), next if not $sth;
     $_->[8] = pack('H*', $_->[8]);
     $rc = $sth->execute(@$_);
-    ok(defined($rc), "Send row $i - test 6");
+    ok(defined($rc), $test_name);
     ++$i;
   }
 
   $rc = $dbh->rollback;
   ok($rc, 'test 6 rollback');
-  $rc = $sth->finish;
-  ok($rc, 'test 6 finish');
+  ok($sth && $sth->finish, 'test 6 finish');
   $sth = undef;
 
   my $sth2 = $dbh->prepare("select count(*) from #tmp where a1 like 'test6 %'");
   ok(defined($sth2), 'test 6 prepare select');
+  if ($sth2) {
   $rc = $sth2->execute;
   ok($rc, 'test 6 execute select');
   my $row = $sth2->fetch;
   ok($row && $row->[0] == 0, 'test 6 row value');
   $sth2->finish;
+  }
+  else {
+      fail('test 6 execute select');
+      fail('test 6 row value');
+  }
   $sth2 = undef;
   $dbh->commit;
   
@@ -262,24 +277,27 @@
 						 identity_column => 1 }});
   ok(defined($sth), 'Prepare test 6 (2)');
   foreach (@data) {
+    my $test_name = "Send row $i - test 6";
+    fail($test_name), next if not $sth;
     $_->[8] = pack('H*', $_->[8]);
     $rc = $sth->execute(@$_);
-    ok(defined($rc), "Send row $i - test 6");
+    ok(defined($rc), $test_name);
     ++$i;
   }
   $rc = $dbh->commit;
   ok($rc, 'test 6 commit');
   foreach (@data) {
+    my $test_name = "Send row $i - test 6";
+    fail($test_name), next if not $sth;
     $_->[8] = pack('H*', $_->[8]);
     $rc = $sth->execute(@$_);
-    ok(defined($rc), "Send row $i - test 6");
+    ok(defined($rc), $test_name);
     ++$i;
   }
 
   $rc = $dbh->rollback;
   ok($rc, 'test 6 rollback');
-  $rc = $sth->finish;
-  ok($rc, 'test 6 finish');
+  ok($sth && $sth->finish, 'test 6 finish');
   $sth = undef;
 }
 
@@ -331,17 +349,17 @@
 
   my $i = 1;
   foreach (@data) {
+    my $test_name = "Send row $i - test 8";
+    fail($test_name), next if not $sth;
     $_->[8] = pack('H*', $_->[8]);
     $rc = $sth->execute(@$_);
-    ok(defined($rc), "Send row $i - test 8");
+    ok(defined($rc), $test_name);
     ++$i;
   }
 
   $rc = $dbh->commit();
   ok($rc, 'Commit test 8');
-  my $rows = $sth->rows();
-  ok($rows == 3, 'Rows test 8');
+  ok($sth && $sth->rows() == 3, 'Rows test 8');
   
-#  $sth->finish;
   $sth = undef;
 }

-- 
Ed Avis