Commit | Line | Data |
843f8ecd |
1 | package DBIx::Class::Storage::DBI::mysql; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
698775ed |
6 | use base qw/ |
7 | DBIx::Class::Storage::DBI::MultiColumnIn |
8 | DBIx::Class::Storage::DBI::AmbiguousGlob |
9 | DBIx::Class::Storage::DBI |
10 | /; |
843f8ecd |
11 | |
87aa29e2 |
12 | __PACKAGE__->sql_maker_class('DBIx::Class::SQLAHacks::MySQL'); |
843f8ecd |
13 | |
e96a93df |
14 | sub with_deferred_fk_checks { |
15 | my ($self, $sub) = @_; |
16 | |
17 | $self->dbh->do('SET foreign_key_checks=0'); |
18 | $sub->(); |
19 | $self->dbh->do('SET foreign_key_checks=1'); |
20 | } |
21 | |
d4f16b21 |
22 | sub _dbh_last_insert_id { |
23 | my ($self, $dbh, $source, $col) = @_; |
24 | $dbh->{mysql_insertid}; |
843f8ecd |
25 | } |
26 | |
e8d293df |
27 | sub sqlt_type { |
28 | return 'MySQL'; |
29 | } |
30 | |
adb3554a |
31 | sub _svp_begin { |
eeb8cfeb |
32 | my ($self, $name) = @_; |
adb3554a |
33 | |
eeb8cfeb |
34 | $self->dbh->do("SAVEPOINT $name"); |
adb3554a |
35 | } |
36 | |
37 | sub _svp_release { |
eeb8cfeb |
38 | my ($self, $name) = @_; |
adb3554a |
39 | |
eeb8cfeb |
40 | $self->dbh->do("RELEASE SAVEPOINT $name"); |
adb3554a |
41 | } |
42 | |
43 | sub _svp_rollback { |
eeb8cfeb |
44 | my ($self, $name) = @_; |
adb3554a |
45 | |
eeb8cfeb |
46 | $self->dbh->do("ROLLBACK TO SAVEPOINT $name") |
adb3554a |
47 | } |
48fe9087 |
48 | |
106d5f3b |
49 | sub is_replicating { |
f797e89e |
50 | my $status = shift->dbh->selectrow_hashref('show slave status'); |
51 | return ($status->{Slave_IO_Running} eq 'Yes') && ($status->{Slave_SQL_Running} eq 'Yes'); |
106d5f3b |
52 | } |
53 | |
54 | sub lag_behind_master { |
f797e89e |
55 | return shift->dbh->selectrow_hashref('show slave status')->{Seconds_Behind_Master}; |
106d5f3b |
56 | } |
57 | |
613f65e5 |
58 | # MySql can not do subquery update/deletes, only way is slow per-row operations. |
ab807c12 |
59 | # This assumes you have set proper transaction isolation and use innodb. |
b5963465 |
60 | sub _subq_update_delete { |
613f65e5 |
61 | return shift->_per_row_update_delete (@_); |
62 | } |
63 | |
843f8ecd |
64 | 1; |
65 | |
75d07914 |
66 | =head1 NAME |
843f8ecd |
67 | |
68 | DBIx::Class::Storage::DBI::mysql - Automatic primary key class for MySQL |
69 | |
70 | =head1 SYNOPSIS |
71 | |
72 | # In your table classes |
73 | __PACKAGE__->load_components(qw/PK::Auto Core/); |
74 | __PACKAGE__->set_primary_key('id'); |
75 | |
76 | =head1 DESCRIPTION |
77 | |
78 | This class implements autoincrements for MySQL. |
79 | |
80 | =head1 AUTHORS |
81 | |
82 | Matt S. Trout <mst@shadowcatsystems.co.uk> |
83 | |
84 | =head1 LICENSE |
85 | |
86 | You may distribute this code under the same terms as Perl itself. |
87 | |
88 | =cut |