line |
true |
false |
branch |
892
|
0 |
0 |
unless lc $_ eq $_ |
897
|
0 |
2 |
if not defined $t{'debug'} && $t{'debug'} =~ /^\d+$/o and defined $ENV{'DATASTORE_DEBUG'} and $ENV{'DATASTORE_DEBUG'} =~ /^\d+$/o |
898
|
2 |
0 |
unless defined $t{'debug'} and $t{'debug'} =~ /^\d+$/o |
901
|
0 |
2 |
if (defined $t{'paging'}) |
902
|
0 |
0 |
if (exists $TV{lc $t{'paging'}}) { } |
|
0 |
0 |
elsif (exists $FV{lc $t{'paging'}}) { } |
913
|
2 |
0 |
unless defined $t{'use_home'} and $t{'use_home'} =~ /^\d+$/o |
915
|
0 |
2 |
if defined $t{'config'} and length $t{'config'} > 0 |
931
|
1 |
0 |
if (scalar @_ > 0 and ref $_[0] eq 'HASH') |
942
|
1 |
0 |
if (exists $opts->{'config'}) |
943
|
0 |
1 |
if &DEBUG() |
944
|
1 |
0 |
if (ref $opts->{'config'} eq 'HASH') { } |
|
0 |
0 |
elsif ($opts->{'config'} =~ m[^/] and -r $opts->{'config'}) { } |
|
0 |
0 |
elsif (length $opts->{'config'} > 0) { } |
959
|
0 |
0 |
if ($self->{'config'} = YAML::Syck::Load($opts->{'config'})) |
964
|
0 |
1 |
if (scalar @configs > 0) |
968
|
0 |
0 |
unless -r $path |
969
|
0 |
0 |
if ($self->{'config'} = YAML::Syck::LoadFile($path)) { } |
973
|
0 |
0 |
if &DEBUG() |
978
|
0 |
1 |
unless $found_config |
981
|
0 |
1 |
if (defined $opts->{'cache_connections'}) { } |
|
0 |
1 |
elsif (not defined $self->{'config'}{'cache_connections'}) { } |
988
|
0 |
1 |
if (defined $opts->{'cache_statements'}) { } |
|
0 |
1 |
elsif (not defined $self->{'config'}{'cache_statements'}) { } |
997
|
0 |
0 |
if ($found_config != 1 and defined $opts->{'store'} and length $opts->{'store'} > 0) |
999
|
0 |
0 |
if ($@ or not defined $self->{'config'}) { } |
1007
|
0 |
1 |
if ($found_config != 1 and scalar @args > 0) |
1009
|
0 |
0 |
if ($@ or not defined $self->{'config'}) { } |
1010
|
0 |
0 |
if &DEBUG() |
1012
|
0 |
0 |
if &DEBUG() >= 3 |
1016
|
0 |
0 |
if (scalar @manual_schemas > 0) |
1017
|
0 |
0 |
if &DEBUG() >= 2 |
1019
|
0 |
0 |
if (defined $self->{'config'}{'readers'} and ref $self->{'config'}{'readers'} eq 'ARRAY') |
1031
|
0 |
1 |
if ($found_config != 1) |
1034
|
0 |
0 |
unless $p[0] eq 'main' |
1036
|
0 |
0 |
if (scalar @packages > 0) |
1038
|
0 |
0 |
if ($@ or not defined $self->{'config'}) { } |
1039
|
0 |
0 |
if &DEBUG() |
1047
|
0 |
1 |
if ($found_config != 1) |
1049
|
0 |
0 |
if ($@ or not defined $self->{'config'}) |
1056
|
0 |
1 |
unless ($self->{'handles'}{'primary'} = _db_connect('cache', $self->{'config'}{'cache_connections'}, %{$$self{'config'}{'primary'};})) |
1070
|
0 |
1 |
defined $self->{'config'}{'readers'} && ref $self->{'config'}{'readers'} eq 'HASH' ? : |
1072
|
0 |
1 |
if defined $opts->{'reader'} |
1076
|
0 |
0 |
if not defined $self->{'config'}{'default_reader'} or lc $self->{'config'}{'default_reader'} eq 'none' or length $self->{'config'}{'default_reader'} < 1 or $num_readers < 1 |
1084
|
0 |
1 |
if (defined $self->{'config'}{'default_reader'} and $self->{'config'}{'default_reader'} ne 'primary') |
1085
|
0 |
0 |
if ($self->{'config'}{'default_reader'} eq '__random') { } |
1086
|
0 |
0 |
if ($num_readers > 0) |
1096
|
0 |
0 |
unless exists $self->{'config'}{'readers'}{$self->{'config'}{'default_reader'}} |
1101
|
1 |
0 |
if (scalar @reader_list < 1) { } |
1111
|
0 |
0 |
if ($dbh = _db_connect('cache', $self->{'config'}{'cache_connections'}, %{$$self{'config'}{'readers'}{$reader};})) |
1126
|
0 |
0 |
if ($found_reader != 1) |
1136
|
0 |
1 |
defined $self->{'config'}{'primary'}{'dbd_opts'} && ref $self->{'config'}{'primary'}{'dbd_opts'} eq 'HASH' && defined $self->{'config'}{'primary'}{'dbd_opts'}{'AutoCommit'} && $self->{'config'}{'primary'}{'dbd_opts'}{'AutoCommit'} == 0 ? : |
1159
|
0 |
1 |
if ($self->{'autocommit'} == 0) |
1177
|
0 |
0 |
if ($driver eq 'mysql') { } |
|
0 |
0 |
elsif ($driver eq 'pg') { } |
|
0 |
0 |
elsif ($driver eq 'oracle') { } |
|
0 |
0 |
elsif ($driver eq 'db2') { } |
1187
|
0 |
0 |
if (defined $self->{'config'}{'primary'}{'schemas'} and ref $self->{'config'}{'primary'}{'schemas'} eq 'ARRAY') { } |
1224
|
0 |
0 |
if ($res) { } |
1241
|
0 |
2 |
unless defined $self->{'config'}{'primary'}{'driver'} |
1256
|
0 |
0 |
if ($self->{'st_count'} == 0 and $self->{'in_tx'} == 1 and $self->{'autocommit'} == 0) |
1263
|
0 |
2 |
if ($driver eq 'mysql') { } |
|
0 |
2 |
elsif ($driver eq 'pg') { } |
|
2 |
0 |
elsif ($driver eq 'sqlite') { } |
|
0 |
0 |
elsif ($driver eq 'db2') { } |
1264
|
0 |
0 |
if ($self->{'in_tx'} > 0) |
1268
|
0 |
0 |
if ($self->{'in_tx'} > 0) |
1272
|
0 |
2 |
if ($self->{'in_tx'} > 0) |
1276
|
0 |
0 |
if ($self->{'in_tx'} > 0) |
1281
|
0 |
2 |
unless $self->{'handles'}{'primary'}->begin_work |
1291
|
0 |
1 |
unless $self->{'in_tx'} > 0 |
1293
|
0 |
1 |
unless $self->{'handles'}{'primary'}->commit |
1302
|
0 |
1 |
if ($self->{'autocommit'} == 0) |
1308
|
0 |
1 |
if ($self->{'autocommit'} == 0 and defined $self->{'config'}{'primary'}{'schemas'}) |
1323
|
0 |
0 |
if ($driver eq 'mysql') { } |
|
0 |
0 |
elsif ($driver eq 'pg') { } |
|
0 |
0 |
elsif ($driver eq 'db2') { } |
1352
|
0 |
0 |
if ($res) { } |
1372
|
0 |
0 |
if defined $config{'pass'} |
1381
|
0 |
0 |
unless defined $self->{'config'}{'default_reader'} and exists $self->{'config'}{'readers'}{$self->{'config'}{'default_reader'}} |
1385
|
0 |
0 |
if defined $config{'pass'} |
1396
|
1 |
18 |
if (scalar @args > 1 and ref $args[0] eq 'HASH') |
1404
|
18 |
1 |
unless defined $opts->{'per_page'} and $opts->{'per_page'} =~ /^\d+$/o |
1405
|
18 |
1 |
unless defined $opts->{'page'} and $opts->{'page'} =~ /^\d+$/o |
1409
|
19 |
0 |
unless defined $opts->{'prepare'} and $opts->{'prepare'} =~ /^\d+$/o |
1421
|
11 |
8 |
if ($self->{'in_tx'} > 0 or $st_type ne 'select') { } |
1424
|
0 |
8 |
if (exists $self->{'config'}{'reader_failover'} and $self->{'config'}{'reader_failover'} == 1) { } |
1425
|
0 |
0 |
exists $self->{'config'}{'flag_bad_readers'} && $self->{'config'}{'flag_bad_readers'} == 1 ? : |
1427
|
0 |
0 |
if (not $self->{'handles'}{'reader'}->do('select 1')) { } |
1428
|
0 |
0 |
if ($self->{'config'}{'default_reader'} eq 'primary') |
1441
|
0 |
0 |
if ($check_limit < 1) |
1442
|
0 |
0 |
if &DEBUG() |
1445
|
0 |
0 |
if &DEBUG() |
1449
|
0 |
0 |
if ($flag_bad) { } |
1457
|
0 |
0 |
if scalar @new_readers < 1 |
1468
|
0 |
0 |
if ($dbh = _db_connect('cache', $self->{'config'}{'cache_connections'}, %{$$self{'config'}{'readers'}{$reader};})) |
1475
|
0 |
0 |
if ($dbh->do('select 1')) |
1485
|
0 |
0 |
unless ($reader_found) |
1486
|
0 |
0 |
if ($self->{'handles'}{'primary'}->do('select 1')) { } |
1505
|
19 |
0 |
unless ($opts->{'prepare'}) |
1506
|
0 |
19 |
if &DEBUG() |
1512
|
1 |
18 |
if ($opts->{'page'} > 0) |
1517
|
0 |
1 |
$self->{'in_tx'} > 0 ? : |
1522
|
0 |
1 |
if ($sql =~ /limit\s+\d+(\s+offset\s+\d+|\s*,\s*\d+)\s*$/iso or $sql =~ /rows\s+\d+(\s+to\s+\d+)\s*$/iso) |
1525
|
0 |
0 |
if &DEBUG() |
1530
|
0 |
1 |
unless $limit_offset > 0 |
1534
|
1 |
0 |
if (exists {map({$_, '';} 'mysql', 'pg', 'sqlite')}->{$driver}) { } |
|
0 |
0 |
elsif (exists {map({$_, '';} 'interbase', 'firebird')}->{$driver}) { } |
1550
|
0 |
19 |
if ($opts->{'prepare'}) { } |
1551
|
0 |
0 |
if (defined $self->{'config'}{'cache_statements'} and $self->{'config'}{'cache_statements'} == 1) { } |
1557
|
0 |
0 |
unless ($sth = $dbh->prepare_cached($sql, $opts, 3)) |
1558
|
0 |
0 |
if &DEBUG() |
1562
|
0 |
0 |
unless ($sth = $dbh->prepare($sql, $opts)) |
1563
|
0 |
0 |
if &DEBUG() |
1568
|
0 |
0 |
if ($error == 0) |
1569
|
0 |
0 |
unless ($dbi_res = $sth->execute(@binds)) |
1570
|
0 |
0 |
if &DEBUG() |
1580
|
8 |
11 |
if ($st_type ne 'select' and not $sql =~ /\s+returning\s+\w+(\s*,\s*\w+)*\s*/iso) { } |
1585
|
0 |
8 |
unless ($dbi_res = $dbh->do($sql)) |
1586
|
0 |
0 |
if &DEBUG() |
1590
|
11 |
0 |
if ($sth = $dbh->prepare($sql, $opts)) { } |
1591
|
0 |
11 |
unless ($dbi_res = $sth->execute) |
1592
|
0 |
0 |
if &DEBUG() |
1596
|
0 |
0 |
if &DEBUG() |
1602
|
8 |
11 |
unless $st_type eq 'select' |
1608
|
0 |
19 |
if $error |
1630
|
1 |
0 |
if defined $self->{'in_tx'} and $self->{'in_tx'} > 0 |
1641
|
0 |
2 |
if (exists {map({$_, '';} 'mysql', 'informix')}->{$driver}) |
1645
|
2 |
0 |
if (my $id = $self->{'handles'}{'primary'}->last_insert_id(@args)) { } |
1656
|
0 |
0 |
$self->{'config'}{'default_reader'} eq 'primary' ? : |
1659
|
0 |
0 |
unless ($self->{'handles'}{$server}->do('select 1')) |
1660
|
0 |
0 |
if &DEBUG() |
1671
|
0 |
2 |
unless $self->{'in_tx'} > 0 |
1676
|
1 |
1 |
if (defined $savepoint) { } |
1680
|
0 |
1 |
if ($driver eq 'sybase') { } |
|
0 |
1 |
elsif ($driver eq 'pg') { } |
1683
|
0 |
0 |
unless ($self->{'handles'}{'primary'}->pg_rollback_to($savepoint)) |
1692
|
0 |
1 |
unless ($self->{'handles'}{'primary'}->do($sql)) |
1700
|
0 |
1 |
unless $self->{'handles'}{'primary'}->rollback |
1710
|
0 |
2 |
if ($self->{'autocommit'} == 0) |
1716
|
0 |
2 |
if ($self->{'autocommit'} == 0 and defined $self->{'config'}{'primary'}{'schemas'}) |
1727
|
0 |
1 |
unless $self->{'in_tx'} > 0 |
1728
|
0 |
1 |
unless defined $savepoint and $savepoint =~ /\w+/o |
1737
|
0 |
1 |
if ($driver eq 'sybase') { } |
|
0 |
1 |
elsif ($driver eq 'pg') { } |
1740
|
0 |
0 |
unless ($self->{'handles'}{'primary'}->pg_savepoint($savepoint)) |
1749
|
0 |
1 |
unless ($self->{'handles'}{'primary'}->do($sql)) |
1760
|
0 |
0 |
if (defined $schemas and ref $schemas eq 'ARRAY') { } |
1761
|
0 |
0 |
if &DEBUG() >= 2 |
1764
|
0 |
0 |
if $self->{'reader'} ne 'primary' |
1774
|
0 |
0 |
if $self->{'reader'} ne 'primary' |
1776
|
0 |
0 |
if &DEBUG() >= 4 |
1780
|
0 |
0 |
if defined $self->{'config'}{'primary'}{'schemas'} and ref $self->{'config'}{'primary'}{'schemas'} eq 'ARRAY' and scalar @{$self->{'config'}{'primary'}{'schemas'};} > 0 |
1793
|
0 |
0 |
if defined $config{'password'} |
1799
|
0 |
0 |
if defined $config{'password'} |
1815
|
0 |
0 |
if ($driver eq 'mysql') { } |
|
0 |
0 |
elsif ($driver eq 'pg') { } |
|
0 |
0 |
elsif ($driver eq 'oracle') { } |
|
0 |
0 |
elsif ($driver eq 'db2') { } |
1824
|
0 |
0 |
if (defined $self->{'config'}{'primary'}{'schemas'} and ref $self->{'config'}{'primary'}{'schemas'} eq 'ARRAY') { } |
1861
|
0 |
0 |
if ($res) { } |
1882
|
0 |
0 |
if ($driver eq 'mysql') { } |
|
0 |
0 |
elsif ($driver eq 'pg') { } |
|
0 |
0 |
elsif ($driver eq 'oracle') { } |
|
0 |
0 |
elsif ($driver eq 'db2') { } |
1892
|
0 |
0 |
if (defined $self->{'config'}{'primary'}{'schemas'} and ref $self->{'config'}{'primary'}{'schemas'} eq 'ARRAY') { } |
1929
|
0 |
0 |
if ($res) { } |
1956
|
0 |
0 |
unless ($self->{'st_count'} == 0 and $self->{'in_tx'} == 1 and $self->{'autocommit'} == 0) |
1957
|
0 |
0 |
if &DEBUG() |
1959
|
0 |
0 |
unless $self->{'handles'}{'primary'}->rollback |
1975
|
1 |
0 |
if (defined $args{'dsn'} and length $args{'dsn'} > 0) { } |
1978
|
0 |
1 |
unless (exists $args{$_}) |
1979
|
0 |
0 |
if &DEBUG() >= 3 |
1989
|
0 |
0 |
unless (exists $args{$_}) |
1990
|
0 |
0 |
if &DEBUG() >= 3 |
1997
|
0 |
0 |
unless (exists $args{$_}) |
1998
|
0 |
0 |
if &DEBUG() >= 3 |
2004
|
0 |
0 |
if defined $args{'port'} and $args{'port'} =~ /^\d+$/ |
2007
|
0 |
1 |
if &DEBUG() |
2014
|
0 |
1 |
if ($args{'cache'} and $dbh = 'DBI'->connect_cached($dsn, $args{'user'}, $args{'password'}, $args{'dbd_opts'})) { } |
|
1 |
0 |
elsif (not $args{'cache'} and $dbh = 'DBI'->connect($dsn, $args{'user'}, $args{'password'}, $args{'dbd_opts'})) { } |
2015
|
0 |
0 |
if $dbh->ping >= 3 |
2016
|
0 |
0 |
if &DEBUG() >= 3 |
2019
|
0 |
1 |
if $dbh->ping >= 3 |
2020
|
0 |
1 |
if &DEBUG() >= 3 |
2023
|
0 |
0 |
if &DEBUG() |
2033
|
0 |
1 |
if &DEBUG() >= 4 |
2035
|
0 |
1 |
unless (defined $driver) |
2036
|
0 |
0 |
if &DEBUG() |
2041
|
1 |
0 |
unless lc $driver eq 'pg' |
2043
|
0 |
0 |
if (not defined $schemas or ref $schemas ne 'ARRAY' or scalar @{$schemas;} < 1) |
2044
|
0 |
0 |
if &DEBUG() |
2048
|
0 |
0 |
if &DEBUG() >= 2 |
2056
|
0 |
0 |
if (lc $driver eq 'pg') |
2060
|
0 |
0 |
if (length $sql > 0) { } |
2061
|
0 |
0 |
if ($dbh->do($sql)) { } |
2068
|
0 |
0 |
if &DEBUG() >= 2 |
2082
|
0 |
19 |
if $st_type eq 'with' |
2085
|
13 |
6 |
if not @binds or scalar @binds < 1 |
2090
|
0 |
6 |
if ($st_type eq 'update' and $sql =~ /\s+set\s+$HASH_PH/iso and scalar @binds < 1 || ref $binds[0] ne 'HASH') { } |
|
0 |
6 |
elsif ($st_type eq 'insert' and $sql =~ /^\s*insert\s+into\s+\S+\s+(values\s+)?$HASH_PH/iso and scalar @binds < 1 || !(ref $binds[0] eq 'ARRAY' || ref $binds[0] eq 'HASH')) { } |
|
3 |
6 |
elsif ($st_type eq 'select' and scalar @binds > 0) { } |
2098
|
0 |
3 |
if (ref $_ eq 'HASH') |
2106
|
1 |
5 |
if ($st_type eq 'update' and $sql =~ /$HASH_PH/o) |
2107
|
1 |
0 |
if ($sql =~ s/(set\s+)$HASH_PH(\s*)/$1 . join(', ', map({"$_ = ?";} sort(keys %{$binds[0];}))) . $2;/eisx) |
2122
|
2 |
4 |
if ($st_type eq 'insert' and $sql =~ /^\s*insert\s+into\s+\S+\s+(values\s+)?$HASH_PH/iso) |
2124
|
1 |
1 |
if (ref $binds[0] eq 'HASH') { } |
|
1 |
0 |
elsif (ref $binds[0] eq 'ARRAY') { } |
2130
|
0 |
2 |
if scalar @cols < 1 |
2134
|
1 |
1 |
ref $binds[0] eq 'ARRAY' ? : |
2140
|
1 |
1 |
if (ref $binds[0] eq 'ARRAY') { } |
2156
|
1 |
3 |
if (ref $bind eq 'ARRAY') { } |
2159
|
1 |
0 |
if ($sql =~ /((in\s+)([(]?\s*$ARRAY_PH\s*[)]?)|(array\s*\[\s*$ARRAY_PH\s*\]))/is) { } |
2161
|
1 |
0 |
if ($ph_block =~ /^in/is) { } |
|
0 |
0 |
elsif ($ph_block =~ /^array/is) { } |
2162
|
1 |
0 |
if ($sql =~ s/(in\s+)([(]?\s*$ARRAY_PH\s*[)]?)/$1 . '( ' . join(', ', ('?') x scalar(@{$bind;})) . ' )';/eisx) |
2166
|
0 |
0 |
if ($sql =~ s/\s*array\s*\[\s*$ARRAY_PH\s*\]/' array [ ' . join(', ', ('?') x scalar(@{$bind;})) . ' ] ';/eisx) |
2185
|
0 |
6 |
if (scalar grep({$st_type eq $_;} 'insert', 'update', 'delete') > 0 and $sql =~ /\s+returning\s+(\*|\w)/iso) |
2189
|
0 |
6 |
if &DEBUG() >= 2 |