[Omaha.pm] :Sybase success, build errors

Jay Hannah jhannah at omnihotels.com
Wed Aug 10 08:20:12 PDT 2005


> I did get quite a few build errors though, and only half of 
> them (or so) are listed in 
> 
>   DBD-Sybase-1.06/README.freetds
> 
> so I thought I'd post my build dialogue here. I'm ignoring 
> all the errors below unless someone slaps me.

Looks like last year I threatened to attempt to patch the tests so they'd run clean under freetds. I never did it. Now, feeling shamed, I've given exec.t a shot.

On my box (

  Perl            : 5.008007    (i686-linux)
  OS              : linux       (2.4.21-243-default)
  DBI             : 1.48
  DBD::Sybase     : 1.06
  freetds v0.63 
     (./configure --prefix=/usr/local/freetds --with-tdsver=7.0)

)

The below modified exec.t runs like so:

$ perl exec.t
1..41
ok 1 - use DBI;
ok 2 - use DBD::Sybase;
ok 3 - Connect
ok 4 - Prepare sp_helpindex
ok 5 - exec sysusers
ok 6 - -1 (create proc)
ok 7 - prepare dbitest
ok 8 - bind_param 1
ok 9 - bind_param 2
cs_convert failed (to_numeric(3.2)) at exec.t line 63.
ok 10 - bind_param 3
ok 11 - bind_param 4
ok 12 - bind_param 5
ok 13 # skip freetds seg faults here
ok 14 # skip freetds doesn't support placeholders
ok 15 # skip freetds doesn't support placeholders
ok 16 # skip freetds doesn't support $sth->func?
ok 17 # skip freetds doesn't support $sth->func?
ok 18 # skip freetds doesn't support placeholders
ok 19 # skip freetds doesn't support placeholders
ok 20 # skip freetds doesn't support placeholders
ok 21 # skip freetds doesn't support placeholders
ok 22 # skip freetds doesn't support placeholders
ok 23 # skip freetds doesn't support placeholders
ok 24 - drop proc dbitest 1
ok 25 - drop proc dbitest 2
ok 26 - -1 (create proc)
ok 27 # skip freetds doesn't support bind_param nor placeholders
ok 28 # skip freetds doesn't support bind_param nor placeholders
ok 29 # skip freetds doesn't support bind_param nor placeholders
ok 30 # skip freetds doesn't support bind_param nor placeholders
ok 31 # skip freetds doesn't support bind_param nor placeholders
ok 32 # skip freetds doesn't support bind_param nor placeholders
ok 33 # skip freetds doesn't support bind_param nor placeholders
ok 34 # skip freetds doesn't support bind_param nor placeholders
ok 35 # skip freetds doesn't support bind_param nor placeholders
ok 36 # skip freetds doesn't support bind_param nor placeholders
ok 37 # skip freetds doesn't support bind_param nor placeholders
ok 38 # skip freetds doesn't support bind_param nor placeholders
ok 39 # skip freetds doesn't support bind_param nor placeholders
ok 40 # skip freetds doesn't support bind_param nor placeholders
ok 41 - drop proc dbitest

I hope this diff format works for you and my patch is good. That diff command came from the perl5-porters FAQ, so I hope its what you want.

I hope this helps. If it does I can take a stab at the other test files too.

Cheers,

j



diff -ruN exec.t.original exec.t

--- exec.t.original	2005-08-10 09:25:52.000000000 -0500
+++ exec.t	2005-08-10 10:09:33.000000000 -0500
@@ -11,7 +11,7 @@
 use strict;
 
 #use Test::More qw(no_plan);
