MySQL/Introspect/Tables.pm

filter: Statementstmt 46.6% 7 / 15 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 38.4% 10 / 26 CC 4 SCAR 26.1
CC
4
Cov
33%
fetch
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 13.7
« MySQL/Introspect/Indexes.pm ↑ Summary MySQL/Introspect/Util.pm »
1 package DBIO::MySQL::Introspect::Tables;
2 # ABSTRACT: Introspect MySQL/MariaDB tables and views
3  
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8  
9 0 ▶sub fetch {
Subroutine fetch: not called CC=4 SCAR=30.0
Pod documented
10 0 my ($class, $dbh) = @_;
11  
12 0 my $sth = $dbh->prepare(q{
13 SELECT
14 table_name AS name,
15 table_type AS table_type,
16 engine AS engine,
17 table_collation AS table_collation,
18 row_format AS row_format,
19 table_comment AS comment
20 FROM information_schema.tables
21 WHERE table_schema = DATABASE()
22 ORDER BY table_name
23 });
24 0 $sth->execute;
25  
26 0 my %tables;
27 0 ▶ while (my $row = $sth->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth->fetchrow_hashref) 0 0 0
28 0 ▶ my $kind = ($row->{table_type} // '') eq 'VIEW' ? 'view' : 'table';
Branch: 1 branch
BranchTrueFalseTotal
($row->{'table_type'} // '') eq 'VIEW' ? : 0 0 0
Condition0%0/2
$row->{"table_type"} // ""
l!l
00
MC/DC0%0/1
$row->{"table_type"} // ""
$row->{"table_type"}
Truth table0%0/2
A
A= $row->{"table_type"}
Aresult
11
00
29 $tables{ $row->{name} } = {
30 table_name => $row->{name},
31 kind => $kind,
32 engine => $row->{engine},
33 table_collation => $row->{table_collation},
34 row_format => $row->{row_format},
35 comment => $row->{comment},
36 0 };
37 }
38 0 return \%tables;
39 }
40  
41 4 1;
42  
43 __END__
44  
45 =pod
46  
47 =encoding UTF-8
48  
49 =head1 NAME
50  
51 DBIO::MySQL::Introspect::Tables - Introspect MySQL/MariaDB tables and views
52  
53 =head1 VERSION
54  
55 version 0.900001
56  
57 =head1 DESCRIPTION
58  
59 Fetches MySQL/MariaDB table and view metadata from
60 C<information_schema.tables>, scoped to the current C<DATABASE()>.
61  
62 =head1 METHODS
63  
64 =head2 fetch
65  
66 my $tables = DBIO::MySQL::Introspect::Tables->fetch($dbh);
67  
68 Returns a hashref keyed by table name. Each value is a hashref with keys:
69 C<table_name>, C<kind> (C<table> or C<view>), C<engine>,
70 C<table_collation>, C<row_format>, C<comment>.
71  
72 =head1 AUTHOR
73  
74 DBIO & DBIx::Class Authors
75  
76 =head1 COPYRIGHT AND LICENSE
77  
78 Copyright (C) 2026 DBIO Authors
79 Portions Copyright (C) 2005-2025 DBIx::Class Authors
80 Based on DBIx::Class, heavily modified.
81  
82 This is free software; you can redistribute it and/or modify it under
83 the same terms as the Perl 5 programming language system itself.
84  
85 =cut
« MySQL/Introspect/Indexes.pm ↑ Summary MySQL/Introspect/Util.pm »