← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:07 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/DBD/mysql.pm
StatementsExecuted 66031 statements in 504ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1895081149ms397msDBD::mysql::st::::__ANON__[:870]DBD::mysql::st::__ANON__[:870]
30002117.0ms63.1msDBD::mysql::st::::__ANON__[:881]DBD::mysql::st::__ANON__[:881]
1111.05ms1.05msDBD::mysql::db::::_loginDBD::mysql::db::_login (xsub)
111187µs2.37msDBD::mysql::dr::::BEGIN@119DBD::mysql::dr::BEGIN@119
1511121µs456µsDBD::mysql::db::::prepareDBD::mysql::db::prepare
11159µs59µsDBD::mysql::::bootstrap DBD::mysql::bootstrap (xsub)
11139µs142µsDBD::mysql::::driver DBD::mysql::driver
151136µs36µsDBD::mysql::st::::_prepareDBD::mysql::st::_prepare (xsub)
11126µs1.12msDBD::mysql::dr::::connectDBD::mysql::dr::connect
11121µs21µsDBD::mysql::db::::BEGIN@837DBD::mysql::db::BEGIN@837
11115µs15µsDBD::mysql::st::::BEGIN@856DBD::mysql::st::BEGIN@856
22115µs15µsDBD::mysql::::CORE:match DBD::mysql::CORE:match (opcode)
11112µs26µsDBD::mysql::::_OdbcParse DBD::mysql::_OdbcParse
11110µs11µsDBI::_firesafe::::BEGIN@3DBI::_firesafe::BEGIN@3
1118µs10µsDBD::mysql::dr::::BEGIN@117DBD::mysql::dr::BEGIN@117
1117µs28µsDBD::mysql::::BEGIN@9 DBD::mysql::BEGIN@9
1116µs8µsDBD::mysql::db::::BEGIN@204DBD::mysql::db::BEGIN@204
1116µs20µsDBD::mysql::db::::BEGIN@841DBD::mysql::db::BEGIN@841
1116µs9µsDBI::_firesafe::::BEGIN@4DBI::_firesafe::BEGIN@4
1115µs6µsDBD::mysql::st::::BEGIN@854DBD::mysql::st::BEGIN@854
1114µs28µsDBD::mysql::::BEGIN@11 DBD::mysql::BEGIN@11
1114µs10µsDBD::mysql::st::::BEGIN@874DBD::mysql::st::BEGIN@874
1114µs186µsDBD::mysql::db::::BEGIN@205DBD::mysql::db::BEGIN@205
1114µs365µsDBD::mysql::dr::::BEGIN@118DBD::mysql::dr::BEGIN@118
1114µs9µsDBD::mysql::st::::BEGIN@861DBD::mysql::st::BEGIN@861
1112µs2µsDBD::mysql::::BEGIN@10 DBD::mysql::BEGIN@10
0000s0sDBD::mysql::::AUTOLOAD DBD::mysql::AUTOLOAD
0000s0sDBD::mysql::::CLONE DBD::mysql::CLONE
0000s0sDBD::mysql::::_OdbcParseHost DBD::mysql::_OdbcParseHost
0000s0sDBD::mysql::db::::ANSI2dbDBD::mysql::db::ANSI2db
0000s0sDBD::mysql::db::::_ListTablesDBD::mysql::db::_ListTables
0000s0sDBD::mysql::db::::_SelectDBDBD::mysql::db::_SelectDB
0000s0sDBD::mysql::db::::__ANON__[:848]DBD::mysql::db::__ANON__[:848]
0000s0sDBD::mysql::db::::_versionDBD::mysql::db::_version
0000s0sDBD::mysql::db::::adminDBD::mysql::db::admin
0000s0sDBD::mysql::db::::column_infoDBD::mysql::db::column_info
0000s0sDBD::mysql::db::::db2ANSIDBD::mysql::db::db2ANSI
0000s0sDBD::mysql::db::::foreign_key_infoDBD::mysql::db::foreign_key_info
0000s0sDBD::mysql::db::::get_infoDBD::mysql::db::get_info
0000s0sDBD::mysql::db::::primary_key_infoDBD::mysql::db::primary_key_info
0000s0sDBD::mysql::db::::statistics_infoDBD::mysql::db::statistics_info
0000s0sDBD::mysql::db::::table_infoDBD::mysql::db::table_info
0000s0sDBD::mysql::dr::::adminDBD::mysql::dr::admin
0000s0sDBD::mysql::dr::::data_sourcesDBD::mysql::dr::data_sources
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1#!/usr/bin/perl
2
3215µs213µ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
use strict;
# spent 11µs making 1 call to DBI::_firesafe::BEGIN@3 # spent 2µs making 1 call to strict::import
4217µs212µ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
use warnings;
# spent 9µs making 1 call to DBI::_firesafe::BEGIN@4 # spent 3µs making 1 call to warnings::import
518µsrequire 5.008_001; # just as DBI
6
7package DBD::mysql;
8
9216µs250µ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
use DBI;
# spent 28µs making 1 call to DBD::mysql::BEGIN@9 # spent 21µs making 1 call to Exporter::import
10213µs12µs
# spent 2µs within DBD::mysql::BEGIN@10 which was called: # once (2µs+0s) by DBI::install_driver at line 10
use DynaLoader();
# spent 2µs making 1 call to DBD::mysql::BEGIN@10
112388µs251µ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
use Carp;
# spent 28µs making 1 call to DBD::mysql::BEGIN@11 # spent 23µs making 1 call to Exporter::import
1215µsour @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
181100nsour $VERSION = '4.040';
19
2014µs11.08msbootstrap DBD::mysql $VERSION;
# spent 1.08ms making 1 call to DynaLoader::bootstrap
21
22
231200nsour $err = 0; # holds error code for DBI::err
241200nsour $errstr = ""; # holds error string for DBI::errstr
251200nsour $drh = undef; # holds driver handle once initialised
26
271200nsmy $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
sub driver{
291200ns return $drh if $drh;
301400ns my($class, $attr) = @_;
31
321500ns $class .= "::dr";
33
34 # not a 'my' since we use it above to prevent multiple drivers
3514µs129µ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
421300ns if (!$methods_are_installed) {
4313µs130µs DBD::mysql::db->install_method('mysql_fd');
# spent 30µs making 1 call to DBD::_::common::install_method
441900ns113µs DBD::mysql::db->install_method('mysql_async_result');
# spent 13µs making 1 call to DBD::_::common::install_method
451700ns110µs DBD::mysql::db->install_method('mysql_async_ready');
# spent 10µs making 1 call to DBD::_::common::install_method
4612µs111µs DBD::mysql::st->install_method('mysql_async_result');
# spent 11µs making 1 call to DBD::_::common::install_method
47120µs111µs DBD::mysql::st->install_method('mysql_async_ready');
# spent 11µs making 1 call to DBD::_::common::install_method
48
491500ns $methods_are_installed++;
50 }
51
5213µs $drh;
53}
54
55sub 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
sub _OdbcParse($$$) {
601300ns my($class, $dsn, $hash, $args) = @_;
611100ns my($var, $val);
6211µs if (!defined($dsn)) {
63 return;
64 }
6513µs while (length($dsn)) {
66117µs113µ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 {
711300ns $val = $dsn;
721400ns $dsn = '';
73 }
7413µs11µs if ($val =~ /([^=]*)=(.*)/) {
# spent 1µs making 1 call to DBD::mysql::CORE:match
751500ns $var = $1;
761800ns $val = $2;
771900ns 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 {
821400ns $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
95sub _OdbcParseHost ($$) {
96 my($class, $dsn) = @_;
97 my($hash) = {};
98 $class->_OdbcParse($dsn, $hash, ['host', 'port']);
99 ($hash->{'host'}, $hash->{'port'});
100}
101
102sub 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
1131;
114
115
116package DBD::mysql::dr; # ====== DRIVER ======
117216µs211µ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
use strict;
# spent 10µs making 1 call to DBD::mysql::dr::BEGIN@117 # spent 1µs making 1 call to strict::import
118218µs2727µ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
use DBI qw(:sql_types);
# spent 365µs making 1 call to DBD::mysql::dr::BEGIN@118 # spent 361µs making 1 call to Exporter::import
1192549µs22.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
use DBI::Const::GetInfoType;
# 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
sub connect {
1221500ns my($drh, $dsn, $username, $password, $attrhash) = @_;
1231200ns my($port);
124 my($cWarn);
1251600ns my $connect_ref= { 'Name' => $dsn };
1261100ns my $dbi_imp_data;
127
128 # Avoid warnings for undefined values
1291100ns $username ||= '';
1301100ns $password ||= '';
1311100ns $attrhash ||= {};
1321500ns $attrhash->{mysql_conn_attrs} ||= {};
13312µs $attrhash->{mysql_conn_attrs}->{'program_name'} ||= $0;
134
135 # create a 'blank' dbh
1361300ns my($this, $privateAttrHash) = (undef, $attrhash);
13713µs $privateAttrHash = { %$privateAttrHash,
138 'Name' => $dsn,
139 'user' => $username,
140 'password' => $password
141 };
142
14312µs126µs DBD::mysql->_OdbcParse($dsn, $privateAttrHash,
# spent 26µs making 1 call to DBD::mysql::_OdbcParse
144 ['database', 'host', 'port']);
145
146
14711µs if ($DBI::VERSION >= 1.49)
148 {
1491300ns $dbi_imp_data = delete $attrhash->{dbi_imp_data};
1501200ns $connect_ref->{'dbi_imp_data'} = $dbi_imp_data;
151 }
152
15311µs120µ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
16011.05ms11.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
16314µs if ($this && ($ENV{MOD_PERL} || $ENV{GATEWAY_INTERFACE})) {
164 $this->{mysql_auto_reconnect} = 1;
165 }
16613µs $this;
167}
168
169sub 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
187sub 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
203package DBD::mysql::db; # ====== DATABASE ======
204215µs29µ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
use strict;
# spent 8µs making 1 call to DBD::mysql::db::BEGIN@204 # spent 2µs making 1 call to strict::import
20521.36ms2369µ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
use DBI qw(:sql_types);
# spent 186µs making 1 call to DBD::mysql::db::BEGIN@205 # spent 182µs making 1 call to Exporter::import
206
20712µ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
21516µ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
sub prepare {
238156µs my($dbh, $statement, $attribs)= @_;
239
2401549µs1520µ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
2431536µs15279µ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.
2461563µs1536µ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
2501536µs $sth;
251}
252
253sub db2ANSI {
254 my $self = shift;
255 my $type = shift;
256 return $DBD::mysql::db::db2ANSI{"$type"};
257}
258
259sub ANSI2db {
260 my $self = shift;
261 my $type = shift;
262 return $DBD::mysql::db::ANSI2db{"$type"};
263}
264
265sub 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
274sub _SelectDB ($$) {
275 die "_SelectDB is removed from this module; use DBI->connect instead.";
276}
277
278sub 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
408sub _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
417sub 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
613sub 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
667sub 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';
681SELECT 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
700EOF
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/
751sub 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';
765SELECT 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
779EOF
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
814sub _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
827sub 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
BEGIN {
83811µs my @needs_async_check = qw/data_sources quote_identifier begin_work/;
839
84015µs foreach my $method (@needs_async_check) {
841266µs233µ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
no strict 'refs';
# spent 20µs making 1 call to DBD::mysql::db::BEGIN@841 # spent 13µs making 1 call to strict::unimport
842
84333µs my $super = "SUPER::$method";
844 *$method = sub {
845 my $h = shift;
846 return unless $h->func('_async_check');
847 return $h->$super(@_);
848313µs };
849 }
850117µs121µs}
# spent 21µs making 1 call to DBD::mysql::db::BEGIN@837
851
852
853package DBD::mysql::st; # ====== STATEMENT ======
854234µs27µ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
use strict;
# 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
BEGIN {
8571600ns my @needs_async_result = qw/fetchrow_hashref fetchall_hashref/;
8581300ns my @needs_async_check = qw/bind_param_array bind_col bind_columns execute_for_fetch/;
859
8601300ns foreach my $method (@needs_async_result) {
861261µs215µ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
no strict 'refs';
# spent 9µs making 1 call to DBD::mysql::st::BEGIN@861 # spent 6µs making 1 call to strict::unimport
862
8632700ns 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
*$method = sub {
865189506.33ms my $sth = shift;
8661895086.4ms1895019.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 }
86918950371ms56850306ms 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
87024µs };
871 }
872
87314µs foreach my $method (@needs_async_check) {
874242µs216µ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
no strict 'refs';
# spent 10µs making 1 call to DBD::mysql::st::BEGIN@874 # spent 6µs making 1 call to strict::unimport
875
8764900ns 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
*$method = sub {
8783000722µs my $h = shift;
87930008.88ms30003.13ms return unless $h->func('_async_check');
# spent 3.13ms making 3000 calls to DBI::common::func, avg 1µs/call
880300026.0ms300043.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
88146µs };
882 }
883119µs115µs}
# spent 15µs making 1 call to DBD::mysql::st::BEGIN@856
884
88516µs1;
886
887__END__
 
# spent 15µs within DBD::mysql::CORE:match which was called 2 times, avg 7µs/call: # once (13µs+0s) by DBD::mysql::_OdbcParse at line 66 # once (1µs+0s) by DBD::mysql::_OdbcParse at line 74
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
sub DBD::mysql::bootstrap; # xsub
# spent 1.05ms within DBD::mysql::db::_login which was called: # once (1.05ms+0s) by DBD::mysql::dr::connect at line 160
sub DBD::mysql::db::_login; # xsub
# 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
sub DBD::mysql::st::_prepare; # xsub