| 1 | package Helios::ObjectDriver::DBI; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use 5.008; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | ▶ | use base qw(Data::ObjectDriver::Driver::DBI); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 1 | our $VERSION = '2.61'; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | # [LH] 2012-07-11: Changed the DBI connection creation to use connect_cached() | ||||||||||||||||||||
| 11 | # instead of connect() to implement connection caching. Also added | ||||||||||||||||||||
| 12 | # 'private_heliconn_$pid' option to ensure connections opened by separate | ||||||||||||||||||||
| 13 | # processes stay separated. | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 1 | my %Handles; | |||||||||||||||||||
| 17 | 0 | ▶ | sub init_db { | ||||||||||||||||||
|
Subroutine
init_db: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||
| 18 | 0 | my $driver = shift; | |||||||||||||||||||
| 19 | 0 | my $dbh; | |||||||||||||||||||
| 20 | 0 | ▶ | if ($driver->reuse_dbh) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 21 | 0 | $dbh = $Handles{$driver->dsn}; | |||||||||||||||||||
| 22 | } | ||||||||||||||||||||
| 23 | 0 | ▶ | unless ($dbh) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | 0 | eval { | |||||||||||||||||||
| 25 | # [LH] 2012-07-11: Changed the DBI connection creation to use | ||||||||||||||||||||
| 26 | # connect_cached() instead of connect() to implement connection | ||||||||||||||||||||
| 27 | # caching. Also added 'private_heliconn_$pid' option to ensure | ||||||||||||||||||||
| 28 | # connections opened by separate processes stay separated. | ||||||||||||||||||||
| 29 | $dbh = DBI->connect_cached($driver->dsn, $driver->username, $driver->password, | ||||||||||||||||||||
| 30 | { RaiseError => 1, PrintError => 0, AutoCommit => 1, 'private_heliconn_'.$$ => $$, | ||||||||||||||||||||
| 31 | 0 | ▶ | %{$driver->connect_options || {}} }) | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$driver->connect_options || {}
MC/DC0%0/1
$driver->connect_options || {}
$driver->connect_options
Truth table0%0/2
A
A= $driver->connect_options
| |||||||||||||||||||||
| 32 | or Carp::croak("Connection error: " . $DBI::errstr); | ||||||||||||||||||||
| 33 | }; | ||||||||||||||||||||
| 34 | 0 | ▶ | if ($@) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | 0 | Carp::croak($@); | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | 0 | ▶ | if ($driver->reuse_dbh) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 0 | $Handles{$driver->dsn} = $dbh; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | 0 | $driver->dbd->init_dbh($dbh); | |||||||||||||||||||
| 42 | 0 | $driver->{__dbh_init_by_driver} = 1; | |||||||||||||||||||
| 43 | 0 | return $dbh; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 48 | # [LH] 2012-07-11: Removed DBI->disconnect() call. | ||||||||||||||||||||
| 49 | # Unlike in the base Data::ObjectDriver::Driver::DBI | ||||||||||||||||||||
| 50 | # we don't want to disconnect the database connection | ||||||||||||||||||||
| 51 | # EVEN IF we created it. | ||||||||||||||||||||
| 52 | # We'll let DBI handle disconnection exclusively | ||||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 1 | 1; | |||||||||||||||||||
| 56 | __END__ | ||||||||||||||||||||