Author: timbo
Date: Tue Feb  6 16:41:03 2007
New Revision: 8805

Modified:
   dbi/trunk/lib/DBD/Gofer.pm
   dbi/trunk/lib/DBD/Gofer/Transport/Base.pm
   dbi/trunk/lib/DBD/Gofer/Transport/stream.pm
   dbi/trunk/lib/DBI/Gofer/Transport/Base.pm
   dbi/trunk/test.pl

Log:
Replace go_ssh attribute with more general go_url attribute.
Move attributes out of *DBI*::Gofer::Transport::Base.


Modified: dbi/trunk/lib/DBD/Gofer.pm
==============================================================================
--- dbi/trunk/lib/DBD/Gofer.pm  (original)
+++ dbi/trunk/lib/DBD/Gofer.pm  Tue Feb  6 16:41:03 2007
@@ -91,7 +91,6 @@
     my %dsn_attr_defaults = (
         go_dsn => undef,
         go_url => undef,
-        go_ssh => undef,
         go_transport => undef,
     );
 
@@ -717,7 +716,7 @@
 
 or
 
-    export DBI_AUTOPROXY=dbi:Gofer:transport=stream;[EMAIL PROTECTED]
+    export DBI_AUTOPROXY=dbi:Gofer:transport=stream;url=ssh:[EMAIL PROTECTED]
 
 
 =head1 CONFIGURING VIA POLICY

Modified: dbi/trunk/lib/DBD/Gofer/Transport/Base.pm
==============================================================================
--- dbi/trunk/lib/DBD/Gofer/Transport/Base.pm   (original)
+++ dbi/trunk/lib/DBD/Gofer/Transport/Base.pm   Tue Feb  6 16:41:03 2007
@@ -14,6 +14,13 @@
 
 our $VERSION = sprintf("0.%06d", q$Revision$ =~ /(\d+)/o);
 
+__PACKAGE__->mk_accessors(qw(
+    trace
+    go_dsn
+    go_url
+));
+
+
 sub _init_trace { $ENV{DBD_GOFER_TRACE} || 0 }
 
 1;

Modified: dbi/trunk/lib/DBD/Gofer/Transport/stream.pm
==============================================================================
--- dbi/trunk/lib/DBD/Gofer/Transport/stream.pm (original)
+++ dbi/trunk/lib/DBD/Gofer/Transport/stream.pm Tue Feb  6 16:41:03 2007
@@ -18,7 +18,6 @@
 our $VERSION = sprintf("0.%06d", q$Revision: 8748 $ =~ /(\d+)/o);
 
 __PACKAGE__->mk_accessors(qw(
-    go_ssh
 )); 
 
 
@@ -33,13 +32,14 @@
         if (not $connection || ($connection->{pid} && not kill 0, 
$connection->{pid})) {
             my $cmd = [qw(perl -MDBI::Gofer::Transport::stream -e 
run_stdio_hex)];
             #push @$cmd, "DBI_TRACE=2=/tmp/goferstream.log", "sh", "-c";
-            if (my $ssh = $self->go_ssh) {
-                #my $ssh = '[EMAIL PROTECTED]';
+            if (my $url = $self->go_url) {
+                die "Only 'ssh:[EMAIL PROTECTED]' style url supported by this 
transport"
+                    unless $url =~ s/^ssh://;
+                my $ssh = $url;
                 my $setup_env = join "||", map { "source $_ 2>/dev/null" }
                                     qw(.bash_profile .bash_login .profile);
                 my $setup = $setup_env.q{; eval "$@"};
                 unshift @$cmd, qw(ssh -q), split(' ', $ssh), qw(bash -c), 
$setup;
-                #warn "[EMAIL PROTECTED]";
             }
             # XXX add a handshake - some message from 
DBI::Gofer::Transport::stream that's
             # sent as soon as it starts that we can wait for to report success 
- and soak up
@@ -81,6 +81,7 @@
     my ($pid, $rfh, $efh) = @{$connection}{qw(pid rfh efh)};
 
     # blocks till a newline has been read
+    $! = 0;
     my $frozen_response = <$rfh>; # always one line
     my $frozen_response_errno = $!;
 

Modified: dbi/trunk/lib/DBI/Gofer/Transport/Base.pm
==============================================================================
--- dbi/trunk/lib/DBI/Gofer/Transport/Base.pm   (original)
+++ dbi/trunk/lib/DBI/Gofer/Transport/Base.pm   Tue Feb  6 16:41:03 2007
@@ -16,22 +16,15 @@
 
 our $VERSION = sprintf("0.%06d", q$Revision$ =~ /(\d+)/o);
 
-sub _init_trace { $ENV{DBI_GOFER_TRACE} || 0 }
-
 
 __PACKAGE__->mk_accessors(qw(
     trace
-    go_dsn
-    go_url
-    go_ssh
 ));
 
 
-sub _new {
-    my ($class, $args) = @_;
-    $args->{trace} ||= $class->_init_trace;
-    return $class->SUPER::new($args);
-}
+sub _init_trace { $ENV{DBI_GOFER_TRACE} || 0 }
+
+
 sub new {
     my ($class, $args) = @_;
     $args->{trace} ||= $class->_init_trace;

Modified: dbi/trunk/test.pl
==============================================================================
--- dbi/trunk/test.pl   (original)
+++ dbi/trunk/test.pl   Tue Feb  6 16:41:03 2007
@@ -49,7 +49,7 @@
 
 # Now ask for some information from the DBI Switch
 my $switch = DBI->internal;
-$switch->debug($::opt_h); # 2=detailed handle trace
+$switch->trace($::opt_h); # 2=detailed handle trace
 
 DBI->trace($::opt_d, $::opt_l) if $::opt_d || $::opt_l;
 
@@ -58,8 +58,8 @@
 print "Available Drivers: ",join(", ",DBI->available_drivers(1)),"\n";
 
 
-my $dbh = DBI->connect("dbi:$driver:", '', '');
-$dbh->debug($::opt_h);
+my $dbh = DBI->connect("dbi:$driver:", '', '') or die;
+$dbh->trace($::opt_h);
 
 if (0) {
     DBI->trace(3);
@@ -109,11 +109,12 @@
     my $tds= Benchmark::timestr($td);
     my $dur = $td->cpu_a || (1/$count); # fudge if cpu_a==0
 
-    printf "%5d NullP sth/s perl %8s %s (%s %s %s)\n\n",
+    printf "%5d NullP sth/s perl %8s %s (%s %s %s) %fs\n\n",
            $count/$dur, $], $Config{archname},
            $Config{gccversion} ? 'gcc' : $Config{cc},
            (split / /, $Config{gccversion}||$Config{ccversion}||'')[0]||'',
-           $Config{optimize};
+           $Config{optimize},
+            $dur/$count;
 
     $null_dbh->disconnect;
 }

Reply via email to