| 1 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | package DBD::ExampleP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 66 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 66 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 66 | ▶ | use Symbol; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 66 | ▶ | use DBI qw(:sql_types); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 66 | require File::Spec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 66 | our (@EXPORT,$VERSION,@statnames,%statnames,@stattypes,%stattypes, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | @statprec,%statprec,$drh,); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 66 | @EXPORT = qw(); # Do NOT @EXPORT anything. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 66 | $VERSION = "12.014311"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # $Id: ExampleP.pm 14310 2010-08-02 06:35:25Z Jens $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # Copyright (c) 1994,1997,1998 Tim Bunce | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # You may distribute under the terms of either the GNU General Public | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # License or the Artistic License, as specified in the Perl README file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 66 | @statnames = qw(dev ino mode nlink | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | uid gid rdev size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | atime mtime ctime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | blksize blocks name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 66 | @statnames{@statnames} = (0 .. @statnames-1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 66 | @stattypes = (SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | SQL_INTEGER, SQL_INTEGER, SQL_INTEGER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | SQL_INTEGER, SQL_INTEGER, SQL_VARCHAR); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 66 | @stattypes{@statnames} = @stattypes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 66 | @statprec = ((10) x (@statnames-1), 1024); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 66 | @statprec{@statnames} = @statprec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 66 | ▶ | die unless @statnames == @stattypes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 66 | ▶ | die unless @statprec == @stattypes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 66 | $drh = undef; # holds driver handle once initialised | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | #$gensym = "SYM000"; # used by st::execute() for filehandles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 66 | ▶ | sub driver{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
driver: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 66 | ▶ | return $drh if $drh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 66 | my($class, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 66 | $class .= "::dr"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 66 | ($drh) = DBI::_new_drh($class, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 'Name' => 'ExampleP', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 'Version' => $VERSION, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 'Attribution' => 'DBD Example Perl stub by Tim Bunce', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | }, ['example implementors private data '.__PACKAGE__]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 66 | $drh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub CLONE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | undef $drh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 66 | { package DBD::ExampleP::dr; # ====== DRIVER ====== | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 66 | $imp_data_size = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 66 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2427 | ▶ | sub connect { # normally overridden, but a handy default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 2427 | my($drh, $dbname, $user, $auth)= @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2427 | my ($outer, $dbh) = DBI::_new_dbh($drh, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | Name => $dbname, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | examplep_private_dbh_attrib => 42, # an example, for testing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | $dbh->{examplep_get_info} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2427 | 29 => '"', # SQL_IDENTIFIER_QUOTE_CHAR | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 41 => '.', # SQL_CATALOG_NAME_SEPARATOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 114 => 1, # SQL_CATALOG_LOCATION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | #$dbh->{Name} = $dbname; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 2427 | $dbh->STORE('Active', 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2427 | return $outer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | sub data_sources { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
data_sources: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | return ("dbi:ExampleP:dir=."); # possibly usefully meaningless | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 66 | { package DBD::ExampleP::db; # ====== DATABASE ====== | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 66 | $imp_data_size = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 66 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 5764 | ▶ | sub prepare { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 5764 | my($dbh, $statement)= @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 5764 | my @fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 5764 | my($fields, $dir) = $statement =~ m/^\s*select\s+(.*?)\s+from\s+(\S*)/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 5764 | ▶ | if (defined $fields and defined $dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $fields and defined $dir
MC/DC50%1/2
defined $fields and defined $dir
defined $fields
defined $dir
Truth table66%2/3
A and B
A= defined $fieldsB= defined $dir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 4301 | ▶ | @fields = ($fields eq '*') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | ? keys %DBD::ExampleP::statnames | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | : split(/\s*,\s*/, $fields); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1463 | ▶ | return $dbh->set_err($DBI::stderr, "Syntax error in select statement (\"$statement\")") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | unless $statement =~ m/^\s*set\s+/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # the SET syntax is just a hack so the ExampleP driver can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # be used to test non-select statements. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # Now we have DBI::DBM etc., ExampleP should be deprecated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 5764 | my ($outer, $sth) = DBI::_new_sth($dbh, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 'Statement' => $statement, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | examplep_private_sth_attrib => 24, # an example, for testing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | }, ['example implementors private data '.__PACKAGE__]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | my @bad = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 5764 | ▶ | defined $DBD::ExampleP::statnames{$_} ? () : $_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } @fields; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 5764 | ▶ | return $dbh->set_err($DBI::stderr, "Unknown field names: @bad") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | if @bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 5728 | $outer->STORE('NUM_OF_FIELDS' => scalar(@fields)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 5728 | ▶ | $sth->{examplep_ex_dir} = $dir if defined($dir) && $dir !~ /\?/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $dir and not $dir =~ /\?/
MC/DC100%2/2
defined $dir and not $dir =~ /\?/
defined $dir
not $dir =~ /\?/
Truth table100%3/3
A and not(B)
A= defined $dirB= not $dir =~ /\?/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 5728 | ▶ | $outer->STORE('NUM_OF_PARAMS' => ($dir) ? $dir =~ tr/?/?/ : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 5728 | ▶ | if (@fields) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 4265 | $outer->STORE('NAME' => \@fields); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 4265 | $outer->STORE('NULLABLE' => [ (0) x @fields ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 4265 | $outer->STORE('SCALE' => [ (0) x @fields ]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 5728 | $outer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 16 | ▶ | sub table_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
table_info: called CC=13 SCAR=26.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 16 | my $dbh = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 16 | my ($catalog, $schema, $table, $type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 16 | ▶ | my @types = split(/["']*,["']/, $type || 'TABLE'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$type || 'TABLE'
MC/DC100%1/1
$type || 'TABLE'
$type
Truth table100%2/2
A
A= $type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 16 | my %types = map { $_=>$_ } @types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # Return a list of all subdirectories | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 16 | my $dh = Symbol::gensym(); # "DBD::ExampleP::".++$DBD::ExampleP::gensym; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 16 | ▶ | my $dir = $catalog || File::Spec->curdir(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$catalog || 'File::Spec'->curdir
MC/DC0%0/2
$catalog || 'File::Spec'->curdir
$catalog
'File::Spec'->curdir
Truth table66%2/3
A || B
A= $catalogB= 'File::Spec'->curdir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 16 | my @list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 16 | ▶ | if ($types{VIEW}) { # for use by test harness | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 4 | push @list, [ undef, "schema", "table", 'VIEW', undef ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 4 | push @list, [ undef, "sch-ema", "table", 'VIEW', undef ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 4 | push @list, [ undef, "schema", "ta-ble", 'VIEW', undef ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 4 | push @list, [ undef, "sch ema", "table", 'VIEW', undef ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 4 | push @list, [ undef, "schema", "ta ble", 'VIEW', undef ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 16 | ▶ | if ($types{TABLE}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 66 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 12 | ▶ | opendir($dh, $dir) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | or return $dbh->set_err(int($!), "Failed to open directory $dir: $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 12 | ▶ | while (defined(my $item = readdir($dh))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 448 | ▶ | if ($^O eq 'VMS') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # if on VMS then avoid warnings from catdir if you use a file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # (not a dir) as the item below | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | next if $item !~ /\.dir$/oi; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 448 | my $file = File::Spec->catdir($dir,$item); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 448 | ▶ | next unless -d $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 92 | my($dev, $ino, $mode, $nlink, $uid) = lstat($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 92 | my $pwnam = undef; # eval { scalar(getpwnam($uid)) } || $uid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 92 | push @list, [ $dir, $pwnam, $item, 'TABLE', undef ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 12 | close($dh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # We would like to simply do a DBI->connect() here. However, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # this is wrong if we are in a subclass like DBI::ProxyServer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 16 | ▶ | $dbh->{'dbd_sponge_dbh'} ||= DBI->connect("DBI:Sponge:", '','') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$dbh->{"dbd_sponge_dbh"} ||= "DBI"->connect("DBI:Sponge:", "", "")
MC/DC0%0/2
$dbh->{"dbd_sponge_dbh"} ||= "DBI"->connect("DBI:Sponge:", "", "")
$dbh->{"dbd_sponge_dbh"}
"DBI"->connect("DBI:Sponge:", "", "")
Truth table66%2/3
A ||= B
A= $dbh->{"dbd_sponge_dbh"}B= "DBI"->connect("DBI:Sponge:", "", "")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | or return $dbh->set_err($DBI::err, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | "Failed to connect to DBI::Sponge: $DBI::errstr"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 16 | my $attr = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 'rows' => \@list, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 'NUM_OF_FIELDS' => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 'NAME' => ['TABLE_CAT', 'TABLE_SCHEM', 'TABLE_NAME', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 'TABLE_TYPE', 'REMARKS'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 'TYPE' => [DBI::SQL_VARCHAR(), DBI::SQL_VARCHAR(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | DBI::SQL_VARCHAR(), DBI::SQL_VARCHAR(), DBI::SQL_VARCHAR() ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 'NULLABLE' => [1, 1, 1, 1, 1] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 16 | my $sdbh = $dbh->{'dbd_sponge_dbh'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 16 | ▶ | my $sth = $sdbh->prepare("SHOW TABLES FROM $dir", $attr) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | or return $dbh->set_err($sdbh->err(), $sdbh->errstr()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 16 | $sth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 12 | ▶ | sub type_info_all { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
type_info_all: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 12 | my ($dbh) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 12 | my $ti = [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | { TYPE_NAME => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | DATA_TYPE => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | COLUMN_SIZE => 2, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | LITERAL_PREFIX => 3, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | LITERAL_SUFFIX => 4, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | CREATE_PARAMS => 5, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | NULLABLE => 6, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | CASE_SENSITIVE => 7, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | SEARCHABLE => 8, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | UNSIGNED_ATTRIBUTE=> 9, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | FIXED_PREC_SCALE=> 10, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | AUTO_UNIQUE_VALUE => 11, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | LOCAL_TYPE_NAME => 12, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | MINIMUM_SCALE => 13, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | MAXIMUM_SCALE => 14, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | [ 'VARCHAR', DBI::SQL_VARCHAR, 1024, "'","'", undef, 0, 1, 1, 0, 0,0,undef,0,0 ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | [ 'INTEGER', DBI::SQL_INTEGER, 10, "","", undef, 0, 0, 1, 0, 0,0,undef,0,0 ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 12 | return $ti; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 3041 | ▶ | sub ping { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ping: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 3041 | ▶ | (shift->FETCH('Active')) ? 2 : 0; # the value 2 is checked for by t/80proxy.t | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 2404 | ▶ | sub disconnect { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disconnect: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 2404 | shift->STORE(Active => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 2404 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 72 | ▶ | sub get_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_info: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 72 | my ($dbh, $info_type) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 72 | return $dbh->{examplep_get_info}->{$info_type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 34438 | ▶ | sub FETCH { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 34438 | my ($dbh, $attrib) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # In reality this would interrogate the database engine to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # either return dynamic values that cannot be precomputed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | # or fetch and cache attribute values too expensive to prefetch. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # else pass up to DBI to handle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 34438 | ▶ | return $INC{"DBD/ExampleP.pm"} if $attrib eq 'example_driver_path'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 32087 | return $dbh->SUPER::FETCH($attrib); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 50719 | ▶ | sub STORE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORE: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 50719 | my ($dbh, $attrib, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # store only known attributes else pass up to DBI to handle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 50719 | ▶ | if ($attrib eq 'examplep_set_err') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # a fake attribute to enable a test case where STORE issues a warning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 4 | $dbh->set_err($value, $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 50715 | ▶ | if ($attrib eq 'AutoCommit') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # convert AutoCommit values to magic ones to let DBI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # know that the driver has 'handled' the AutoCommit attribute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 5350 | ▶ | $value = ($value) ? -901 : -900; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 50715 | ▶ | return $dbh->{$attrib} = $value if $attrib =~ /^examplep_/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 50711 | return $dbh->SUPER::STORE($attrib, $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2402 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 2402 | my $dbh = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 2402 | ▶ | $dbh->disconnect if $dbh->FETCH('Active'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2402 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | # This is an example to demonstrate the use of driver-specific | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | # methods via $dbh->func(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # Use it as follows: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # my @tables = $dbh->func($re, 'examplep_tables'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # Returns all the tables that match the regular expression $re. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 4 | ▶ | sub examplep_tables { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
examplep_tables: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 4 | my $dbh = shift; my $re = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 4 | grep { $_ =~ /$re/ } $dbh->tables(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 166 | ▶ | sub parse_trace_flag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_trace_flag: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 166 | my ($h, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 166 | ▶ | return 0x01000000 if $name eq 'foo'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 152 | ▶ | return 0x02000000 if $name eq 'bar'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 138 | ▶ | return 0x04000000 if $name eq 'baz'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 124 | ▶ | return 0x08000000 if $name eq 'boo'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 110 | ▶ | return 0x10000000 if $name eq 'bop'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 96 | return $h->SUPER::parse_trace_flag($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 2329 | ▶ | sub private_attribute_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
private_attribute_info: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 2329 | return { example_driver_path => undef }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 66 | { package DBD::ExampleP::st; # ====== STATEMENT ====== | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 66 | $imp_data_size = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 66 | ▶ | use strict; no strict 'refs'; # cause problems with filehandles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 3896 | ▶ | sub bind_param { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bind_param: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 3896 | my($sth, $param, $value, $attribs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 3896 | $sth->{'dbd_param'}->[$param-1] = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 3896 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 5375 | ▶ | sub execute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 5375 | my($sth, @dir) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 5375 | my $dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 5375 | ▶ | if (@dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | $sth->bind_param($_, $dir[$_-1]) or return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 1898 | ▶ | foreach (1..@dir); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 5375 | ▶ | my $dbd_param = $sth->{'dbd_param'} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$sth->{'dbd_param'} || []
MC/DC100%1/1
$sth->{'dbd_param'} || []
$sth->{'dbd_param'}
Truth table100%2/2
A
A= $sth->{'dbd_param'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | return $sth->set_err(2, @$dbd_param." values bound when $sth->{NUM_OF_PARAMS} expected") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 5375 | ▶ | unless @$dbd_param == $sth->{NUM_OF_PARAMS}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 5363 | ▶ | return 0 unless $sth->{NUM_OF_FIELDS}; # not a select | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 3900 | ▶ | $dir = $dbd_param->[0] || $sth->{examplep_ex_dir}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$dbd_param->[0] || $sth->{'examplep_ex_dir'}
MC/DC0%0/2
$dbd_param->[0] || $sth->{'examplep_ex_dir'}
$dbd_param->[0]
$sth->{'examplep_ex_dir'}
Truth table66%2/3
A || B
A= $dbd_param->[0]B= $sth->{'examplep_ex_dir'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 3900 | ▶ | return $sth->set_err(2, "No bind parameter supplied") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | unless defined $dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 3900 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | # If the users asks for directory "long_list_4532", then we fake a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | # directory with files "file4351", "file4350", ..., "file0". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # This is a special case used for testing, especially DBD::Proxy. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 3900 | ▶ | if ($dir =~ /^long_list_(\d+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 12 | $sth->{dbd_dir} = [ $1 ]; # array ref indicates special mode | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 12 | $sth->{dbd_datahandle} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 3888 | $sth->{dbd_dir} = $dir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 3888 | my $sym = Symbol::gensym(); # "DBD::ExampleP::".++$DBD::ExampleP::gensym; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 3888 | ▶ | opendir($sym, $dir) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | or return $sth->set_err(2, "opendir($dir): $!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 3876 | $sth->{dbd_datahandle} = $sym; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 3888 | $sth->STORE(Active => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 3888 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 104437 | ▶ | sub fetch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 104437 | my $sth = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 104437 | my $dir = $sth->{dbd_dir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 104437 | my %s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 104437 | ▶ | if (ref $dir) { # special fake-data test mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 1212 | my $num = $dir->[0]--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 1212 | ▶ | unless ($num > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 12 | $sth->finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 1200 | my $time = time; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 1200 | @s{@DBD::ExampleP::statnames} = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | ( 2051, 1000+$num, 0644, 2, $>, $), 0, 1024, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | $time, $time, $time, 512, 2, "file$num") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | else { # normal mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | my $dh = $sth->{dbd_datahandle} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 103225 | ▶ | or return $sth->set_err($DBI::stderr, "fetch without successful execute"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 103068 | my $f = readdir($dh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 103068 | ▶ | unless ($f) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 2023 | $sth->finish; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 2023 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # untaint $f so that we can use this for DBI taint tests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 101045 | ($f) = ($f =~ m/^(.*)$/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 101045 | my $file = File::Spec->catfile($dir, $f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | # put in all the data fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 101045 | @s{ @DBD::ExampleP::statnames } = (lstat($file), $f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | # return just what fields the query asks for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 102245 | my @new = @s{ @{$sth->{NAME}} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 102245 | return $sth->_set_fbav(\@new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 66 | *fetchrow_arrayref = \&fetch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 9879 | ▶ | sub finish { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finish: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 9879 | my $sth = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 9879 | ▶ | closedir($sth->{dbd_datahandle}) if $sth->{dbd_datahandle}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 9879 | $sth->{dbd_datahandle} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 9879 | $sth->{dbd_dir} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 9879 | $sth->SUPER::finish(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 9879 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 8633 | ▶ | sub FETCH { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 8633 | my ($sth, $attrib) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | # In reality this would interrogate the database engine to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | # either return dynamic values that cannot be precomputed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | # or fetch and cache attribute values too expensive to prefetch. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 8633 | ▶ | if ($attrib eq 'TYPE'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 2103 | return [ @DBD::ExampleP::stattypes{ @{ $sth->FETCH(q{NAME_lc}) } } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | elsif ($attrib eq 'PRECISION'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 2103 | return [ @DBD::ExampleP::statprec{ @{ $sth->FETCH(q{NAME_lc}) } } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | elsif ($attrib eq 'ParamValues') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 14 | ▶ | my $dbd_param = $sth->{dbd_param} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$sth->{'dbd_param'} || []
MC/DC0%0/1
$sth->{'dbd_param'} || []
$sth->{'dbd_param'}
Truth table50%1/2
A
A= $sth->{'dbd_param'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 14 | my %pv = map { $_ => $dbd_param->[$_-1] } 1..@$dbd_param; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 14 | return \%pv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | # else pass up to DBI to handle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 4413 | return $sth->SUPER::FETCH($attrib); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 28168 | ▶ | sub STORE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORE: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 28168 | my ($sth, $attrib, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | # would normally validate and only store known attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | # else pass up to DBI to handle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 28168 | ▶ | return $sth->{$attrib} = $value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition88%8/9
$attrib eq "NAME" or $attrib eq "NULLABLE" or $attrib eq "SCALE" or $attrib eq "PRECISION"
$attrib eq "NAME" or $attrib eq "NULLABLE" or $attrib eq "SCALE"
$attrib eq "NAME" or $attrib eq "NULLABLE"
MC/DC75%3/4
$attrib eq "NAME" or $attrib eq "NULLABLE" or $attrib eq "SCALE" or $attrib eq "PRECISION"
$attrib eq "NAME"
$attrib eq "NULLABLE"
$attrib eq "SCALE"
$attrib eq "PRECISION"
Truth table80%4/5
A or B or C or D
A= $attrib eq "NAME"B= $attrib eq "NULLABLE"C= $attrib eq "SCALE"D= $attrib eq "PRECISION"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | if $attrib eq 'NAME' or $attrib eq 'NULLABLE' or $attrib eq 'SCALE' or $attrib eq 'PRECISION'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 15371 | return $sth->SUPER::STORE($attrib, $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 66 | *parse_trace_flag = \&DBD::ExampleP::db::parse_trace_flag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 66 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # vim: sw=4:ts=8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||