| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DBIx::Changeset::Loader::Mysql; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
6824
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
67
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
52
|
|
|
5
|
2
|
|
|
2
|
|
10
|
use File::Spec; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
39
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
28
|
use base qw/DBIx::Changeset::Loader/; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
174
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
10
|
use vars qw{$VERSION}; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
114
|
|
|
10
|
|
|
|
|
|
|
BEGIN { |
|
11
|
2
|
|
|
2
|
|
753
|
$VERSION = '1.11'; |
|
12
|
|
|
|
|
|
|
} |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
DBIx::Changeset::Loader::Mysql - Mysql factory object for loading changesets into a mysql database |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Perhaps a little code snippet. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use DBIx::Changeset::Loader; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $foo = DBIx::Changeset::Loader->new('Mysql', $opts); |
|
25
|
|
|
|
|
|
|
... |
|
26
|
|
|
|
|
|
|
$foo->apply_changeset($record); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 start_transaction |
|
31
|
|
|
|
|
|
|
This is the start_transaction interface to implement in your own class |
|
32
|
|
|
|
|
|
|
=cut |
|
33
|
1
|
|
|
1
|
1
|
48
|
sub start_transaction { |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 commit_transaction |
|
37
|
|
|
|
|
|
|
This is the commit_transaction interface to implement in your own class |
|
38
|
|
|
|
|
|
|
=cut |
|
39
|
1
|
|
|
1
|
1
|
393
|
sub commit_transaction { |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 rollback_transaction |
|
43
|
|
|
|
|
|
|
This is the rollback_transaction interface to implement in your own class |
|
44
|
|
|
|
|
|
|
=cut |
|
45
|
1
|
|
|
1
|
1
|
610
|
sub rollback_transaction { |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 apply_changeset |
|
49
|
|
|
|
|
|
|
This is the apply_changeset interface to implement in your own class |
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
sub apply_changeset { |
|
52
|
4
|
|
|
4
|
1
|
3750
|
my ($self, $record) = @_; |
|
53
|
|
|
|
|
|
|
|
|
54
|
4
|
100
|
|
|
|
15
|
unless ( defined $record ) { DBIx::Changeset::Exception::LoaderException->throw(error => 'Missing a DBIx::Changeset::Record'); } |
|
|
2
|
|
|
|
|
28
|
|
|
55
|
2
|
50
|
|
|
|
16
|
unless ( $record->valid() ) { DBIx::Changeset::Exception::LoaderException->throw(error => 'Passed an Invalid DBIx::Changeset::Record'); } |
|
|
0
|
|
|
|
|
0
|
|
|
56
|
2
|
50
|
|
|
|
23
|
unless ( defined $self->db_name ) { DBIx::Changeset::Exception::LoaderException->throw(error => 'need a db_name parameter'); } |
|
|
2
|
|
|
|
|
44
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $perms = ""; |
|
59
|
0
|
0
|
|
|
|
|
$perms = "-u".$self->db_user() if ($self->db_user); |
|
60
|
0
|
0
|
|
|
|
|
$perms .= " -p".$self->db_pass() if ($self->db_pass); |
|
61
|
0
|
0
|
|
|
|
|
$perms .= " -h".$self->db_host() if ($self->db_host); |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $DB = ""; |
|
64
|
0
|
0
|
|
|
|
|
$DB = $self->db_name if ($self->db_name); |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $sql = File::Spec->catfile($record->changeset_location, $record->uri); |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $result = qx/mysql $perms $DB < $sql 2>&1/; |
|
69
|
0
|
0
|
0
|
|
|
|
if ($? or ($result =~ m#ERROR#xmgs)) { |
|
70
|
0
|
|
|
|
|
|
DBIx::Changeset::Exception::LoaderException->throw(error => $result); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Copyright 2004-2008 Grox Pty Ltd. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
81
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
The full text of the license can be found in the LICENSE file included with this module. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; # End of DBIx::Changeset |