-use Test::More tests => 22;
+use Test::More tests => 41;
 
 
 BEGIN { use_ok('DBI', ':sql_types');
@@ -20,6 +20,7 @@
 
 use vars qw($Pwd $Uid $Srv $Db);
 
+my $using_freetds = ($ENV{SYBASE} =~ /freetds/i) ? 1 : 0;
 
 #DBI->trace(3);
 
@@ -31,13 +32,11 @@
 ok(defined($dbh), 'Connect');
 
 $SIG{__WARN__} = sub { print @_; };
-my $sth = $dbh->prepare("exec sp_helpindex \@objname = ?");
+my $sth = $dbh->prepare("exec sp_helpindex \@objname = 'sysusers'");   # Placeholders not supported in freetds
 ok(defined($sth), 'Prepare sp_helpindex');
 
 my $rc;
-
-$rc = $sth->execute("sysusers");
-
+$rc = $sth->execute();
 ok(defined($rc), "exec sysusers");
 
 get_all_results($sth);
@@ -45,38 +44,45 @@
 #$dbh->do("use tempdb");
 $dbh->do("set arithabort off");
 $dbh->do("if object_id('dbitest') != NULL drop proc dbitest");
-$rc = $dbh->do(qq{
-create proc dbitest \@one varchar(20), \@two int, \@three numeric(5,2), \@four smalldatetime, \@five float output
+$rc = $dbh->do(q{
+create proc dbitest @one varchar(20), @two int, @three numeric(5,2), @four smalldatetime, @five float output
 as
-    select \@one, \@two, \@three, \@four
+    select @one, @two, @three, @four
     select * from master..sysprocesses
 
-    return \@two
+    return @two
 });
 
-ok(defined($rc), "$rc (create proc)\n");
+ok(defined($rc), "$rc (create proc)");
 
 $sth = $dbh->prepare("exec dbitest \@one = ?, \@two = ?, \@three = ?, \@four = ?, \@five = ? output");
 #$rc = $sth->execute("one", 2, 3.2, "jan 1 2001", 5.4);
 ok(defined($sth), "prepare dbitest");
-$sth->bind_param(1, "one");
-$sth->bind_param(2, 2, SQL_INTEGER);
-$sth->bind_param(3, 3.2, SQL_DECIMAL);
-$sth->bind_param(4, "jan 1 2001");
-$sth->bind_param(5, 5.4, SQL_FLOAT);
-$rc = $sth->execute();
-ok(defined($rc), "execute dbitest 1");
-#DBI->trace(4);
-get_all_results($sth);
+ok($sth->bind_param(1, "one"),               "bind_param 1");
+ok($sth->bind_param(2, 2, SQL_INTEGER),      "bind_param 2");
+ok($sth->bind_param(3, 3.2, SQL_DECIMAL),    "bind_param 3");
+ok($sth->bind_param(4, "jan 1 2001"),        "bind_param 4");
+ok($sth->bind_param(5, 5.4, SQL_FLOAT),      "bind_param 5");
+SKIP: {
+  skip "freetds seg faults here", 1 if $using_freetds;
+  ok($rc = $sth->execute(), "execute dbitest 1");
+}
 
-$rc = $sth->execute("one", 25, 333.2, "jan 1 2001", 5.4);
-ok(defined($rc), "exec dbitest 2");
-get_all_results($sth);
+SKIP: {
+  skip "freetds doesn't support placeholders", 2 if $using_freetds;
+  #DBI->trace(4);
+  get_all_results($sth);
+  ok($rc = $sth->execute("one", 25, 333.2, "jan 1 2001", 5.4),  "exec dbitest 2");
+  get_all_results($sth);
+  ok($rc = $sth->execute(undef, 25, 3.2234, "jan 3 2001", 5.4), "exec dbitest 3");
+}
+
+SKIP: {
+  skip "freetds doesn't support \$sth->func?", 2 if $using_freetds;
+  ok(my @out = $sth->func('syb_output_params'),                 '$sth->func');
+  is($out[0], 5.4,                                              "out param 1");
+}
 
-$rc = $sth->execute(undef, 25, 3.2234, "jan 3 2001", 5.4);
-ok(defined($rc), "exec dbitest 3");
-my @out = $sth->func('syb_output_params');
-ok($out[0] == 5.4, "out param 1");
 
 #print "@out\n";
 #do {
@@ -91,72 +97,74 @@
 $sth->{syb_do_proc_status} = 1;
 $dbh->{syb_flush_finish} = 0;
 
-$rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4);
-ok(defined($rc), "execute fail mode 1");
-get_all_results($sth);
-#DBI->trace(3);
-$rc = $sth->execute("raise", 1, 3.2234, "jan 3 2001", 5.4);
-ok(defined($rc), "execute fail mode 2");
-get_all_results($sth);
-$rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4);
-#DBI->trace(0);
-ok(defined($rc), "execute fail mode 3");
-get_all_results($sth);
-
-$dbh->{syb_flush_finish} = 1;
-$rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4);
-ok(defined($rc), "execute fail mode 4");
-get_all_results($sth);
-#DBI->trace(3);
-$rc = $sth->execute(undef, 1, 3.2234, "jan 3 2001", 5.4);
-ok(defined($rc), "execute fail mode 5");
-get_all_results($sth);
-#DBI->trace(0);
-$rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4);
-ok(defined($rc), "execute fail mode 6");
-get_all_results($sth);
-
+SKIP: {
+  skip "freetds doesn't support placeholders", 6 if $using_freetds;
+  ok($rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4),   "execute fail mode 1");
+  get_all_results($sth);
+  #DBI->trace(3);
+  ok($rc = $sth->execute("raise", 1, 3.2234, "jan 3 2001", 5.4), "execute fail mode 2");
+  get_all_results($sth);
+  ok($rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4),   "execute fail mode 3");
+  #DBI->trace(0);
+  get_all_results($sth);
+
+  $dbh->{syb_flush_finish} = 1;
+  ok($rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4),   "execute fail mode 4");
+  get_all_results($sth);
+  #DBI->trace(3);
+  ok($rc = $sth->execute(undef, 1, 3.2234, "jan 3 2001", 5.4),   "execute fail mode 5");
+  get_all_results($sth);
+  #DBI->trace(0);
+  ok($rc = $sth->execute(undef, 0, 3.2234, "jan 3 2001", 5.4),   "execute fail mode 6");
+  get_all_results($sth);
+}
 
