| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojo::SQLite::Transaction; |
|
2
|
6
|
|
|
6
|
|
45
|
use Mojo::Base -base; |
|
|
6
|
|
|
|
|
23
|
|
|
|
6
|
|
|
|
|
44
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
6
|
|
|
6
|
|
999
|
use Carp 'croak'; |
|
|
6
|
|
|
|
|
13
|
|
|
|
6
|
|
|
|
|
2629
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '3.008'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has db => undef, weak => 1; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my %behaviors = map { ($_ => 1) } qw(deferred immediate exclusive); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
23
|
|
|
23
|
1
|
91
|
my $self = shift->SUPER::new(@_, rollback => 1); |
|
14
|
23
|
|
|
|
|
680
|
my $dbh = $self->{dbh} = $self->db->dbh; |
|
15
|
23
|
50
|
|
|
|
180
|
if (my $behavior = $self->{behavior}) { |
|
16
|
0
|
0
|
|
|
|
0
|
croak qq{Invalid transaction behavior $behavior} unless exists $behaviors{lc $behavior}; |
|
17
|
0
|
|
|
|
|
0
|
$dbh->do("begin $behavior transaction"); |
|
18
|
|
|
|
|
|
|
} else { |
|
19
|
23
|
|
|
|
|
102
|
$dbh->begin_work; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
23
|
|
|
|
|
339
|
return $self; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub DESTROY { |
|
25
|
23
|
|
|
23
|
|
142
|
my $self = shift; |
|
26
|
23
|
100
|
66
|
|
|
127
|
if ($self->{rollback} && (my $dbh = $self->{dbh})) { $dbh->rollback } |
|
|
5
|
|
|
|
|
202
|
|
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub commit { |
|
30
|
18
|
|
|
18
|
1
|
37
|
my $self = shift; |
|
31
|
18
|
50
|
|
|
|
2173
|
$self->{dbh}->commit if delete $self->{rollback}; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Mojo::SQLite::Transaction - Transaction |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
use Mojo::SQLite::Transaction; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
my $tx = Mojo::SQLite::Transaction->new(db => $db); |
|
45
|
|
|
|
|
|
|
$tx->commit; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
L is a scope guard for L transactions |
|
50
|
|
|
|
|
|
|
used by L. |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
L implements the following attributes. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 db |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $db = $tx->db; |
|
59
|
|
|
|
|
|
|
$tx = $tx->db(Mojo::SQLite::Database->new); |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
L object this transaction belongs to. Note that this |
|
62
|
|
|
|
|
|
|
attribute is weakened. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 METHODS |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
L inherits all methods from L and |
|
67
|
|
|
|
|
|
|
implements the following new ones. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 new |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $tx = Mojo::SQLite::Transaction->new; |
|
72
|
|
|
|
|
|
|
my $tx = Mojo::SQLite::Transaction->new(db => Mojo::SQLite::Database->new); |
|
73
|
|
|
|
|
|
|
my $tx = Mojo::SQLite::Transaction->new({db => Mojo::SQLite::Database->new}); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Construct a new L object. |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 commit |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$tx->commit; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Commit transaction. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 BUGS |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Report any issues on the public bugtracker. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 AUTHOR |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Dan Book, C |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Copyright 2015, Dan Book. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This library is free software; you may redistribute it and/or modify it under |
|
96
|
|
|
|
|
|
|
the terms of the Artistic License version 2.0. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
L |