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