Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/Schema.pm |
Statements | Executed 53051 statements in 134ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
6320 | 8 | 3 | 85.7ms | 266ms | source | DBIx::Class::Schema::
2030 | 21 | 9 | 40.2ms | 748ms | resultset | DBIx::Class::Schema::
94 | 2 | 1 | 4.18ms | 11.2ms | _register_source | DBIx::Class::Schema::
147 | 1 | 1 | 2.84ms | 56.6ms | txn_scope_guard | DBIx::Class::Schema::
6 | 1 | 1 | 1.55ms | 11.3ms | clone | DBIx::Class::Schema::
2 | 2 | 2 | 1.25ms | 239ms | load_namespaces | DBIx::Class::Schema::
4 | 1 | 1 | 931µs | 17.9ms | _findallmod | DBIx::Class::Schema::
76 | 3 | 1 | 520µs | 2.73ms | _ns_get_rsrc_instance | DBIx::Class::Schema::
76 | 1 | 1 | 343µs | 1.27ms | __ANON__[:204] | DBIx::Class::Schema::
37 | 3 | 2 | 296µs | 6.49ms | register_class | DBIx::Class::Schema::
57 | 1 | 1 | 292µs | 5.86ms | register_extra_source | DBIx::Class::Schema::
6 | 2 | 2 | 219µs | 24.6ms | connection | DBIx::Class::Schema::
37 | 1 | 1 | 162µs | 529µs | __ANON__[:1378] | DBIx::Class::Schema::
13 | 5 | 4 | 140µs | 140µs | schema_version | DBIx::Class::Schema::
1 | 1 | 1 | 135µs | 137µs | BEGIN@174 | DBIx::Class::Schema::
37 | 1 | 1 | 112µs | 5.76ms | register_source | DBIx::Class::Schema::
4 | 2 | 1 | 102µs | 184µs | CORE:sort (opcode) | DBIx::Class::Schema::
47 | 2 | 1 | 97µs | 97µs | CORE:match (opcode) | DBIx::Class::Schema::
4 | 2 | 1 | 94µs | 18.0ms | _map_namespaces | DBIx::Class::Schema::
11 | 3 | 3 | 94µs | 290µs | sources | DBIx::Class::Schema::
4 | 2 | 2 | 92µs | 8.22s | deploy | DBIx::Class::Schema::
6 | 3 | 3 | 79µs | 43.1ms | connect (recurses: max depth 1, inclusive time 1.23ms) | DBIx::Class::Schema::
4 | 1 | 1 | 68µs | 4.67ms | throw_exception | DBIx::Class::Schema::
4 | 1 | 1 | 62µs | 279µs | ddl_filename | DBIx::Class::Schema::
4 | 1 | 1 | 61µs | 256ms | deployment_statements | DBIx::Class::Schema::
6 | 1 | 1 | 40µs | 22.4ms | __ANON__[:829] | DBIx::Class::Schema::
6 | 2 | 1 | 26µs | 28µs | _expand_relative_name | DBIx::Class::Schema::
8 | 2 | 1 | 21µs | 21µs | CORE:subst (opcode) | DBIx::Class::Schema::
1 | 1 | 1 | 20µs | 23µs | BEGIN@3 | DBIx::Class::Schema::
1 | 1 | 1 | 12µs | 562µs | BEGIN@11 | DBIx::Class::Schema::
1 | 1 | 1 | 11µs | 29µs | BEGIN@10 | DBIx::Class::Schema::
1 | 1 | 1 | 10µs | 17µs | BEGIN@380 | DBIx::Class::Schema::
1 | 1 | 1 | 9µs | 103µs | BEGIN@7 | DBIx::Class::Schema::
1 | 1 | 1 | 9µs | 91µs | BEGIN@14 | DBIx::Class::Schema::
1 | 1 | 1 | 9µs | 28µs | BEGIN@240 | DBIx::Class::Schema::
1 | 1 | 1 | 8µs | 22µs | BEGIN@920 | DBIx::Class::Schema::
1 | 1 | 1 | 8µs | 40µs | BEGIN@8 | DBIx::Class::Schema::
1 | 1 | 1 | 8µs | 16µs | BEGIN@916 | DBIx::Class::Schema::
1 | 1 | 1 | 8µs | 29µs | BEGIN@9 | DBIx::Class::Schema::
1 | 1 | 1 | 8µs | 16µs | BEGIN@378 | DBIx::Class::Schema::
1 | 1 | 1 | 8µs | 16µs | BEGIN@1284 | DBIx::Class::Schema::
1 | 1 | 1 | 7µs | 16µs | BEGIN@1516 | DBIx::Class::Schema::
1 | 1 | 1 | 7µs | 16µs | BEGIN@242 | DBIx::Class::Schema::
1 | 1 | 1 | 7µs | 230µs | BEGIN@12 | DBIx::Class::Schema::
1 | 1 | 1 | 6µs | 6µs | END | DBIx::Class::Schema::
1 | 1 | 1 | 6µs | 12µs | BEGIN@943 | DBIx::Class::Schema::
1 | 1 | 1 | 6µs | 13µs | BEGIN@918 | DBIx::Class::Schema::
1 | 1 | 1 | 6µs | 14µs | BEGIN@4 | DBIx::Class::Schema::
1 | 1 | 1 | 5µs | 5µs | BEGIN@6 | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | DESTROY | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | __ANON__[:1495] | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | __ANON__[:1499] | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | __ANON__[:1518] | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | __ANON__[:208] | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | __ANON__[:241] | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | __ANON__[:379] | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | __ANON__[:834] | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | __ANON__[:917] | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | __ANON__[:945] | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | _normalize_storage_type | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | _unregister_source | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | class | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | compose_connection | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | compose_namespace | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | create_ddl_dir | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | dclone | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | freeze | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | load_classes | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | populate | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | setup_connection_class | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | svp_begin | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | svp_release | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | svp_rollback | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | thaw | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | txn_begin | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | txn_commit | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | txn_do | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | txn_rollback | DBIx::Class::Schema::
0 | 0 | 0 | 0s | 0s | unregister_source | DBIx::Class::Schema::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package DBIx::Class::Schema; | ||||
2 | |||||
3 | 3 | 17µs | 2 | 25µs | # spent 23µs (20+2) within DBIx::Class::Schema::BEGIN@3 which was called:
# once (20µs+2µs) by parent::import at line 3 # spent 23µs making 1 call to DBIx::Class::Schema::BEGIN@3
# spent 2µs making 1 call to strict::import |
4 | 3 | 16µs | 2 | 22µs | # spent 14µs (6+8) within DBIx::Class::Schema::BEGIN@4 which was called:
# once (6µs+8µs) by parent::import at line 4 # spent 14µs making 1 call to DBIx::Class::Schema::BEGIN@4
# spent 8µs making 1 call to warnings::import |
5 | |||||
6 | 3 | 17µs | 1 | 5µs | # spent 5µs within DBIx::Class::Schema::BEGIN@6 which was called:
# once (5µs+0s) by parent::import at line 6 # spent 5µs making 1 call to DBIx::Class::Schema::BEGIN@6 |
7 | 3 | 25µs | 2 | 197µs | # spent 103µs (9+94) within DBIx::Class::Schema::BEGIN@7 which was called:
# once (9µs+94µs) by parent::import at line 7 # spent 103µs making 1 call to DBIx::Class::Schema::BEGIN@7
# spent 94µs making 1 call to DBIx::Class::Carp::import |
8 | 3 | 20µs | 2 | 71µs | # spent 40µs (8+31) within DBIx::Class::Schema::BEGIN@8 which was called:
# once (8µs+31µs) by parent::import at line 8 # spent 40µs making 1 call to DBIx::Class::Schema::BEGIN@8
# spent 32µs making 1 call to Exporter::import |
9 | 3 | 19µs | 2 | 50µs | # spent 29µs (8+21) within DBIx::Class::Schema::BEGIN@9 which was called:
# once (8µs+21µs) by parent::import at line 9 # spent 29µs making 1 call to DBIx::Class::Schema::BEGIN@9
# spent 21µs making 1 call to Exporter::import |
10 | 3 | 27µs | 2 | 47µs | # spent 29µs (11+18) within DBIx::Class::Schema::BEGIN@10 which was called:
# once (11µs+18µs) by parent::import at line 10 # spent 29µs making 1 call to DBIx::Class::Schema::BEGIN@10
# spent 18µs making 1 call to Exporter::import |
11 | 3 | 22µs | 2 | 1.11ms | # spent 562µs (12+550) within DBIx::Class::Schema::BEGIN@11 which was called:
# once (12µs+550µs) by parent::import at line 11 # spent 562µs making 1 call to DBIx::Class::Schema::BEGIN@11
# spent 550µs making 1 call to Exporter::import |
12 | 3 | 21µs | 2 | 454µs | # spent 230µs (7+224) within DBIx::Class::Schema::BEGIN@12 which was called:
# once (7µs+224µs) by parent::import at line 12 # spent 230µs making 1 call to DBIx::Class::Schema::BEGIN@12
# spent 224µs making 1 call to namespace::clean::import |
13 | |||||
14 | 3 | 206µs | 2 | 173µs | # spent 91µs (9+82) within DBIx::Class::Schema::BEGIN@14 which was called:
# once (9µs+82µs) by parent::import at line 14 # spent 91µs making 1 call to DBIx::Class::Schema::BEGIN@14
# spent 82µs making 1 call to base::import |
15 | |||||
16 | 1 | 6µs | 1 | 263µs | __PACKAGE__->mk_classdata('class_mappings' => {}); # spent 263µs making 1 call to DBIx::Class::mk_classdata |
17 | 1 | 2µs | 1 | 143µs | __PACKAGE__->mk_classdata('source_registrations' => {}); # spent 143µs making 1 call to DBIx::Class::mk_classdata |
18 | 1 | 1µs | 1 | 156µs | __PACKAGE__->mk_classdata('storage_type' => '::DBI'); # spent 156µs making 1 call to DBIx::Class::mk_classdata |
19 | 1 | 1µs | 1 | 134µs | __PACKAGE__->mk_classdata('storage'); # spent 134µs making 1 call to DBIx::Class::mk_classdata |
20 | 1 | 1µs | 1 | 131µs | __PACKAGE__->mk_classdata('exception_action'); # spent 131µs making 1 call to DBIx::Class::mk_classdata |
21 | 1 | 2µs | 1 | 135µs | __PACKAGE__->mk_classdata('stacktrace' => $ENV{DBIC_TRACE} || 0); # spent 135µs making 1 call to DBIx::Class::mk_classdata |
22 | 1 | 2µs | 1 | 142µs | __PACKAGE__->mk_classdata('default_resultset_attributes' => {}); # spent 142µs making 1 call to DBIx::Class::mk_classdata |
23 | |||||
24 | =head1 NAME | ||||
25 | |||||
26 | DBIx::Class::Schema - composable schemas | ||||
27 | |||||
28 | =head1 SYNOPSIS | ||||
29 | |||||
30 | package Library::Schema; | ||||
31 | use base qw/DBIx::Class::Schema/; | ||||
32 | |||||
33 | # load all Result classes in Library/Schema/Result/ | ||||
34 | __PACKAGE__->load_namespaces(); | ||||
35 | |||||
36 | package Library::Schema::Result::CD; | ||||
37 | use base qw/DBIx::Class::Core/; | ||||
38 | |||||
39 | __PACKAGE__->load_components(qw/InflateColumn::DateTime/); # for example | ||||
40 | __PACKAGE__->table('cd'); | ||||
41 | |||||
42 | # Elsewhere in your code: | ||||
43 | my $schema1 = Library::Schema->connect( | ||||
44 | $dsn, | ||||
45 | $user, | ||||
46 | $password, | ||||
47 | { AutoCommit => 1 }, | ||||
48 | ); | ||||
49 | |||||
50 | my $schema2 = Library::Schema->connect($coderef_returning_dbh); | ||||
51 | |||||
52 | # fetch objects using Library::Schema::Result::DVD | ||||
53 | my $resultset = $schema1->resultset('DVD')->search( ... ); | ||||
54 | my @dvd_objects = $schema2->resultset('DVD')->search( ... ); | ||||
55 | |||||
56 | =head1 DESCRIPTION | ||||
57 | |||||
58 | Creates database classes based on a schema. This is the recommended way to | ||||
59 | use L<DBIx::Class> and allows you to use more than one concurrent connection | ||||
60 | with your classes. | ||||
61 | |||||
62 | NB: If you're used to L<Class::DBI> it's worth reading the L</SYNOPSIS> | ||||
63 | carefully, as DBIx::Class does things a little differently. Note in | ||||
64 | particular which module inherits off which. | ||||
65 | |||||
66 | =head1 SETUP METHODS | ||||
67 | |||||
68 | =head2 load_namespaces | ||||
69 | |||||
70 | =over 4 | ||||
71 | |||||
72 | =item Arguments: %options? | ||||
73 | |||||
74 | =back | ||||
75 | |||||
76 | __PACKAGE__->load_namespaces(); | ||||
77 | |||||
78 | __PACKAGE__->load_namespaces( | ||||
79 | result_namespace => 'Res', | ||||
80 | resultset_namespace => 'RSet', | ||||
81 | default_resultset_class => '+MyDB::Othernamespace::RSet', | ||||
82 | ); | ||||
83 | |||||
84 | With no arguments, this method uses L<Module::Find> to load all of the | ||||
85 | Result and ResultSet classes under the namespace of the schema from | ||||
86 | which it is called. For example, C<My::Schema> will by default find | ||||
87 | and load Result classes named C<My::Schema::Result::*> and ResultSet | ||||
88 | classes named C<My::Schema::ResultSet::*>. | ||||
89 | |||||
90 | ResultSet classes are associated with Result class of the same name. | ||||
91 | For example, C<My::Schema::Result::CD> will get the ResultSet class | ||||
92 | C<My::Schema::ResultSet::CD> if it is present. | ||||
93 | |||||
94 | Both Result and ResultSet namespaces are configurable via the | ||||
95 | C<result_namespace> and C<resultset_namespace> options. | ||||
96 | |||||
97 | Another option, C<default_resultset_class> specifies a custom default | ||||
98 | ResultSet class for Result classes with no corresponding ResultSet. | ||||
99 | |||||
100 | All of the namespace and classname options are by default relative to | ||||
101 | the schema classname. To specify a fully-qualified name, prefix it | ||||
102 | with a literal C<+>. For example, C<+Other::NameSpace::Result>. | ||||
103 | |||||
104 | =head3 Warnings | ||||
105 | |||||
106 | You will be warned if ResultSet classes are discovered for which there | ||||
107 | are no matching Result classes like this: | ||||
108 | |||||
109 | load_namespaces found ResultSet class $classname with no corresponding Result class | ||||
110 | |||||
111 | If a Result class is found to already have a ResultSet class set using | ||||
112 | L</resultset_class> to some other class, you will be warned like this: | ||||
113 | |||||
114 | We found ResultSet class '$rs_class' for '$result', but it seems | ||||
115 | that you had already set '$result' to use '$rs_set' instead | ||||
116 | |||||
117 | =head3 Examples | ||||
118 | |||||
119 | # load My::Schema::Result::CD, My::Schema::Result::Artist, | ||||
120 | # My::Schema::ResultSet::CD, etc... | ||||
121 | My::Schema->load_namespaces; | ||||
122 | |||||
123 | # Override everything to use ugly names. | ||||
124 | # In this example, if there is a My::Schema::Res::Foo, but no matching | ||||
125 | # My::Schema::RSets::Foo, then Foo will have its | ||||
126 | # resultset_class set to My::Schema::RSetBase | ||||
127 | My::Schema->load_namespaces( | ||||
128 | result_namespace => 'Res', | ||||
129 | resultset_namespace => 'RSets', | ||||
130 | default_resultset_class => 'RSetBase', | ||||
131 | ); | ||||
132 | |||||
133 | # Put things in other namespaces | ||||
134 | My::Schema->load_namespaces( | ||||
135 | result_namespace => '+Some::Place::Results', | ||||
136 | resultset_namespace => '+Another::Place::RSets', | ||||
137 | ); | ||||
138 | |||||
139 | To search multiple namespaces for either Result or ResultSet classes, | ||||
140 | use an arrayref of namespaces for that option. In the case that the | ||||
141 | same result (or resultset) class exists in multiple namespaces, later | ||||
142 | entries in the list of namespaces will override earlier ones. | ||||
143 | |||||
144 | My::Schema->load_namespaces( | ||||
145 | # My::Schema::Results_C::Foo takes precedence over My::Schema::Results_B::Foo : | ||||
146 | result_namespace => [ 'Results_A', 'Results_B', 'Results_C' ], | ||||
147 | resultset_namespace => [ '+Some::Place::RSets', 'RSets' ], | ||||
148 | ); | ||||
149 | |||||
150 | =cut | ||||
151 | |||||
152 | # Pre-pends our classname to the given relative classname or | ||||
153 | # class namespace, unless there is a '+' prefix, which will | ||||
154 | # be stripped. | ||||
155 | sub _expand_relative_name { | ||||
156 | 20 | 36µs | my ($class, $name) = @_; | ||
157 | return if !$name; | ||||
158 | 4 | 2µs | $name = $class . '::' . $name if ! ($name =~ s/^\+//); # spent 2µs making 4 calls to DBIx::Class::Schema::CORE:subst, avg 500ns/call | ||
159 | return $name; | ||||
160 | } | ||||
161 | |||||
162 | # Finds all modules in the supplied namespace, or if omitted in the | ||||
163 | # namespace of $class. Untaints all findings as they can be assumed | ||||
164 | # to be safe | ||||
165 | # spent 17.9ms (931µs+17.0) within DBIx::Class::Schema::_findallmod which was called 4 times, avg 4.47ms/call:
# 4 times (931µs+17.0ms) by DBIx::Class::Schema::_map_namespaces at line 188, avg 4.47ms/call | ||||
166 | 61 | 327µs | my $proto = shift; | ||
167 | my $ns = shift || ref $proto || $proto; | ||||
168 | |||||
169 | require Module::Find; | ||||
170 | 4 | 12.3ms | my @mods = Module::Find::findallmod($ns); # spent 12.3ms making 4 calls to Module::Find::findallmod, avg 3.07ms/call | ||
171 | |||||
172 | # try to untaint module names. mods where this fails | ||||
173 | # are left alone so we don't have to change the old behavior | ||||
174 | 3 | 440µs | 2 | 140µs | # spent 137µs (135+3) within DBIx::Class::Schema::BEGIN@174 which was called:
# once (135µs+3µs) by parent::import at line 174 # spent 137µs making 1 call to DBIx::Class::Schema::BEGIN@174
# spent 3µs making 1 call to locale::unimport |
175 | 41 | 75µs | return map { $_ =~ m/^( (?:\w+::)* \w+ )$/x ? $1 : $_ } @mods; # spent 75µs making 41 calls to DBIx::Class::Schema::CORE:match, avg 2µs/call | ||
176 | } | ||||
177 | |||||
178 | # returns a hash of $shortname => $fullname for every package | ||||
179 | # found in the given namespaces ($shortname is with the $fullname's | ||||
180 | # namespace stripped off) | ||||
181 | sub _map_namespaces { | ||||
182 | 20 | 93µs | my ($class, @namespaces) = @_; | ||
183 | |||||
184 | my @results_hash; | ||||
185 | foreach my $namespace (@namespaces) { | ||||
186 | push( | ||||
187 | @results_hash, | ||||
188 | 4 | 17.9ms | map { (substr($_, length "${namespace}::"), $_) } # spent 17.9ms making 4 calls to DBIx::Class::Schema::_findallmod, avg 4.47ms/call | ||
189 | $class->_findallmod($namespace) | ||||
190 | ); | ||||
191 | } | ||||
192 | |||||
193 | @results_hash; | ||||
194 | } | ||||
195 | |||||
196 | # returns the result_source_instance for the passed class/object, | ||||
197 | # or dies with an informative message (used by load_namespaces) | ||||
198 | # spent 2.73ms (520µs+2.21) within DBIx::Class::Schema::_ns_get_rsrc_instance which was called 76 times, avg 36µs/call:
# 35 times (235µs+1.12ms) by DBIx::Class::Schema::load_namespaces at line 267, avg 39µs/call
# 35 times (228µs+851µs) by DBIx::Class::Schema::load_namespaces at line 284, avg 31µs/call
# 6 times (57µs+237µs) by DBIx::Class::Schema::load_namespaces at line 281, avg 49µs/call | ||||
199 | 228 | 465µs | my $me = shift; | ||
200 | my $rs_class = ref ($_[0]) || $_[0]; | ||||
201 | |||||
202 | # spent 1.27ms (343µs+930µs) within DBIx::Class::Schema::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/Schema.pm:204] which was called 76 times, avg 17µs/call:
# 76 times (343µs+930µs) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 17µs/call | ||||
203 | 76 | 277µs | 76 | 930µs | $rs_class->result_source_instance # spent 53µs making 2 calls to Tapper::Schema::ReportsDB::Result::Contact::result_source_instance, avg 26µs/call
# spent 50µs making 3 calls to Tapper::Schema::TestrunDB::Result::Testrun::result_source_instance, avg 17µs/call
# spent 39µs making 3 calls to Tapper::Schema::TestrunDB::Result::Precondition::result_source_instance, avg 13µs/call
# spent 39µs making 3 calls to Tapper::Schema::TestrunDB::Result::Host::result_source_instance, avg 13µs/call
# spent 38µs making 3 calls to Tapper::Schema::ReportsDB::Result::ReportgroupTestrun::result_source_instance, avg 12µs/call
# spent 36µs making 3 calls to Tapper::Schema::TestrunDB::Result::Queue::result_source_instance, avg 12µs/call
# spent 35µs making 3 calls to Tapper::Schema::TestrunDB::Result::TestrunScheduling::result_source_instance, avg 12µs/call
# spent 32µs making 2 calls to Tapper::Schema::ReportsDB::Result::ReportFile::result_source_instance, avg 16µs/call
# spent 24µs making 2 calls to Tapper::Schema::TestrunDB::Result::Message::result_source_instance, avg 12µs/call
# spent 24µs making 2 calls to Tapper::Schema::TestrunDB::Result::TestrunRequestedFeature::result_source_instance, avg 12µs/call
# spent 24µs making 2 calls to Tapper::Schema::TestrunDB::Result::TestrunRequestedHost::result_source_instance, avg 12µs/call
# spent 24µs making 2 calls to Tapper::Schema::ReportsDB::Result::ReportgroupArbitrary::result_source_instance, avg 12µs/call
# spent 23µs making 2 calls to Tapper::Schema::TestrunDB::Result::TestrunPrecondition::result_source_instance, avg 12µs/call
# spent 23µs making 2 calls to Tapper::Schema::ReportsDB::Result::ReportSection::result_source_instance, avg 12µs/call
# spent 23µs making 2 calls to Tapper::Schema::TestrunDB::Result::TestplanInstance::result_source_instance, avg 12µs/call
# spent 23µs making 2 calls to Tapper::Schema::ReportsDB::Result::View010TestrunOverviewReports::result_source_instance, avg 12µs/call
# spent 23µs making 2 calls to Tapper::Schema::ReportsDB::Result::User::result_source_instance, avg 12µs/call
# spent 23µs making 2 calls to Tapper::Schema::ReportsDB::Result::Suite::result_source_instance, avg 12µs/call
# spent 23µs making 2 calls to Tapper::Schema::TestrunDB::Result::HostFeature::result_source_instance, avg 12µs/call
# spent 23µs making 2 calls to Tapper::Schema::TestrunDB::Result::State::result_source_instance, avg 11µs/call
# spent 23µs making 2 calls to Tapper::Schema::ReportsDB::Result::ReportgroupTestrunStats::result_source_instance, avg 11µs/call
# spent 22µs making 2 calls to Tapper::Schema::ReportsDB::Result::ReportComment::result_source_instance, avg 11µs/call
# spent 22µs making 2 calls to Tapper::Schema::TestrunDB::Result::ScenarioElement::result_source_instance, avg 11µs/call
# spent 22µs making 2 calls to Tapper::Schema::TestrunDB::Result::Scenario::result_source_instance, avg 11µs/call
# spent 22µs making 2 calls to Tapper::Schema::TestrunDB::Result::PrePrecondition::result_source_instance, avg 11µs/call
# spent 22µs making 2 calls to Tapper::Schema::TestrunDB::Result::User::result_source_instance, avg 11µs/call
# spent 22µs making 2 calls to Tapper::Schema::ReportsDB::Result::ReportTopic::result_source_instance, avg 11µs/call
# spent 22µs making 2 calls to Tapper::Schema::ReportsDB::Result::View020TestrunOverview::result_source_instance, avg 11µs/call
# spent 22µs making 2 calls to Tapper::Schema::ReportsDB::Result::Notification::result_source_instance, avg 11µs/call
# spent 22µs making 2 calls to Tapper::Schema::TestrunDB::Result::QueueHost::result_source_instance, avg 11µs/call
# spent 22µs making 2 calls to Tapper::Schema::ReportsDB::Result::Report::result_source_instance, avg 11µs/call
# spent 22µs making 2 calls to Tapper::Schema::TestrunDB::Result::Preconditiontype::result_source_instance, avg 11µs/call
# spent 21µs making 2 calls to Tapper::Schema::TestrunDB::Result::Topic::result_source_instance, avg 11µs/call
# spent 21µs making 2 calls to Tapper::Schema::ReportsDB::Result::NotificationEvent::result_source_instance, avg 11µs/call
# spent 21µs making 2 calls to Tapper::Schema::ReportsDB::Result::Tap::result_source_instance, avg 10µs/call |
204 | } catch { | ||||
205 | $me->throw_exception ( | ||||
206 | "Attempt to load_namespaces() class $rs_class failed - are you sure this is a real Result Class?: $_" | ||||
207 | ); | ||||
208 | 152 | 2.21ms | }; # spent 2.03ms making 76 calls to Try::Tiny::try, avg 27µs/call
# spent 185µs making 76 calls to Try::Tiny::catch, avg 2µs/call | ||
209 | } | ||||
210 | |||||
211 | # spent 239ms (1.25+237) within DBIx::Class::Schema::load_namespaces which was called 2 times, avg 119ms/call:
# once (711µs+163ms) by Tapper::Schema::TestTools::BEGIN@20 at line 33 of Tapper/Schema/TestrunDB.pm
# once (536µs+74.6ms) by Tapper::Schema::TestTools::BEGIN@21 at line 33 of Tapper/Schema/ReportsDB.pm | ||||
212 | 321 | 1.25ms | my ($class, %args) = @_; | ||
213 | |||||
214 | my $result_namespace = delete $args{result_namespace} || 'Result'; | ||||
215 | my $resultset_namespace = delete $args{resultset_namespace} || 'ResultSet'; | ||||
216 | my $default_resultset_class = delete $args{default_resultset_class}; | ||||
217 | |||||
218 | $class->throw_exception('load_namespaces: unknown option(s): ' | ||||
219 | . join(q{,}, map { qq{'$_'} } keys %args)) | ||||
220 | if scalar keys %args; | ||||
221 | |||||
222 | 2 | 5µs | $default_resultset_class # spent 5µs making 2 calls to DBIx::Class::Schema::_expand_relative_name, avg 3µs/call | ||
223 | = $class->_expand_relative_name($default_resultset_class); | ||||
224 | |||||
225 | for my $arg ($result_namespace, $resultset_namespace) { | ||||
226 | $arg = [ $arg ] if !ref($arg) && $arg; | ||||
227 | |||||
228 | $class->throw_exception('load_namespaces: namespace arguments must be ' | ||||
229 | . 'a simple string or an arrayref') | ||||
230 | if ref($arg) ne 'ARRAY'; | ||||
231 | |||||
232 | 4 | 23µs | $_ = $class->_expand_relative_name($_) for (@$arg); # spent 23µs making 4 calls to DBIx::Class::Schema::_expand_relative_name, avg 6µs/call | ||
233 | } | ||||
234 | |||||
235 | 2 | 15.5ms | my %results = $class->_map_namespaces(@$result_namespace); # spent 15.5ms making 2 calls to DBIx::Class::Schema::_map_namespaces, avg 7.76ms/call | ||
236 | 2 | 2.48ms | my %resultsets = $class->_map_namespaces(@$resultset_namespace); # spent 2.48ms making 2 calls to DBIx::Class::Schema::_map_namespaces, avg 1.24ms/call | ||
237 | |||||
238 | my @to_register; | ||||
239 | { | ||||
240 | 3 | 55µs | 2 | 47µs | # spent 28µs (9+19) within DBIx::Class::Schema::BEGIN@240 which was called:
# once (9µs+19µs) by parent::import at line 240 # spent 28µs making 1 call to DBIx::Class::Schema::BEGIN@240
# spent 19µs making 1 call to warnings::unimport |
241 | local *Class::C3::reinitialize = sub { } if DBIx::Class::_ENV_::OLD_MRO; | ||||
242 | 3 | 462µs | 2 | 26µs | # spent 16µs (7+10) within DBIx::Class::Schema::BEGIN@242 which was called:
# once (7µs+10µs) by parent::import at line 242 # spent 16µs making 1 call to DBIx::Class::Schema::BEGIN@242
# spent 10µs making 1 call to warnings::import |
243 | |||||
244 | # ensure classes are loaded and attached in inheritance order | ||||
245 | for my $res (values %results) { | ||||
246 | 35 | 115ms | $class->ensure_class_loaded($res); # spent 115ms making 35 calls to Class::C3::Componentised::ensure_class_loaded, avg 3.29ms/call | ||
247 | } | ||||
248 | my %inh_idx; | ||||
249 | my @subclass_last = sort { | ||||
250 | |||||
251 | 37 | 262µs | ($inh_idx{$a} ||= # spent 181µs making 2 calls to DBIx::Class::Schema::CORE:sort, avg 90µs/call
# spent 82µs making 35 calls to mro::get_linear_isa, avg 2µs/call | ||
252 | scalar @{mro::get_linear_isa( $results{$a} )} | ||||
253 | ) | ||||
254 | |||||
255 | <=> | ||||
256 | |||||
257 | ($inh_idx{$b} ||= | ||||
258 | scalar @{mro::get_linear_isa( $results{$b} )} | ||||
259 | ) | ||||
260 | |||||
261 | } keys(%results); | ||||
262 | |||||
263 | foreach my $result (@subclass_last) { | ||||
264 | my $result_class = $results{$result}; | ||||
265 | |||||
266 | my $rs_class = delete $resultsets{$result}; | ||||
267 | 70 | 1.91ms | my $rs_set = $class->_ns_get_rsrc_instance ($result_class)->resultset_class; # spent 1.36ms making 35 calls to DBIx::Class::Schema::_ns_get_rsrc_instance, avg 39µs/call
# spent 550µs making 35 calls to DBIx::Class::ResultSource::resultset_class, avg 16µs/call | ||
268 | |||||
269 | if($rs_set && $rs_set ne 'DBIx::Class::ResultSet') { | ||||
270 | if($rs_class && $rs_class ne $rs_set) { | ||||
271 | carp "We found ResultSet class '$rs_class' for '$result', but it seems " | ||||
272 | . "that you had already set '$result' to use '$rs_set' instead"; | ||||
273 | } | ||||
274 | } | ||||
275 | elsif($rs_class ||= $default_resultset_class) { | ||||
276 | 6 | 94.1ms | $class->ensure_class_loaded($rs_class); # spent 94.1ms making 6 calls to Class::C3::Componentised::ensure_class_loaded, avg 15.7ms/call | ||
277 | 6 | 14µs | if(!$rs_class->isa("DBIx::Class::ResultSet")) { # spent 14µs making 6 calls to UNIVERSAL::isa, avg 2µs/call | ||
278 | carp "load_namespaces found ResultSet class $rs_class that does not subclass DBIx::Class::ResultSet"; | ||||
279 | } | ||||
280 | |||||
281 | 12 | 434µs | $class->_ns_get_rsrc_instance ($result_class)->resultset_class($rs_class); # spent 294µs making 6 calls to DBIx::Class::Schema::_ns_get_rsrc_instance, avg 49µs/call
# spent 140µs making 6 calls to DBIx::Class::ResultSource::resultset_class, avg 23µs/call | ||
282 | } | ||||
283 | |||||
284 | 51 | 1.41ms | my $source_name = $class->_ns_get_rsrc_instance ($result_class)->source_name || $result; # spent 1.08ms making 35 calls to DBIx::Class::Schema::_ns_get_rsrc_instance, avg 31µs/call
# spent 292µs making 3 calls to DBIx::Class::ResultSource::source_name, avg 97µs/call
# spent 38µs making 13 calls to DBIx::Class::ResultSource::Table::source_name, avg 3µs/call | ||
285 | |||||
286 | push(@to_register, [ $source_name, $result_class ]); | ||||
287 | } | ||||
288 | } | ||||
289 | |||||
290 | 2 | 3µs | foreach (sort keys %resultsets) { # spent 3µs making 2 calls to DBIx::Class::Schema::CORE:sort, avg 1µs/call | ||
291 | carp "load_namespaces found ResultSet class $_ with no " | ||||
292 | . 'corresponding Result class'; | ||||
293 | } | ||||
294 | |||||
295 | Class::C3->reinitialize if DBIx::Class::_ENV_::OLD_MRO; | ||||
296 | |||||
297 | 35 | 5.99ms | $class->register_class(@$_) for (@to_register); # spent 5.99ms making 35 calls to DBIx::Class::Schema::register_class, avg 171µs/call | ||
298 | |||||
299 | return; | ||||
300 | } | ||||
301 | |||||
302 | =head2 load_classes | ||||
303 | |||||
304 | =over 4 | ||||
305 | |||||
306 | =item Arguments: @classes?, { $namespace => [ @classes ] }+ | ||||
307 | |||||
308 | =back | ||||
309 | |||||
310 | L</load_classes> is an alternative method to L</load_namespaces>, both of | ||||
311 | which serve similar purposes, each with different advantages and disadvantages. | ||||
312 | In the general case you should use L</load_namespaces>, unless you need to | ||||
313 | be able to specify that only specific classes are loaded at runtime. | ||||
314 | |||||
315 | With no arguments, this method uses L<Module::Find> to find all classes under | ||||
316 | the schema's namespace. Otherwise, this method loads the classes you specify | ||||
317 | (using L<use>), and registers them (using L</"register_class">). | ||||
318 | |||||
319 | It is possible to comment out classes with a leading C<#>, but note that perl | ||||
320 | will think it's a mistake (trying to use a comment in a qw list), so you'll | ||||
321 | need to add C<no warnings 'qw';> before your load_classes call. | ||||
322 | |||||
323 | If any classes found do not appear to be Result class files, you will | ||||
324 | get the following warning: | ||||
325 | |||||
326 | Failed to load $comp_class. Can't find source_name method. Is | ||||
327 | $comp_class really a full DBIC result class? Fix it, move it elsewhere, | ||||
328 | or make your load_classes call more specific. | ||||
329 | |||||
330 | Example: | ||||
331 | |||||
332 | My::Schema->load_classes(); # loads My::Schema::CD, My::Schema::Artist, | ||||
333 | # etc. (anything under the My::Schema namespace) | ||||
334 | |||||
335 | # loads My::Schema::CD, My::Schema::Artist, Other::Namespace::Producer but | ||||
336 | # not Other::Namespace::LinerNotes nor My::Schema::Track | ||||
337 | My::Schema->load_classes(qw/ CD Artist #Track /, { | ||||
338 | Other::Namespace => [qw/ Producer #LinerNotes /], | ||||
339 | }); | ||||
340 | |||||
341 | =cut | ||||
342 | |||||
343 | sub load_classes { | ||||
344 | my ($class, @params) = @_; | ||||
345 | |||||
346 | my %comps_for; | ||||
347 | |||||
348 | if (@params) { | ||||
349 | foreach my $param (@params) { | ||||
350 | if (ref $param eq 'ARRAY') { | ||||
351 | # filter out commented entries | ||||
352 | my @modules = grep { $_ !~ /^#/ } @$param; | ||||
353 | |||||
354 | push (@{$comps_for{$class}}, @modules); | ||||
355 | } | ||||
356 | elsif (ref $param eq 'HASH') { | ||||
357 | # more than one namespace possible | ||||
358 | for my $comp ( keys %$param ) { | ||||
359 | # filter out commented entries | ||||
360 | my @modules = grep { $_ !~ /^#/ } @{$param->{$comp}}; | ||||
361 | |||||
362 | push (@{$comps_for{$comp}}, @modules); | ||||
363 | } | ||||
364 | } | ||||
365 | else { | ||||
366 | # filter out commented entries | ||||
367 | push (@{$comps_for{$class}}, $param) if $param !~ /^#/; | ||||
368 | } | ||||
369 | } | ||||
370 | } else { | ||||
371 | my @comp = map { substr $_, length "${class}::" } | ||||
372 | $class->_findallmod; | ||||
373 | $comps_for{$class} = \@comp; | ||||
374 | } | ||||
375 | |||||
376 | my @to_register; | ||||
377 | { | ||||
378 | 3 | 39µs | 2 | 24µs | # spent 16µs (8+8) within DBIx::Class::Schema::BEGIN@378 which was called:
# once (8µs+8µs) by parent::import at line 378 # spent 16µs making 1 call to DBIx::Class::Schema::BEGIN@378
# spent 8µs making 1 call to warnings::unimport |
379 | local *Class::C3::reinitialize = sub { } if DBIx::Class::_ENV_::OLD_MRO; | ||||
380 | 3 | 784µs | 2 | 23µs | # spent 17µs (10+7) within DBIx::Class::Schema::BEGIN@380 which was called:
# once (10µs+7µs) by parent::import at line 380 # spent 17µs making 1 call to DBIx::Class::Schema::BEGIN@380
# spent 6µs making 1 call to warnings::import |
381 | |||||
382 | foreach my $prefix (keys %comps_for) { | ||||
383 | foreach my $comp (@{$comps_for{$prefix}||[]}) { | ||||
384 | my $comp_class = "${prefix}::${comp}"; | ||||
385 | $class->ensure_class_loaded($comp_class); | ||||
386 | |||||
387 | my $snsub = $comp_class->can('source_name'); | ||||
388 | if(! $snsub ) { | ||||
389 | carp "Failed to load $comp_class. Can't find source_name method. Is $comp_class really a full DBIC result class? Fix it, move it elsewhere, or make your load_classes call more specific."; | ||||
390 | next; | ||||
391 | } | ||||
392 | $comp = $snsub->($comp_class) || $comp; | ||||
393 | |||||
394 | push(@to_register, [ $comp, $comp_class ]); | ||||
395 | } | ||||
396 | } | ||||
397 | } | ||||
398 | Class::C3->reinitialize if DBIx::Class::_ENV_::OLD_MRO; | ||||
399 | |||||
400 | foreach my $to (@to_register) { | ||||
401 | $class->register_class(@$to); | ||||
402 | } | ||||
403 | } | ||||
404 | |||||
405 | =head2 storage_type | ||||
406 | |||||
407 | =over 4 | ||||
408 | |||||
409 | =item Arguments: $storage_type|{$storage_type, \%args} | ||||
410 | |||||
411 | =item Return value: $storage_type|{$storage_type, \%args} | ||||
412 | |||||
413 | =item Default value: DBIx::Class::Storage::DBI | ||||
414 | |||||
415 | =back | ||||
416 | |||||
417 | Set the storage class that will be instantiated when L</connect> is called. | ||||
418 | If the classname starts with C<::>, the prefix C<DBIx::Class::Storage> is | ||||
419 | assumed by L</connect>. | ||||
420 | |||||
421 | You want to use this to set subclasses of L<DBIx::Class::Storage::DBI> | ||||
422 | in cases where the appropriate subclass is not autodetected. | ||||
423 | |||||
424 | If your storage type requires instantiation arguments, those are | ||||
425 | defined as a second argument in the form of a hashref and the entire | ||||
426 | value needs to be wrapped into an arrayref or a hashref. We support | ||||
427 | both types of refs here in order to play nice with your | ||||
428 | Config::[class] or your choice. See | ||||
429 | L<DBIx::Class::Storage::DBI::Replicated> for an example of this. | ||||
430 | |||||
431 | =head2 exception_action | ||||
432 | |||||
433 | =over 4 | ||||
434 | |||||
435 | =item Arguments: $code_reference | ||||
436 | |||||
437 | =item Return value: $code_reference | ||||
438 | |||||
439 | =item Default value: None | ||||
440 | |||||
441 | =back | ||||
442 | |||||
443 | When L</throw_exception> is invoked and L</exception_action> is set to a code | ||||
444 | reference, this reference will be called instead of | ||||
445 | L<DBIx::Class::Exception/throw>, with the exception message passed as the only | ||||
446 | argument. | ||||
447 | |||||
448 | Your custom throw code B<must> rethrow the exception, as L</throw_exception> is | ||||
449 | an integral part of DBIC's internal execution control flow. | ||||
450 | |||||
451 | Example: | ||||
452 | |||||
453 | package My::Schema; | ||||
454 | use base qw/DBIx::Class::Schema/; | ||||
455 | use My::ExceptionClass; | ||||
456 | __PACKAGE__->exception_action(sub { My::ExceptionClass->throw(@_) }); | ||||
457 | __PACKAGE__->load_classes; | ||||
458 | |||||
459 | # or: | ||||
460 | my $schema_obj = My::Schema->connect( .... ); | ||||
461 | $schema_obj->exception_action(sub { My::ExceptionClass->throw(@_) }); | ||||
462 | |||||
463 | =head2 stacktrace | ||||
464 | |||||
465 | =over 4 | ||||
466 | |||||
467 | =item Arguments: boolean | ||||
468 | |||||
469 | =back | ||||
470 | |||||
471 | Whether L</throw_exception> should include stack trace information. | ||||
472 | Defaults to false normally, but defaults to true if C<$ENV{DBIC_TRACE}> | ||||
473 | is true. | ||||
474 | |||||
475 | =head2 sqlt_deploy_hook | ||||
476 | |||||
477 | =over | ||||
478 | |||||
479 | =item Arguments: $sqlt_schema | ||||
480 | |||||
481 | =back | ||||
482 | |||||
483 | An optional sub which you can declare in your own Schema class that will get | ||||
484 | passed the L<SQL::Translator::Schema> object when you deploy the schema via | ||||
485 | L</create_ddl_dir> or L</deploy>. | ||||
486 | |||||
487 | For an example of what you can do with this, see | ||||
488 | L<DBIx::Class::Manual::Cookbook/Adding Indexes And Functions To Your SQL>. | ||||
489 | |||||
490 | Note that sqlt_deploy_hook is called by L</deployment_statements>, which in turn | ||||
491 | is called before L</deploy>. Therefore the hook can be used only to manipulate | ||||
492 | the L<SQL::Translator::Schema> object before it is turned into SQL fed to the | ||||
493 | database. If you want to execute post-deploy statements which can not be generated | ||||
494 | by L<SQL::Translator>, the currently suggested method is to overload L</deploy> | ||||
495 | and use L<dbh_do|DBIx::Class::Storage::DBI/dbh_do>. | ||||
496 | |||||
497 | =head1 METHODS | ||||
498 | |||||
499 | =head2 connect | ||||
500 | |||||
501 | =over 4 | ||||
502 | |||||
503 | =item Arguments: @connectinfo | ||||
504 | |||||
505 | =item Return Value: $new_schema | ||||
506 | |||||
507 | =back | ||||
508 | |||||
509 | Creates and returns a new Schema object. The connection info set on it | ||||
510 | is used to create a new instance of the storage backend and set it on | ||||
511 | the Schema object. | ||||
512 | |||||
513 | See L<DBIx::Class::Storage::DBI/"connect_info"> for DBI-specific | ||||
514 | syntax on the C<@connectinfo> argument, or L<DBIx::Class::Storage> in | ||||
515 | general. | ||||
516 | |||||
517 | Note that C<connect_info> expects an arrayref of arguments, but | ||||
518 | C<connect> does not. C<connect> wraps its arguments in an arrayref | ||||
519 | before passing them to C<connect_info>. | ||||
520 | |||||
521 | =head3 Overloading | ||||
522 | |||||
523 | C<connect> is a convenience method. It is equivalent to calling | ||||
524 | $schema->clone->connection(@connectinfo). To write your own overloaded | ||||
525 | version, overload L</connection> instead. | ||||
526 | |||||
527 | =cut | ||||
528 | |||||
529 | 6 | 73µs | 12 | 44.3ms | # spent 43.1ms (79µs+43.0) within DBIx::Class::Schema::connect which was called 6 times, avg 7.19ms/call:
# 3 times (24µs+-24µs) by DBIx::Class::Schema::Versioned::_on_connect at line 593 of DBIx/Class/Schema/Versioned.pm, avg 0s/call
# 2 times (40µs+32.6ms) by Tapper::Schema::TestTools::setup_db at line 40 of Tapper/Schema/TestTools.pm, avg 16.3ms/call
# once (15µs+10.5ms) by Tapper::Model::model at line 46 of Tapper/Model.pm # spent 32.4ms making 3 calls to DBIx::Class::Schema::Versioned::connection, avg 10.8ms/call
# spent 11.3ms making 6 calls to DBIx::Class::Schema::clone, avg 1.89ms/call
# spent 531µs making 3 calls to DBIx::Class::Schema::connection, avg 177µs/call |
530 | |||||
531 | =head2 resultset | ||||
532 | |||||
533 | =over 4 | ||||
534 | |||||
535 | =item Arguments: $source_name | ||||
536 | |||||
537 | =item Return Value: $resultset | ||||
538 | |||||
539 | =back | ||||
540 | |||||
541 | my $rs = $schema->resultset('DVD'); | ||||
542 | |||||
543 | Returns the L<DBIx::Class::ResultSet> object for the registered source | ||||
544 | name. | ||||
545 | |||||
546 | =cut | ||||
547 | |||||
548 | # spent 748ms (40.2+707) within DBIx::Class::Schema::resultset which was called 2030 times, avg 368µs/call:
# 477 times (5.30ms+100ms) by Tapper::MCP::Scheduler::PrioQueue::get_testrequests at line 38 of lib/Tapper/MCP/Scheduler/PrioQueue.pm, avg 221µs/call
# 331 times (4.81ms+96.1ms) by Tapper::Model::get_hardware_overview at line 96 of Tapper/Model.pm, avg 305µs/call
# 180 times (4.31ms+107ms) by Tapper::Model::free_hosts_with_features at line 76 of Tapper/Model.pm, avg 620µs/call
# 180 times (4.25ms+89.5ms) by main::toggle_host_free at line 55 of xt/tapper-mcp-scheduler-with-db-longrun.t, avg 521µs/call
# 180 times (1.99ms+38.3ms) by Tapper::MCP::Scheduler::Controller::get_next_job at line 82 of lib/Tapper/MCP/Scheduler/Controller.pm, avg 224µs/call
# 147 times (3.80ms+99.3ms) by Tapper::Schema::TestrunDB::Result::Testrun::rerun at line 151 of Tapper/Schema/TestrunDB/Result/Testrun.pm, avg 701µs/call
# 147 times (8.78ms+25.3ms) by Tapper::Schema::TestrunDB::Result::Testrun::rerun at line 132 of Tapper/Schema/TestrunDB/Result/Testrun.pm, avg 232µs/call
# 147 times (1.61ms+30.7ms) by Tapper::Schema::TestrunDB::Result::Testrun::rerun at line 122 of Tapper/Schema/TestrunDB/Result/Testrun.pm, avg 219µs/call
# 129 times (3.02ms+66.3ms) by Tapper::Schema::TestrunDB::Result::Testrun::assign_preconditions at line 193 of Tapper/Schema/TestrunDB/Result/Testrun.pm, avg 538µs/call
# 34 times (579µs+11.9ms) by main::toggle_host_free at line 57 of xt/tapper-mcp-scheduler-with-db-longrun.t, avg 367µs/call
# 22 times (539µs+11.6ms) by Test::Fixture::DBIC::Schema::_insert at line 77 of Test/Fixture/DBIC/Schema.pm, avg 552µs/call
# 22 times (451µs+9.50ms) by Test::Fixture::DBIC::Schema::_insert at line 76 of Test/Fixture/DBIC/Schema.pm, avg 452µs/call
# 19 times (524µs+15.0ms) by Test::Fixture::DBIC::Schema::_delete_all at line 66 of Test/Fixture/DBIC/Schema.pm, avg 817µs/call
# 5 times (108µs+2.98ms) by DBIx::Class::Schema::Versioned::get_db_version at line 528 of DBIx/Class/Schema/Versioned.pm, avg 618µs/call
# 3 times (27µs+907µs) by DBIx::Class::Schema::Versioned::_on_connect at line 596 of DBIx/Class/Schema/Versioned.pm, avg 311µs/call
# 2 times (50µs+1.17ms) by DBIx::Class::Schema::Versioned::_set_db_version at line 697 of DBIx/Class/Schema/Versioned.pm, avg 612µs/call
# once (26µs+506µs) by main::RUNTIME at line 40 of xt/tapper-mcp-scheduler-with-db-longrun.t
# once (12µs+231µs) by Tapper::MCP::Scheduler::Algorithm::__ANON__[lib/Tapper/MCP/Scheduler/Algorithm.pm:12] at line 12 of lib/Tapper/MCP/Scheduler/Algorithm.pm
# once (10µs+217µs) by Tapper::Model::model at line 51 of Tapper/Model.pm
# once (11µs+206µs) by Tapper::Schema::TestrunDB::Result::TestrunScheduling::gen_schema_functions at line 93 of Tapper/Schema/TestrunDB/Result/TestrunScheduling.pm
# once (11µs+202µs) by main::RUNTIME at line 39 of xt/tapper-mcp-scheduler-with-db-longrun.t | ||||
549 | 6090 | 34.7ms | my ($self, $moniker) = @_; | ||
550 | $self->throw_exception('resultset() expects a source name') | ||||
551 | unless defined $moniker; | ||||
552 | 4060 | 707ms | return $self->source($moniker)->resultset; # spent 614ms making 2030 calls to DBIx::Class::ResultSource::resultset, avg 303µs/call
# spent 93.0ms making 2030 calls to DBIx::Class::Schema::source, avg 46µs/call | ||
553 | } | ||||
554 | |||||
555 | =head2 sources | ||||
556 | |||||
557 | =over 4 | ||||
558 | |||||
559 | =item Return Value: @source_names | ||||
560 | |||||
561 | =back | ||||
562 | |||||
563 | my @source_names = $schema->sources; | ||||
564 | |||||
565 | Lists names of all the sources registered on this Schema object. | ||||
566 | |||||
567 | =cut | ||||
568 | |||||
569 | 11 | 118µs | 11 | 196µs | # spent 290µs (94+196) within DBIx::Class::Schema::sources which was called 11 times, avg 26µs/call:
# 6 times (47µs+92µs) by DBIx::Class::Schema::clone at line 1039, avg 23µs/call
# 4 times (35µs+81µs) by SQL::Translator::Parser::DBIx::Class::parse at line 59 of SQL/Translator/Parser/DBIx/Class.pm, avg 29µs/call
# once (11µs+23µs) by Test::Fixture::DBIC::Schema::_delete_all at line 66 of Test/Fixture/DBIC/Schema.pm # spent 196µs making 11 calls to DBIx::Class::Schema::source_registrations, avg 18µs/call |
570 | |||||
571 | =head2 source | ||||
572 | |||||
573 | =over 4 | ||||
574 | |||||
575 | =item Arguments: $source_name | ||||
576 | |||||
577 | =item Return Value: $result_source | ||||
578 | |||||
579 | =back | ||||
580 | |||||
581 | my $source = $schema->source('Book'); | ||||
582 | |||||
583 | Returns the L<DBIx::Class::ResultSource> object for the registered | ||||
584 | source name. | ||||
585 | |||||
586 | =cut | ||||
587 | |||||
588 | # spent 266ms (85.7+180) within DBIx::Class::Schema::source which was called 6320 times, avg 42µs/call:
# 4155 times (61.3ms+110ms) by DBIx::Class::ResultSource::related_source at line 1853 of DBIx/Class/ResultSource.pm, avg 41µs/call
# 2030 times (23.6ms+69.4ms) by DBIx::Class::Schema::resultset at line 552, avg 46µs/call
# 57 times (395µs+836µs) by DBIx::Class::Schema::clone at line 1040, avg 22µs/call
# 37 times (145µs+291µs) by SQL::Translator::Parser::DBIx::Class::parse at line 78 of SQL/Translator/Parser/DBIx/Class.pm, avg 12µs/call
# 35 times (159µs+360µs) by SQL::Translator::Parser::DBIx::Class::parse at line 90 of SQL/Translator/Parser/DBIx/Class.pm, avg 15µs/call
# 2 times (12µs+20µs) by SQL::Translator::Parser::DBIx::Class::parse at line 303 of SQL/Translator/Parser/DBIx/Class.pm, avg 16µs/call
# 2 times (7µs+16µs) by SQL::Translator::Parser::DBIx::Class::parse at line 313 of SQL/Translator/Parser/DBIx/Class.pm, avg 12µs/call
# 2 times (7µs+16µs) by SQL::Translator::Parser::DBIx::Class::parse at line 305 of SQL/Translator/Parser/DBIx/Class.pm, avg 12µs/call | ||||
589 | 44065 | 84.5ms | my $self = shift; | ||
590 | |||||
591 | $self->throw_exception("source() expects a source name") | ||||
592 | unless @_; | ||||
593 | |||||
594 | my $moniker = shift; | ||||
595 | |||||
596 | 6320 | 129ms | my $sreg = $self->source_registrations; # spent 129ms making 6320 calls to DBIx::Class::Schema::source_registrations, avg 20µs/call | ||
597 | return $sreg->{$moniker} if exists $sreg->{$moniker}; | ||||
598 | |||||
599 | # if we got here, they probably passed a full class name | ||||
600 | 4155 | 51.3ms | my $mapped = $self->class_mappings->{$moniker}; # spent 51.3ms making 4155 calls to DBIx::Class::Schema::class_mappings, avg 12µs/call | ||
601 | $self->throw_exception("Can't find source for ${moniker}") | ||||
602 | unless $mapped && exists $sreg->{$mapped}; | ||||
603 | return $sreg->{$mapped}; | ||||
604 | } | ||||
605 | |||||
606 | =head2 class | ||||
607 | |||||
608 | =over 4 | ||||
609 | |||||
610 | =item Arguments: $source_name | ||||
611 | |||||
612 | =item Return Value: $classname | ||||
613 | |||||
614 | =back | ||||
615 | |||||
616 | my $class = $schema->class('CD'); | ||||
617 | |||||
618 | Retrieves the Result class name for the given source name. | ||||
619 | |||||
620 | =cut | ||||
621 | |||||
622 | sub class { | ||||
623 | my ($self, $moniker) = @_; | ||||
624 | return $self->source($moniker)->result_class; | ||||
625 | } | ||||
626 | |||||
627 | =head2 txn_do | ||||
628 | |||||
629 | =over 4 | ||||
630 | |||||
631 | =item Arguments: C<$coderef>, @coderef_args? | ||||
632 | |||||
633 | =item Return Value: The return value of $coderef | ||||
634 | |||||
635 | =back | ||||
636 | |||||
637 | Executes C<$coderef> with (optional) arguments C<@coderef_args> atomically, | ||||
638 | returning its result (if any). Equivalent to calling $schema->storage->txn_do. | ||||
639 | See L<DBIx::Class::Storage/"txn_do"> for more information. | ||||
640 | |||||
641 | This interface is preferred over using the individual methods L</txn_begin>, | ||||
642 | L</txn_commit>, and L</txn_rollback> below. | ||||
643 | |||||
644 | WARNING: If you are connected with C<< AutoCommit => 0 >> the transaction is | ||||
645 | considered nested, and you will still need to call L</txn_commit> to write your | ||||
646 | changes when appropriate. You will also want to connect with C<< auto_savepoint => | ||||
647 | 1 >> to get partial rollback to work, if the storage driver for your database | ||||
648 | supports it. | ||||
649 | |||||
650 | Connecting with C<< AutoCommit => 1 >> is recommended. | ||||
651 | |||||
652 | =cut | ||||
653 | |||||
654 | sub txn_do { | ||||
655 | my $self = shift; | ||||
656 | |||||
657 | $self->storage or $self->throw_exception | ||||
658 | ('txn_do called on $schema without storage'); | ||||
659 | |||||
660 | $self->storage->txn_do(@_); | ||||
661 | } | ||||
662 | |||||
663 | =head2 txn_scope_guard | ||||
664 | |||||
665 | Runs C<txn_scope_guard> on the schema's storage. See | ||||
666 | L<DBIx::Class::Storage/txn_scope_guard>. | ||||
667 | |||||
668 | =cut | ||||
669 | |||||
670 | # spent 56.6ms (2.84+53.8) within DBIx::Class::Schema::txn_scope_guard which was called 147 times, avg 385µs/call:
# 147 times (2.84ms+53.8ms) by DBIx::Class::Relationship::CascadeActions::update at line 55 of DBIx/Class/Relationship/CascadeActions.pm, avg 385µs/call | ||||
671 | 441 | 2.35ms | my $self = shift; | ||
672 | |||||
673 | 147 | 3.46ms | $self->storage or $self->throw_exception # spent 3.46ms making 147 calls to DBIx::Class::Schema::storage, avg 24µs/call | ||
674 | ('txn_scope_guard called on $schema without storage'); | ||||
675 | |||||
676 | 294 | 50.4ms | $self->storage->txn_scope_guard(@_); # spent 47.9ms making 147 calls to DBIx::Class::Storage::txn_scope_guard, avg 326µs/call
# spent 2.48ms making 147 calls to DBIx::Class::Schema::storage, avg 17µs/call | ||
677 | } | ||||
678 | |||||
679 | =head2 txn_begin | ||||
680 | |||||
681 | Begins a transaction (does nothing if AutoCommit is off). Equivalent to | ||||
682 | calling $schema->storage->txn_begin. See | ||||
683 | L<DBIx::Class::Storage/"txn_begin"> for more information. | ||||
684 | |||||
685 | =cut | ||||
686 | |||||
687 | sub txn_begin { | ||||
688 | my $self = shift; | ||||
689 | |||||
690 | $self->storage or $self->throw_exception | ||||
691 | ('txn_begin called on $schema without storage'); | ||||
692 | |||||
693 | $self->storage->txn_begin; | ||||
694 | } | ||||
695 | |||||
696 | =head2 txn_commit | ||||
697 | |||||
698 | Commits the current transaction. Equivalent to calling | ||||
699 | $schema->storage->txn_commit. See L<DBIx::Class::Storage/"txn_commit"> | ||||
700 | for more information. | ||||
701 | |||||
702 | =cut | ||||
703 | |||||
704 | sub txn_commit { | ||||
705 | my $self = shift; | ||||
706 | |||||
707 | $self->storage or $self->throw_exception | ||||
708 | ('txn_commit called on $schema without storage'); | ||||
709 | |||||
710 | $self->storage->txn_commit; | ||||
711 | } | ||||
712 | |||||
713 | =head2 txn_rollback | ||||
714 | |||||
715 | Rolls back the current transaction. Equivalent to calling | ||||
716 | $schema->storage->txn_rollback. See | ||||
717 | L<DBIx::Class::Storage/"txn_rollback"> for more information. | ||||
718 | |||||
719 | =cut | ||||
720 | |||||
721 | sub txn_rollback { | ||||
722 | my $self = shift; | ||||
723 | |||||
724 | $self->storage or $self->throw_exception | ||||
725 | ('txn_rollback called on $schema without storage'); | ||||
726 | |||||
727 | $self->storage->txn_rollback; | ||||
728 | } | ||||
729 | |||||
730 | =head2 storage | ||||
731 | |||||
732 | my $storage = $schema->storage; | ||||
733 | |||||
734 | Returns the L<DBIx::Class::Storage> object for this Schema. Grab this | ||||
735 | if you want to turn on SQL statement debugging at runtime, or set the | ||||
736 | quote character. For the default storage, the documentation can be | ||||
737 | found in L<DBIx::Class::Storage::DBI>. | ||||
738 | |||||
739 | =head2 populate | ||||
740 | |||||
741 | =over 4 | ||||
742 | |||||
743 | =item Arguments: $source_name, \@data; | ||||
744 | |||||
745 | =item Return value: \@$objects | nothing | ||||
746 | |||||
747 | =back | ||||
748 | |||||
749 | Pass this method a resultsource name, and an arrayref of | ||||
750 | arrayrefs. The arrayrefs should contain a list of column names, | ||||
751 | followed by one or many sets of matching data for the given columns. | ||||
752 | |||||
753 | In void context, C<insert_bulk> in L<DBIx::Class::Storage::DBI> is used | ||||
754 | to insert the data, as this is a fast method. However, insert_bulk currently | ||||
755 | assumes that your datasets all contain the same type of values, using scalar | ||||
756 | references in a column in one row, and not in another will probably not work. | ||||
757 | |||||
758 | Otherwise, each set of data is inserted into the database using | ||||
759 | L<DBIx::Class::ResultSet/create>, and a arrayref of the resulting row | ||||
760 | objects is returned. | ||||
761 | |||||
762 | e.g. | ||||
763 | |||||
764 | $schema->populate('Artist', [ | ||||
765 | [ qw/artistid name/ ], | ||||
766 | [ 1, 'Popular Band' ], | ||||
767 | [ 2, 'Indie Band' ], | ||||
768 | ... | ||||
769 | ]); | ||||
770 | |||||
771 | Since wantarray context is basically the same as looping over $rs->create(...) | ||||
772 | you won't see any performance benefits and in this case the method is more for | ||||
773 | convenience. Void context sends the column information directly to storage | ||||
774 | using <DBI>s bulk insert method. So the performance will be much better for | ||||
775 | storages that support this method. | ||||
776 | |||||
777 | Because of this difference in the way void context inserts rows into your | ||||
778 | database you need to note how this will effect any loaded components that | ||||
779 | override or augment insert. For example if you are using a component such | ||||
780 | as L<DBIx::Class::UUIDColumns> to populate your primary keys you MUST use | ||||
781 | wantarray context if you want the PKs automatically created. | ||||
782 | |||||
783 | =cut | ||||
784 | |||||
785 | sub populate { | ||||
786 | my ($self, $name, $data) = @_; | ||||
787 | if(my $rs = $self->resultset($name)) { | ||||
788 | if(defined wantarray) { | ||||
789 | return $rs->populate($data); | ||||
790 | } else { | ||||
791 | $rs->populate($data); | ||||
792 | } | ||||
793 | } else { | ||||
794 | $self->throw_exception("$name is not a resultset"); | ||||
795 | } | ||||
796 | } | ||||
797 | |||||
798 | =head2 connection | ||||
799 | |||||
800 | =over 4 | ||||
801 | |||||
802 | =item Arguments: @args | ||||
803 | |||||
804 | =item Return Value: $new_schema | ||||
805 | |||||
806 | =back | ||||
807 | |||||
808 | Similar to L</connect> except sets the storage object and connection | ||||
809 | data in-place on the Schema class. You should probably be calling | ||||
810 | L</connect> to get a proper Schema object instead. | ||||
811 | |||||
812 | =head3 Overloading | ||||
813 | |||||
814 | Overload C<connection> to change the behaviour of C<connect>. | ||||
815 | |||||
816 | =cut | ||||
817 | |||||
818 | # spent 24.6ms (219µs+24.4) within DBIx::Class::Schema::connection which was called 6 times, avg 4.10ms/call:
# 3 times (137µs+23.9ms) by DBIx::Class::Schema::Versioned::connection at line 28 of mro.pm, avg 8.01ms/call
# 3 times (82µs+449µs) by DBIx::Class::Schema::connect at line 529, avg 177µs/call | ||||
819 | 54 | 221µs | my ($self, @info) = @_; | ||
820 | return $self if !@info && $self->storage; | ||||
821 | |||||
822 | 12 | 228µs | my ($storage_class, $args) = ref $self->storage_type ? # spent 228µs making 12 calls to DBIx::Class::Schema::storage_type, avg 19µs/call | ||
823 | ($self->_normalize_storage_type($self->storage_type),{}) : ($self->storage_type, {}); | ||||
824 | |||||
825 | 6 | 22µs | $storage_class = 'DBIx::Class::Storage'.$storage_class # spent 22µs making 6 calls to DBIx::Class::Schema::CORE:match, avg 4µs/call | ||
826 | if $storage_class =~ m/^::/; | ||||
827 | # spent 22.4ms (40µs+22.4) within DBIx::Class::Schema::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/Schema.pm:829] which was called 6 times, avg 3.74ms/call:
# 6 times (40µs+22.4ms) by Try::Tiny::try at line 76 of Try/Tiny.pm, avg 3.74ms/call | ||||
828 | 6 | 46µs | 6 | 22.4ms | $self->ensure_class_loaded ($storage_class); # spent 22.4ms making 6 calls to Class::C3::Componentised::ensure_class_loaded, avg 3.73ms/call |
829 | } | ||||
830 | catch { | ||||
831 | $self->throw_exception( | ||||
832 | "Unable to load storage class ${storage_class}: $_" | ||||
833 | ); | ||||
834 | 12 | 22.6ms | }; # spent 22.6ms making 6 calls to Try::Tiny::try, avg 3.76ms/call
# spent 33µs making 6 calls to Try::Tiny::catch, avg 5µs/call | ||
835 | 6 | 709µs | my $storage = $storage_class->new($self=>$args); # spent 709µs making 6 calls to DBIx::Class::Storage::DBI::new, avg 118µs/call | ||
836 | 6 | 745µs | $storage->connect_info(\@info); # spent 745µs making 6 calls to DBIx::Class::Storage::DBI::connect_info, avg 124µs/call | ||
837 | 6 | 66µs | $self->storage($storage); # spent 66µs making 6 calls to DBIx::Class::Schema::storage, avg 11µs/call | ||
838 | return $self; | ||||
839 | } | ||||
840 | |||||
841 | sub _normalize_storage_type { | ||||
842 | my ($self, $storage_type) = @_; | ||||
843 | if(ref $storage_type eq 'ARRAY') { | ||||
844 | return @$storage_type; | ||||
845 | } elsif(ref $storage_type eq 'HASH') { | ||||
846 | return %$storage_type; | ||||
847 | } else { | ||||
848 | $self->throw_exception('Unsupported REFTYPE given: '. ref $storage_type); | ||||
849 | } | ||||
850 | } | ||||
851 | |||||
852 | =head2 compose_namespace | ||||
853 | |||||
854 | =over 4 | ||||
855 | |||||
856 | =item Arguments: $target_namespace, $additional_base_class? | ||||
857 | |||||
858 | =item Retur Value: $new_schema | ||||
859 | |||||
860 | =back | ||||
861 | |||||
862 | For each L<DBIx::Class::ResultSource> in the schema, this method creates a | ||||
863 | class in the target namespace (e.g. $target_namespace::CD, | ||||
864 | $target_namespace::Artist) that inherits from the corresponding classes | ||||
865 | attached to the current schema. | ||||
866 | |||||
867 | It also attaches a corresponding L<DBIx::Class::ResultSource> object to the | ||||
868 | new $schema object. If C<$additional_base_class> is given, the new composed | ||||
869 | classes will inherit from first the corresponding class from the current | ||||
870 | schema then the base class. | ||||
871 | |||||
872 | For example, for a schema with My::Schema::CD and My::Schema::Artist classes, | ||||
873 | |||||
874 | $schema->compose_namespace('My::DB', 'Base::Class'); | ||||
875 | print join (', ', @My::DB::CD::ISA) . "\n"; | ||||
876 | print join (', ', @My::DB::Artist::ISA) ."\n"; | ||||
877 | |||||
878 | will produce the output | ||||
879 | |||||
880 | My::Schema::CD, Base::Class | ||||
881 | My::Schema::Artist, Base::Class | ||||
882 | |||||
883 | =cut | ||||
884 | |||||
885 | # this might be oversimplified | ||||
886 | # sub compose_namespace { | ||||
887 | # my ($self, $target, $base) = @_; | ||||
888 | |||||
889 | # my $schema = $self->clone; | ||||
890 | # foreach my $moniker ($schema->sources) { | ||||
891 | # my $source = $schema->source($moniker); | ||||
892 | # my $target_class = "${target}::${moniker}"; | ||||
893 | # $self->inject_base( | ||||
894 | # $target_class => $source->result_class, ($base ? $base : ()) | ||||
895 | # ); | ||||
896 | # $source->result_class($target_class); | ||||
897 | # $target_class->result_source_instance($source) | ||||
898 | # if $target_class->can('result_source_instance'); | ||||
899 | # $schema->register_source($moniker, $source); | ||||
900 | # } | ||||
901 | # return $schema; | ||||
902 | # } | ||||
903 | |||||
904 | sub compose_namespace { | ||||
905 | my ($self, $target, $base) = @_; | ||||
906 | |||||
907 | my $schema = $self->clone; | ||||
908 | |||||
909 | $schema->source_registrations({}); | ||||
910 | |||||
911 | # the original class-mappings must remain - otherwise | ||||
912 | # reverse_relationship_info will not work | ||||
913 | #$schema->class_mappings({}); | ||||
914 | |||||
915 | { | ||||
916 | 3 | 42µs | 2 | 24µs | # spent 16µs (8+8) within DBIx::Class::Schema::BEGIN@916 which was called:
# once (8µs+8µs) by parent::import at line 916 # spent 16µs making 1 call to DBIx::Class::Schema::BEGIN@916
# spent 8µs making 1 call to warnings::unimport |
917 | local *Class::C3::reinitialize = sub { } if DBIx::Class::_ENV_::OLD_MRO; | ||||
918 | 3 | 18µs | 2 | 20µs | # spent 13µs (6+7) within DBIx::Class::Schema::BEGIN@918 which was called:
# once (6µs+7µs) by parent::import at line 918 # spent 13µs making 1 call to DBIx::Class::Schema::BEGIN@918
# spent 7µs making 1 call to warnings::import |
919 | |||||
920 | 3 | 100µs | 2 | 36µs | # spent 22µs (8+14) within DBIx::Class::Schema::BEGIN@920 which was called:
# once (8µs+14µs) by parent::import at line 920 # spent 22µs making 1 call to DBIx::Class::Schema::BEGIN@920
# spent 14µs making 1 call to strict::unimport |
921 | foreach my $moniker ($self->sources) { | ||||
922 | my $orig_source = $self->source($moniker); | ||||
923 | |||||
924 | my $target_class = "${target}::${moniker}"; | ||||
925 | $self->inject_base($target_class, $orig_source->result_class, ($base || ()) ); | ||||
926 | |||||
927 | # register_source examines result_class, and then returns us a clone | ||||
928 | my $new_source = $schema->register_source($moniker, bless | ||||
929 | { %$orig_source, result_class => $target_class }, | ||||
930 | ref $orig_source, | ||||
931 | ); | ||||
932 | |||||
933 | if ($target_class->can('result_source_instance')) { | ||||
934 | # give the class a schema-less source copy | ||||
935 | $target_class->result_source_instance( bless | ||||
936 | { %$new_source, schema => ref $new_source->{schema} || $new_source->{schema} }, | ||||
937 | ref $new_source, | ||||
938 | ); | ||||
939 | } | ||||
940 | } | ||||
941 | |||||
942 | foreach my $meth (qw/class source resultset/) { | ||||
943 | 3 | 748µs | 2 | 18µs | # spent 12µs (6+6) within DBIx::Class::Schema::BEGIN@943 which was called:
# once (6µs+6µs) by parent::import at line 943 # spent 12µs making 1 call to DBIx::Class::Schema::BEGIN@943
# spent 6µs making 1 call to warnings::unimport |
944 | *{"${target}::${meth}"} = subname "${target}::${meth}" => | ||||
945 | sub { shift->schema->$meth(@_) }; | ||||
946 | } | ||||
947 | } | ||||
948 | |||||
949 | Class::C3->reinitialize() if DBIx::Class::_ENV_::OLD_MRO; | ||||
950 | |||||
951 | return $schema; | ||||
952 | } | ||||
953 | |||||
954 | sub setup_connection_class { | ||||
955 | my ($class, $target, @info) = @_; | ||||
956 | $class->inject_base($target => 'DBIx::Class::DB'); | ||||
957 | #$target->load_components('DB'); | ||||
958 | $target->connection(@info); | ||||
959 | } | ||||
960 | |||||
961 | =head2 svp_begin | ||||
962 | |||||
963 | Creates a new savepoint (does nothing outside a transaction). | ||||
964 | Equivalent to calling $schema->storage->svp_begin. See | ||||
965 | L<DBIx::Class::Storage/"svp_begin"> for more information. | ||||
966 | |||||
967 | =cut | ||||
968 | |||||
969 | sub svp_begin { | ||||
970 | my ($self, $name) = @_; | ||||
971 | |||||
972 | $self->storage or $self->throw_exception | ||||
973 | ('svp_begin called on $schema without storage'); | ||||
974 | |||||
975 | $self->storage->svp_begin($name); | ||||
976 | } | ||||
977 | |||||
978 | =head2 svp_release | ||||
979 | |||||
980 | Releases a savepoint (does nothing outside a transaction). | ||||
981 | Equivalent to calling $schema->storage->svp_release. See | ||||
982 | L<DBIx::Class::Storage/"svp_release"> for more information. | ||||
983 | |||||
984 | =cut | ||||
985 | |||||
986 | sub svp_release { | ||||
987 | my ($self, $name) = @_; | ||||
988 | |||||
989 | $self->storage or $self->throw_exception | ||||
990 | ('svp_release called on $schema without storage'); | ||||
991 | |||||
992 | $self->storage->svp_release($name); | ||||
993 | } | ||||
994 | |||||
995 | =head2 svp_rollback | ||||
996 | |||||
997 | Rollback to a savepoint (does nothing outside a transaction). | ||||
998 | Equivalent to calling $schema->storage->svp_rollback. See | ||||
999 | L<DBIx::Class::Storage/"svp_rollback"> for more information. | ||||
1000 | |||||
1001 | =cut | ||||
1002 | |||||
1003 | sub svp_rollback { | ||||
1004 | my ($self, $name) = @_; | ||||
1005 | |||||
1006 | $self->storage or $self->throw_exception | ||||
1007 | ('svp_rollback called on $schema without storage'); | ||||
1008 | |||||
1009 | $self->storage->svp_rollback($name); | ||||
1010 | } | ||||
1011 | |||||
1012 | =head2 clone | ||||
1013 | |||||
1014 | =over 4 | ||||
1015 | |||||
1016 | =item Arguments: %attrs? | ||||
1017 | |||||
1018 | =item Return Value: $new_schema | ||||
1019 | |||||
1020 | =back | ||||
1021 | |||||
1022 | Clones the schema and its associated result_source objects and returns the | ||||
1023 | copy. The resulting copy will have the same attributes as the source schema, | ||||
1024 | except for those attributes explicitly overriden by the provided C<%attrs>. | ||||
1025 | |||||
1026 | =cut | ||||
1027 | |||||
1028 | # spent 11.3ms (1.55+9.78) within DBIx::Class::Schema::clone which was called 6 times, avg 1.89ms/call:
# 6 times (1.55ms+9.78ms) by DBIx::Class::Schema::connect at line 529, avg 1.89ms/call | ||||
1029 | 219 | 1.04ms | my $self = shift; | ||
1030 | |||||
1031 | my $clone = { | ||||
1032 | (ref $self ? %$self : ()), | ||||
1033 | (@_ == 1 && ref $_[0] eq 'HASH' ? %{ $_[0] } : @_), | ||||
1034 | }; | ||||
1035 | bless $clone, (ref $self || $self); | ||||
1036 | |||||
1037 | 12 | 378µs | $clone->class_mappings({ %{$clone->class_mappings} }); # spent 378µs making 12 calls to DBIx::Class::Schema::class_mappings, avg 32µs/call | ||
1038 | 12 | 223µs | $clone->source_registrations({ %{$clone->source_registrations} }); # spent 223µs making 12 calls to DBIx::Class::Schema::source_registrations, avg 19µs/call | ||
1039 | 6 | 140µs | foreach my $moniker ($self->sources) { # spent 140µs making 6 calls to DBIx::Class::Schema::sources, avg 23µs/call | ||
1040 | 57 | 1.23ms | my $source = $self->source($moniker); # spent 1.23ms making 57 calls to DBIx::Class::Schema::source, avg 22µs/call | ||
1041 | 57 | 1.64ms | my $new = $source->new($source); # spent 1.55ms making 55 calls to DBIx::Class::ResultSource::new, avg 28µs/call
# spent 82µs making 2 calls to DBIx::Class::ResultSource::View::new, avg 41µs/call | ||
1042 | # we use extra here as we want to leave the class_mappings as they are | ||||
1043 | # but overwrite the source_registrations entry with the new source | ||||
1044 | 1 | 241µs | 114 | 5.98ms | $clone->register_extra_source($moniker => $new); # spent 5.86ms making 57 calls to DBIx::Class::Schema::register_extra_source, avg 103µs/call
# spent 124µs making 57 calls to DBIx::Class::ResultSource::DESTROY, avg 2µs/call |
1045 | } | ||||
1046 | 6 | 191µs | $clone->storage->set_schema($clone) if $clone->storage; # spent 191µs making 6 calls to DBIx::Class::Schema::storage, avg 32µs/call | ||
1047 | |||||
1048 | return $clone; | ||||
1049 | } | ||||
1050 | |||||
1051 | =head2 throw_exception | ||||
1052 | |||||
1053 | =over 4 | ||||
1054 | |||||
1055 | =item Arguments: $message | ||||
1056 | |||||
1057 | =back | ||||
1058 | |||||
1059 | Throws an exception. Obeys the exemption rules of L<DBIx::Class::Carp> to report | ||||
1060 | errors from outer-user's perspective. See L</exception_action> for details on overriding | ||||
1061 | this method's behavior. If L</stacktrace> is turned on, C<throw_exception>'s | ||||
1062 | default behavior will provide a detailed stack trace. | ||||
1063 | |||||
1064 | =cut | ||||
1065 | |||||
1066 | 1 | 100ns | my $false_exception_action_warned; | ||
1067 | # spent 4.67ms (68µs+4.60) within DBIx::Class::Schema::throw_exception which was called 4 times, avg 1.17ms/call:
# 4 times (68µs+4.60ms) by DBIx::Class::Storage::throw_exception at line 111 of DBIx/Class/Storage.pm, avg 1.17ms/call | ||||
1068 | 12 | 48µs | my $self = shift; | ||
1069 | |||||
1070 | 4 | 242µs | if (my $act = $self->exception_action) { # spent 242µs making 4 calls to DBIx::Class::Schema::exception_action, avg 61µs/call | ||
1071 | if ($act->(@_)) { | ||||
1072 | DBIx::Class::Exception->throw( | ||||
1073 | "Invocation of the exception_action handler installed on $self did *not*" | ||||
1074 | .' result in an exception. DBIx::Class is unable to function without a reliable' | ||||
1075 | .' exception mechanism, ensure that exception_action does not hide exceptions' | ||||
1076 | ." (original error: $_[0])" | ||||
1077 | ); | ||||
1078 | } | ||||
1079 | elsif(! $false_exception_action_warned++) { | ||||
1080 | carp ( | ||||
1081 | "The exception_action handler installed on $self returned false instead" | ||||
1082 | .' of throwing an exception. This behavior has been deprecated, adjust your' | ||||
1083 | .' handler to always rethrow the supplied error.' | ||||
1084 | ); | ||||
1085 | } | ||||
1086 | } | ||||
1087 | |||||
1088 | 8 | 4.36ms | DBIx::Class::Exception->throw($_[0], $self->stacktrace); # spent 4.24ms making 4 calls to DBIx::Class::Exception::throw, avg 1.06ms/call
# spent 120µs making 4 calls to DBIx::Class::Schema::stacktrace, avg 30µs/call | ||
1089 | } | ||||
1090 | |||||
1091 | =head2 deploy | ||||
1092 | |||||
1093 | =over 4 | ||||
1094 | |||||
1095 | =item Arguments: \%sqlt_args, $dir | ||||
1096 | |||||
1097 | =back | ||||
1098 | |||||
1099 | Attempts to deploy the schema to the current storage using L<SQL::Translator>. | ||||
1100 | |||||
1101 | See L<SQL::Translator/METHODS> for a list of values for C<\%sqlt_args>. | ||||
1102 | The most common value for this would be C<< { add_drop_table => 1 } >> | ||||
1103 | to have the SQL produced include a C<DROP TABLE> statement for each table | ||||
1104 | created. For quoting purposes supply C<quote_table_names> and | ||||
1105 | C<quote_field_names>. | ||||
1106 | |||||
1107 | Additionally, the DBIx::Class parser accepts a C<sources> parameter as a hash | ||||
1108 | ref or an array ref, containing a list of source to deploy. If present, then | ||||
1109 | only the sources listed will get deployed. Furthermore, you can use the | ||||
1110 | C<add_fk_index> parser parameter to prevent the parser from creating an index for each | ||||
1111 | FK. | ||||
1112 | |||||
1113 | =cut | ||||
1114 | |||||
1115 | # spent 8.22s (92µs+8.22) within DBIx::Class::Schema::deploy which was called 4 times, avg 2.05s/call:
# 2 times (45µs+7.98s) by DBIx::Class::Schema::Versioned::deploy at line 28 of mro.pm, avg 3.99s/call
# 2 times (47µs+240ms) by DBIx::Class::Schema::Versioned::install at line 259 of DBIx/Class/Schema/Versioned.pm, avg 120ms/call | ||||
1116 | 12 | 85µs | my ($self, $sqltargs, $dir) = @_; | ||
1117 | 4 | 53µs | $self->throw_exception("Can't deploy without storage") unless $self->storage; # spent 53µs making 4 calls to DBIx::Class::Schema::storage, avg 13µs/call | ||
1118 | 8 | 8.22s | $self->storage->deploy($self, undef, $sqltargs, $dir); # spent 8.22s making 4 calls to DBIx::Class::Storage::DBI::deploy, avg 2.05s/call
# spent 31µs making 4 calls to DBIx::Class::Schema::storage, avg 8µs/call | ||
1119 | } | ||||
1120 | |||||
1121 | =head2 deployment_statements | ||||
1122 | |||||
1123 | =over 4 | ||||
1124 | |||||
1125 | =item Arguments: See L<DBIx::Class::Storage::DBI/deployment_statements> | ||||
1126 | |||||
1127 | =item Return value: $listofstatements | ||||
1128 | |||||
1129 | =back | ||||
1130 | |||||
1131 | A convenient shortcut to | ||||
1132 | C<< $self->storage->deployment_statements($self, @args) >>. | ||||
1133 | Returns the SQL statements used by L</deploy> and | ||||
1134 | L<DBIx::Class::Schema::Storage/deploy>. | ||||
1135 | |||||
1136 | =cut | ||||
1137 | |||||
1138 | # spent 256ms (61µs+256) within DBIx::Class::Schema::deployment_statements which was called 4 times, avg 64.0ms/call:
# 4 times (61µs+256ms) by DBIx::Class::Storage::DBI::deploy at line 2768 of DBIx/Class/Storage/DBI.pm, avg 64.0ms/call | ||||
1139 | 12 | 39µs | my $self = shift; | ||
1140 | |||||
1141 | 4 | 32µs | $self->throw_exception("Can't generate deployment statements without a storage") # spent 32µs making 4 calls to DBIx::Class::Schema::storage, avg 8µs/call | ||
1142 | if not $self->storage; | ||||
1143 | |||||
1144 | 8 | 9.43ms | $self->storage->deployment_statements($self, @_); # spent 7.09ms making 2 calls to DBIx::Class::Storage::DBI::SQLite::deployment_statements, avg 3.54ms/call
# spent 2.31ms making 2 calls to DBIx::Class::Storage::DBI::deployment_statements, avg 1.15ms/call
# spent 30µs making 4 calls to DBIx::Class::Schema::storage, avg 8µs/call | ||
1145 | } | ||||
1146 | |||||
1147 | =head2 create_ddl_dir | ||||
1148 | |||||
1149 | =over 4 | ||||
1150 | |||||
1151 | =item Arguments: See L<DBIx::Class::Storage::DBI/create_ddl_dir> | ||||
1152 | |||||
1153 | =back | ||||
1154 | |||||
1155 | A convenient shortcut to | ||||
1156 | C<< $self->storage->create_ddl_dir($self, @args) >>. | ||||
1157 | |||||
1158 | Creates an SQL file based on the Schema, for each of the specified | ||||
1159 | database types, in the given directory. | ||||
1160 | |||||
1161 | =cut | ||||
1162 | |||||
1163 | sub create_ddl_dir { | ||||
1164 | my $self = shift; | ||||
1165 | |||||
1166 | $self->throw_exception("Can't create_ddl_dir without storage") unless $self->storage; | ||||
1167 | $self->storage->create_ddl_dir($self, @_); | ||||
1168 | } | ||||
1169 | |||||
1170 | =head2 ddl_filename | ||||
1171 | |||||
1172 | =over 4 | ||||
1173 | |||||
1174 | =item Arguments: $database-type, $version, $directory, $preversion | ||||
1175 | |||||
1176 | =item Return value: $normalised_filename | ||||
1177 | |||||
1178 | =back | ||||
1179 | |||||
1180 | my $filename = $table->ddl_filename($type, $version, $dir, $preversion) | ||||
1181 | |||||
1182 | This method is called by C<create_ddl_dir> to compose a file name out of | ||||
1183 | the supplied directory, database type and version number. The default file | ||||
1184 | name format is: C<$dir$schema-$version-$type.sql>. | ||||
1185 | |||||
1186 | You may override this method in your schema if you wish to use a different | ||||
1187 | format. | ||||
1188 | |||||
1189 | WARNING | ||||
1190 | |||||
1191 | Prior to DBIx::Class version 0.08100 this method had a different signature: | ||||
1192 | |||||
1193 | my $filename = $table->ddl_filename($type, $dir, $version, $preversion) | ||||
1194 | |||||
1195 | In recent versions variables $dir and $version were reversed in order to | ||||
1196 | bring the signature in line with other Schema/Storage methods. If you | ||||
1197 | really need to maintain backward compatibility, you can do the following | ||||
1198 | in any overriding methods: | ||||
1199 | |||||
1200 | ($dir, $version) = ($version, $dir) if ($DBIx::Class::VERSION < 0.08100); | ||||
1201 | |||||
1202 | =cut | ||||
1203 | |||||
1204 | # spent 279µs (62+217) within DBIx::Class::Schema::ddl_filename which was called 4 times, avg 70µs/call:
# 4 times (62µs+217µs) by DBIx::Class::Storage::DBI::deployment_statements at line 2704 of DBIx/Class/Storage/DBI.pm, avg 70µs/call | ||||
1205 | 28 | 87µs | my ($self, $type, $version, $dir, $preversion) = @_; | ||
1206 | |||||
1207 | require File::Spec; | ||||
1208 | |||||
1209 | my $filename = ref($self); | ||||
1210 | 4 | 19µs | $filename =~ s/::/-/g; # spent 19µs making 4 calls to DBIx::Class::Schema::CORE:subst, avg 5µs/call | ||
1211 | 4 | 198µs | $filename = File::Spec->catfile($dir, "$filename-$version-$type.sql"); # spent 198µs making 4 calls to File::Spec::Unix::catfile, avg 49µs/call | ||
1212 | $filename =~ s/$version/$preversion-$version/ if($preversion); | ||||
1213 | |||||
1214 | return $filename; | ||||
1215 | } | ||||
1216 | |||||
1217 | =head2 thaw | ||||
1218 | |||||
1219 | Provided as the recommended way of thawing schema objects. You can call | ||||
1220 | C<Storable::thaw> directly if you wish, but the thawed objects will not have a | ||||
1221 | reference to any schema, so are rather useless. | ||||
1222 | |||||
1223 | =cut | ||||
1224 | |||||
1225 | sub thaw { | ||||
1226 | my ($self, $obj) = @_; | ||||
1227 | local $DBIx::Class::ResultSourceHandle::thaw_schema = $self; | ||||
1228 | require Storable; | ||||
1229 | return Storable::thaw($obj); | ||||
1230 | } | ||||
1231 | |||||
1232 | =head2 freeze | ||||
1233 | |||||
1234 | This doesn't actually do anything more than call L<Storable/nfreeze>, it is just | ||||
1235 | provided here for symmetry. | ||||
1236 | |||||
1237 | =cut | ||||
1238 | |||||
1239 | sub freeze { | ||||
1240 | require Storable; | ||||
1241 | return Storable::nfreeze($_[1]); | ||||
1242 | } | ||||
1243 | |||||
1244 | =head2 dclone | ||||
1245 | |||||
1246 | =over 4 | ||||
1247 | |||||
1248 | =item Arguments: $object | ||||
1249 | |||||
1250 | =item Return Value: dcloned $object | ||||
1251 | |||||
1252 | =back | ||||
1253 | |||||
1254 | Recommended way of dcloning L<DBIx::Class::Row> and L<DBIx::Class::ResultSet> | ||||
1255 | objects so their references to the schema object | ||||
1256 | (which itself is B<not> cloned) are properly maintained. | ||||
1257 | |||||
1258 | =cut | ||||
1259 | |||||
1260 | sub dclone { | ||||
1261 | my ($self, $obj) = @_; | ||||
1262 | local $DBIx::Class::ResultSourceHandle::thaw_schema = $self; | ||||
1263 | require Storable; | ||||
1264 | return Storable::dclone($obj); | ||||
1265 | } | ||||
1266 | |||||
1267 | =head2 schema_version | ||||
1268 | |||||
1269 | Returns the current schema class' $VERSION in a normalised way. | ||||
1270 | |||||
1271 | =cut | ||||
1272 | |||||
1273 | # spent 140µs within DBIx::Class::Schema::schema_version which was called 13 times, avg 11µs/call:
# 4 times (29µs+0s) by DBIx::Class::Storage::DBI::deployment_statements at line 2702 of DBIx/Class/Storage/DBI.pm, avg 7µs/call
# 4 times (22µs+0s) by SQL::Translator::Parser::DBIx::Class::parse at line 56 of SQL/Translator/Parser/DBIx/Class.pm, avg 5µs/call
# 2 times (57µs+0s) by Tapper::Schema::TestTools::setup_db at line 43 of Tapper/Schema/TestTools.pm, avg 28µs/call
# 2 times (21µs+0s) by DBIx::Class::Schema::Versioned::install at line 255 of DBIx/Class/Schema/Versioned.pm, avg 11µs/call
# once (11µs+0s) by DBIx::Class::Schema::Versioned::_on_connect at line 613 of DBIx/Class/Schema/Versioned.pm | ||||
1274 | 78 | 157µs | my ($self) = @_; | ||
1275 | my $class = ref($self)||$self; | ||||
1276 | |||||
1277 | # does -not- use $schema->VERSION | ||||
1278 | # since that varies in results depending on if version.pm is installed, and if | ||||
1279 | # so the perl or XS versions. If you want this to change, bug the version.pm | ||||
1280 | # author to make vpp and vxs behave the same. | ||||
1281 | |||||
1282 | my $version; | ||||
1283 | { | ||||
1284 | 3 | 584µs | 2 | 24µs | # spent 16µs (8+8) within DBIx::Class::Schema::BEGIN@1284 which was called:
# once (8µs+8µs) by parent::import at line 1284 # spent 16µs making 1 call to DBIx::Class::Schema::BEGIN@1284
# spent 8µs making 1 call to strict::unimport |
1285 | $version = ${"${class}::VERSION"}; | ||||
1286 | } | ||||
1287 | return $version; | ||||
1288 | } | ||||
1289 | |||||
1290 | |||||
1291 | =head2 register_class | ||||
1292 | |||||
1293 | =over 4 | ||||
1294 | |||||
1295 | =item Arguments: $moniker, $component_class | ||||
1296 | |||||
1297 | =back | ||||
1298 | |||||
1299 | This method is called by L</load_namespaces> and L</load_classes> to install the found classes into your Schema. You should be using those instead of this one. | ||||
1300 | |||||
1301 | You will only need this method if you have your Result classes in | ||||
1302 | files which are not named after the packages (or all in the same | ||||
1303 | file). You may also need it to register classes at runtime. | ||||
1304 | |||||
1305 | Registers a class which isa DBIx::Class::ResultSourceProxy. Equivalent to | ||||
1306 | calling: | ||||
1307 | |||||
1308 | $schema->register_source($moniker, $component_class->result_source_instance); | ||||
1309 | |||||
1310 | =cut | ||||
1311 | |||||
1312 | # spent 6.49ms (296µs+6.19) within DBIx::Class::Schema::register_class which was called 37 times, avg 175µs/call:
# 35 times (276µs+5.71ms) by DBIx::Class::Schema::load_namespaces at line 297, avg 171µs/call
# once (12µs+302µs) by Class::C3::Componentised::ensure_class_loaded at line 52 of DBIx/Class/Schema/Versioned.pm
# once (8µs+182µs) by Class::C3::Componentised::ensure_class_loaded at line 60 of DBIx/Class/Schema/Versioned.pm | ||||
1313 | 74 | 238µs | my ($self, $moniker, $to_register) = @_; | ||
1314 | 74 | 6.19ms | $self->register_source($moniker => $to_register->result_source_instance); # spent 5.76ms making 37 calls to DBIx::Class::Schema::register_source, avg 156µs/call
# spent 14µs making 1 call to Tapper::Schema::TestrunDB::Result::TestrunRequestedHost::result_source_instance
# spent 13µs making 1 call to Tapper::Schema::TestrunDB::Result::HostFeature::result_source_instance
# spent 13µs making 1 call to Tapper::Schema::TestrunDB::Result::TestrunRequestedFeature::result_source_instance
# spent 13µs making 1 call to Tapper::Schema::TestrunDB::Result::TestplanInstance::result_source_instance
# spent 13µs making 1 call to Tapper::Schema::TestrunDB::Result::PrePrecondition::result_source_instance
# spent 13µs making 1 call to Tapper::Schema::TestrunDB::Result::TestrunPrecondition::result_source_instance
# spent 12µs making 1 call to Tapper::Schema::TestrunDB::Result::QueueHost::result_source_instance
# spent 12µs making 1 call to Tapper::Schema::TestrunDB::Result::Scenario::result_source_instance
# spent 12µs making 1 call to Tapper::Schema::TestrunDB::Result::ScenarioElement::result_source_instance
# spent 12µs making 1 call to Tapper::Schema::TestrunDB::Result::Precondition::result_source_instance
# spent 12µs making 1 call to Tapper::Schema::TestrunDB::Result::Queue::result_source_instance
# spent 12µs making 1 call to Tapper::Schema::TestrunDB::Result::Topic::result_source_instance
# spent 12µs making 1 call to Tapper::Schema::TestrunDB::Result::Message::result_source_instance
# spent 12µs making 1 call to Tapper::Schema::TestrunDB::Result::Testrun::result_source_instance
# spent 12µs making 1 call to Tapper::Schema::TestrunDB::Result::TestrunScheduling::result_source_instance
# spent 12µs making 1 call to Tapper::Schema::TestrunDB::Result::User::result_source_instance
# spent 12µs making 1 call to Tapper::Schema::TestrunDB::Result::Preconditiontype::result_source_instance
# spent 12µs making 1 call to Tapper::Schema::ReportsDB::Result::ReportComment::result_source_instance
# spent 12µs making 1 call to Tapper::Schema::ReportsDB::Result::ReportFile::result_source_instance
# spent 12µs making 1 call to Tapper::Schema::TestrunDB::Result::Host::result_source_instance
# spent 11µs making 1 call to Tapper::Schema::ReportsDB::Result::NotificationEvent::result_source_instance
# spent 11µs making 1 call to Tapper::Schema::TestrunDB::Result::State::result_source_instance
# spent 11µs making 1 call to Tapper::Schema::ReportsDB::Result::Notification::result_source_instance
# spent 11µs making 1 call to Tapper::Schema::ReportsDB::Result::ReportgroupTestrunStats::result_source_instance
# spent 11µs making 1 call to Tapper::Schema::ReportsDB::Result::View010TestrunOverviewReports::result_source_instance
# spent 11µs making 1 call to Tapper::Schema::ReportsDB::Result::Report::result_source_instance
# spent 11µs making 1 call to Tapper::Schema::ReportsDB::Result::View020TestrunOverview::result_source_instance
# spent 11µs making 1 call to Tapper::Schema::ReportsDB::Result::Suite::result_source_instance
# spent 11µs making 1 call to Tapper::Schema::ReportsDB::Result::Tap::result_source_instance
# spent 11µs making 1 call to Tapper::Schema::ReportsDB::Result::ReportSection::result_source_instance
# spent 11µs making 1 call to Tapper::Schema::ReportsDB::Result::ReportgroupArbitrary::result_source_instance
# spent 11µs making 1 call to Tapper::Schema::ReportsDB::Result::ReportTopic::result_source_instance
# spent 11µs making 1 call to Tapper::Schema::ReportsDB::Result::Contact::result_source_instance
# spent 11µs making 1 call to Tapper::Schema::ReportsDB::Result::User::result_source_instance
# spent 11µs making 1 call to Tapper::Schema::ReportsDB::Result::ReportgroupTestrun::result_source_instance
# spent 10µs making 1 call to DBIx::Class::Version::TableCompat::result_source_instance
# spent 10µs making 1 call to DBIx::Class::Version::Table::result_source_instance | ||
1315 | } | ||||
1316 | |||||
1317 | =head2 register_source | ||||
1318 | |||||
1319 | =over 4 | ||||
1320 | |||||
1321 | =item Arguments: $moniker, $result_source | ||||
1322 | |||||
1323 | =back | ||||
1324 | |||||
1325 | This method is called by L</register_class>. | ||||
1326 | |||||
1327 | Registers the L<DBIx::Class::ResultSource> in the schema with the given | ||||
1328 | moniker. | ||||
1329 | |||||
1330 | =cut | ||||
1331 | |||||
1332 | 37 | 104µs | 37 | 5.65ms | # spent 5.76ms (112µs+5.65) within DBIx::Class::Schema::register_source which was called 37 times, avg 156µs/call:
# 37 times (112µs+5.65ms) by DBIx::Class::Schema::register_class at line 1314, avg 156µs/call # spent 5.65ms making 37 calls to DBIx::Class::Schema::_register_source, avg 153µs/call |
1333 | |||||
1334 | =head2 unregister_source | ||||
1335 | |||||
1336 | =over 4 | ||||
1337 | |||||
1338 | =item Arguments: $moniker | ||||
1339 | |||||
1340 | =back | ||||
1341 | |||||
1342 | Removes the L<DBIx::Class::ResultSource> from the schema for the given moniker. | ||||
1343 | |||||
1344 | =cut | ||||
1345 | |||||
1346 | sub unregister_source { shift->_unregister_source(@_) } | ||||
1347 | |||||
1348 | =head2 register_extra_source | ||||
1349 | |||||
1350 | =over 4 | ||||
1351 | |||||
1352 | =item Arguments: $moniker, $result_source | ||||
1353 | |||||
1354 | =back | ||||
1355 | |||||
1356 | As L</register_source> but should be used if the result class already | ||||
1357 | has a source and you want to register an extra one. | ||||
1358 | |||||
1359 | =cut | ||||
1360 | |||||
1361 | 57 | 272µs | 57 | 5.56ms | # spent 5.86ms (292µs+5.56) within DBIx::Class::Schema::register_extra_source which was called 57 times, avg 103µs/call:
# 57 times (292µs+5.56ms) by DBIx::Class::Schema::clone at line 1044, avg 103µs/call # spent 5.56ms making 57 calls to DBIx::Class::Schema::_register_source, avg 98µs/call |
1362 | |||||
1363 | # spent 11.2ms (4.18+7.03) within DBIx::Class::Schema::_register_source which was called 94 times, avg 119µs/call:
# 57 times (2.63ms+2.94ms) by DBIx::Class::Schema::register_extra_source at line 1361, avg 98µs/call
# 37 times (1.55ms+4.10ms) by DBIx::Class::Schema::register_source at line 1332, avg 153µs/call | ||||
1364 | 1011 | 3.78ms | my ($self, $moniker, $source, $params) = @_; | ||
1365 | |||||
1366 | 94 | 1.90ms | $source = $source->new({ %$source, source_name => $moniker }); # spent 1.78ms making 90 calls to DBIx::Class::ResultSource::new, avg 20µs/call
# spent 116µs making 4 calls to DBIx::Class::ResultSource::View::new, avg 29µs/call | ||
1367 | |||||
1368 | 94 | 207µs | $source->schema($self); # spent 207µs making 94 calls to DBIx::Class::ResultSource::schema, avg 2µs/call | ||
1369 | 57 | 64µs | weaken $source->{schema} if ref($self); # spent 64µs making 57 calls to Scalar::Util::weaken, avg 1µs/call | ||
1370 | |||||
1371 | 94 | 1.31ms | my %reg = %{$self->source_registrations}; # spent 1.31ms making 94 calls to DBIx::Class::Schema::source_registrations, avg 14µs/call | ||
1372 | $reg{$moniker} = $source; | ||||
1373 | 94 | 1.09ms | $self->source_registrations(\%reg); # spent 1.09ms making 94 calls to DBIx::Class::Schema::source_registrations, avg 12µs/call | ||
1374 | |||||
1375 | return $source if $params->{extra}; | ||||
1376 | |||||
1377 | 37 | 1.00ms | my $rs_class = $source->result_class; # spent 1.00ms making 37 calls to DBIx::Class::ResultSource::result_class, avg 27µs/call | ||
1378 | 37 | 99µs | 74 | 1.21ms | # spent 529µs (162+367) within DBIx::Class::Schema::__ANON__[/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/Schema.pm:1378] which was called 37 times, avg 14µs/call:
# 37 times (162µs+367µs) by Try::Tiny::try at line 71 of Try/Tiny.pm, avg 14µs/call # spent 839µs making 37 calls to Try::Tiny::try, avg 23µs/call
# spent 13µs making 1 call to Tapper::Schema::ReportsDB::Result::Suite::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::ReportsDB::Result::ReportSection::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::ReportsDB::Result::View010TestrunOverviewReports::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::TestrunRequestedHost::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::ReportsDB::Result::ReportgroupTestrun::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::ReportsDB::Result::ReportgroupArbitrary::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::ReportsDB::Result::Contact::result_source_instance
# spent 10µs making 1 call to DBIx::Class::Version::Table::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::PrePrecondition::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::ReportsDB::Result::NotificationEvent::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::ReportsDB::Result::ReportComment::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::ReportsDB::Result::ReportTopic::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::ReportsDB::Result::ReportgroupTestrunStats::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::ReportsDB::Result::User::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::ReportsDB::Result::View020TestrunOverview::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::HostFeature::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::Preconditiontype::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::ScenarioElement::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::TestrunPrecondition::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::TestrunRequestedFeature::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::Topic::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::ReportsDB::Result::Notification::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::ReportsDB::Result::ReportFile::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::User::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::Message::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::Precondition::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::QueueHost::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::State::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::ReportsDB::Result::Report::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::ReportsDB::Result::Tap::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::Queue::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::TestrunScheduling::result_source_instance
# spent 10µs making 1 call to DBIx::Class::Version::TableCompat::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::Host::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::Scenario::result_source_instance
# spent 10µs making 1 call to Tapper::Schema::TestrunDB::Result::Testrun::result_source_instance
# spent 9µs making 1 call to Tapper::Schema::TestrunDB::Result::TestplanInstance::result_source_instance |
1379 | 37 | 358µs | my %map = %{$self->class_mappings}; # spent 358µs making 37 calls to DBIx::Class::Schema::class_mappings, avg 10µs/call | ||
1380 | if ( | ||||
1381 | exists $map{$rs_class} | ||||
1382 | and | ||||
1383 | $map{$rs_class} ne $moniker | ||||
1384 | and | ||||
1385 | $rsrc ne $_[2] # orig_source | ||||
1386 | ) { | ||||
1387 | carp | ||||
1388 | "$rs_class already had a registered source which was replaced by this call. " | ||||
1389 | . 'Perhaps you wanted register_extra_source(), though it is more likely you did ' | ||||
1390 | . 'something wrong.' | ||||
1391 | ; | ||||
1392 | } | ||||
1393 | |||||
1394 | $map{$rs_class} = $moniker; | ||||
1395 | 37 | 272µs | $self->class_mappings(\%map); # spent 272µs making 37 calls to DBIx::Class::Schema::class_mappings, avg 7µs/call | ||
1396 | } | ||||
1397 | |||||
1398 | return $source; | ||||
1399 | } | ||||
1400 | |||||
1401 | { | ||||
1402 | 2 | 1µs | my $global_phase_destroy; | ||
1403 | |||||
1404 | # SpeedyCGI runs END blocks every cycle but keeps object instances | ||||
1405 | # hence we have to disable the globaldestroy hatch, and rely on the | ||||
1406 | # eval trap below (which appears to work, but is risky done so late) | ||||
1407 | 1 | 10µs | # spent 6µs within DBIx::Class::Schema::END which was called:
# once (6µs+0s) by main::RUNTIME at line 0 of xt/tapper-mcp-scheduler-with-db-longrun.t | ||
1408 | |||||
1409 | sub DESTROY { | ||||
1410 | return if $global_phase_destroy; | ||||
1411 | |||||
1412 | my $self = shift; | ||||
1413 | my $srcs = $self->source_registrations; | ||||
1414 | |||||
1415 | for my $moniker (keys %$srcs) { | ||||
1416 | # find first source that is not about to be GCed (someone other than $self | ||||
1417 | # holds a reference to it) and reattach to it, weakening our own link | ||||
1418 | # | ||||
1419 | # during global destruction (if we have not yet bailed out) this will throw | ||||
1420 | # which will serve as a signal to not try doing anything else | ||||
1421 | if (ref $srcs->{$moniker} and svref_2object($srcs->{$moniker})->REFCNT > 1) { | ||||
1422 | local $@; | ||||
1423 | eval { | ||||
1424 | $srcs->{$moniker}->schema($self); | ||||
1425 | 1; | ||||
1426 | } or do { | ||||
1427 | $global_phase_destroy = 1; | ||||
1428 | last; | ||||
1429 | }; | ||||
1430 | |||||
1431 | weaken $srcs->{$moniker}; | ||||
1432 | last; | ||||
1433 | } | ||||
1434 | } | ||||
1435 | } | ||||
1436 | } | ||||
1437 | |||||
1438 | sub _unregister_source { | ||||
1439 | my ($self, $moniker) = @_; | ||||
1440 | my %reg = %{$self->source_registrations}; | ||||
1441 | |||||
1442 | my $source = delete $reg{$moniker}; | ||||
1443 | $self->source_registrations(\%reg); | ||||
1444 | if ($source->result_class) { | ||||
1445 | my %map = %{$self->class_mappings}; | ||||
1446 | delete $map{$source->result_class}; | ||||
1447 | $self->class_mappings(\%map); | ||||
1448 | } | ||||
1449 | } | ||||
1450 | |||||
1451 | |||||
1452 | =head2 compose_connection (DEPRECATED) | ||||
1453 | |||||
1454 | =over 4 | ||||
1455 | |||||
1456 | =item Arguments: $target_namespace, @db_info | ||||
1457 | |||||
1458 | =item Return Value: $new_schema | ||||
1459 | |||||
1460 | =back | ||||
1461 | |||||
1462 | DEPRECATED. You probably wanted compose_namespace. | ||||
1463 | |||||
1464 | Actually, you probably just wanted to call connect. | ||||
1465 | |||||
1466 | =begin hidden | ||||
1467 | |||||
1468 | (hidden due to deprecation) | ||||
1469 | |||||
1470 | Calls L<DBIx::Class::Schema/"compose_namespace"> to the target namespace, | ||||
1471 | calls L<DBIx::Class::Schema/connection> with @db_info on the new schema, | ||||
1472 | then injects the L<DBix::Class::ResultSetProxy> component and a | ||||
1473 | resultset_instance classdata entry on all the new classes, in order to support | ||||
1474 | $target_namespaces::$class->search(...) method calls. | ||||
1475 | |||||
1476 | This is primarily useful when you have a specific need for class method access | ||||
1477 | to a connection. In normal usage it is preferred to call | ||||
1478 | L<DBIx::Class::Schema/connect> and use the resulting schema object to operate | ||||
1479 | on L<DBIx::Class::ResultSet> objects with L<DBIx::Class::Schema/resultset> for | ||||
1480 | more information. | ||||
1481 | |||||
1482 | =end hidden | ||||
1483 | |||||
1484 | =cut | ||||
1485 | |||||
1486 | sub compose_connection { | ||||
1487 | my ($self, $target, @info) = @_; | ||||
1488 | |||||
1489 | carp_once "compose_connection deprecated as of 0.08000" | ||||
1490 | unless $INC{"DBIx/Class/CDBICompat.pm"}; | ||||
1491 | |||||
1492 | my $base = 'DBIx::Class::ResultSetProxy'; | ||||
1493 | try { | ||||
1494 | eval "require ${base};" | ||||
1495 | } | ||||
1496 | catch { | ||||
1497 | $self->throw_exception | ||||
1498 | ("No arguments to load_classes and couldn't load ${base} ($_)") | ||||
1499 | }; | ||||
1500 | |||||
1501 | if ($self eq $target) { | ||||
1502 | # Pathological case, largely caused by the docs on early C::M::DBIC::Plain | ||||
1503 | foreach my $moniker ($self->sources) { | ||||
1504 | my $source = $self->source($moniker); | ||||
1505 | my $class = $source->result_class; | ||||
1506 | $self->inject_base($class, $base); | ||||
1507 | $class->mk_classdata(resultset_instance => $source->resultset); | ||||
1508 | $class->mk_classdata(class_resolver => $self); | ||||
1509 | } | ||||
1510 | $self->connection(@info); | ||||
1511 | return $self; | ||||
1512 | } | ||||
1513 | |||||
1514 | my $schema = $self->compose_namespace($target, $base); | ||||
1515 | { | ||||
1516 | 3 | 112µs | 2 | 26µs | # spent 16µs (7+9) within DBIx::Class::Schema::BEGIN@1516 which was called:
# once (7µs+9µs) by parent::import at line 1516 # spent 16µs making 1 call to DBIx::Class::Schema::BEGIN@1516
# spent 9µs making 1 call to strict::unimport |
1517 | my $name = join '::', $target, 'schema'; | ||||
1518 | *$name = subname $name, sub { $schema }; | ||||
1519 | } | ||||
1520 | |||||
1521 | $schema->connection(@info); | ||||
1522 | foreach my $moniker ($schema->sources) { | ||||
1523 | my $source = $schema->source($moniker); | ||||
1524 | my $class = $source->result_class; | ||||
1525 | #warn "$moniker $class $source ".$source->storage; | ||||
1526 | $class->mk_classdata(result_source_instance => $source); | ||||
1527 | $class->mk_classdata(resultset_instance => $source->resultset); | ||||
1528 | $class->mk_classdata(class_resolver => $schema); | ||||
1529 | } | ||||
1530 | return $schema; | ||||
1531 | } | ||||
1532 | |||||
1533 | 1 | 8µs | 1; | ||
1534 | |||||
1535 | =head1 AUTHORS | ||||
1536 | |||||
1537 | Matt S. Trout <mst@shadowcatsystems.co.uk> | ||||
1538 | |||||
1539 | =head1 LICENSE | ||||
1540 | |||||
1541 | You may distribute this code under the same terms as Perl itself. | ||||
1542 | |||||
1543 | 1 | 25µs | 1 | 596µs | =cut # spent 596µs making 1 call to B::Hooks::EndOfScope::__ANON__[B/Hooks/EndOfScope.pm:26] |
sub DBIx::Class::Schema::CORE:match; # opcode | |||||
sub DBIx::Class::Schema::CORE:sort; # opcode | |||||
sub DBIx::Class::Schema::CORE:subst; # opcode |