Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/DBD/mysql.pm |
Statements | Executed 66031 statements in 504ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
18950 | 8 | 1 | 149ms | 397ms | __ANON__[:870] | DBD::mysql::st::
3000 | 2 | 1 | 17.0ms | 63.1ms | __ANON__[:881] | DBD::mysql::st::
1 | 1 | 1 | 1.05ms | 1.05ms | _login (xsub) | DBD::mysql::db::
1 | 1 | 1 | 187µs | 2.37ms | BEGIN@119 | DBD::mysql::dr::
15 | 1 | 1 | 121µs | 456µs | prepare | DBD::mysql::db::
1 | 1 | 1 | 59µs | 59µs | bootstrap (xsub) | DBD::mysql::
1 | 1 | 1 | 39µs | 142µs | driver | DBD::mysql::
15 | 1 | 1 | 36µs | 36µs | _prepare (xsub) | DBD::mysql::st::
1 | 1 | 1 | 26µs | 1.12ms | connect | DBD::mysql::dr::
1 | 1 | 1 | 21µs | 21µs | BEGIN@837 | DBD::mysql::db::
1 | 1 | 1 | 15µs | 15µs | BEGIN@856 | DBD::mysql::st::
2 | 2 | 1 | 15µs | 15µs | CORE:match (opcode) | DBD::mysql::
1 | 1 | 1 | 12µs | 26µs | _OdbcParse | DBD::mysql::
1 | 1 | 1 | 10µs | 11µs | BEGIN@3 | DBI::_firesafe::
1 | 1 | 1 | 8µs | 10µs | BEGIN@117 | DBD::mysql::dr::
1 | 1 | 1 | 7µs | 28µs | BEGIN@9 | DBD::mysql::
1 | 1 | 1 | 6µs | 8µs | BEGIN@204 | DBD::mysql::db::
1 | 1 | 1 | 6µs | 20µs | BEGIN@841 | DBD::mysql::db::
1 | 1 | 1 | 6µs | 9µs | BEGIN@4 | DBI::_firesafe::
1 | 1 | 1 | 5µs | 6µs | BEGIN@854 | DBD::mysql::st::
1 | 1 | 1 | 4µs | 28µs | BEGIN@11 | DBD::mysql::
1 | 1 | 1 | 4µs | 10µs | BEGIN@874 | DBD::mysql::st::
1 | 1 | 1 | 4µs | 186µs | BEGIN@205 | DBD::mysql::db::
1 | 1 | 1 | 4µs | 365µs | BEGIN@118 | DBD::mysql::dr::
1 | 1 | 1 | 4µs | 9µs | BEGIN@861 | DBD::mysql::st::
1 | 1 | 1 | 2µs | 2µs | BEGIN@10 | DBD::mysql::
0 | 0 | 0 | 0s | 0s | AUTOLOAD | DBD::mysql::
0 | 0 | 0 | 0s | 0s | CLONE | DBD::mysql::
0 | 0 | 0 | 0s | 0s | _OdbcParseHost | DBD::mysql::
0 | 0 | 0 | 0s | 0s | ANSI2db | DBD::mysql::db::
0 | 0 | 0 | 0s | 0s | _ListTables | DBD::mysql::db::
0 | 0 | 0 | 0s | 0s | _SelectDB | DBD::mysql::db::
0 | 0 | 0 | 0s | 0s | __ANON__[:848] | DBD::mysql::db::
0 | 0 | 0 | 0s | 0s | _version | DBD::mysql::db::
0 | 0 | 0 | 0s | 0s | admin | DBD::mysql::db::
0 | 0 | 0 | 0s | 0s | column_info | DBD::mysql::db::
0 | 0 | 0 | 0s | 0s | db2ANSI | DBD::mysql::db::
0 | 0 | 0 | 0s | 0s | foreign_key_info | DBD::mysql::db::
0 | 0 | 0 | 0s | 0s | get_info | DBD::mysql::db::
0 | 0 | 0 | 0s | 0s | primary_key_info | DBD::mysql::db::
0 | 0 | 0 | 0s | 0s | statistics_info | DBD::mysql::db::
0 | 0 | 0 | 0s | 0s | table_info | DBD::mysql::db::
0 | 0 | 0 | 0s | 0s | admin | DBD::mysql::dr::
0 | 0 | 0 | 0s | 0s | data_sources | DBD::mysql::dr::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | #!/usr/bin/perl | ||||
2 | |||||
3 | 2 | 15µs | 2 | 13µs | # spent 11µs (10+2) within DBI::_firesafe::BEGIN@3 which was called:
# once (10µs+2µs) by DBI::install_driver at line 3 # spent 11µs making 1 call to DBI::_firesafe::BEGIN@3
# spent 2µs making 1 call to strict::import |
4 | 2 | 17µs | 2 | 12µs | # spent 9µs (6+3) within DBI::_firesafe::BEGIN@4 which was called:
# once (6µs+3µs) by DBI::install_driver at line 4 # spent 9µs making 1 call to DBI::_firesafe::BEGIN@4
# spent 3µs making 1 call to warnings::import |
5 | 1 | 8µs | require 5.008_001; # just as DBI | ||
6 | |||||
7 | package DBD::mysql; | ||||
8 | |||||
9 | 2 | 16µs | 2 | 50µs | # spent 28µs (7+21) within DBD::mysql::BEGIN@9 which was called:
# once (7µs+21µs) by DBI::install_driver at line 9 # spent 28µs making 1 call to DBD::mysql::BEGIN@9
# spent 21µs making 1 call to Exporter::import |
10 | 2 | 13µs | 1 | 2µs | # spent 2µs within DBD::mysql::BEGIN@10 which was called:
# once (2µs+0s) by DBI::install_driver at line 10 # spent 2µs making 1 call to DBD::mysql::BEGIN@10 |
11 | 2 | 388µs | 2 | 51µs | # spent 28µs (4+23) within DBD::mysql::BEGIN@11 which was called:
# once (4µs+23µs) by DBI::install_driver at line 11 # spent 28µs making 1 call to DBD::mysql::BEGIN@11
# spent 23µs making 1 call to Exporter::import |
12 | 1 | 5µs | our @ISA = qw(DynaLoader); | ||
13 | |||||
14 | # please make sure the sub-version does not increase above '099' | ||||
15 | # SQL_DRIVER_VER is formatted as dd.dd.dddd | ||||
16 | # for version 5.x please switch to 5.00(_00) version numbering | ||||
17 | # keep $VERSION in Bundle/DBD/mysql.pm in sync | ||||
18 | 1 | 100ns | our $VERSION = '4.040'; | ||
19 | |||||
20 | 1 | 4µs | 1 | 1.08ms | bootstrap DBD::mysql $VERSION; # spent 1.08ms making 1 call to DynaLoader::bootstrap |
21 | |||||
22 | |||||
23 | 1 | 200ns | our $err = 0; # holds error code for DBI::err | ||
24 | 1 | 200ns | our $errstr = ""; # holds error string for DBI::errstr | ||
25 | 1 | 200ns | our $drh = undef; # holds driver handle once initialised | ||
26 | |||||
27 | 1 | 200ns | my $methods_are_installed = 0; | ||
28 | # spent 142µs (39+103) within DBD::mysql::driver which was called:
# once (39µs+103µs) by DBI::install_driver at line 833 of DBI.pm | ||||
29 | 1 | 200ns | return $drh if $drh; | ||
30 | 1 | 400ns | my($class, $attr) = @_; | ||
31 | |||||
32 | 1 | 500ns | $class .= "::dr"; | ||
33 | |||||
34 | # not a 'my' since we use it above to prevent multiple drivers | ||||
35 | 1 | 4µs | 1 | 29µs | $drh = DBI::_new_drh($class, { 'Name' => 'mysql', # spent 29µs making 1 call to DBI::_new_drh |
36 | 'Version' => $VERSION, | ||||
37 | 'Err' => \$DBD::mysql::err, | ||||
38 | 'Errstr' => \$DBD::mysql::errstr, | ||||
39 | 'Attribution' => 'DBD::mysql by Patrick Galbraith' | ||||
40 | }); | ||||
41 | |||||
42 | 1 | 300ns | if (!$methods_are_installed) { | ||
43 | 1 | 3µs | 1 | 30µs | DBD::mysql::db->install_method('mysql_fd'); # spent 30µs making 1 call to DBD::_::common::install_method |
44 | 1 | 900ns | 1 | 13µs | DBD::mysql::db->install_method('mysql_async_result'); # spent 13µs making 1 call to DBD::_::common::install_method |
45 | 1 | 700ns | 1 | 10µs | DBD::mysql::db->install_method('mysql_async_ready'); # spent 10µs making 1 call to DBD::_::common::install_method |
46 | 1 | 2µs | 1 | 11µs | DBD::mysql::st->install_method('mysql_async_result'); # spent 11µs making 1 call to DBD::_::common::install_method |
47 | 1 | 20µs | 1 | 11µs | DBD::mysql::st->install_method('mysql_async_ready'); # spent 11µs making 1 call to DBD::_::common::install_method |
48 | |||||
49 | 1 | 500ns | $methods_are_installed++; | ||
50 | } | ||||
51 | |||||
52 | 1 | 3µs | $drh; | ||
53 | } | ||||
54 | |||||
55 | sub CLONE { | ||||
56 | undef $drh; | ||||
57 | } | ||||
58 | |||||
59 | # spent 26µs (12+15) within DBD::mysql::_OdbcParse which was called:
# once (12µs+15µs) by DBD::mysql::dr::connect at line 143 | ||||
60 | 1 | 300ns | my($class, $dsn, $hash, $args) = @_; | ||
61 | 1 | 100ns | my($var, $val); | ||
62 | 1 | 1µs | if (!defined($dsn)) { | ||
63 | return; | ||||
64 | } | ||||
65 | 1 | 3µs | while (length($dsn)) { | ||
66 | 1 | 17µs | 1 | 13µs | if ($dsn =~ /([^:;]*\[.*]|[^:;]*)[:;](.*)/) { # spent 13µs making 1 call to DBD::mysql::CORE:match |
67 | $val = $1; | ||||
68 | $dsn = $2; | ||||
69 | $val =~ s/\[|]//g; # Remove [] if present, the rest of the code prefers plain IPv6 addresses | ||||
70 | } else { | ||||
71 | 1 | 300ns | $val = $dsn; | ||
72 | 1 | 400ns | $dsn = ''; | ||
73 | } | ||||
74 | 1 | 3µs | 1 | 1µs | if ($val =~ /([^=]*)=(.*)/) { # spent 1µs making 1 call to DBD::mysql::CORE:match |
75 | 1 | 500ns | $var = $1; | ||
76 | 1 | 800ns | $val = $2; | ||
77 | 1 | 900ns | if ($var eq 'hostname' || $var eq 'host') { | ||
78 | $hash->{'host'} = $val; | ||||
79 | } elsif ($var eq 'db' || $var eq 'dbname') { | ||||
80 | $hash->{'database'} = $val; | ||||
81 | } else { | ||||
82 | 1 | 400ns | $hash->{$var} = $val; | ||
83 | } | ||||
84 | } else { | ||||
85 | foreach $var (@$args) { | ||||
86 | if (!defined($hash->{$var})) { | ||||
87 | $hash->{$var} = $val; | ||||
88 | last; | ||||
89 | } | ||||
90 | } | ||||
91 | } | ||||
92 | } | ||||
93 | } | ||||
94 | |||||
95 | sub _OdbcParseHost ($$) { | ||||
96 | my($class, $dsn) = @_; | ||||
97 | my($hash) = {}; | ||||
98 | $class->_OdbcParse($dsn, $hash, ['host', 'port']); | ||||
99 | ($hash->{'host'}, $hash->{'port'}); | ||||
100 | } | ||||
101 | |||||
102 | sub AUTOLOAD { | ||||
103 | my ($meth) = $DBD::mysql::AUTOLOAD; | ||||
104 | my ($smeth) = $meth; | ||||
105 | $smeth =~ s/(.*)\:\://; | ||||
106 | |||||
107 | my $val = constant($smeth, @_ ? $_[0] : 0); | ||||
108 | if ($! == 0) { eval "sub $meth { $val }"; return $val; } | ||||
109 | |||||
110 | Carp::croak "$meth: Not defined"; | ||||
111 | } | ||||
112 | |||||
113 | 1; | ||||
114 | |||||
115 | |||||
116 | package DBD::mysql::dr; # ====== DRIVER ====== | ||||
117 | 2 | 16µs | 2 | 11µs | # spent 10µs (8+1) within DBD::mysql::dr::BEGIN@117 which was called:
# once (8µs+1µs) by DBI::install_driver at line 117 # spent 10µs making 1 call to DBD::mysql::dr::BEGIN@117
# spent 1µs making 1 call to strict::import |
118 | 2 | 18µs | 2 | 727µs | # spent 365µs (4+361) within DBD::mysql::dr::BEGIN@118 which was called:
# once (4µs+361µs) by DBI::install_driver at line 118 # spent 365µs making 1 call to DBD::mysql::dr::BEGIN@118
# spent 361µs making 1 call to Exporter::import |
119 | 2 | 549µs | 2 | 2.41ms | # spent 2.37ms (187µs+2.18) within DBD::mysql::dr::BEGIN@119 which was called:
# once (187µs+2.18ms) by DBI::install_driver at line 119 # spent 2.37ms making 1 call to DBD::mysql::dr::BEGIN@119
# spent 45µs making 1 call to Exporter::import |
120 | |||||
121 | # spent 1.12ms (26µs+1.09) within DBD::mysql::dr::connect which was called:
# once (26µs+1.09ms) by DBI::dr::connect at line 683 of DBI.pm | ||||
122 | 1 | 500ns | my($drh, $dsn, $username, $password, $attrhash) = @_; | ||
123 | 1 | 200ns | my($port); | ||
124 | my($cWarn); | ||||
125 | 1 | 600ns | my $connect_ref= { 'Name' => $dsn }; | ||
126 | 1 | 100ns | my $dbi_imp_data; | ||
127 | |||||
128 | # Avoid warnings for undefined values | ||||
129 | 1 | 100ns | $username ||= ''; | ||
130 | 1 | 100ns | $password ||= ''; | ||
131 | 1 | 100ns | $attrhash ||= {}; | ||
132 | 1 | 500ns | $attrhash->{mysql_conn_attrs} ||= {}; | ||
133 | 1 | 2µs | $attrhash->{mysql_conn_attrs}->{'program_name'} ||= $0; | ||
134 | |||||
135 | # create a 'blank' dbh | ||||
136 | 1 | 300ns | my($this, $privateAttrHash) = (undef, $attrhash); | ||
137 | 1 | 3µs | $privateAttrHash = { %$privateAttrHash, | ||
138 | 'Name' => $dsn, | ||||
139 | 'user' => $username, | ||||
140 | 'password' => $password | ||||
141 | }; | ||||
142 | |||||
143 | 1 | 2µs | 1 | 26µs | DBD::mysql->_OdbcParse($dsn, $privateAttrHash, # spent 26µs making 1 call to DBD::mysql::_OdbcParse |
144 | ['database', 'host', 'port']); | ||||
145 | |||||
146 | |||||
147 | 1 | 1µs | if ($DBI::VERSION >= 1.49) | ||
148 | { | ||||
149 | 1 | 300ns | $dbi_imp_data = delete $attrhash->{dbi_imp_data}; | ||
150 | 1 | 200ns | $connect_ref->{'dbi_imp_data'} = $dbi_imp_data; | ||
151 | } | ||||
152 | |||||
153 | 1 | 1µs | 1 | 20µs | if (!defined($this = DBI::_new_dbh($drh, # spent 20µs making 1 call to DBI::_new_dbh |
154 | $connect_ref, | ||||
155 | $privateAttrHash))) | ||||
156 | { | ||||
157 | return undef; | ||||
158 | } | ||||
159 | |||||
160 | 1 | 1.05ms | 1 | 1.05ms | DBD::mysql::db::_login($this, $dsn, $username, $password) # spent 1.05ms making 1 call to DBD::mysql::db::_login |
161 | or $this = undef; | ||||
162 | |||||
163 | 1 | 4µs | if ($this && ($ENV{MOD_PERL} || $ENV{GATEWAY_INTERFACE})) { | ||
164 | $this->{mysql_auto_reconnect} = 1; | ||||
165 | } | ||||
166 | 1 | 3µs | $this; | ||
167 | } | ||||
168 | |||||
169 | sub data_sources { | ||||
170 | my($self) = shift; | ||||
171 | my($attributes) = shift; | ||||
172 | my($host, $port, $user, $password) = ('', '', '', ''); | ||||
173 | if ($attributes) { | ||||
174 | $host = $attributes->{host} || ''; | ||||
175 | $port = $attributes->{port} || ''; | ||||
176 | $user = $attributes->{user} || ''; | ||||
177 | $password = $attributes->{password} || ''; | ||||
178 | } | ||||
179 | my(@dsn) = $self->func($host, $port, $user, $password, '_ListDBs'); | ||||
180 | my($i); | ||||
181 | for ($i = 0; $i < @dsn; $i++) { | ||||
182 | $dsn[$i] = "DBI:mysql:$dsn[$i]"; | ||||
183 | } | ||||
184 | @dsn; | ||||
185 | } | ||||
186 | |||||
187 | sub admin { | ||||
188 | my($drh) = shift; | ||||
189 | my($command) = shift; | ||||
190 | my($dbname) = ($command eq 'createdb' || $command eq 'dropdb') ? | ||||
191 | shift : ''; | ||||
192 | my($host, $port) = DBD::mysql->_OdbcParseHost(shift(@_) || ''); | ||||
193 | my($user) = shift || ''; | ||||
194 | my($password) = shift || ''; | ||||
195 | |||||
196 | $drh->func(undef, $command, | ||||
197 | $dbname || '', | ||||
198 | $host || '', | ||||
199 | $port || '', | ||||
200 | $user, $password, '_admin_internal'); | ||||
201 | } | ||||
202 | |||||
203 | package DBD::mysql::db; # ====== DATABASE ====== | ||||
204 | 2 | 15µs | 2 | 9µs | # spent 8µs (6+2) within DBD::mysql::db::BEGIN@204 which was called:
# once (6µs+2µs) by DBI::install_driver at line 204 # spent 8µs making 1 call to DBD::mysql::db::BEGIN@204
# spent 2µs making 1 call to strict::import |
205 | 2 | 1.36ms | 2 | 369µs | # spent 186µs (4+182) within DBD::mysql::db::BEGIN@205 which was called:
# once (4µs+182µs) by DBI::install_driver at line 205 # spent 186µs making 1 call to DBD::mysql::db::BEGIN@205
# spent 182µs making 1 call to Exporter::import |
206 | |||||
207 | 1 | 2µs | %DBD::mysql::db::db2ANSI = ( | ||
208 | "INT" => "INTEGER", | ||||
209 | "CHAR" => "CHAR", | ||||
210 | "REAL" => "REAL", | ||||
211 | "IDENT" => "DECIMAL" | ||||
212 | ); | ||||
213 | |||||
214 | ### ANSI datatype mapping to MySQL datatypes | ||||
215 | 1 | 6µs | %DBD::mysql::db::ANSI2db = ( | ||
216 | "CHAR" => "CHAR", | ||||
217 | "VARCHAR" => "CHAR", | ||||
218 | "LONGVARCHAR" => "CHAR", | ||||
219 | "NUMERIC" => "INTEGER", | ||||
220 | "DECIMAL" => "INTEGER", | ||||
221 | "BIT" => "INTEGER", | ||||
222 | "TINYINT" => "INTEGER", | ||||
223 | "SMALLINT" => "INTEGER", | ||||
224 | "INTEGER" => "INTEGER", | ||||
225 | "BIGINT" => "INTEGER", | ||||
226 | "REAL" => "REAL", | ||||
227 | "FLOAT" => "REAL", | ||||
228 | "DOUBLE" => "REAL", | ||||
229 | "BINARY" => "CHAR", | ||||
230 | "VARBINARY" => "CHAR", | ||||
231 | "LONGVARBINARY" => "CHAR", | ||||
232 | "DATE" => "CHAR", | ||||
233 | "TIME" => "CHAR", | ||||
234 | "TIMESTAMP" => "CHAR" | ||||
235 | ); | ||||
236 | |||||
237 | # spent 456µs (121+335) within DBD::mysql::db::prepare which was called 15 times, avg 30µs/call:
# 15 times (121µs+335µs) by DBI::db::prepare at line 45 of BenchmarkAnything/Storage/Backend/SQL/Query.pm, avg 30µs/call | ||||
238 | 15 | 6µs | my($dbh, $statement, $attribs)= @_; | ||
239 | |||||
240 | 15 | 49µs | 15 | 20µs | return unless $dbh->func('_async_check'); # spent 20µs making 15 calls to DBI::common::func, avg 1µs/call |
241 | |||||
242 | # create a 'blank' dbh | ||||
243 | 15 | 36µs | 15 | 279µs | my $sth = DBI::_new_sth($dbh, {'Statement' => $statement}); # spent 279µs making 15 calls to DBI::_new_sth, avg 19µs/call |
244 | |||||
245 | # Populate internal handle data. | ||||
246 | 15 | 63µs | 15 | 36µs | if (!DBD::mysql::st::_prepare($sth, $statement, $attribs)) { # spent 36µs making 15 calls to DBD::mysql::st::_prepare, avg 2µs/call |
247 | $sth = undef; | ||||
248 | } | ||||
249 | |||||
250 | 15 | 36µs | $sth; | ||
251 | } | ||||
252 | |||||
253 | sub db2ANSI { | ||||
254 | my $self = shift; | ||||
255 | my $type = shift; | ||||
256 | return $DBD::mysql::db::db2ANSI{"$type"}; | ||||
257 | } | ||||
258 | |||||
259 | sub ANSI2db { | ||||
260 | my $self = shift; | ||||
261 | my $type = shift; | ||||
262 | return $DBD::mysql::db::ANSI2db{"$type"}; | ||||
263 | } | ||||
264 | |||||
265 | sub admin { | ||||
266 | my($dbh) = shift; | ||||
267 | my($command) = shift; | ||||
268 | my($dbname) = ($command eq 'createdb' || $command eq 'dropdb') ? | ||||
269 | shift : ''; | ||||
270 | $dbh->{'Driver'}->func($dbh, $command, $dbname, '', '', '', | ||||
271 | '_admin_internal'); | ||||
272 | } | ||||
273 | |||||
274 | sub _SelectDB ($$) { | ||||
275 | die "_SelectDB is removed from this module; use DBI->connect instead."; | ||||
276 | } | ||||
277 | |||||
278 | sub table_info ($) { | ||||
279 | my ($dbh, $catalog, $schema, $table, $type, $attr) = @_; | ||||
280 | $dbh->{mysql_server_prepare}||= 0; | ||||
281 | my $mysql_server_prepare_save= $dbh->{mysql_server_prepare}; | ||||
282 | $dbh->{mysql_server_prepare}= 0; | ||||
283 | my @names = qw(TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS); | ||||
284 | my @rows; | ||||
285 | |||||
286 | my $sponge = DBI->connect("DBI:Sponge:", '','') | ||||
287 | or return $dbh->DBI::set_err($DBI::err, "DBI::Sponge: $DBI::errstr"); | ||||
288 | |||||
289 | # Return the list of catalogs | ||||
290 | if (defined $catalog && $catalog eq "%" && | ||||
291 | (!defined($schema) || $schema eq "") && | ||||
292 | (!defined($table) || $table eq "")) | ||||
293 | { | ||||
294 | @rows = (); # Empty, because MySQL doesn't support catalogs (yet) | ||||
295 | } | ||||
296 | # Return the list of schemas | ||||
297 | elsif (defined $schema && $schema eq "%" && | ||||
298 | (!defined($catalog) || $catalog eq "") && | ||||
299 | (!defined($table) || $table eq "")) | ||||
300 | { | ||||
301 | my $sth = $dbh->prepare("SHOW DATABASES") | ||||
302 | or ($dbh->{mysql_server_prepare}= $mysql_server_prepare_save && | ||||
303 | return undef); | ||||
304 | |||||
305 | $sth->execute() | ||||
306 | or ($dbh->{mysql_server_prepare}= $mysql_server_prepare_save && | ||||
307 | return DBI::set_err($dbh, $sth->err(), $sth->errstr())); | ||||
308 | |||||
309 | while (my $ref = $sth->fetchrow_arrayref()) | ||||
310 | { | ||||
311 | push(@rows, [ undef, $ref->[0], undef, undef, undef ]); | ||||
312 | } | ||||
313 | } | ||||
314 | # Return the list of table types | ||||
315 | elsif (defined $type && $type eq "%" && | ||||
316 | (!defined($catalog) || $catalog eq "") && | ||||
317 | (!defined($schema) || $schema eq "") && | ||||
318 | (!defined($table) || $table eq "")) | ||||
319 | { | ||||
320 | @rows = ( | ||||
321 | [ undef, undef, undef, "TABLE", undef ], | ||||
322 | [ undef, undef, undef, "VIEW", undef ], | ||||
323 | ); | ||||
324 | } | ||||
325 | # Special case: a catalog other than undef, "", or "%" | ||||
326 | elsif (defined $catalog && $catalog ne "" && $catalog ne "%") | ||||
327 | { | ||||
328 | @rows = (); # Nothing, because MySQL doesn't support catalogs yet. | ||||
329 | } | ||||
330 | # Uh oh, we actually have a meaty table_info call. Work is required! | ||||
331 | else | ||||
332 | { | ||||
333 | my @schemas; | ||||
334 | # If no table was specified, we want them all | ||||
335 | $table ||= "%"; | ||||
336 | |||||
337 | # If something was given for the schema, we need to expand it to | ||||
338 | # a list of schemas, since it may be a wildcard. | ||||
339 | if (defined $schema && $schema ne "") | ||||
340 | { | ||||
341 | my $sth = $dbh->prepare("SHOW DATABASES LIKE " . | ||||
342 | $dbh->quote($schema)) | ||||
343 | or ($dbh->{mysql_server_prepare}= $mysql_server_prepare_save && | ||||
344 | return undef); | ||||
345 | $sth->execute() | ||||
346 | or ($dbh->{mysql_server_prepare}= $mysql_server_prepare_save && | ||||
347 | return DBI::set_err($dbh, $sth->err(), $sth->errstr())); | ||||
348 | |||||
349 | while (my $ref = $sth->fetchrow_arrayref()) | ||||
350 | { | ||||
351 | push @schemas, $ref->[0]; | ||||
352 | } | ||||
353 | } | ||||
354 | # Otherwise we want the current database | ||||
355 | else | ||||
356 | { | ||||
357 | push @schemas, $dbh->selectrow_array("SELECT DATABASE()"); | ||||
358 | } | ||||
359 | |||||
360 | # Figure out which table types are desired | ||||
361 | my ($want_tables, $want_views); | ||||
362 | if (defined $type && $type ne "") | ||||
363 | { | ||||
364 | $want_tables = ($type =~ m/table/i); | ||||
365 | $want_views = ($type =~ m/view/i); | ||||
366 | } | ||||
367 | else | ||||
368 | { | ||||
369 | $want_tables = $want_views = 1; | ||||
370 | } | ||||
371 | |||||
372 | for my $database (@schemas) | ||||
373 | { | ||||
374 | my $sth = $dbh->prepare("SHOW /*!50002 FULL*/ TABLES FROM " . | ||||
375 | $dbh->quote_identifier($database) . | ||||
376 | " LIKE " . $dbh->quote($table)) | ||||
377 | or ($dbh->{mysql_server_prepare}= $mysql_server_prepare_save && | ||||
378 | return undef); | ||||
379 | |||||
380 | $sth->execute() or | ||||
381 | ($dbh->{mysql_server_prepare}= $mysql_server_prepare_save && | ||||
382 | return DBI::set_err($dbh, $sth->err(), $sth->errstr())); | ||||
383 | |||||
384 | while (my $ref = $sth->fetchrow_arrayref()) | ||||
385 | { | ||||
386 | my $type = (defined $ref->[1] && | ||||
387 | $ref->[1] =~ /view/i) ? 'VIEW' : 'TABLE'; | ||||
388 | next if $type eq 'TABLE' && not $want_tables; | ||||
389 | next if $type eq 'VIEW' && not $want_views; | ||||
390 | push @rows, [ undef, $database, $ref->[0], $type, undef ]; | ||||
391 | } | ||||
392 | } | ||||
393 | } | ||||
394 | |||||
395 | my $sth = $sponge->prepare("table_info", | ||||
396 | { | ||||
397 | rows => \@rows, | ||||
398 | NUM_OF_FIELDS => scalar @names, | ||||
399 | NAME => \@names, | ||||
400 | }) | ||||
401 | or ($dbh->{mysql_server_prepare}= $mysql_server_prepare_save && | ||||
402 | return $dbh->DBI::set_err($sponge->err(), $sponge->errstr())); | ||||
403 | |||||
404 | $dbh->{mysql_server_prepare}= $mysql_server_prepare_save; | ||||
405 | return $sth; | ||||
406 | } | ||||
407 | |||||
408 | sub _ListTables { | ||||
409 | my $dbh = shift; | ||||
410 | if (!$DBD::mysql::QUIET) { | ||||
411 | warn "_ListTables is deprecated, use \$dbh->tables()"; | ||||
412 | } | ||||
413 | return map { $_ =~ s/.*\.//; $_ } $dbh->tables(); | ||||
414 | } | ||||
415 | |||||
416 | |||||
417 | sub column_info { | ||||
418 | my ($dbh, $catalog, $schema, $table, $column) = @_; | ||||
419 | |||||
420 | return unless $dbh->func('_async_check'); | ||||
421 | |||||
422 | $dbh->{mysql_server_prepare}||= 0; | ||||
423 | my $mysql_server_prepare_save= $dbh->{mysql_server_prepare}; | ||||
424 | $dbh->{mysql_server_prepare}= 0; | ||||
425 | |||||
426 | # ODBC allows a NULL to mean all columns, so we'll accept undef | ||||
427 | $column = '%' unless defined $column; | ||||
428 | |||||
429 | my $ER_NO_SUCH_TABLE= 1146; | ||||
430 | |||||
431 | my $table_id = $dbh->quote_identifier($catalog, $schema, $table); | ||||
432 | |||||
433 | my @names = qw( | ||||
434 | TABLE_CAT TABLE_SCHEM TABLE_NAME COLUMN_NAME | ||||
435 | DATA_TYPE TYPE_NAME COLUMN_SIZE BUFFER_LENGTH DECIMAL_DIGITS | ||||
436 | NUM_PREC_RADIX NULLABLE REMARKS COLUMN_DEF | ||||
437 | SQL_DATA_TYPE SQL_DATETIME_SUB CHAR_OCTET_LENGTH | ||||
438 | ORDINAL_POSITION IS_NULLABLE CHAR_SET_CAT | ||||
439 | CHAR_SET_SCHEM CHAR_SET_NAME COLLATION_CAT COLLATION_SCHEM COLLATION_NAME | ||||
440 | UDT_CAT UDT_SCHEM UDT_NAME DOMAIN_CAT DOMAIN_SCHEM DOMAIN_NAME | ||||
441 | SCOPE_CAT SCOPE_SCHEM SCOPE_NAME MAX_CARDINALITY | ||||
442 | DTD_IDENTIFIER IS_SELF_REF | ||||
443 | mysql_is_pri_key mysql_type_name mysql_values | ||||
444 | mysql_is_auto_increment | ||||
445 | ); | ||||
446 | my %col_info; | ||||
447 | |||||
448 | local $dbh->{FetchHashKeyName} = 'NAME_lc'; | ||||
449 | # only ignore ER_NO_SUCH_TABLE in internal_execute if issued from here | ||||
450 | my $desc_sth = $dbh->prepare("DESCRIBE $table_id " . $dbh->quote($column)); | ||||
451 | my $desc = $dbh->selectall_arrayref($desc_sth, { Columns=>{} }); | ||||
452 | |||||
453 | #return $desc_sth if $desc_sth->err(); | ||||
454 | if (my $err = $desc_sth->err()) | ||||
455 | { | ||||
456 | # return the error, unless it is due to the table not | ||||
457 | # existing per DBI spec | ||||
458 | if ($err != $ER_NO_SUCH_TABLE) | ||||
459 | { | ||||
460 | $dbh->{mysql_server_prepare}= $mysql_server_prepare_save; | ||||
461 | return undef; | ||||
462 | } | ||||
463 | $dbh->set_err(undef,undef); | ||||
464 | $desc = []; | ||||
465 | } | ||||
466 | |||||
467 | my $ordinal_pos = 0; | ||||
468 | my @fields; | ||||
469 | for my $row (@$desc) | ||||
470 | { | ||||
471 | my $type = $row->{type}; | ||||
472 | $type =~ m/^(\w+)(\((.+)\))?\s?(.*)?$/; | ||||
473 | my $basetype = lc($1); | ||||
474 | my $typemod = $3; | ||||
475 | my $attr = $4; | ||||
476 | |||||
477 | push @fields, $row->{field}; | ||||
478 | my $info = $col_info{ $row->{field} }= { | ||||
479 | TABLE_CAT => $catalog, | ||||
480 | TABLE_SCHEM => $schema, | ||||
481 | TABLE_NAME => $table, | ||||
482 | COLUMN_NAME => $row->{field}, | ||||
483 | NULLABLE => ($row->{null} eq 'YES') ? 1 : 0, | ||||
484 | IS_NULLABLE => ($row->{null} eq 'YES') ? "YES" : "NO", | ||||
485 | TYPE_NAME => uc($basetype), | ||||
486 | COLUMN_DEF => $row->{default}, | ||||
487 | ORDINAL_POSITION => ++$ordinal_pos, | ||||
488 | mysql_is_pri_key => ($row->{key} eq 'PRI'), | ||||
489 | mysql_type_name => $row->{type}, | ||||
490 | mysql_is_auto_increment => ($row->{extra} =~ /auto_increment/i ? 1 : 0), | ||||
491 | }; | ||||
492 | # | ||||
493 | # This code won't deal with a pathological case where a value | ||||
494 | # contains a single quote followed by a comma, and doesn't unescape | ||||
495 | # any escaped values. But who would use those in an enum or set? | ||||
496 | # | ||||
497 | my @type_params= ($typemod && index($typemod,"'")>=0) ? | ||||
498 | ("$typemod," =~ /'(.*?)',/g) # assume all are quoted | ||||
499 | : split /,/, $typemod||''; # no quotes, plain list | ||||
500 | s/''/'/g for @type_params; # undo doubling of quotes | ||||
501 | |||||
502 | my @type_attr= split / /, $attr||''; | ||||
503 | |||||
504 | $info->{DATA_TYPE}= SQL_VARCHAR(); | ||||
505 | if ($basetype =~ /^(char|varchar|\w*text|\w*blob)/) | ||||
506 | { | ||||
507 | $info->{DATA_TYPE}= SQL_CHAR() if $basetype eq 'char'; | ||||
508 | if ($type_params[0]) | ||||
509 | { | ||||
510 | $info->{COLUMN_SIZE} = $type_params[0]; | ||||
511 | } | ||||
512 | else | ||||
513 | { | ||||
514 | $info->{COLUMN_SIZE} = 65535; | ||||
515 | $info->{COLUMN_SIZE} = 255 if $basetype =~ /^tiny/; | ||||
516 | $info->{COLUMN_SIZE} = 16777215 if $basetype =~ /^medium/; | ||||
517 | $info->{COLUMN_SIZE} = 4294967295 if $basetype =~ /^long/; | ||||
518 | } | ||||
519 | } | ||||
520 | elsif ($basetype =~ /^(binary|varbinary)/) | ||||
521 | { | ||||
522 | $info->{COLUMN_SIZE} = $type_params[0]; | ||||
523 | # SQL_BINARY & SQL_VARBINARY are tempting here but don't match the | ||||
524 | # semantics for mysql (not hex). SQL_CHAR & SQL_VARCHAR are correct here. | ||||
525 | $info->{DATA_TYPE} = ($basetype eq 'binary') ? SQL_CHAR() : SQL_VARCHAR(); | ||||
526 | } | ||||
527 | elsif ($basetype =~ /^(enum|set)/) | ||||
528 | { | ||||
529 | if ($basetype eq 'set') | ||||
530 | { | ||||
531 | $info->{COLUMN_SIZE} = length(join ",", @type_params); | ||||
532 | } | ||||
533 | else | ||||
534 | { | ||||
535 | my $max_len = 0; | ||||
536 | length($_) > $max_len and $max_len = length($_) for @type_params; | ||||
537 | $info->{COLUMN_SIZE} = $max_len; | ||||
538 | } | ||||
539 | $info->{"mysql_values"} = \@type_params; | ||||
540 | } | ||||
541 | elsif ($basetype =~ /int/ || $basetype eq 'bit' ) | ||||
542 | { | ||||
543 | # big/medium/small/tiny etc + unsigned? | ||||
544 | $info->{DATA_TYPE} = SQL_INTEGER(); | ||||
545 | $info->{NUM_PREC_RADIX} = 10; | ||||
546 | $info->{COLUMN_SIZE} = $type_params[0]; | ||||
547 | } | ||||
548 | elsif ($basetype =~ /^decimal/) | ||||
549 | { | ||||
550 | $info->{DATA_TYPE} = SQL_DECIMAL(); | ||||
551 | $info->{NUM_PREC_RADIX} = 10; | ||||
552 | $info->{COLUMN_SIZE} = $type_params[0]; | ||||
553 | $info->{DECIMAL_DIGITS} = $type_params[1]; | ||||
554 | } | ||||
555 | elsif ($basetype =~ /^(float|double)/) | ||||
556 | { | ||||
557 | $info->{DATA_TYPE} = ($basetype eq 'float') ? SQL_FLOAT() : SQL_DOUBLE(); | ||||
558 | $info->{NUM_PREC_RADIX} = 2; | ||||
559 | $info->{COLUMN_SIZE} = ($basetype eq 'float') ? 32 : 64; | ||||
560 | } | ||||
561 | elsif ($basetype =~ /date|time/) | ||||
562 | { | ||||
563 | # date/datetime/time/timestamp | ||||
564 | if ($basetype eq 'time' or $basetype eq 'date') | ||||
565 | { | ||||
566 | #$info->{DATA_TYPE} = ($basetype eq 'time') ? SQL_TYPE_TIME() : SQL_TYPE_DATE(); | ||||
567 | $info->{DATA_TYPE} = ($basetype eq 'time') ? SQL_TIME() : SQL_DATE(); | ||||
568 | $info->{COLUMN_SIZE} = ($basetype eq 'time') ? 8 : 10; | ||||
569 | } | ||||
570 | else | ||||
571 | { | ||||
572 | # datetime/timestamp | ||||
573 | #$info->{DATA_TYPE} = SQL_TYPE_TIMESTAMP(); | ||||
574 | $info->{DATA_TYPE} = SQL_TIMESTAMP(); | ||||
575 | $info->{SQL_DATA_TYPE} = SQL_DATETIME(); | ||||
576 | $info->{SQL_DATETIME_SUB} = $info->{DATA_TYPE} - ($info->{SQL_DATA_TYPE} * 10); | ||||
577 | $info->{COLUMN_SIZE} = ($basetype eq 'datetime') ? 19 : $type_params[0] || 14; | ||||
578 | } | ||||
579 | $info->{DECIMAL_DIGITS}= 0; # no fractional seconds | ||||
580 | } | ||||
581 | elsif ($basetype eq 'year') | ||||
582 | { | ||||
583 | # no close standard so treat as int | ||||
584 | $info->{DATA_TYPE} = SQL_INTEGER(); | ||||
585 | $info->{NUM_PREC_RADIX} = 10; | ||||
586 | $info->{COLUMN_SIZE} = 4; | ||||
587 | } | ||||
588 | else | ||||
589 | { | ||||
590 | Carp::carp("column_info: unrecognized column type '$basetype' of $table_id.$row->{field} treated as varchar"); | ||||
591 | } | ||||
592 | $info->{SQL_DATA_TYPE} ||= $info->{DATA_TYPE}; | ||||
593 | #warn Dumper($info); | ||||
594 | } | ||||
595 | |||||
596 | my $sponge = DBI->connect("DBI:Sponge:", '','') | ||||
597 | or ( $dbh->{mysql_server_prepare}= $mysql_server_prepare_save && | ||||
598 | return $dbh->DBI::set_err($DBI::err, "DBI::Sponge: $DBI::errstr")); | ||||
599 | |||||
600 | my $sth = $sponge->prepare("column_info $table", { | ||||
601 | rows => [ map { [ @{$_}{@names} ] } map { $col_info{$_} } @fields ], | ||||
602 | NUM_OF_FIELDS => scalar @names, | ||||
603 | NAME => \@names, | ||||
604 | }) or | ||||
605 | return ($dbh->{mysql_server_prepare}= $mysql_server_prepare_save && | ||||
606 | $dbh->DBI::set_err($sponge->err(), $sponge->errstr())); | ||||
607 | |||||
608 | $dbh->{mysql_server_prepare}= $mysql_server_prepare_save; | ||||
609 | return $sth; | ||||
610 | } | ||||
611 | |||||
612 | |||||
613 | sub primary_key_info { | ||||
614 | my ($dbh, $catalog, $schema, $table) = @_; | ||||
615 | |||||
616 | return unless $dbh->func('_async_check'); | ||||
617 | |||||
618 | $dbh->{mysql_server_prepare}||= 0; | ||||
619 | my $mysql_server_prepare_save= $dbh->{mysql_server_prepare}; | ||||
620 | |||||
621 | my $table_id = $dbh->quote_identifier($catalog, $schema, $table); | ||||
622 | |||||
623 | my @names = qw( | ||||
624 | TABLE_CAT TABLE_SCHEM TABLE_NAME COLUMN_NAME KEY_SEQ PK_NAME | ||||
625 | ); | ||||
626 | my %col_info; | ||||
627 | |||||
628 | local $dbh->{FetchHashKeyName} = 'NAME_lc'; | ||||
629 | my $desc_sth = $dbh->prepare("SHOW KEYS FROM $table_id"); | ||||
630 | my $desc= $dbh->selectall_arrayref($desc_sth, { Columns=>{} }); | ||||
631 | my $ordinal_pos = 0; | ||||
632 | for my $row (grep { $_->{key_name} eq 'PRIMARY'} @$desc) | ||||
633 | { | ||||
634 | $col_info{ $row->{column_name} }= { | ||||
635 | TABLE_CAT => $catalog, | ||||
636 | TABLE_SCHEM => $schema, | ||||
637 | TABLE_NAME => $table, | ||||
638 | COLUMN_NAME => $row->{column_name}, | ||||
639 | KEY_SEQ => $row->{seq_in_index}, | ||||
640 | PK_NAME => $row->{key_name}, | ||||
641 | }; | ||||
642 | } | ||||
643 | |||||
644 | my $sponge = DBI->connect("DBI:Sponge:", '','') | ||||
645 | or | ||||
646 | ($dbh->{mysql_server_prepare}= $mysql_server_prepare_save && | ||||
647 | return $dbh->DBI::set_err($DBI::err, "DBI::Sponge: $DBI::errstr")); | ||||
648 | |||||
649 | my $sth= $sponge->prepare("primary_key_info $table", { | ||||
650 | rows => [ | ||||
651 | map { [ @{$_}{@names} ] } | ||||
652 | sort { $a->{KEY_SEQ} <=> $b->{KEY_SEQ} } | ||||
653 | values %col_info | ||||
654 | ], | ||||
655 | NUM_OF_FIELDS => scalar @names, | ||||
656 | NAME => \@names, | ||||
657 | }) or | ||||
658 | ($dbh->{mysql_server_prepare}= $mysql_server_prepare_save && | ||||
659 | return $dbh->DBI::set_err($sponge->err(), $sponge->errstr())); | ||||
660 | |||||
661 | $dbh->{mysql_server_prepare}= $mysql_server_prepare_save; | ||||
662 | |||||
663 | return $sth; | ||||
664 | } | ||||
665 | |||||
666 | |||||
667 | sub foreign_key_info { | ||||
668 | my ($dbh, | ||||
669 | $pk_catalog, $pk_schema, $pk_table, | ||||
670 | $fk_catalog, $fk_schema, $fk_table, | ||||
671 | ) = @_; | ||||
672 | |||||
673 | return unless $dbh->func('_async_check'); | ||||
674 | |||||
675 | # INFORMATION_SCHEMA.KEY_COLUMN_USAGE was added in 5.0.6 | ||||
676 | # no one is going to be running 5.0.6, taking out the check for $point > .6 | ||||
677 | my ($maj, $min, $point) = _version($dbh); | ||||
678 | return if $maj < 5 ; | ||||
679 | |||||
680 | my $sql = <<'EOF'; | ||||
681 | SELECT NULL AS PKTABLE_CAT, | ||||
682 | A.REFERENCED_TABLE_SCHEMA AS PKTABLE_SCHEM, | ||||
683 | A.REFERENCED_TABLE_NAME AS PKTABLE_NAME, | ||||
684 | A.REFERENCED_COLUMN_NAME AS PKCOLUMN_NAME, | ||||
685 | A.TABLE_CATALOG AS FKTABLE_CAT, | ||||
686 | A.TABLE_SCHEMA AS FKTABLE_SCHEM, | ||||
687 | A.TABLE_NAME AS FKTABLE_NAME, | ||||
688 | A.COLUMN_NAME AS FKCOLUMN_NAME, | ||||
689 | A.ORDINAL_POSITION AS KEY_SEQ, | ||||
690 | NULL AS UPDATE_RULE, | ||||
691 | NULL AS DELETE_RULE, | ||||
692 | A.CONSTRAINT_NAME AS FK_NAME, | ||||
693 | NULL AS PK_NAME, | ||||
694 | NULL AS DEFERABILITY, | ||||
695 | NULL AS UNIQUE_OR_PRIMARY | ||||
696 | FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE A, | ||||
697 | INFORMATION_SCHEMA.TABLE_CONSTRAINTS B | ||||
698 | WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA AND A.TABLE_NAME = B.TABLE_NAME | ||||
699 | AND A.CONSTRAINT_NAME = B.CONSTRAINT_NAME AND B.CONSTRAINT_TYPE IS NOT NULL | ||||
700 | EOF | ||||
701 | |||||
702 | my @where; | ||||
703 | my @bind; | ||||
704 | |||||
705 | # catalogs are not yet supported by MySQL | ||||
706 | |||||
707 | # if (defined $pk_catalog) { | ||||
708 | # push @where, 'A.REFERENCED_TABLE_CATALOG = ?'; | ||||
709 | # push @bind, $pk_catalog; | ||||
710 | # } | ||||
711 | |||||
712 | if (defined $pk_schema) { | ||||
713 | push @where, 'A.REFERENCED_TABLE_SCHEMA = ?'; | ||||
714 | push @bind, $pk_schema; | ||||
715 | } | ||||
716 | |||||
717 | if (defined $pk_table) { | ||||
718 | push @where, 'A.REFERENCED_TABLE_NAME = ?'; | ||||
719 | push @bind, $pk_table; | ||||
720 | } | ||||
721 | |||||
722 | # if (defined $fk_catalog) { | ||||
723 | # push @where, 'A.TABLE_CATALOG = ?'; | ||||
724 | # push @bind, $fk_schema; | ||||
725 | # } | ||||
726 | |||||
727 | if (defined $fk_schema) { | ||||
728 | push @where, 'A.TABLE_SCHEMA = ?'; | ||||
729 | push @bind, $fk_schema; | ||||
730 | } | ||||
731 | |||||
732 | if (defined $fk_table) { | ||||
733 | push @where, 'A.TABLE_NAME = ?'; | ||||
734 | push @bind, $fk_table; | ||||
735 | } | ||||
736 | |||||
737 | if (@where) { | ||||
738 | $sql .= ' AND '; | ||||
739 | $sql .= join ' AND ', @where; | ||||
740 | } | ||||
741 | $sql .= " ORDER BY A.TABLE_SCHEMA, A.TABLE_NAME, A.ORDINAL_POSITION"; | ||||
742 | |||||
743 | local $dbh->{FetchHashKeyName} = 'NAME_uc'; | ||||
744 | my $sth = $dbh->prepare($sql); | ||||
745 | $sth->execute(@bind); | ||||
746 | |||||
747 | return $sth; | ||||
748 | } | ||||
749 | # #86030: PATCH: adding statistics_info support | ||||
750 | # Thank you to David Dick http://search.cpan.org/~ddick/ | ||||
751 | sub statistics_info { | ||||
752 | my ($dbh, | ||||
753 | $catalog, $schema, $table, | ||||
754 | $unique_only, $quick, | ||||
755 | ) = @_; | ||||
756 | |||||
757 | return unless $dbh->func('_async_check'); | ||||
758 | |||||
759 | # INFORMATION_SCHEMA.KEY_COLUMN_USAGE was added in 5.0.6 | ||||
760 | # no one is going to be running 5.0.6, taking out the check for $point > .6 | ||||
761 | my ($maj, $min, $point) = _version($dbh); | ||||
762 | return if $maj < 5 ; | ||||
763 | |||||
764 | my $sql = <<'EOF'; | ||||
765 | SELECT TABLE_CATALOG AS TABLE_CAT, | ||||
766 | TABLE_SCHEMA AS TABLE_SCHEM, | ||||
767 | TABLE_NAME AS TABLE_NAME, | ||||
768 | NON_UNIQUE AS NON_UNIQUE, | ||||
769 | NULL AS INDEX_QUALIFIER, | ||||
770 | INDEX_NAME AS INDEX_NAME, | ||||
771 | LCASE(INDEX_TYPE) AS TYPE, | ||||
772 | SEQ_IN_INDEX AS ORDINAL_POSITION, | ||||
773 | COLUMN_NAME AS COLUMN_NAME, | ||||
774 | COLLATION AS ASC_OR_DESC, | ||||
775 | CARDINALITY AS CARDINALITY, | ||||
776 | NULL AS PAGES, | ||||
777 | NULL AS FILTER_CONDITION | ||||
778 | FROM INFORMATION_SCHEMA.STATISTICS | ||||
779 | EOF | ||||
780 | |||||
781 | my @where; | ||||
782 | my @bind; | ||||
783 | |||||
784 | # catalogs are not yet supported by MySQL | ||||
785 | |||||
786 | # if (defined $catalog) { | ||||
787 | # push @where, 'TABLE_CATALOG = ?'; | ||||
788 | # push @bind, $catalog; | ||||
789 | # } | ||||
790 | |||||
791 | if (defined $schema) { | ||||
792 | push @where, 'TABLE_SCHEMA = ?'; | ||||
793 | push @bind, $schema; | ||||
794 | } | ||||
795 | |||||
796 | if (defined $table) { | ||||
797 | push @where, 'TABLE_NAME = ?'; | ||||
798 | push @bind, $table; | ||||
799 | } | ||||
800 | |||||
801 | if (@where) { | ||||
802 | $sql .= ' WHERE '; | ||||
803 | $sql .= join ' AND ', @where; | ||||
804 | } | ||||
805 | $sql .= " ORDER BY TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION"; | ||||
806 | |||||
807 | local $dbh->{FetchHashKeyName} = 'NAME_uc'; | ||||
808 | my $sth = $dbh->prepare($sql); | ||||
809 | $sth->execute(@bind); | ||||
810 | |||||
811 | return $sth; | ||||
812 | } | ||||
813 | |||||
814 | sub _version { | ||||
815 | my $dbh = shift; | ||||
816 | |||||
817 | return | ||||
818 | $dbh->get_info($DBI::Const::GetInfoType::GetInfoType{SQL_DBMS_VER}) | ||||
819 | =~ /(\d+)\.(\d+)\.(\d+)/; | ||||
820 | } | ||||
821 | |||||
822 | |||||
823 | #################### | ||||
824 | # get_info() | ||||
825 | # Generated by DBI::DBD::Metadata | ||||
826 | |||||
827 | sub get_info { | ||||
828 | my($dbh, $info_type) = @_; | ||||
829 | |||||
830 | return unless $dbh->func('_async_check'); | ||||
831 | require DBD::mysql::GetInfo; | ||||
832 | my $v = $DBD::mysql::GetInfo::info{int($info_type)}; | ||||
833 | $v = $v->($dbh) if ref $v eq 'CODE'; | ||||
834 | return $v; | ||||
835 | } | ||||
836 | |||||
837 | # spent 21µs within DBD::mysql::db::BEGIN@837 which was called:
# once (21µs+0s) by DBI::install_driver at line 850 | ||||
838 | 1 | 1µs | my @needs_async_check = qw/data_sources quote_identifier begin_work/; | ||
839 | |||||
840 | 1 | 5µs | foreach my $method (@needs_async_check) { | ||
841 | 2 | 66µs | 2 | 33µs | # spent 20µs (6+13) within DBD::mysql::db::BEGIN@841 which was called:
# once (6µs+13µs) by DBI::install_driver at line 841 # spent 20µs making 1 call to DBD::mysql::db::BEGIN@841
# spent 13µs making 1 call to strict::unimport |
842 | |||||
843 | 3 | 3µs | my $super = "SUPER::$method"; | ||
844 | *$method = sub { | ||||
845 | my $h = shift; | ||||
846 | return unless $h->func('_async_check'); | ||||
847 | return $h->$super(@_); | ||||
848 | 3 | 13µs | }; | ||
849 | } | ||||
850 | 1 | 17µs | 1 | 21µs | } # spent 21µs making 1 call to DBD::mysql::db::BEGIN@837 |
851 | |||||
852 | |||||
853 | package DBD::mysql::st; # ====== STATEMENT ====== | ||||
854 | 2 | 34µs | 2 | 7µs | # spent 6µs (5+1) within DBD::mysql::st::BEGIN@854 which was called:
# once (5µs+1µs) by DBI::install_driver at line 854 # spent 6µs making 1 call to DBD::mysql::st::BEGIN@854
# spent 1µs making 1 call to strict::import |
855 | |||||
856 | # spent 15µs within DBD::mysql::st::BEGIN@856 which was called:
# once (15µs+0s) by DBI::install_driver at line 883 | ||||
857 | 1 | 600ns | my @needs_async_result = qw/fetchrow_hashref fetchall_hashref/; | ||
858 | 1 | 300ns | my @needs_async_check = qw/bind_param_array bind_col bind_columns execute_for_fetch/; | ||
859 | |||||
860 | 1 | 300ns | foreach my $method (@needs_async_result) { | ||
861 | 2 | 61µs | 2 | 15µs | # spent 9µs (4+6) within DBD::mysql::st::BEGIN@861 which was called:
# once (4µs+6µs) by DBI::install_driver at line 861 # spent 9µs making 1 call to DBD::mysql::st::BEGIN@861
# spent 6µs making 1 call to strict::unimport |
862 | |||||
863 | 2 | 700ns | my $super = "SUPER::$method"; | ||
864 | # spent 397ms (149+249) within DBD::mysql::st::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/DBD/mysql.pm:870] which was called 18950 times, avg 21µs/call:
# 4650 times (37.2ms+59.3ms) by DBI::st::fetchrow_hashref at line 304 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 21µs/call
# 4650 times (35.0ms+60.4ms) by DBI::st::fetchrow_hashref at line 274 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 21µs/call
# 4650 times (27.5ms+52.9ms) by DBI::st::fetchrow_hashref at line 325 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 17µs/call
# 1000 times (9.68ms+19.9ms) by DBI::st::fetchrow_hashref at line 418 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 30µs/call
# 1000 times (9.74ms+18.6ms) by DBI::st::fetchrow_hashref at line 436 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 28µs/call
# 1000 times (11.9ms+12.0ms) by DBI::st::fetchrow_hashref at line 186 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 24µs/call
# 1000 times (6.49ms+15.3ms) by DBI::st::fetchrow_hashref at line 647 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 22µs/call
# 1000 times (11.0ms+10.4ms) by DBI::st::fetchrow_hashref at line 238 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 21µs/call | ||||
865 | 18950 | 6.33ms | my $sth = shift; | ||
866 | 18950 | 86.4ms | 18950 | 19.4ms | if(defined $sth->mysql_async_ready) { # spent 19.4ms making 18950 calls to DBI::st::mysql_async_ready, avg 1µs/call |
867 | return unless $sth->mysql_async_result; | ||||
868 | } | ||||
869 | 18950 | 371ms | 56850 | 306ms | return $sth->$super(@_); # spent 229ms making 18950 calls to DBD::_::st::fetchrow_hashref, avg 12µs/call
# spent 43.2ms making 18950 calls to DBI::common::FETCH, avg 2µs/call
# spent 33.4ms making 18950 calls to DBI::st::fetch, avg 2µs/call |
870 | 2 | 4µs | }; | ||
871 | } | ||||
872 | |||||
873 | 1 | 4µs | foreach my $method (@needs_async_check) { | ||
874 | 2 | 42µs | 2 | 16µs | # spent 10µs (4+6) within DBD::mysql::st::BEGIN@874 which was called:
# once (4µs+6µs) by DBI::install_driver at line 874 # spent 10µs making 1 call to DBD::mysql::st::BEGIN@874
# spent 6µs making 1 call to strict::unimport |
875 | |||||
876 | 4 | 900ns | my $super = "SUPER::$method"; | ||
877 | # spent 63.1ms (17.0+46.2) within DBD::mysql::st::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/DBD/mysql.pm:881] which was called 3000 times, avg 21µs/call:
# 2000 times (8.66ms+2.86ms) by DBI::st::bind_col at line 1919 of DBI.pm, avg 6µs/call
# 1000 times (8.29ms+43.3ms) by DBI::st::bind_columns at line 2083 of DBI.pm, avg 52µs/call | ||||
878 | 3000 | 722µs | my $h = shift; | ||
879 | 3000 | 8.88ms | 3000 | 3.13ms | return unless $h->func('_async_check'); # spent 3.13ms making 3000 calls to DBI::common::func, avg 1µs/call |
880 | 3000 | 26.0ms | 3000 | 43.0ms | return $h->$super(@_); # spent 41.2ms making 1000 calls to DBD::_::st::bind_columns, avg 41µs/call
# spent 1.80ms making 2000 calls to DBD::_::st::bind_col, avg 899ns/call |
881 | 4 | 6µs | }; | ||
882 | } | ||||
883 | 1 | 19µs | 1 | 15µs | } # spent 15µs making 1 call to DBD::mysql::st::BEGIN@856 |
884 | |||||
885 | 1 | 6µs | 1; | ||
886 | |||||
887 | __END__ | ||||
sub DBD::mysql::CORE:match; # opcode | |||||
# spent 59µs within DBD::mysql::bootstrap which was called:
# once (59µs+0s) by DynaLoader::bootstrap at line 216 of DynaLoader.pm | |||||
# spent 1.05ms within DBD::mysql::db::_login which was called:
# once (1.05ms+0s) by DBD::mysql::dr::connect at line 160 | |||||
# spent 36µs within DBD::mysql::st::_prepare which was called 15 times, avg 2µs/call:
# 15 times (36µs+0s) by DBD::mysql::db::prepare at line 246, avg 2µs/call |