line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBD::mysqlPPrawSjis; |
2
|
1
|
|
|
1
|
|
15583
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use DBI; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
5
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
44
|
|
6
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION $err $errstr $state $drh); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
438
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$VERSION = '0.13'; |
9
|
|
|
|
|
|
|
$VERSION = $VERSION; |
10
|
|
|
|
|
|
|
$err = 0; |
11
|
|
|
|
|
|
|
$errstr = ''; |
12
|
|
|
|
|
|
|
$state = undef; |
13
|
|
|
|
|
|
|
$drh = undef; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub driver |
17
|
|
|
|
|
|
|
{ |
18
|
0
|
0
|
|
0
|
0
|
|
return $drh if $drh; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $class = shift; |
21
|
0
|
|
|
|
|
|
my $attr = shift; |
22
|
0
|
|
|
|
|
|
$class .= '::dr'; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
$drh = DBI::_new_drh($class, { |
25
|
|
|
|
|
|
|
Name => 'mysqlPPrawSjis', |
26
|
|
|
|
|
|
|
Version => $VERSION, |
27
|
|
|
|
|
|
|
Err => \$DBD::mysqlPPrawSjis::err, |
28
|
|
|
|
|
|
|
Errstr => \$DBD::mysqlPPrawSjis::errstr, |
29
|
|
|
|
|
|
|
State => \$DBD::mysqlPPrawSjis::state, |
30
|
|
|
|
|
|
|
Attribution => 'DBD::mysqlPPrawSjis by Hiroyuki OYAMA and ShiftJIS support by INABA Hitoshi', |
31
|
|
|
|
|
|
|
}, {}); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _parse_dsn |
36
|
|
|
|
|
|
|
{ |
37
|
0
|
|
|
0
|
|
|
my $class = shift; |
38
|
0
|
|
|
|
|
|
my ($dsn, $args) = @_; |
39
|
0
|
|
|
|
|
|
my($hash, $var, $val); |
40
|
0
|
0
|
|
|
|
|
return if ! defined $dsn; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
while (length $dsn) { |
43
|
0
|
0
|
|
|
|
|
if ($dsn =~ /([^:;]*)[:;](.*)/) { |
44
|
0
|
|
|
|
|
|
$val = $1; |
45
|
0
|
|
|
|
|
|
$dsn = $2; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
else { |
48
|
0
|
|
|
|
|
|
$val = $dsn; |
49
|
0
|
|
|
|
|
|
$dsn = ''; |
50
|
|
|
|
|
|
|
} |
51
|
0
|
0
|
|
|
|
|
if ($val =~ /([^=]*)=(.*)/) { |
52
|
0
|
|
|
|
|
|
$var = $1; |
53
|
0
|
|
|
|
|
|
$val = $2; |
54
|
0
|
0
|
0
|
|
|
|
if ($var eq 'hostname' || $var eq 'host') { |
|
|
0
|
0
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$hash->{'host'} = $val; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
elsif ($var eq 'db' || $var eq 'dbname') { |
58
|
0
|
|
|
|
|
|
$hash->{'database'} = $val; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
else { |
61
|
0
|
|
|
|
|
|
$hash->{$var} = $val; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
else { |
65
|
0
|
|
|
|
|
|
for $var (@$args) { |
66
|
0
|
0
|
|
|
|
|
if (!defined($hash->{$var})) { |
67
|
0
|
|
|
|
|
|
$hash->{$var} = $val; |
68
|
0
|
|
|
|
|
|
last; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# DBD::mysqlPPrawSjis (1 of 5) |
75
|
0
|
0
|
|
|
|
|
$hash->{'host'} = '127.0.0.1' unless defined $hash->{'host'}; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return $hash; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _parse_dsn_host |
82
|
|
|
|
|
|
|
{ |
83
|
0
|
|
|
0
|
|
|
my($class, $dsn) = @_; |
84
|
0
|
|
|
|
|
|
my $hash = $class->_parse_dsn($dsn, ['host', 'port']); |
85
|
0
|
|
|
|
|
|
($hash->{'host'}, $hash->{'port'}); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
package DBD::mysqlPPrawSjis::dr; |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
1
|
|
7
|
use vars qw($imp_data_size); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
43
|
|
93
|
|
|
|
|
|
|
$DBD::mysqlPPrawSjis::dr::imp_data_size = 0; |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
1
|
|
431
|
use Net::MySQL; |
|
1
|
|
|
|
|
22464
|
|
|
1
|
|
|
|
|
29
|
|
96
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
816
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub connect |
100
|
|
|
|
|
|
|
{ |
101
|
0
|
|
|
0
|
|
|
my $drh = shift; |
102
|
0
|
|
|
|
|
|
my ($dsn, $user, $password, $attrhash) = @_; |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
my $data_source_info = DBD::mysqlPPrawSjis->_parse_dsn( |
105
|
|
|
|
|
|
|
$dsn, ['database', 'host', 'port'], |
106
|
|
|
|
|
|
|
); |
107
|
0
|
|
0
|
|
|
|
$user ||= ''; |
108
|
0
|
|
0
|
|
|
|
$password ||= ''; |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
my $dbh = DBI::_new_dbh($drh, { |
111
|
|
|
|
|
|
|
Name => $dsn, |
112
|
|
|
|
|
|
|
USER => $user, |
113
|
|
|
|
|
|
|
CURRENT_USRE => $user, |
114
|
|
|
|
|
|
|
}, {}); |
115
|
0
|
|
|
|
|
|
eval { |
116
|
|
|
|
|
|
|
my $mysql = Net::MySQL->new( |
117
|
|
|
|
|
|
|
hostname => $data_source_info->{host}, |
118
|
|
|
|
|
|
|
port => $data_source_info->{port}, |
119
|
|
|
|
|
|
|
database => $data_source_info->{database}, |
120
|
|
|
|
|
|
|
user => $user, |
121
|
|
|
|
|
|
|
password => $password, |
122
|
|
|
|
|
|
|
debug => $attrhash->{protocol_dump}, |
123
|
0
|
|
|
|
|
|
); |
124
|
0
|
|
|
|
|
|
$dbh->STORE(mysqlpprawsjis_connection => $mysql); |
125
|
0
|
|
|
|
|
|
$dbh->STORE(thread_id => $mysql->{server_thread_id}); |
126
|
|
|
|
|
|
|
}; |
127
|
0
|
0
|
|
|
|
|
if ($@) { |
128
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, $@); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# DBD::mysqlPPrawSjis (2 of 5) |
132
|
0
|
|
|
|
|
|
return $dbh; |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
my $sth = $dbh->prepare(q{SHOW VARIABLES LIKE 'character\\_set\\_%'}); |
135
|
0
|
|
|
|
|
|
$sth->execute(); |
136
|
0
|
|
|
|
|
|
my %character_set = (); |
137
|
0
|
|
|
|
|
|
while(my($variable_name,$value) = $sth->fetchrow_array()){ |
138
|
0
|
|
|
|
|
|
$character_set{$variable_name} = $value; |
139
|
|
|
|
|
|
|
} |
140
|
0
|
0
|
0
|
|
|
|
if (($character_set{'character_set_server'} eq 'cp932') and |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
141
|
|
|
|
|
|
|
($character_set{'character_set_database'} eq 'cp932') and |
142
|
|
|
|
|
|
|
($character_set{'character_set_client'} eq 'cp932') |
143
|
|
|
|
|
|
|
) { |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
elsif (($character_set{'character_set_server'} eq 'sjis') and |
146
|
|
|
|
|
|
|
($character_set{'character_set_database'} eq 'sjis') and |
147
|
|
|
|
|
|
|
($character_set{'character_set_client'} eq 'sjis') |
148
|
|
|
|
|
|
|
) { |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
elsif ($character_set{'character_set_server'} ne 'cp932') { |
151
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Variable 'character_set_server' is not 'cp932').\n"); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
elsif ($character_set{'character_set_database'} ne 'cp932') { |
154
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Variable 'character_set_database' is not 'cp932').\n"); |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
elsif ($character_set{'character_set_client'} ne 'cp932') { |
157
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Variable 'character_set_client' is not 'cp932').\n"); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
eval { |
161
|
0
|
|
|
|
|
|
$dbh->do(q{DROP TABLE test_character_set}); |
162
|
|
|
|
|
|
|
}; |
163
|
0
|
|
|
|
|
|
$dbh->do(q{CREATE TABLE test_character_set (id INT, c_cp932 TEXT)}); |
164
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 1, 'ab'); # |
165
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 2, '\\'); # 0x5C |
166
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 3, "\xB6\xC5"); # |
167
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 4, "\x83\x4A\x83\x69"); # |
168
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 5, "\x81\x60\x81\x61"); # |
169
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 6, "\x87\x40\x87\x62"); # |
170
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 7, "\xFA\x42\xFB\xFC"); # |
171
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 8, "\xF8\x9F"); # 0xF89F |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 9, "\x00"); # NUL |
174
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 10, "\x0A"); # LF |
175
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 11, "\x0D"); # CR |
176
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 12, "\x1A"); # Ctrl+Z |
177
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 13, "\x5C"); # \ |
178
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 14, "\x27"); # ' |
179
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 15, "\x22"); # " |
180
|
0
|
|
|
|
|
|
$dbh->do(q{INSERT INTO test_character_set (id,c_cp932) VALUES (?,?)}, {}, 16, "\x83\x5C"); # |
181
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
my $sth2 = $dbh->prepare(q{SELECT id, c_cp932 FROM test_character_set}); |
183
|
0
|
|
|
|
|
|
$sth2->execute(); |
184
|
0
|
|
|
|
|
|
my %c_cp932 = (); |
185
|
0
|
|
|
|
|
|
while(my($id,$c_cp932) = $sth2->fetchrow_array()){ |
186
|
0
|
|
|
|
|
|
$c_cp932{$id} = $c_cp932; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
0
|
0
|
|
|
|
|
if ($c_cp932{1} ne "\x61\x62") { |
190
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('61','62') can't select such as).\n"); |
191
|
|
|
|
|
|
|
} |
192
|
0
|
0
|
|
|
|
|
if ($c_cp932{2} ne "\x5C") { |
193
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('5C') can't select such as).\n"); |
194
|
|
|
|
|
|
|
} |
195
|
0
|
0
|
|
|
|
|
if ($c_cp932{3} ne "\xB6\xC5") { |
196
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('B6','C5') can't select such as).\n"); |
197
|
|
|
|
|
|
|
} |
198
|
0
|
0
|
|
|
|
|
if ($c_cp932{4} ne "\x83\x4A\x83\x69") { |
199
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('834A','8369') can't select such as).\n"); |
200
|
|
|
|
|
|
|
} |
201
|
0
|
0
|
|
|
|
|
if ($c_cp932{5} ne "\x81\x60\x81\x61") { |
202
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('8160','8161') can't select such as).\n"); |
203
|
|
|
|
|
|
|
} |
204
|
0
|
0
|
|
|
|
|
if ($c_cp932{6} ne "\x87\x40\x87\x62") { |
205
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('8740','8762') can't select such as).\n"); |
206
|
|
|
|
|
|
|
} |
207
|
0
|
0
|
|
|
|
|
if ($c_cp932{7} ne "\xFA\x42\xFB\xFC") { |
208
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('FA42','FBFC') can't select such as).\n"); |
209
|
|
|
|
|
|
|
} |
210
|
0
|
0
|
|
|
|
|
if ($c_cp932{8} ne "\xF8\x9F") { |
211
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('F89F') can't select such as).\n"); |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
0
|
0
|
|
|
|
|
if ($c_cp932{9} ne "\x00") { |
215
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('00') can't select such as).\n"); |
216
|
|
|
|
|
|
|
} |
217
|
0
|
0
|
|
|
|
|
if ($c_cp932{10} ne "\x0A") { |
218
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('0A') can't select such as).\n"); |
219
|
|
|
|
|
|
|
} |
220
|
0
|
0
|
|
|
|
|
if ($c_cp932{11} ne "\x0D") { |
221
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('0D') can't select such as).\n"); |
222
|
|
|
|
|
|
|
} |
223
|
0
|
0
|
|
|
|
|
if ($c_cp932{12} ne "\x1A") { |
224
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('1A') can't select such as).\n"); |
225
|
|
|
|
|
|
|
} |
226
|
0
|
0
|
|
|
|
|
if ($c_cp932{13} ne "\x5C") { |
227
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('5C') can't select such as).\n"); |
228
|
|
|
|
|
|
|
} |
229
|
0
|
0
|
|
|
|
|
if ($c_cp932{14} ne "\x27") { |
230
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('27') can't select such as).\n"); |
231
|
|
|
|
|
|
|
} |
232
|
0
|
0
|
|
|
|
|
if ($c_cp932{15} ne "\x22") { |
233
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('22') can't select such as).\n"); |
234
|
|
|
|
|
|
|
} |
235
|
0
|
0
|
|
|
|
|
if ($c_cp932{16} ne "\x83\x5C") { |
236
|
0
|
|
|
|
|
|
return $dbh->DBI::set_err(1, "Can't handle cp932(Inserted HEX('835C') can't select such as).\n"); |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
0
|
|
|
|
|
|
return $dbh; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
sub data_sources |
244
|
|
|
|
|
|
|
{ |
245
|
0
|
|
|
0
|
|
|
return ("dbi:mysqlPPrawSjis:"); |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
|
249
|
|
|
|
0
|
|
|
sub disconnect_all {} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
package DBD::mysqlPPrawSjis::db; |
254
|
|
|
|
|
|
|
|
255
|
1
|
|
|
1
|
|
13
|
use vars qw($imp_data_size); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
256
|
|
|
|
|
|
|
$DBD::mysqlPPrawSjis::db::imp_data_size = 0; |
257
|
1
|
|
|
1
|
|
11
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1071
|
|
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
# Patterns referred to 'mysql_sub_escape_string()' of libmysql.c |
261
|
|
|
|
|
|
|
sub quote |
262
|
|
|
|
|
|
|
{ |
263
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
264
|
0
|
|
|
|
|
|
my ($statement, $type) = @_; |
265
|
0
|
0
|
|
|
|
|
return 'NULL' unless defined $statement; |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
# DBD::mysqlPPrawSjis (3 of 5) |
268
|
0
|
|
|
|
|
|
if (1) { |
269
|
0
|
|
|
|
|
|
my @statement = (); |
270
|
0
|
|
|
|
|
|
while ($statement =~ /\G ( [\x81-\x9F\xE0-\xFC][\x00-\xFF] | [\x00-\xFF] )/gsx) { |
271
|
|
|
|
|
|
|
push @statement, |
272
|
|
|
|
|
|
|
{ |
273
|
|
|
|
|
|
|
# ref. mysql_real_escape_string() |
274
|
|
|
|
|
|
|
qq(\\) => q(\\\\), |
275
|
|
|
|
|
|
|
qq(\0) => q(\\0), |
276
|
|
|
|
|
|
|
qq(\n) => q(\\n), |
277
|
|
|
|
|
|
|
qq(\r) => q(\\r), |
278
|
|
|
|
|
|
|
qq(') => q(\\'), |
279
|
|
|
|
|
|
|
qq(") => q(\\"), |
280
|
|
|
|
|
|
|
qq(\x1A) => q(\\Z), |
281
|
0
|
|
0
|
|
|
|
}->{$1} || $1; |
282
|
|
|
|
|
|
|
} |
283
|
0
|
|
|
|
|
|
$statement = join '', @statement; |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
else { |
286
|
|
|
|
|
|
|
for ($statement) { |
287
|
|
|
|
|
|
|
s/\\/\\\\/g; |
288
|
|
|
|
|
|
|
s/\0/\\0/g; |
289
|
|
|
|
|
|
|
s/\n/\\n/g; |
290
|
|
|
|
|
|
|
s/\r/\\r/g; |
291
|
|
|
|
|
|
|
s/'/\\'/g; |
292
|
|
|
|
|
|
|
s/"/\\"/g; |
293
|
|
|
|
|
|
|
s/\x1a/\\Z/g; |
294
|
|
|
|
|
|
|
} |
295
|
|
|
|
|
|
|
} |
296
|
0
|
|
|
|
|
|
return "'$statement'"; |
297
|
|
|
|
|
|
|
} |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
sub _count_param |
301
|
|
|
|
|
|
|
{ |
302
|
|
|
|
|
|
|
# DBD::mysqlPPrawSjis (4 of 5) |
303
|
0
|
|
|
0
|
|
|
if (1) { |
304
|
0
|
|
|
|
|
|
my $statement = shift; |
305
|
0
|
|
|
|
|
|
my $num = 0; |
306
|
|
|
|
|
|
|
|
307
|
0
|
|
|
|
|
|
while ($statement =~ /\G ( |
308
|
|
|
|
|
|
|
' (?: '' | \\' | [\x81-\x9F\xE0-\xFC][\x00-\xFF] | [^\x81-\x9F\xE0-\xFC'] )*? ' | |
309
|
|
|
|
|
|
|
" (?: "" | \\" | [\x81-\x9F\xE0-\xFC][\x00-\xFF] | [^\x81-\x9F\xE0-\xFC"] )*? " | |
310
|
|
|
|
|
|
|
(?: [\x81-\x9F\xE0-\xFC][\x00-\xFF] | [\x00-\xFF] ) |
311
|
|
|
|
|
|
|
)/gsx) { |
312
|
0
|
0
|
|
|
|
|
$num++ if $1 eq '?'; |
313
|
|
|
|
|
|
|
} |
314
|
0
|
|
|
|
|
|
return $num; |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
else { |
317
|
|
|
|
|
|
|
my @statement = split //, shift; |
318
|
|
|
|
|
|
|
my $num = 0; |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
while (defined(my $c = shift @statement)) { |
321
|
|
|
|
|
|
|
if ($c eq '"' || $c eq "'") { |
322
|
|
|
|
|
|
|
my $end = $c; |
323
|
|
|
|
|
|
|
while (defined(my $c = shift @statement)) { |
324
|
|
|
|
|
|
|
last if $c eq $end; |
325
|
|
|
|
|
|
|
@statement = splice @statement, 2 if $c eq '\\'; |
326
|
|
|
|
|
|
|
} |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
elsif ($c eq '?') { |
329
|
|
|
|
|
|
|
$num++; |
330
|
|
|
|
|
|
|
} |
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
return $num; |
333
|
|
|
|
|
|
|
} |
334
|
|
|
|
|
|
|
} |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
sub prepare |
338
|
|
|
|
|
|
|
{ |
339
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
340
|
0
|
|
|
|
|
|
my ($statement, @attribs) = @_; |
341
|
|
|
|
|
|
|
|
342
|
0
|
|
|
|
|
|
my $sth = DBI::_new_sth($dbh, { |
343
|
|
|
|
|
|
|
Statement => $statement, |
344
|
|
|
|
|
|
|
}); |
345
|
0
|
|
|
|
|
|
$sth->STORE(mysqlpprawsjis_handle => $dbh->FETCH('mysqlpprawsjis_connection')); |
346
|
0
|
|
|
|
|
|
$sth->STORE(mysqlpprawsjis_params => []); |
347
|
0
|
|
|
|
|
|
$sth->STORE(NUM_OF_PARAMS => _count_param($statement)); |
348
|
0
|
|
|
|
|
|
$sth; |
349
|
|
|
|
|
|
|
} |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
sub commit |
353
|
|
|
|
|
|
|
{ |
354
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
355
|
0
|
0
|
|
|
|
|
if ($dbh->FETCH('Warn')) { |
356
|
0
|
|
|
|
|
|
warn 'Commit ineffective while AutoCommit is on'; |
357
|
|
|
|
|
|
|
} |
358
|
0
|
|
|
|
|
|
1; |
359
|
|
|
|
|
|
|
} |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
sub rollback |
363
|
|
|
|
|
|
|
{ |
364
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
365
|
0
|
0
|
|
|
|
|
if ($dbh->FETCH('Warn')) { |
366
|
0
|
|
|
|
|
|
warn 'Rollback ineffective while AutoCommit is on'; |
367
|
|
|
|
|
|
|
} |
368
|
0
|
|
|
|
|
|
1; |
369
|
|
|
|
|
|
|
} |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
sub tables |
373
|
|
|
|
|
|
|
{ |
374
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
375
|
0
|
|
|
|
|
|
my @args = @_; |
376
|
0
|
|
|
|
|
|
my $mysql = $dbh->FETCH('mysqlpprawsjis_connection'); |
377
|
|
|
|
|
|
|
|
378
|
0
|
|
|
|
|
|
my @database_list; |
379
|
0
|
|
|
|
|
|
eval { |
380
|
0
|
|
|
|
|
|
$mysql->query('show tables'); |
381
|
0
|
0
|
|
|
|
|
die $mysql->get_error_message if $mysql->is_error; |
382
|
0
|
0
|
|
|
|
|
if ($mysql->has_selected_record) { |
383
|
0
|
|
|
|
|
|
my $record = $mysql->create_record_iterator; |
384
|
0
|
|
|
|
|
|
while (my $db_name = $record->each) { |
385
|
0
|
|
|
|
|
|
push @database_list, $db_name->[0]; |
386
|
|
|
|
|
|
|
} |
387
|
|
|
|
|
|
|
} |
388
|
|
|
|
|
|
|
}; |
389
|
0
|
0
|
|
|
|
|
if ($@) { |
390
|
0
|
|
|
|
|
|
warn $mysql->get_error_message; |
391
|
|
|
|
|
|
|
} |
392
|
0
|
0
|
|
|
|
|
return $mysql->is_error |
393
|
|
|
|
|
|
|
? undef |
394
|
|
|
|
|
|
|
: @database_list; |
395
|
|
|
|
|
|
|
} |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
sub _ListDBs |
399
|
|
|
|
|
|
|
{ |
400
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
401
|
0
|
|
|
|
|
|
my @args = @_; |
402
|
0
|
|
|
|
|
|
my $mysql = $dbh->FETCH('mysqlpprawsjis_connection'); |
403
|
|
|
|
|
|
|
|
404
|
0
|
|
|
|
|
|
my @database_list; |
405
|
0
|
|
|
|
|
|
eval { |
406
|
0
|
|
|
|
|
|
$mysql->query('show databases'); |
407
|
0
|
0
|
|
|
|
|
die $mysql->get_error_message if $mysql->is_error; |
408
|
0
|
0
|
|
|
|
|
if ($mysql->has_selected_record) { |
409
|
0
|
|
|
|
|
|
my $record = $mysql->create_record_iterator; |
410
|
0
|
|
|
|
|
|
while (my $db_name = $record->each) { |
411
|
0
|
|
|
|
|
|
push @database_list, $db_name->[0]; |
412
|
|
|
|
|
|
|
} |
413
|
|
|
|
|
|
|
} |
414
|
|
|
|
|
|
|
}; |
415
|
0
|
0
|
|
|
|
|
if ($@) { |
416
|
0
|
|
|
|
|
|
warn $mysql->get_error_message; |
417
|
|
|
|
|
|
|
} |
418
|
0
|
0
|
|
|
|
|
return $mysql->is_error |
419
|
|
|
|
|
|
|
? undef |
420
|
|
|
|
|
|
|
: @database_list; |
421
|
|
|
|
|
|
|
} |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
sub _ListTables |
425
|
|
|
|
|
|
|
{ |
426
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
427
|
0
|
|
|
|
|
|
return $dbh->tables; |
428
|
|
|
|
|
|
|
} |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
sub disconnect |
432
|
|
|
|
|
|
|
{ |
433
|
0
|
|
|
0
|
|
|
return 1; |
434
|
|
|
|
|
|
|
} |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
sub FETCH |
438
|
|
|
|
|
|
|
{ |
439
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
440
|
0
|
|
|
|
|
|
my $key = shift; |
441
|
|
|
|
|
|
|
|
442
|
0
|
0
|
|
|
|
|
return 1 if $key eq 'AutoCommit'; |
443
|
0
|
0
|
|
|
|
|
return $dbh->{$key} if $key =~ /^(?:mysqlpprawsjis_.*|thread_id|mysql_insertid)$/; |
444
|
0
|
|
|
|
|
|
return $dbh->SUPER::FETCH($key); |
445
|
|
|
|
|
|
|
} |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
sub STORE |
449
|
|
|
|
|
|
|
{ |
450
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
451
|
0
|
|
|
|
|
|
my ($key, $value) = @_; |
452
|
|
|
|
|
|
|
|
453
|
0
|
0
|
|
|
|
|
if ($key eq 'AutoCommit') { |
|
|
0
|
|
|
|
|
|
454
|
0
|
0
|
|
|
|
|
die "Can't disable AutoCommit" unless $value; |
455
|
0
|
|
|
|
|
|
return 1; |
456
|
|
|
|
|
|
|
} |
457
|
|
|
|
|
|
|
elsif ($key =~ /^(?:mysqlpprawsjis_.*|thread_id|mysql_insertid)$/) { |
458
|
0
|
|
|
|
|
|
$dbh->{$key} = $value; |
459
|
0
|
|
|
|
|
|
return 1; |
460
|
|
|
|
|
|
|
} |
461
|
0
|
|
|
|
|
|
return $dbh->SUPER::STORE($key, $value); |
462
|
|
|
|
|
|
|
} |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
sub DESTROY |
466
|
|
|
|
|
|
|
{ |
467
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
468
|
0
|
|
|
|
|
|
my $mysql = $dbh->FETCH('mysqlpprawsjis_connection'); |
469
|
0
|
|
|
|
|
|
$mysql->close; |
470
|
|
|
|
|
|
|
} |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
package DBD::mysqlPPrawSjis::st; |
474
|
|
|
|
|
|
|
|
475
|
1
|
|
|
1
|
|
6
|
use vars qw($imp_data_size); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
476
|
|
|
|
|
|
|
$DBD::mysqlPPrawSjis::st::imp_data_size = 0; |
477
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
931
|
|
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
sub bind_param |
481
|
|
|
|
|
|
|
{ |
482
|
0
|
|
|
0
|
|
|
my $sth = shift; |
483
|
0
|
|
|
|
|
|
my ($index, $value, $attr) = @_; |
484
|
0
|
0
|
|
|
|
|
my $type = (ref $attr) ? $attr->{TYPE} : $attr; |
485
|
0
|
0
|
|
|
|
|
if ($type) { |
486
|
0
|
|
|
|
|
|
my $dbh = $sth->{Database}; |
487
|
0
|
|
|
|
|
|
$value = $dbh->quote($sth, $type); |
488
|
|
|
|
|
|
|
} |
489
|
0
|
|
|
|
|
|
my $params = $sth->FETCH('mysqlpprawsjis_param'); |
490
|
0
|
|
|
|
|
|
$params->[$index - 1] = $value; |
491
|
|
|
|
|
|
|
} |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
sub execute |
495
|
|
|
|
|
|
|
{ |
496
|
0
|
|
|
0
|
|
|
my $sth = shift; |
497
|
0
|
|
|
|
|
|
my @bind_values = @_; |
498
|
0
|
0
|
|
|
|
|
my $params = (@bind_values) ? |
499
|
|
|
|
|
|
|
\@bind_values : $sth->FETCH('mysqlpprawsjis_params'); |
500
|
0
|
|
|
|
|
|
my $num_param = $sth->FETCH('NUM_OF_PARAMS'); |
501
|
0
|
0
|
|
|
|
|
if (@$params != $num_param) { |
502
|
|
|
|
|
|
|
# ... |
503
|
|
|
|
|
|
|
} |
504
|
0
|
|
|
|
|
|
my $statement = $sth->{Statement}; |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
# DBD::mysqlPPrawSjis (5 of 5) |
507
|
0
|
|
|
|
|
|
if (1) { |
508
|
0
|
|
|
|
|
|
my $dbh = $sth->{Database}; |
509
|
0
|
|
|
|
|
|
my @statement = (); |
510
|
0
|
|
|
|
|
|
my $i = 0; |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
# LIMIT m,n [Li][Ii][Mm][Ii][Tt] for ignorecase on ShiftJIS (Can't use /LIMIT/i) |
513
|
|
|
|
|
|
|
# LIMIT n |
514
|
|
|
|
|
|
|
# OFFSET m |
515
|
|
|
|
|
|
|
|
516
|
0
|
|
|
|
|
|
while ($statement =~ /\G ( |
517
|
|
|
|
|
|
|
' (?: '' | \\' | [\x81-\x9F\xE0-\xFC][\x00-\xFF] | [^\x81-\x9F\xE0-\xFC'] )*? ' | |
518
|
|
|
|
|
|
|
" (?: "" | \\" | [\x81-\x9F\xE0-\xFC][\x00-\xFF] | [^\x81-\x9F\xE0-\xFC"] )*? " | |
519
|
|
|
|
|
|
|
(?: \s+ [Ll][Ii][Mm][Ii][Tt] \s+ [?] \s* , \s* [?] ) | |
520
|
|
|
|
|
|
|
(?: \s+ [Ll][Ii][Mm][Ii][Tt] \s+ [0-9]+ \s* , \s* [?] ) | |
521
|
|
|
|
|
|
|
(?: \s+ [Ll][Ii][Mm][Ii][Tt] \s+ [?] \s* , \s* [0-9]+ ) | |
522
|
|
|
|
|
|
|
(?: \s+ [Ll][Ii][Mm][Ii][Tt] \s+ [?] ) | |
523
|
|
|
|
|
|
|
(?: \s+ [Oo][Ff][Ff][Ss][Ee][Tt] \s+ [?] ) | |
524
|
|
|
|
|
|
|
(?: [\x81-\x9F\xE0-\xFC][\x00-\xFF] | [\x00-\xFF] ) |
525
|
|
|
|
|
|
|
)/gsx) { |
526
|
0
|
|
|
|
|
|
my $element = $1; |
527
|
0
|
0
|
0
|
|
|
|
if (($element =~ /\A \s+ [Ll][Ii][Mm][Ii][Tt] \s+ [?] \s* , \s* [?] \z/x) and |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
528
|
|
|
|
|
|
|
defined($params->[$i+1]) and |
529
|
|
|
|
|
|
|
($params->[$i+0] =~ /^[0-9]+$/) and |
530
|
|
|
|
|
|
|
($params->[$i+1] =~ /^[0-9]+$/) |
531
|
|
|
|
|
|
|
) { |
532
|
0
|
|
|
|
|
|
$element =~ s{[?]}{$params->[$i++]}e; |
|
0
|
|
|
|
|
|
|
533
|
0
|
|
|
|
|
|
$element =~ s{[?]}{$params->[$i++]}e; |
|
0
|
|
|
|
|
|
|
534
|
0
|
|
|
|
|
|
push @statement, $element; |
535
|
|
|
|
|
|
|
} |
536
|
|
|
|
|
|
|
elsif ( |
537
|
|
|
|
|
|
|
($element =~ /\A \s+ [Ll][Ii][Mm][Ii][Tt] \s+ /x) and |
538
|
|
|
|
|
|
|
defined($params->[$i]) and |
539
|
|
|
|
|
|
|
($params->[$i] =~ /^[0-9]+$/) |
540
|
|
|
|
|
|
|
) { |
541
|
0
|
|
|
|
|
|
$element =~ s{[?]}{$params->[$i++]}e; |
|
0
|
|
|
|
|
|
|
542
|
0
|
|
|
|
|
|
push @statement, $element; |
543
|
|
|
|
|
|
|
} |
544
|
|
|
|
|
|
|
elsif ( |
545
|
|
|
|
|
|
|
($element =~ /\A \s+ [Oo][Ff][Ff][Ss][Ee][Tt] \s+ /x) and |
546
|
|
|
|
|
|
|
defined($params->[$i]) and |
547
|
|
|
|
|
|
|
($params->[$i] =~ /^[0-9]+$/) |
548
|
|
|
|
|
|
|
) { |
549
|
0
|
|
|
|
|
|
$element =~ s{[?]}{$params->[$i++]}e; |
|
0
|
|
|
|
|
|
|
550
|
0
|
|
|
|
|
|
push @statement, $element; |
551
|
|
|
|
|
|
|
} |
552
|
|
|
|
|
|
|
elsif (($element eq '?') and defined($params->[$i])) { |
553
|
0
|
|
|
|
|
|
push @statement, $dbh->quote($params->[$i++]); |
554
|
|
|
|
|
|
|
} |
555
|
|
|
|
|
|
|
else { |
556
|
0
|
|
|
|
|
|
push @statement, $element; |
557
|
|
|
|
|
|
|
} |
558
|
|
|
|
|
|
|
} |
559
|
0
|
|
|
|
|
|
$statement = join '', @statement; |
560
|
|
|
|
|
|
|
} |
561
|
|
|
|
|
|
|
else { |
562
|
|
|
|
|
|
|
for (my $i = 0; $i < $num_param; $i++) { |
563
|
|
|
|
|
|
|
my $dbh = $sth->{Database}; |
564
|
|
|
|
|
|
|
my $quoted_param = $dbh->quote($params->[$i]); |
565
|
|
|
|
|
|
|
$statement =~ s/\?/$quoted_param/e; |
566
|
|
|
|
|
|
|
} |
567
|
|
|
|
|
|
|
} |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
# for debug DBD::mysqlPPrawSjis |
570
|
0
|
|
|
|
|
|
if (0) { |
571
|
|
|
|
|
|
|
open(QUERY,'>>query.log'); |
572
|
|
|
|
|
|
|
my($year,$month,$day,$hour,$min,$sec) = (localtime)[5,4,3,2,1,0]; |
573
|
|
|
|
|
|
|
printf QUERY ("-- %04d-%02d-%02d %02d:%02d:%02d\n", 1900+$year,$month+1,$day,$hour,$min,$sec); |
574
|
|
|
|
|
|
|
print QUERY $statement, "\n"; |
575
|
|
|
|
|
|
|
close(QUERY); |
576
|
|
|
|
|
|
|
} |
577
|
|
|
|
|
|
|
|
578
|
0
|
|
|
|
|
|
my $mysql = $sth->FETCH('mysqlpprawsjis_handle'); |
579
|
0
|
|
|
|
|
|
my $result = eval { |
580
|
0
|
|
|
|
|
|
$sth->{mysqlpprawsjis_record_iterator} = undef; |
581
|
0
|
|
|
|
|
|
$mysql->query($statement); |
582
|
0
|
0
|
|
|
|
|
die if $mysql->is_error; |
583
|
|
|
|
|
|
|
|
584
|
0
|
|
|
|
|
|
my $dbh = $sth->{Database}; |
585
|
0
|
|
|
|
|
|
$dbh->STORE(mysqlpprawsjis_insertid => $mysql->get_insert_id); |
586
|
0
|
|
|
|
|
|
$dbh->STORE(mysql_insertid => $mysql->get_insert_id); |
587
|
|
|
|
|
|
|
|
588
|
0
|
|
|
|
|
|
$sth->{mysqlpprawsjis_rows} = $mysql->get_affected_rows_length; |
589
|
0
|
0
|
|
|
|
|
if ($mysql->has_selected_record) { |
590
|
0
|
|
|
|
|
|
my $record = $mysql->create_record_iterator; |
591
|
0
|
|
|
|
|
|
$sth->{mysqlpprawsjis_record_iterator} = $record; |
592
|
0
|
|
|
|
|
|
$sth->STORE(NUM_OF_FIELDS => $record->get_field_length); |
593
|
0
|
|
|
|
|
|
$sth->STORE(NAME => [ $record->get_field_names ]); |
594
|
|
|
|
|
|
|
} |
595
|
0
|
|
|
|
|
|
$mysql->get_affected_rows_length; |
596
|
|
|
|
|
|
|
}; |
597
|
0
|
0
|
|
|
|
|
if ($@) { |
598
|
0
|
|
|
|
|
|
$sth->DBI::set_err( |
599
|
|
|
|
|
|
|
$mysql->get_error_code, $mysql->get_error_message |
600
|
|
|
|
|
|
|
); |
601
|
0
|
|
|
|
|
|
return undef; |
602
|
|
|
|
|
|
|
} |
603
|
|
|
|
|
|
|
|
604
|
0
|
0
|
|
|
|
|
return $mysql->is_error |
|
|
0
|
|
|
|
|
|
605
|
|
|
|
|
|
|
? undef : $result |
606
|
|
|
|
|
|
|
? $result : '0E0'; |
607
|
|
|
|
|
|
|
} |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
sub fetch |
611
|
|
|
|
|
|
|
{ |
612
|
0
|
|
|
0
|
|
|
my $sth = shift; |
613
|
|
|
|
|
|
|
|
614
|
0
|
|
|
|
|
|
my $iterator = $sth->FETCH('mysqlpprawsjis_record_iterator'); |
615
|
0
|
|
|
|
|
|
my $row = $iterator->each; |
616
|
0
|
0
|
|
|
|
|
return undef unless $row; |
617
|
|
|
|
|
|
|
|
618
|
0
|
0
|
|
|
|
|
if ($sth->FETCH('ChopBlanks')) { |
619
|
0
|
|
|
|
|
|
map {s/\s+$//} @$row; |
|
0
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
} |
621
|
0
|
|
|
|
|
|
return $sth->_set_fbav($row); |
622
|
|
|
|
|
|
|
} |
623
|
1
|
|
|
1
|
|
7
|
use vars qw(*fetchrow_arrayref); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
238
|
|
624
|
|
|
|
|
|
|
*fetchrow_arrayref = \&fetch; |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
sub rows |
628
|
|
|
|
|
|
|
{ |
629
|
0
|
|
|
0
|
|
|
my $sth = shift; |
630
|
0
|
|
|
|
|
|
$sth->FETCH('mysqlpprawsjis_rows'); |
631
|
|
|
|
|
|
|
} |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
sub FETCH |
635
|
|
|
|
|
|
|
{ |
636
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
637
|
0
|
|
|
|
|
|
my $key = shift; |
638
|
|
|
|
|
|
|
|
639
|
0
|
0
|
|
|
|
|
return 1 if $key eq 'AutoCommit'; |
640
|
0
|
0
|
|
|
|
|
return $dbh->{NAME} if $key eq 'NAME'; |
641
|
0
|
0
|
|
|
|
|
return $dbh->{$key} if $key =~ /^mysqlpprawsjis_/; |
642
|
0
|
|
|
|
|
|
return $dbh->SUPER::FETCH($key); |
643
|
|
|
|
|
|
|
} |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
sub STORE |
647
|
|
|
|
|
|
|
{ |
648
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
649
|
0
|
|
|
|
|
|
my ($key, $value) = @_; |
650
|
|
|
|
|
|
|
|
651
|
0
|
0
|
|
|
|
|
if ($key eq 'AutoCommit') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
652
|
0
|
0
|
|
|
|
|
die "Can't disable AutoCommit" unless $value; |
653
|
0
|
|
|
|
|
|
return 1; |
654
|
|
|
|
|
|
|
} |
655
|
|
|
|
|
|
|
elsif ($key eq 'NAME') { |
656
|
0
|
|
|
|
|
|
$dbh->{NAME} = $value; |
657
|
0
|
|
|
|
|
|
return 1; |
658
|
|
|
|
|
|
|
} |
659
|
|
|
|
|
|
|
elsif ($key =~ /^mysqlpprawsjis_/) { |
660
|
0
|
|
|
|
|
|
$dbh->{$key} = $value; |
661
|
0
|
|
|
|
|
|
return 1; |
662
|
|
|
|
|
|
|
} |
663
|
0
|
|
|
|
|
|
return $dbh->SUPER::STORE($key, $value); |
664
|
|
|
|
|
|
|
} |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
sub DESTROY |
668
|
|
|
|
|
|
|
{ |
669
|
0
|
|
|
0
|
|
|
my $dbh = shift; |
670
|
|
|
|
|
|
|
} |
671
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
1; |
674
|
|
|
|
|
|
|
__END__ |