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 | /; |
2ad62d97 |
11 | use mro 'c3'; |
843f8ecd |
12 | |
87aa29e2 |
13 | __PACKAGE__->sql_maker_class('DBIx::Class::SQLAHacks::MySQL'); |
843f8ecd |
14 | |
e96a93df |
15 | sub with_deferred_fk_checks { |
16 | my ($self, $sub) = @_; |
17 | |
5cf7285e |
18 | $self->_do_query('SET FOREIGN_KEY_CHECKS = 0'); |
e96a93df |
19 | $sub->(); |
5cf7285e |
20 | $self->_do_query('SET FOREIGN_KEY_CHECKS = 1'); |
e96a93df |
21 | } |
22 | |
d4f16b21 |
23 | sub _dbh_last_insert_id { |
24 | my ($self, $dbh, $source, $col) = @_; |
25 | $dbh->{mysql_insertid}; |
843f8ecd |
26 | } |
27 | |
e8d293df |
28 | sub sqlt_type { |
29 | return 'MySQL'; |
30 | } |
31 | |
adb3554a |
32 | sub _svp_begin { |
eeb8cfeb |
33 | my ($self, $name) = @_; |
adb3554a |
34 | |
eeb8cfeb |
35 | $self->dbh->do("SAVEPOINT $name"); |
adb3554a |
36 | } |
37 | |
38 | sub _svp_release { |
eeb8cfeb |
39 | my ($self, $name) = @_; |
adb3554a |
40 | |
eeb8cfeb |
41 | $self->dbh->do("RELEASE SAVEPOINT $name"); |
adb3554a |
42 | } |
43 | |
44 | sub _svp_rollback { |
eeb8cfeb |
45 | my ($self, $name) = @_; |
adb3554a |
46 | |
eeb8cfeb |
47 | $self->dbh->do("ROLLBACK TO SAVEPOINT $name") |
adb3554a |
48 | } |
48fe9087 |
49 | |
106d5f3b |
50 | sub is_replicating { |
f797e89e |
51 | my $status = shift->dbh->selectrow_hashref('show slave status'); |
52 | return ($status->{Slave_IO_Running} eq 'Yes') && ($status->{Slave_SQL_Running} eq 'Yes'); |
106d5f3b |
53 | } |
54 | |
55 | sub lag_behind_master { |
f797e89e |
56 | return shift->dbh->selectrow_hashref('show slave status')->{Seconds_Behind_Master}; |
106d5f3b |
57 | } |
58 | |
613f65e5 |
59 | # MySql can not do subquery update/deletes, only way is slow per-row operations. |
ab807c12 |
60 | # This assumes you have set proper transaction isolation and use innodb. |
b5963465 |
61 | sub _subq_update_delete { |
613f65e5 |
62 | return shift->_per_row_update_delete (@_); |
63 | } |
64 | |
843f8ecd |
65 | 1; |
66 | |
75d07914 |
67 | =head1 NAME |
843f8ecd |
68 | |
c9d438ff |
69 | DBIx::Class::Storage::DBI::mysql - Storage::DBI class implementing MySQL specifics |
843f8ecd |
70 | |
71 | =head1 SYNOPSIS |
72 | |
c9d438ff |
73 | Storage::DBI autodetects the underlying MySQL database, and re-blesses the |
74 | C<$storage> object into this class. |
75 | |
312b1119 |
76 | my $schema = MyDb::Schema->connect( $dsn, $user, $pass ); |
843f8ecd |
77 | |
78 | =head1 DESCRIPTION |
79 | |
c9d438ff |
80 | This class implements MySQL specific bits of L<DBIx::Class::Storage::DBI>. |
81 | |
843f8ecd |
82 | =head1 AUTHORS |
83 | |
c9d438ff |
84 | See L<DBIx::Class/CONTRIBUTORS> |
843f8ecd |
85 | |
86 | =head1 LICENSE |
87 | |
88 | You may distribute this code under the same terms as Perl itself. |
89 | |
90 | =cut |