-$dbh->do("drop proc dbitest");
 
-$dbh->do("if object_id('dbitest') != NULL drop proc dbitest");
-$rc = $dbh->do(qq{
-create proc dbitest \@one varchar(20), \@two int, \@three numeric(5,2), \@four smalldatetime --, \@five float = null output
+ok($dbh->do("drop proc dbitest"),                                  "drop proc dbitest 1");
+ok($dbh->do("if object_id('dbitest') != NULL drop proc dbitest"),  "drop proc dbitest 2");
+$rc = $dbh->do(q{
+create proc dbitest @one varchar(20), @two int, @three numeric(5,2), @four smalldatetime --, @five float = null output
 as
-    select \@one, \@two, \@three, \@four
+    select @one, @two, @three, @four
 
 });
 
-ok(defined($rc), "$rc (create proc)\n");
+ok(defined($rc), "$rc (create proc)");
 
-$sth = $dbh->prepare("exec dbitest ?, ?, ?, ?");
-$sth->bind_param(1, 'String 1', SQL_VARCHAR);
-$sth->bind_param(2, 1, SQL_INTEGER);
-$sth->bind_param(3, 3.25, SQL_DECIMAL);
-$sth->bind_param(4, '2005-06-27', SQL_DATETIME);
+SKIP: {
+  skip "freetds doesn't support bind_param nor placeholders", 7 if $using_freetds;
+  ok($sth = $dbh->prepare("exec dbitest ?, ?, ?, ?"),      "prepare");
+  ok($sth->bind_param(1, 'String 1', SQL_VARCHAR),         "bind_param 1");
+  ok($sth->bind_param(2, 1, SQL_INTEGER),                  "bind_param 2");
+  ok($sth->bind_param(3, 3.25, SQL_DECIMAL),               "bind_param 3");
+  ok($sth->bind_param(4, '2005-06-27', SQL_DATETIME),      "bind param 4");
 
-for (0 .. 1) {
+  for (0 .. 1) {
     $sth->execute('String 1', 1, 3.25, '2005-06-27');
     while(my $row = $sth->fetch) {
-	ok($row->[2] == 3.25, "Implicit finish handling");
+      ok($row->[2] == 3.25, "Implicit finish handling");
     }
+  }
 }
 
-$dbh->{syb_do_proc_status} = 1;
-$sth = $dbh->prepare("exec dbitest ?, ?, ?, ?");
-$sth->bind_param(1, 'String 1', SQL_VARCHAR);
-$sth->bind_param(2, 1, SQL_INTEGER);
-$sth->bind_param(3, 3.25, SQL_DECIMAL);
-$sth->bind_param(4, '2005-06-27', SQL_DATETIME);
+SKIP: {
+  skip "freetds doesn't support bind_param nor placeholders", 7 if $using_freetds;
+  $dbh->{syb_do_proc_status} = 1;
+  ok($sth = $dbh->prepare("exec dbitest ?, ?, ?, ?"),  "prepare");
+  ok($sth->bind_param(1, 'String 1', SQL_VARCHAR),     "bind_param 1");
+  ok($sth->bind_param(2, 1, SQL_INTEGER),              "bind_param 2");
+  ok($sth->bind_param(3, 3.25, SQL_DECIMAL),           "bind_param 3");
+  ok($sth->bind_param(4, '2005-06-27', SQL_DATETIME),  "bind_param 4");
 
-for (0 .. 1) {
+  for (0 .. 1) {
     $sth->execute('String 1', 1, 3.25, '2005-06-27');
     while(my $row = $sth->fetch) {
-	ok($row->[2] == 3.25, "Implicit finish handling");
+      ok($row->[2] == 3.25, "Implicit finish handling");
     }
+  }
 }
 
-$dbh->do("drop proc dbitest");
+ok($dbh->do("drop proc dbitest"),     "drop proc dbitest");
 
 sub get_all_results {
     my $sth = shift;




More information about the Omaha-pm mailing list