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