MySQL/SQLMaker/MariaDB.pm

filter: Statementstmt 40.0% 12 / 30 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 75.0% 3 / 4 Podpod n/a totaltotal 25.4% 15 / 59 CC 9 SCAR 42.2
CC
9
Cov
24%
_lock_select
90.0
BEGIN
1.0
BEGIN
1.0
CRAP 67.8
« MySQL/Diff.pm ↑ Summary MySQL/Introspect/Indexes.pm »
1 package DBIO::MySQL::SQLMaker::MariaDB;
2 # ABSTRACT: SQLMaker subclass for MariaDB's SQL syntax quirks
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use base 'DBIO::MySQL::SQLMaker';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 # Reuse the parent's lock_modifiers (NOWAIT / SKIP LOCKED) but override
11 # the lock_types mapping: 'share' means LOCK IN SHARE MODE on MariaDB.
12 1 my $lock_types = {
13 update => 'FOR UPDATE',
14 share => 'LOCK IN SHARE MODE',
15 };
16  
17 1 my $lock_modifiers = {
18 nowait => 'NOWAIT',
19 skip_locked => 'SKIP LOCKED',
20 };
21  
22 0 ▶sub _lock_select {
Subroutine _lock_select: not called CC=9 SCAR=45.0
23 0 my ($self, $type) = @_;
24  
25 0 ▶ if (ref $type eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $type eq "HASH") 0 0 0
26 0 my $lock_type = $type->{type};
27 0 my $tables = $type->{of};
28 0 my $modifier = $type->{modifier};
29  
30 0 ▶ my $lock_clause = $lock_types->{$lock_type}
Condition0%0/3
$lock_types->{$lock_type} || $self->throw_exception("Unknown SELECT .. FOR type '${lock_type}' requested")
l!l&&r!l&&!r
000
MC/DC0%0/2
$lock_types->{$lock_type} || $self->throw_exception("Unknown SELECT .. FOR type '${lock_type}' requested")
$lock_types->{$lock_type} $self->throw_exception("Unknown SELECT .. FOR type '${lock_type}' requested")
Truth table0%0/3
A || B
A= $lock_types->{$lock_type}B= $self->throw_exception("Unknown SELECT .. FOR type '${lock_type}' requested")
ABresult
1X1
011
000
31 || $self->throw_exception("Unknown SELECT .. FOR type '$lock_type' requested");
32  
33 0 ▶ if ($tables) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tables) 0 0 0
34 0 ▶ my @table_list = ref $tables eq 'ARRAY' ? @$tables : ($tables);
Branch: 1 branch
BranchTrueFalseTotal
ref $tables eq 'ARRAY' ? : 0 0 0
35 0 ▶ if (@table_list) {
Branch: 1 branch
BranchTrueFalseTotal
if (@table_list) 0 0 0
36 0 my $quoted_tables = join(', ', map { $self->_quote($_) } @table_list);
37 0 $lock_clause .= " OF $quoted_tables";
38 }
39 }
40  
41 0 ▶ if ($modifier) {
Branch: 1 branch
BranchTrueFalseTotal
if ($modifier) 0 0 0
42 0 ▶ my $mod_sql = $lock_modifiers->{$modifier}
Condition0%0/3
$lock_modifiers->{$modifier} || $self->throw_exception("Unknown lock modifier '${modifier}' requested")
l!l&&r!l&&!r
000
MC/DC0%0/2
$lock_modifiers->{$modifier} || $self->throw_exception("Unknown lock modifier '${modifier}' requested")
$lock_modifiers->{$modifier} $self->throw_exception("Unknown lock modifier '${modifier}' requested")
Truth table0%0/3
A || B
A= $lock_modifiers->{$modifier}B= $self->throw_exception("Unknown lock modifier '${modifier}' requested")
ABresult
1X1
011
000
43 || $self->throw_exception("Unknown lock modifier '$modifier' requested");
44 0 $lock_clause .= " $mod_sql";
45 }
46  
47 0 return " $lock_clause";
48 }
49  
50 0 ▶ my $sql = $lock_types->{$type}
Condition0%0/3
$lock_types->{$type} || $self->throw_exception("Unknown SELECT .. FOR type '${type}' requested")
l!l&&r!l&&!r
000
MC/DC0%0/2
$lock_types->{$type} || $self->throw_exception("Unknown SELECT .. FOR type '${type}' requested")
$lock_types->{$type} $self->throw_exception("Unknown SELECT .. FOR type '${type}' requested")
Truth table0%0/3
A || B
A= $lock_types->{$type}B= $self->throw_exception("Unknown SELECT .. FOR type '${type}' requested")
ABresult
1X1
011
000
51 || $self->throw_exception("Unknown SELECT .. FOR type '$type' requested");
52 0 return " $sql";
53 }
54  
55  
56 1 1;
57  
58 __END__
59  
60 =pod
61  
62 =encoding UTF-8
63  
64 =head1 NAME
65  
66 DBIO::MySQL::SQLMaker::MariaDB - SQLMaker subclass for MariaDB's SQL syntax quirks
67  
68 =head1 VERSION
69  
70 version 0.900001
71  
72 =head1 DESCRIPTION
73  
74 C<DBIO::MySQL::SQLMaker::MariaDB> is a SQLMaker subclass for MariaDB.
75 It is used automatically by L<DBIO::MySQL::Storage::MariaDB>.
76  
77 MariaDB's locking syntax differs from MySQL 8.0+: it only supports
78 C<LOCK IN SHARE MODE>, not C<FOR SHARE>. This subclass overrides
79 C<_lock_select> so that C<< for =E<gt> 'share' >> emits
80 C<LOCK IN SHARE MODE> when talking to MariaDB, while still accepting
81 the same DSL the MySQL parent uses.
82  
83 =seealso
84  
85 =over 4
86  
87 =item * L<DBIO::MySQL::SQLMaker> - MySQL parent class
88  
89 =item * L<DBIO::MySQL::Storage::MariaDB> - consumer of this SQLMaker
90  
91 =back
92  
93 =head1 AUTHOR
94  
95 DBIO & DBIx::Class Authors
96  
97 =head1 COPYRIGHT AND LICENSE
98  
99 Copyright (C) 2026 DBIO Authors
100 Portions Copyright (C) 2005-2025 DBIx::Class Authors
101 Based on DBIx::Class, heavily modified.
102  
103 This is free software; you can redistribute it and/or modify it under
104 the same terms as the Perl 5 programming language system itself.
105  
106 =cut
« MySQL/Diff.pm ↑ Summary MySQL/Introspect/Indexes.pm »