| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
{ |
|
2
|
|
|
|
|
|
|
package DBD::NullP; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
require DBI; |
|
5
|
|
|
|
|
|
|
require Carp; |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
@EXPORT = qw(); # Do NOT @EXPORT anything. |
|
8
|
|
|
|
|
|
|
$VERSION = "12.014715"; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# $Id: NullP.pm 14714 2011-02-22 17:27:07Z Tim $ |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# Copyright (c) 1994-2007 Tim Bunce |
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public |
|
15
|
|
|
|
|
|
|
# License or the Artistic License, as specified in the Perl README file. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$drh = undef; # holds driver handle once initialised |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub driver{ |
|
20
|
6
|
50
|
|
6
|
0
|
17
|
return $drh if $drh; |
|
21
|
6
|
|
|
|
|
11
|
my($class, $attr) = @_; |
|
22
|
6
|
|
|
|
|
9
|
$class .= "::dr"; |
|
23
|
6
|
|
|
|
|
38
|
($drh) = DBI::_new_drh($class, { |
|
24
|
|
|
|
|
|
|
'Name' => 'NullP', |
|
25
|
|
|
|
|
|
|
'Version' => $VERSION, |
|
26
|
|
|
|
|
|
|
'Attribution' => 'DBD Example Null Perl stub by Tim Bunce', |
|
27
|
|
|
|
|
|
|
}, [ qw'example implementors private data']); |
|
28
|
6
|
|
|
|
|
22
|
$drh; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub CLONE { |
|
32
|
0
|
|
|
0
|
|
0
|
undef $drh; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
{ package DBD::NullP::dr; # ====== DRIVER ====== |
|
38
|
|
|
|
|
|
|
$imp_data_size = 0; |
|
39
|
6
|
|
|
6
|
|
30
|
use strict; |
|
|
6
|
|
|
|
|
26
|
|
|
|
6
|
|
|
|
|
639
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub connect { # normally overridden, but a handy default |
|
42
|
12
|
50
|
|
12
|
|
130
|
my $dbh = shift->SUPER::connect(@_) |
|
43
|
|
|
|
|
|
|
or return; |
|
44
|
12
|
|
|
|
|
56
|
$dbh->STORE(Active => 1); |
|
45
|
12
|
|
|
|
|
59
|
$dbh; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
0
|
|
0
|
sub DESTROY { undef } |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
{ package DBD::NullP::db; # ====== DATABASE ====== |
|
54
|
|
|
|
|
|
|
$imp_data_size = 0; |
|
55
|
6
|
|
|
6
|
|
25
|
use strict; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
155
|
|
|
56
|
6
|
|
|
6
|
|
24
|
use Carp qw(croak); |
|
|
6
|
|
|
|
|
9
|
|
|
|
6
|
|
|
|
|
1423
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub prepare { |
|
59
|
9
|
|
|
9
|
|
668
|
my ($dbh, $statement)= @_; |
|
60
|
|
|
|
|
|
|
|
|
61
|
9
|
|
|
|
|
41
|
my ($outer, $sth) = DBI::_new_sth($dbh, { |
|
62
|
|
|
|
|
|
|
'Statement' => $statement, |
|
63
|
|
|
|
|
|
|
}); |
|
64
|
|
|
|
|
|
|
|
|
65
|
9
|
|
|
|
|
39
|
return $outer; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub FETCH { |
|
69
|
43
|
|
|
43
|
|
122
|
my ($dbh, $attrib) = @_; |
|
70
|
|
|
|
|
|
|
# In reality this would interrogate the database engine to |
|
71
|
|
|
|
|
|
|
# either return dynamic values that cannot be precomputed |
|
72
|
|
|
|
|
|
|
# or fetch and cache attribute values too expensive to prefetch. |
|
73
|
43
|
|
|
|
|
187
|
return $dbh->SUPER::FETCH($attrib); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub STORE { |
|
77
|
99
|
|
|
99
|
|
326
|
my ($dbh, $attrib, $value) = @_; |
|
78
|
|
|
|
|
|
|
# would normally validate and only store known attributes |
|
79
|
|
|
|
|
|
|
# else pass up to DBI to handle |
|
80
|
99
|
100
|
|
|
|
207
|
if ($attrib eq 'AutoCommit') { |
|
|
|
50
|
|
|
|
|
|
|
81
|
13
|
50
|
|
|
|
43
|
Carp::croak("Can't disable AutoCommit") unless $value; |
|
82
|
|
|
|
|
|
|
# convert AutoCommit values to magic ones to let DBI |
|
83
|
|
|
|
|
|
|
# know that the driver has 'handled' the AutoCommit attribute |
|
84
|
13
|
50
|
|
|
|
39
|
$value = ($value) ? -901 : -900; |
|
85
|
|
|
|
|
|
|
} elsif ($attrib eq 'nullp_set_err') { |
|
86
|
|
|
|
|
|
|
# a fake attribute to produce a test case where STORE issues a warning |
|
87
|
0
|
|
|
|
|
0
|
$dbh->set_err($value, $value); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
99
|
|
|
|
|
646
|
return $dbh->SUPER::STORE($attrib, $value); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
3
|
|
|
3
|
|
23
|
sub ping { 1 } |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub disconnect { |
|
95
|
4
|
|
|
4
|
|
965
|
shift->STORE(Active => 0); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
{ package DBD::NullP::st; # ====== STATEMENT ====== |
|
102
|
|
|
|
|
|
|
$imp_data_size = 0; |
|
103
|
6
|
|
|
6
|
|
33
|
use strict; |
|
|
6
|
|
|
|
|
7
|
|
|
|
6
|
|
|
|
|
2807
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub bind_param { |
|
106
|
6000
|
|
|
6000
|
|
5703
|
my ($sth, $param, $value, $attr) = @_; |
|
107
|
6000
|
|
|
|
|
10105
|
$sth->{ParamValues}{$param} = $value; |
|
108
|
6000
|
50
|
|
|
|
7796
|
$sth->{ParamAttr}{$param} = $attr |
|
109
|
|
|
|
|
|
|
if defined $attr; # attr is sticky if not explicitly set |
|
110
|
6000
|
|
|
|
|
12860
|
return 1; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub execute { |
|
114
|
2
|
|
|
2
|
|
144
|
my $sth = shift; |
|
115
|
2
|
|
|
|
|
13
|
$sth->bind_param($_, $_[$_-1]) for (1..@_); |
|
116
|
2
|
50
|
|
|
|
19
|
if ($sth->{Statement} =~ m/^ \s* SELECT \s+/xmsi) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
117
|
2
|
|
|
|
|
17
|
$sth->STORE(NUM_OF_FIELDS => 1); |
|
118
|
2
|
|
|
|
|
7
|
$sth->{NAME} = [ "fieldname" ]; |
|
119
|
|
|
|
|
|
|
# just for the sake of returning something, we return the params |
|
120
|
2
|
|
50
|
|
|
10
|
my $params = $sth->{ParamValues} || {}; |
|
121
|
2
|
|
|
|
|
3442
|
$sth->{dbd_nullp_data} = [ @{$params}{ sort keys %$params } ]; |
|
|
2
|
|
|
|
|
1248
|
|
|
122
|
2
|
|
|
|
|
186
|
$sth->STORE(Active => 1); |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
# force a sleep - handy for testing |
|
125
|
|
|
|
|
|
|
elsif ($sth->{Statement} =~ m/^ \s* SLEEP \s+ (\S+) /xmsi) { |
|
126
|
0
|
|
|
|
|
0
|
my $secs = $1; |
|
127
|
0
|
0
|
|
|
|
0
|
if (eval { require Time::HiRes; defined &Time::HiRes::sleep }) { |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
128
|
0
|
|
|
|
|
0
|
Time::HiRes::sleep($secs); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
else { |
|
131
|
0
|
|
|
|
|
0
|
sleep $secs; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
# force an error - handy for testing |
|
135
|
|
|
|
|
|
|
elsif ($sth->{Statement} =~ m/^ \s* ERROR \s+ (\d+) \s* (.*) /xmsi) { |
|
136
|
0
|
|
|
|
|
0
|
return $sth->set_err($1, $2); |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
# anything else is silently ignored, successfully |
|
139
|
2
|
|
|
|
|
11
|
1; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub fetchrow_arrayref { |
|
143
|
1
|
|
|
1
|
|
3
|
my $sth = shift; |
|
144
|
1
|
|
|
|
|
3
|
my $data = $sth->{dbd_nullp_data}; |
|
145
|
1
|
50
|
33
|
|
|
8
|
if (!$data || !@$data) { |
|
146
|
0
|
|
|
|
|
0
|
$sth->finish; # no more data so finish |
|
147
|
0
|
|
|
|
|
0
|
return undef; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
1
|
|
|
|
|
45
|
return $sth->_set_fbav(shift @$data); |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
*fetch = \&fetchrow_arrayref; # alias |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub FETCH { |
|
154
|
69
|
|
|
69
|
|
1345
|
my ($sth, $attrib) = @_; |
|
155
|
|
|
|
|
|
|
# would normally validate and only fetch known attributes |
|
156
|
|
|
|
|
|
|
# else pass up to DBI to handle |
|
157
|
69
|
|
|
|
|
307
|
return $sth->SUPER::FETCH($attrib); |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub STORE { |
|
161
|
5
|
|
|
5
|
|
10
|
my ($sth, $attrib, $value) = @_; |
|
162
|
|
|
|
|
|
|
# would normally validate and only store known attributes |
|
163
|
|
|
|
|
|
|
# else pass up to DBI to handle |
|
164
|
5
|
|
|
|
|
74
|
return $sth->SUPER::STORE($attrib, $value); |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
1; |