line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::Storage::DBI::Replicated::WithDSN; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
5050
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use Scalar::Util 'reftype'; |
5
|
|
|
|
|
|
|
requires qw/_query_start/; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Try::Tiny; |
8
|
|
|
|
|
|
|
use namespace::clean -except => 'meta'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
DBIx::Class::Storage::DBI::Replicated::WithDSN - A DBI Storage Role with DSN |
13
|
|
|
|
|
|
|
information in trace output |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This class is used internally by L<DBIx::Class::Storage::DBI::Replicated>. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This role adds C<DSN: > info to storage debugging output. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 METHODS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This class defines the following methods. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 around: _query_start |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Add C<DSN: > to debugging output. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
around '_query_start' => sub { |
34
|
|
|
|
|
|
|
my ($method, $self, $sql, @bind) = @_; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $dsn = (try { $self->dsn }) || $self->_dbi_connect_info->[0]; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my($op, $rest) = (($sql=~m/^(\w+)(.+)$/),'NOP', 'NO SQL'); |
39
|
|
|
|
|
|
|
my $storage_type = $self->can('active') ? 'REPLICANT' : 'MASTER'; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $query = do { |
42
|
|
|
|
|
|
|
if ((reftype($dsn)||'') ne 'CODE') { |
43
|
|
|
|
|
|
|
"$op [DSN_$storage_type=$dsn]$rest"; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
elsif (my $id = try { $self->id }) { |
46
|
|
|
|
|
|
|
"$op [$storage_type=$id]$rest"; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
|
|
|
|
|
|
"$op [$storage_type]$rest"; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$self->$method($query, @bind); |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 ALSO SEE |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
L<DBIx::Class::Storage::DBI> |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 FURTHER QUESTIONS? |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE> |
67
|
|
|
|
|
|
|
by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can |
68
|
|
|
|
|
|
|
redistribute it and/or modify it under the same terms as the |
69
|
|
|
|
|
|
|
L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |