Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[miscperl] r268: LJSUP-9507 (warn about database/SQL erro...

Committer: ailyin
LJSUP-9507 (warn about database/SQL errors on production/staging servers)
U   trunk/DBI/Role.pm
Modified: trunk/DBI/Role.pm
===================================================================
--- trunk/DBI/Role.pm	2011-06-03 07:19:09 UTC (rev 267)
+++ trunk/DBI/Role.pm	2011-08-15 02:21:08 UTC (rev 268)
@@ -173,7 +173,7 @@
     }
 
     if ($fdsn) {
-        $dbh = get_dbh_conn($self, $fdsn, $role);
+        $dbh = $self->get_dbh_conn( $opts, $fdsn, $role );
         return $dbh if $dbh;
         delete $self->{'DBCACHE'}->{$role};  # guess it was bogus
     }
@@ -199,7 +199,7 @@
             last if $t > $rand;
         }
         my $fdsn = make_dbh_fdsn($self, $applicable[$i]->[0]);
-        $dbh = get_dbh_conn($self, $opts, $fdsn);
+        $dbh = $self->get_dbh_conn( $opts, $fdsn );
         if ($dbh) {
             $self->{'DBCACHE'}->{$role} = $fdsn;
             $self->{'DBCACHE_UNTIL'}->{$role} = $now + 5 + int(rand(10));
@@ -278,11 +278,19 @@
     my $tries = $DBI::Role::HAVE_HIRES ? 8 : 2;
     while ($loop) {
         $loop = 0;
-        $dbh = DBI->connect($dsn, $user, $pass, {
-            PrintError => 0,
-            AutoCommit => 1,
-        });
 
+        my $connection_opts;
+        if ( $opts->{'connection_opts'} ) {
+            $connection_opts = $opts->{'connection_opts'};
+        } else {
+            $connection_opts = {
+                PrintError => 0,
+                AutoCommit => 1,
+            };
+        }
+
+        $dbh = DBI->connect( $dsn, $user, $pass, $connection_opts );
+
         $dbh->{private_role} = $role if $dbh;
 
         # if max connections, try again shortly.

Tags: andy, miscperl, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments