From: Peter Rabbitson Date: Sat, 29 Aug 2009 07:06:07 +0000 (+0000) Subject: Reduce the number of heavy dbh_do calls X-Git-Tag: v0.08111~48 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9a0b7b2691409f5e05e19e8da543b061189bde17;p=dbsrgits%2FDBIx-Class.git Reduce the number of heavy dbh_do calls --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index b92546c..5fb3f82 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1224,7 +1224,7 @@ sub _dbh_execute { sub _execute { my $self = shift; - $self->dbh_do('_dbh_execute', @_) + $self->dbh_do('_dbh_execute', @_); # retry over disconnects } sub insert { @@ -1987,7 +1987,7 @@ sub _dbh_sth { sub sth { my ($self, $sql) = @_; - $self->dbh_do('_dbh_sth', $sql); + $self->dbh_do('_dbh_sth', $sql); # retry over disconnects } sub _dbh_columns_info_for { @@ -2049,7 +2049,7 @@ sub _dbh_columns_info_for { sub columns_info_for { my ($self, $table) = @_; - $self->dbh_do('_dbh_columns_info_for', $table); + $self->_dbh_columns_info_for ($self->_get_dbh, $table); } =head2 last_insert_id @@ -2075,7 +2075,7 @@ EOE sub last_insert_id { my $self = shift; - $self->dbh_do('_dbh_last_insert_id', @_); + $self->_dbh_last_insert_id ($self->_dbh, @_); } =head2 _native_data_type diff --git a/lib/DBIx/Class/Storage/DBI/Pg.pm b/lib/DBIx/Class/Storage/DBI/Pg.pm index 9314396..2a7b529 100644 --- a/lib/DBIx/Class/Storage/DBI/Pg.pm +++ b/lib/DBIx/Class/Storage/DBI/Pg.pm @@ -19,20 +19,24 @@ sub with_deferred_fk_checks { $sub->(); } -sub _dbh_last_insert_id { - my ($self, $dbh, $seq) = @_; - $dbh->last_insert_id(undef, undef, undef, undef, {sequence => $seq}); -} - sub last_insert_id { my ($self,$source,$col) = @_; my $seq = ($source->column_info($col)->{sequence} ||= $self->get_autoinc_seq($source,$col)); $self->throw_exception("could not fetch primary key for " . $source->name . ", could not " . "get autoinc sequence for $col (check that table and column specifications are correct " . "and in the correct case)") unless defined $seq; - $self->dbh_do('_dbh_last_insert_id', $seq); + + $self->_dbh_last_insert_id ($self->_dbh, $seq); } +# there seems to be absolutely no reason to have this as a separate method, +# but leaving intact in case someone is already overriding it +sub _dbh_last_insert_id { + my ($self, $dbh, $seq) = @_; + $dbh->last_insert_id(undef, undef, undef, undef, {sequence => $seq}); +} + + sub _get_pg_search_path { my ($self,$dbh) = @_; # cache the search path as ['schema','schema',...] in the storage