Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/Storage/DBI/SQLite.pm |
Statements | Executed 43308 statements in 209ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
8019 | 1 | 1 | 208ms | 456ms | _dbi_attrs_for_bind | DBIx::Class::Storage::DBI::SQLite::
14 | 1 | 1 | 131µs | 185µs | bind_attribute_by_data_type | DBIx::Class::Storage::DBI::SQLite::
4 | 2 | 2 | 115µs | 254ms | deployment_statements | DBIx::Class::Storage::DBI::SQLite::
14 | 1 | 1 | 38µs | 38µs | CORE:match (opcode) | DBIx::Class::Storage::DBI::SQLite::
1 | 1 | 1 | 20µs | 25µs | BEGIN@3 | DBIx::Class::Storage::DBI::SQLite::
6 | 5 | 2 | 10µs | 11µs | _dbh_autocommit (xsub) | DBIx::Class::Storage::DBI::SQLite::
1 | 1 | 1 | 10µs | 30µs | BEGIN@4 | DBIx::Class::Storage::DBI::SQLite::
5 | 5 | 3 | 9µs | 9µs | debug (xsub) | DBIx::Class::Storage::DBI::SQLite::
5 | 5 | 3 | 9µs | 9µs | transaction_depth (xsub) | DBIx::Class::Storage::DBI::SQLite::
1 | 1 | 1 | 9µs | 102µs | BEGIN@9 | DBIx::Class::Storage::DBI::SQLite::
1 | 1 | 1 | 9µs | 102µs | BEGIN@6 | DBIx::Class::Storage::DBI::SQLite::
1 | 1 | 1 | 8µs | 46µs | BEGIN@10 | DBIx::Class::Storage::DBI::SQLite::
1 | 1 | 1 | 8µs | 179µs | BEGIN@11 | DBIx::Class::Storage::DBI::SQLite::
1 | 1 | 1 | 7µs | 17µs | BEGIN@7 | DBIx::Class::Storage::DBI::SQLite::
3 | 3 | 2 | 3µs | 3µs | _conn_pid (xsub) | DBIx::Class::Storage::DBI::SQLite::
2 | 2 | 2 | 2µs | 2µs | unsafe (xsub) | DBIx::Class::Storage::DBI::SQLite::
2 | 2 | 2 | 2µs | 2µs | disable_sth_caching (xsub) | DBIx::Class::Storage::DBI::SQLite::
2 | 2 | 2 | 2µs | 2µs | on_connect_call (xsub) | DBIx::Class::Storage::DBI::SQLite::
2 | 2 | 2 | 1µs | 1µs | on_connect_do (xsub) | DBIx::Class::Storage::DBI::SQLite::
0 | 0 | 0 | 0s | 0s | _exec_svp_begin | DBIx::Class::Storage::DBI::SQLite::
0 | 0 | 0 | 0s | 0s | _exec_svp_release | DBIx::Class::Storage::DBI::SQLite::
0 | 0 | 0 | 0s | 0s | _exec_svp_rollback | DBIx::Class::Storage::DBI::SQLite::
0 | 0 | 0 | 0s | 0s | backup | DBIx::Class::Storage::DBI::SQLite::
0 | 0 | 0 | 0s | 0s | connect_call_use_foreign_keys | DBIx::Class::Storage::DBI::SQLite::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package DBIx::Class::Storage::DBI::SQLite; | ||||
2 | |||||
3 | 3 | 22µs | 2 | 30µs | # spent 25µs (20+5) within DBIx::Class::Storage::DBI::SQLite::BEGIN@3 which was called:
# once (20µs+5µs) by Class::C3::Componentised::ensure_class_loaded at line 3 # spent 25µs making 1 call to DBIx::Class::Storage::DBI::SQLite::BEGIN@3
# spent 5µs making 1 call to strict::import |
4 | 3 | 27µs | 2 | 51µs | # spent 30µs (10+21) within DBIx::Class::Storage::DBI::SQLite::BEGIN@4 which was called:
# once (10µs+21µs) by Class::C3::Componentised::ensure_class_loaded at line 4 # spent 30µs making 1 call to DBIx::Class::Storage::DBI::SQLite::BEGIN@4
# spent 21µs making 1 call to warnings::import |
5 | |||||
6 | 3 | 22µs | 2 | 196µs | # spent 102µs (9+94) within DBIx::Class::Storage::DBI::SQLite::BEGIN@6 which was called:
# once (9µs+94µs) by Class::C3::Componentised::ensure_class_loaded at line 6 # spent 102µs making 1 call to DBIx::Class::Storage::DBI::SQLite::BEGIN@6
# spent 94µs making 1 call to base::import |
7 | 3 | 20µs | 2 | 26µs | # spent 17µs (7+10) within DBIx::Class::Storage::DBI::SQLite::BEGIN@7 which was called:
# once (7µs+10µs) by Class::C3::Componentised::ensure_class_loaded at line 7 # spent 17µs making 1 call to DBIx::Class::Storage::DBI::SQLite::BEGIN@7
# spent 10µs making 1 call to mro::import |
8 | |||||
9 | 3 | 21µs | 2 | 196µs | # spent 102µs (9+93) within DBIx::Class::Storage::DBI::SQLite::BEGIN@9 which was called:
# once (9µs+93µs) by Class::C3::Componentised::ensure_class_loaded at line 9 # spent 102µs making 1 call to DBIx::Class::Storage::DBI::SQLite::BEGIN@9
# spent 93µs making 1 call to DBIx::Class::Carp::import |
10 | 3 | 20µs | 2 | 83µs | # spent 46µs (8+37) within DBIx::Class::Storage::DBI::SQLite::BEGIN@10 which was called:
# once (8µs+37µs) by Class::C3::Componentised::ensure_class_loaded at line 10 # spent 46µs making 1 call to DBIx::Class::Storage::DBI::SQLite::BEGIN@10
# spent 37µs making 1 call to Exporter::import |
11 | 3 | 629µs | 2 | 350µs | # spent 179µs (8+171) within DBIx::Class::Storage::DBI::SQLite::BEGIN@11 which was called:
# once (8µs+171µs) by Class::C3::Componentised::ensure_class_loaded at line 11 # spent 179µs making 1 call to DBIx::Class::Storage::DBI::SQLite::BEGIN@11
# spent 171µs making 1 call to namespace::clean::import |
12 | |||||
13 | 1 | 10µs | 1 | 46µs | __PACKAGE__->sql_maker_class('DBIx::Class::SQLMaker::SQLite'); # spent 46µs making 1 call to DBIx::Class::Storage::DBI::sql_maker_class |
14 | 1 | 5µs | 1 | 14µs | __PACKAGE__->sql_limit_dialect ('LimitOffset'); # spent 14µs making 1 call to DBIx::Class::Storage::DBI::sql_limit_dialect |
15 | 1 | 5µs | 1 | 12µs | __PACKAGE__->sql_quote_char ('"'); # spent 12µs making 1 call to DBIx::Class::Storage::DBI::sql_quote_char |
16 | 1 | 4µs | 1 | 4µs | __PACKAGE__->datetime_parser_type ('DateTime::Format::SQLite'); # spent 4µs making 1 call to DBIx::Class::Storage::DBI::datetime_parser_type |
17 | |||||
18 | sub backup { | ||||
19 | |||||
20 | require File::Spec; | ||||
21 | require File::Copy; | ||||
22 | require POSIX; | ||||
23 | |||||
24 | my ($self, $dir) = @_; | ||||
25 | $dir ||= './'; | ||||
26 | |||||
27 | ## Where is the db file? | ||||
28 | my $dsn = $self->_dbi_connect_info()->[0]; | ||||
29 | |||||
30 | my $dbname = $1 if($dsn =~ /dbname=([^;]+)/); | ||||
31 | if(!$dbname) | ||||
32 | { | ||||
33 | $dbname = $1 if($dsn =~ /^dbi:SQLite:(.+)$/i); | ||||
34 | } | ||||
35 | $self->throw_exception("Cannot determine name of SQLite db file") | ||||
36 | if(!$dbname || !-f $dbname); | ||||
37 | |||||
38 | # print "Found database: $dbname\n"; | ||||
39 | # my $dbfile = file($dbname); | ||||
40 | my ($vol, $dbdir, $file) = File::Spec->splitpath($dbname); | ||||
41 | # my $file = $dbfile->basename(); | ||||
42 | $file = POSIX::strftime("%Y-%m-%d-%H_%M_%S", localtime()) . $file; | ||||
43 | $file = "B$file" while(-f $file); | ||||
44 | |||||
45 | mkdir($dir) unless -f $dir; | ||||
46 | my $backupfile = File::Spec->catfile($dir, $file); | ||||
47 | |||||
48 | my $res = File::Copy::copy($dbname, $backupfile); | ||||
49 | $self->throw_exception("Backup failed! ($!)") if(!$res); | ||||
50 | |||||
51 | return $backupfile; | ||||
52 | } | ||||
53 | |||||
54 | sub _exec_svp_begin { | ||||
55 | my ($self, $name) = @_; | ||||
56 | |||||
57 | $self->_dbh->do("SAVEPOINT $name"); | ||||
58 | } | ||||
59 | |||||
60 | sub _exec_svp_release { | ||||
61 | my ($self, $name) = @_; | ||||
62 | |||||
63 | $self->_dbh->do("RELEASE SAVEPOINT $name"); | ||||
64 | } | ||||
65 | |||||
66 | sub _exec_svp_rollback { | ||||
67 | my ($self, $name) = @_; | ||||
68 | |||||
69 | # For some reason this statement changes the value of $dbh->{AutoCommit}, so | ||||
70 | # we localize it here to preserve the original value. | ||||
71 | local $self->_dbh->{AutoCommit} = $self->_dbh->{AutoCommit}; | ||||
72 | |||||
73 | $self->_dbh->do("ROLLBACK TRANSACTION TO SAVEPOINT $name"); | ||||
74 | } | ||||
75 | |||||
76 | # spent 254ms (115µs+254) within DBIx::Class::Storage::DBI::SQLite::deployment_statements which was called 4 times, avg 63.4ms/call:
# 2 times (61µs+247ms) by DBIx::Class::Schema::deployment_statements at line 128 of DBIx/Class/Storage/DBI.pm, avg 123ms/call
# 2 times (54µs+7.03ms) by DBIx::Class::Schema::deployment_statements at line 1144 of DBIx/Class/Schema.pm, avg 3.54ms/call | ||||
77 | 20 | 74µs | my $self = shift; | ||
78 | my ($schema, $type, $version, $dir, $sqltargs, @rest) = @_; | ||||
79 | |||||
80 | $sqltargs ||= {}; | ||||
81 | |||||
82 | 4 | 19µs | if ( # spent 19µs making 4 calls to DBIx::Class::Storage::DBI::_server_info, avg 5µs/call | ||
83 | ! exists $sqltargs->{producer_args}{sqlite_version} | ||||
84 | and | ||||
85 | my $dver = $self->_server_info->{normalized_dbms_version} | ||||
86 | ) { | ||||
87 | $sqltargs->{producer_args}{sqlite_version} = $dver; | ||||
88 | } | ||||
89 | |||||
90 | 4 | 50µs | $self->next::method($schema, $type, $version, $dir, $sqltargs, @rest); # spent 50µs making 4 calls to next::method, avg 13µs/call | ||
91 | } | ||||
92 | |||||
93 | # spent 185µs (131+54) within DBIx::Class::Storage::DBI::SQLite::bind_attribute_by_data_type which was called 14 times, avg 13µs/call:
# 14 times (131µs+54µs) by DBIx::Class::Storage::DBI::_dbi_attrs_for_bind at line 1535 of DBIx/Class/Storage/DBI.pm, avg 13µs/call | ||||
94 | $_[1] =~ /^ (?: int(?:eger)? | (?:tiny|small|medium)int ) $/ix | ||||
95 | 28 | 210µs | 21 | 54µs | ? do { require DBI; DBI::SQL_INTEGER() } # spent 38µs making 14 calls to DBIx::Class::Storage::DBI::SQLite::CORE:match, avg 3µs/call
# spent 16µs making 7 calls to DBI::SQL_INTEGER, avg 2µs/call |
96 | : undef | ||||
97 | ; | ||||
98 | } | ||||
99 | |||||
100 | # DBD::SQLite (at least up to version 1.31 has a bug where it will | ||||
101 | # non-fatally nummify a string value bound as an integer, resulting | ||||
102 | # in insertions of '0' into supposed-to-be-numeric fields | ||||
103 | # Since this can result in severe data inconsistency, remove the | ||||
104 | # bind attr if such a sitation is detected | ||||
105 | # | ||||
106 | # FIXME - when a DBD::SQLite version is released that eventually fixes | ||||
107 | # this sutiation (somehow) - no-op this override once a proper DBD | ||||
108 | # version is detected | ||||
109 | # spent 456ms (208+249) within DBIx::Class::Storage::DBI::SQLite::_dbi_attrs_for_bind which was called 8019 times, avg 57µs/call:
# 8019 times (208ms+249ms) by DBIx::Class::Storage::DBI::_execute at line 1558 of DBIx/Class/Storage/DBI.pm, avg 57µs/call | ||||
110 | 32076 | 72.3ms | my ($self, $ident, $bind) = @_; | ||
111 | 8019 | 64.0ms | my $bindattrs = $self->next::method($ident, $bind); # spent 64.0ms making 8019 calls to next::method, avg 8µs/call | ||
112 | |||||
113 | for (0.. $#$bindattrs) { | ||||
114 | 11158 | 136ms | 17978 | 42.7ms | if ( # spent 21.9ms making 8989 calls to DBI::SQL_INTEGER, avg 2µs/call
# spent 20.8ms making 8989 calls to Scalar::Util::looks_like_number, avg 2µs/call |
115 | defined $bindattrs->[$_] | ||||
116 | and | ||||
117 | defined $bind->[$_][1] | ||||
118 | and | ||||
119 | $bindattrs->[$_] eq DBI::SQL_INTEGER() | ||||
120 | and | ||||
121 | ! looks_like_number ($bind->[$_][1]) | ||||
122 | ) { | ||||
123 | carp_unique( sprintf ( | ||||
124 | "Non-numeric value supplied for column '%s' despite the numeric datatype", | ||||
125 | $bind->[$_][0]{dbic_colname} || "# $_" | ||||
126 | ) ); | ||||
127 | undef $bindattrs->[$_]; | ||||
128 | } | ||||
129 | } | ||||
130 | |||||
131 | return $bindattrs; | ||||
132 | } | ||||
133 | |||||
134 | =head2 connect_call_use_foreign_keys | ||||
135 | |||||
136 | Used as: | ||||
137 | |||||
138 | on_connect_call => 'use_foreign_keys' | ||||
139 | |||||
140 | In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to turn on foreign key | ||||
141 | (including cascading) support for recent versions of SQLite and L<DBD::SQLite>. | ||||
142 | |||||
143 | Executes: | ||||
144 | |||||
145 | PRAGMA foreign_keys = ON | ||||
146 | |||||
147 | See L<http://www.sqlite.org/foreignkeys.html> for more information. | ||||
148 | |||||
149 | =cut | ||||
150 | |||||
151 | sub connect_call_use_foreign_keys { | ||||
152 | my $self = shift; | ||||
153 | |||||
154 | $self->_do_query( | ||||
155 | 'PRAGMA foreign_keys = ON' | ||||
156 | ); | ||||
157 | } | ||||
158 | |||||
159 | 1 | 4µs | 1; | ||
160 | |||||
161 | =head1 NAME | ||||
162 | |||||
163 | DBIx::Class::Storage::DBI::SQLite - Automatic primary key class for SQLite | ||||
164 | |||||
165 | =head1 SYNOPSIS | ||||
166 | |||||
167 | # In your table classes | ||||
168 | use base 'DBIx::Class::Core'; | ||||
169 | __PACKAGE__->set_primary_key('id'); | ||||
170 | |||||
171 | =head1 DESCRIPTION | ||||
172 | |||||
173 | This class implements autoincrements for SQLite. | ||||
174 | |||||
175 | =head1 AUTHORS | ||||
176 | |||||
177 | Matt S. Trout <mst@shadowcatsystems.co.uk> | ||||
178 | |||||
179 | =head1 LICENSE | ||||
180 | |||||
181 | You may distribute this code under the same terms as Perl itself. | ||||
182 | |||||
183 | 1 | 8µs | 1 | 362µs | =cut # spent 362µs making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:26] |
# spent 38µs within DBIx::Class::Storage::DBI::SQLite::CORE:match which was called 14 times, avg 3µs/call:
# 14 times (38µs+0s) by DBIx::Class::Storage::DBI::SQLite::bind_attribute_by_data_type at line 95, avg 3µs/call | |||||
# spent 3µs within DBIx::Class::Storage::DBI::SQLite::_conn_pid which was called 3 times, avg 900ns/call:
# once (2µs+0s) by DBIx::Class::Storage::DBI::_populate_dbh at line 1010 of DBIx/Class/Storage/DBI.pm
# once (700ns+0s) by DBIx::Class::Storage::DBI::_verify_pid at line 242 of DBIx/Class/Storage/DBI.pm
# once (500ns+0s) by DBIx::Class::Storage::DBI::_verify_pid at line 781 of Class/Accessor/Grouped.pm | |||||
# spent 11µs (10+1) within DBIx::Class::Storage::DBI::SQLite::_dbh_autocommit which was called 6 times, avg 2µs/call:
# 2 times (2µs+0s) by DBIx::Class::Storage::DBI::txn_commit at line 1361 of DBIx/Class/Storage/DBI.pm, avg 1µs/call
# once (5µs+1µs) by DBIx::Class::Storage::DBI::_connect at line 1308 of DBIx/Class/Storage/DBI.pm
# once (2µs+0s) by DBIx::Class::Storage::DBI::txn_begin at line 1317 of DBIx/Class/Storage/DBI.pm
# once (600ns+0s) by DBIx::Class::Storage::DBI::_populate_dbh at line 1016 of DBIx/Class/Storage/DBI.pm
# once (500ns+0s) by DBIx::Class::Storage::DBI::_connect at line 781 of Class/Accessor/Grouped.pm | |||||
# spent 9µs within DBIx::Class::Storage::DBI::SQLite::debug which was called 5 times, avg 2µs/call:
# once (5µs+0s) by DBIx::Class::Storage::DBI::_query_end at line 1496 of DBIx/Class/Storage/DBI.pm
# once (2µs+0s) by DBIx::Class::Storage::DBI::_query_start at line 1489 of DBIx/Class/Storage/DBI.pm
# once (2µs+0s) by DBIx::Class::Storage::txn_begin at line 274 of DBIx/Class/Storage.pm
# once (1µs+0s) by DBIx::Class::Storage::txn_commit at line 298 of DBIx/Class/Storage.pm
# once (500ns+0s) by DBIx::Class::Storage::DBI::_query_start at line 781 of Class/Accessor/Grouped.pm | |||||
# spent 2µs within DBIx::Class::Storage::DBI::SQLite::disable_sth_caching which was called 2 times, avg 800ns/call:
# once (1µs+0s) by DBIx::Class::Storage::DBI::_dbh_sth at line 2252 of DBIx/Class/Storage/DBI.pm
# once (500ns+0s) by DBIx::Class::Storage::DBI::_dbh_sth at line 781 of Class/Accessor/Grouped.pm | |||||
# spent 2µs within DBIx::Class::Storage::DBI::SQLite::on_connect_call which was called 2 times, avg 800ns/call:
# once (1µs+0s) by DBIx::Class::Storage::DBI::_run_connection_actions at line 1025 of DBIx/Class/Storage/DBI.pm
# once (400ns+0s) by DBIx::Class::Storage::DBI::_run_connection_actions at line 781 of Class/Accessor/Grouped.pm | |||||
# spent 1µs within DBIx::Class::Storage::DBI::SQLite::on_connect_do which was called 2 times, avg 700ns/call:
# once (900ns+0s) by DBIx::Class::Storage::DBI::_parse_connect_do at line 725 of DBIx/Class/Storage/DBI.pm
# once (500ns+0s) by DBIx::Class::Storage::DBI::_parse_connect_do at line 781 of Class/Accessor/Grouped.pm | |||||
# spent 9µs within DBIx::Class::Storage::DBI::SQLite::transaction_depth which was called 5 times, avg 2µs/call:
# once (5µs+0s) by DBIx::Class::Storage::DBI::txn_commit at line 1361 of DBIx/Class/Storage/DBI.pm
# once (2µs+0s) by DBIx::Class::Storage::txn_begin at line 273 of DBIx/Class/Storage.pm
# once (1µs+0s) by DBIx::Class::Storage::DBI::txn_commit at line 1351 of DBIx/Class/Storage/DBI.pm
# once (700ns+0s) by DBIx::Class::Storage::txn_commit at line 297 of DBIx/Class/Storage.pm
# once (500ns+0s) by DBIx::Class::Storage::txn_begin at line 781 of Class/Accessor/Grouped.pm | |||||
# spent 2µs within DBIx::Class::Storage::DBI::SQLite::unsafe which was called 2 times, avg 1µs/call:
# once (2µs+0s) by DBIx::Class::Storage::DBI::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/Storage/DBI.pm:1300] at line 1256 of DBIx/Class/Storage/DBI.pm
# once (500ns+0s) by DBIx::Class::Storage::DBI::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/Storage/DBI.pm:1300] at line 781 of Class/Accessor/Grouped.pm |