Author: timbo
Date: Fri Feb 9 06:48:41 2007
New Revision: 8840
Modified:
dbi/trunk/lib/DBD/Gofer/Transport/null.pm
dbi/trunk/lib/DBI/Gofer/Execute.pm
dbi/trunk/lib/DBI/Gofer/Transport/mod_perl.pm
dbi/trunk/lib/DBI/Gofer/Transport/pipeone.pm
dbi/trunk/lib/DBI/Gofer/Transport/stream.pm
Log:
Convert DBI::Gofer::Execute into an object
Modified: dbi/trunk/lib/DBD/Gofer/Transport/null.pm
==============================================================================
--- dbi/trunk/lib/DBD/Gofer/Transport/null.pm (original)
+++ dbi/trunk/lib/DBD/Gofer/Transport/null.pm Fri Feb 9 06:48:41 2007
@@ -12,7 +12,7 @@
use base qw(DBD::Gofer::Transport::Base);
-use DBI::Gofer::Execute qw(execute_request);
+use DBI::Gofer::Execute;
our $VERSION = sprintf("0.%06d", q$Revision$ =~ /(\d+)/o);
@@ -20,6 +20,8 @@
pending_response
));
+my $executor = DBI::Gofer::Execute->new();
+
sub transmit_request {
my ($self, $request) = @_;
@@ -36,7 +38,7 @@
# but similar logic as used for DBI_TRACE parsing.
#my $prev_trace_level = DBI->trace( ($ENV{DBD_GOFER_NULL_TRACE}) ? (split
/=/, $ENV{DBD_GOFER_NULL_TRACE}) : (0));
- my $response = execute_request( $self->thaw_data($frozen_request,1) );
+ my $response = $executor->execute_request(
$self->thaw_data($frozen_request,1) );
#DBI->trace($prev_trace_level);
Modified: dbi/trunk/lib/DBI/Gofer/Execute.pm
==============================================================================
--- dbi/trunk/lib/DBI/Gofer/Execute.pm (original)
+++ dbi/trunk/lib/DBI/Gofer/Execute.pm Fri Feb 9 06:48:41 2007
@@ -11,18 +11,22 @@
use warnings;
use DBI;
-use DBI::Gofer::Request;
use DBI::Gofer::Response;
-use base qw(Exporter);
+use base qw(DBI::Util::_accessor);
our $VERSION = sprintf("0.%06d", q$Revision$ =~ /(\d+)/o);
-our @EXPORT_OK = qw(
- execute_request
- execute_dbh_request
- execute_sth_request
-);
+__PACKAGE__->mk_accessors(qw(
+ connect_args
+ dbh_method_name
+ dbh_method_args
+ dbh_wantarray
+ dbh_last_insert_id_args
+ sth_method_calls
+ sth_result_attr
+));
+
my @sth_std_attr = qw(
NUM_OF_PARAMS
@@ -69,23 +73,6 @@
},
);
-my %extra_sth_attr = (
- # what driver-specific attributes should be returned for the driver being
used?
- # keyed by $dbh->{Driver}{Name}
- # XXX could split into attr specific to resultsets (where NUM_OF_FIELDS >
0) and others
- # which would reduce processing/traffic for non-select statements
- mysql => [qw(
- mysql_is_blob mysql_is_key mysql_is_num mysql_is_pri_key
mysql_is_auto_increment
- mysql_length mysql_max_length mysql_table mysql_type mysql_type_name
- )],
- Pg => [qw(
- pg_size pg_type pg_oid_status pg_cmd_status
- )],
- Sybase => [qw(
- syb_types syb_result_type syb_proc_status
- )],
-);
-
# set trace for server-side gofer
# Could use DBI_TRACE env var when it's a separate process
@@ -153,7 +140,7 @@
sub execute_request {
- my $request = shift;
+ my ($self, $request) = @_;
DBI->trace_msg("-----> execute_request\n");
my @warnings;
local $SIG{__WARN__} = sub { push @warnings, @_ };
@@ -242,7 +229,7 @@
my ($sth, $request) = @_;
return eval {
my $driver_name = $sth->{Database}{Driver}{Name};
- my $extra_sth_attr = $extra_sth_attr{$driver_name} || [];
+ my $extra_sth_attr = $extra_attr{$driver_name}{sth} || [];
my $sth_attr = {};
$sth_attr->{$_} = 1 for (@sth_std_attr, @$extra_sth_attr);
Modified: dbi/trunk/lib/DBI/Gofer/Transport/mod_perl.pm
==============================================================================
--- dbi/trunk/lib/DBI/Gofer/Transport/mod_perl.pm (original)
+++ dbi/trunk/lib/DBI/Gofer/Transport/mod_perl.pm Fri Feb 9 06:48:41 2007
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use DBI::Gofer::Execute qw(execute_request);
+use DBI::Gofer::Execute;
use Apache::Constants qw(OK);
@@ -12,6 +12,7 @@
our $VERSION = sprintf("0.%06d", q$Revision$ =~ /(\d+)/o);
my $transport = __PACKAGE__->new();
+my $executor = DBI::Gofer::Execute->new();
sub handler {
@@ -20,7 +21,8 @@
$r->read(my $frozen_request, $r->header_in('Content-length'));
- my $response = execute_request( $transport->thaw_data($frozen_request) );
+ my $request = $transport->thaw_data($frozen_request);
+ my $response = $executor->execute_request( $request );
my $frozen_response = $transport->freeze_data($response);
Modified: dbi/trunk/lib/DBI/Gofer/Transport/pipeone.pm
==============================================================================
--- dbi/trunk/lib/DBI/Gofer/Transport/pipeone.pm (original)
+++ dbi/trunk/lib/DBI/Gofer/Transport/pipeone.pm Fri Feb 9 06:48:41 2007
@@ -10,7 +10,7 @@
use strict;
use warnings;
-use DBI::Gofer::Execute qw(execute_request);
+use DBI::Gofer::Execute;
use base qw(DBI::Gofer::Transport::Base Exporter);
@@ -18,6 +18,7 @@
our @EXPORT = qw(run_one_stdio);
+my $executor = DBI::Gofer::Execute->new();
sub run_one_stdio {
@@ -25,7 +26,7 @@
my $frozen_request = do { local $/; <STDIN> };
- my $response = execute_request( $self->thaw_data($frozen_request) );
+ my $response = $executor->execute_request(
$self->thaw_data($frozen_request) );
my $frozen_response = $self->freeze_data($response);
Modified: dbi/trunk/lib/DBI/Gofer/Transport/stream.pm
==============================================================================
--- dbi/trunk/lib/DBI/Gofer/Transport/stream.pm (original)
+++ dbi/trunk/lib/DBI/Gofer/Transport/stream.pm Fri Feb 9 06:48:41 2007
@@ -10,7 +10,7 @@
use strict;
use warnings;
-use DBI::Gofer::Execute qw(execute_request);
+use DBI::Gofer::Execute;
use base qw(DBI::Gofer::Transport::pipeone Exporter);
@@ -18,6 +18,7 @@
our @EXPORT = qw(run_stdio_hex);
+my $executor = DBI::Gofer::Execute->new();
sub run_stdio_hex {
@@ -29,7 +30,7 @@
while ( my $frozen_request = <STDIN> ) {
my $request = $self->thaw_data( pack "H*", $frozen_request );
- my $response = execute_request( $request );
+ my $response = $executor->execute_request( $request );
my $frozen_response = unpack "H*", $self->freeze_data($response);