DB2/Storage.pm

filter: Statementstmt 56.6% 17 / 30 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 44.4% 4 / 9 Podpod 75.0% 3 / 4 totaltotal 43.6% 24 / 55 CC 5 SCAR 20.5
CC
5
Cov
44%
sql_name_sep
20.0
_dbh_last_insert_id
6.0
sqlt_type
2.0
CRAP 7.8
« DB2/Diff/Index.pm ↑ Summary DB2/Diff/Table.pm »
1 package DBIO::DB2::Storage;
2 # ABSTRACT: IBM DB2 support for DBIO
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 qw/DBIO::Storage::DBI/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 __PACKAGE__->register_driver('DB2' => __PACKAGE__);
11  
12 1 __PACKAGE__->datetime_parser_type('DateTime::Format::DB2');
13 1 __PACKAGE__->sql_quote_char ('"');
14 1 __PACKAGE__->sql_maker_class('DBIO::DB2::SQLMaker');
15  
16 0 ▶sub sqlt_type { 'DB2' }
Subroutine sqlt_type: not called CC=1 SCAR=6.9
Pod documented
17  
18  
19 # lazy-default kind of thing
20 0 ▶sub sql_name_sep {
Subroutine sql_name_sep: not called CC=4 SCAR=30.0
Pod documented
21 0 my $self = shift;
22  
23 0 my $v = $self->next::method(@_);
24  
25 0 ▶ if (! defined $v and ! @_) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $v or @_) 0 0 0
Condition0%0/3
defined $v or @_
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $v or @_
defined $v @_
Truth table0%0/3
A or B
A= defined $vB= @_
ABresult
1X1
011
000
26 0 ▶ $v = $self->next::method($self->_dbh_get_info('SQL_QUALIFIER_NAME_SEPARATOR') || '.');
Condition0%0/2
$self->_dbh_get_info('SQL_QUALIFIER_NAME_SEPARATOR') || '.'
l!l
00
MC/DC0%0/1
$self->_dbh_get_info('SQL_QUALIFIER_NAME_SEPARATOR') || '.'
$self->_dbh_get_info('SQL_QUALIFIER_NAME_SEPARATOR')
Truth table0%0/2
A
A= $self->_dbh_get_info('SQL_QUALIFIER_NAME_SEPARATOR')
Aresult
11
00
27 }
28  
29 0 return $v;
30 }
31  
32  
33 0 ▶sub dbio_deploy_class { 'DBIO::DB2::Deploy' };
Subroutine dbio_deploy_class: not called CC=1 SCAR=6.9
Pod undocumented
34  
35 0 ▶sub _dbh_last_insert_id {
Subroutine _dbh_last_insert_id: not called CC=2 SCAR=17.9
36 0 my ($self, $dbh, $source, $col) = @_;
37  
38 0 my $name_sep = $self->sql_name_sep;
39  
40 0 my $sth = $dbh->prepare_cached(
41 # An older equivalent of 'VALUES(IDENTITY_VAL_LOCAL())', for compat
42 # with ancient DB2 versions. Should work on modern DB2's as well:
43 # http://publib.boulder.ibm.com/infocenter/db2luw/v8/topic/com.ibm.db2.udb.doc/admin/r0002369.htm?resultof=%22%73%79%73%64%75%6d%6d%79%31%22%20
44 "SELECT IDENTITY_VAL_LOCAL() FROM sysibm${name_sep}sysdummy1",
45 {},
46 3
47 );
48 0 $sth->execute();
49  
50 0 my @res = $sth->fetchrow_array();
51  
52 0 ▶ return @res ? $res[0] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@res ? : 0 0 0
53 }
54  
55 0 ▶sub deploy_setup { }
Subroutine deploy_setup: not called CC=1 SCAR=0.0
Pod documented
56  
57  
58  
59 1 1;
60  
61 __END__
62  
63 =pod
64  
65 =encoding UTF-8
66  
67 =head1 NAME
68  
69 DBIO::DB2::Storage - IBM DB2 support for DBIO
70  
71 =head1 VERSION
72  
73 version 0.900001
74  
75 =head1 DESCRIPTION
76  
77 Storage driver for IBM DB2 databases. Handles autoincrement column retrieval
78 via C<IDENTITY_VAL_LOCAL()>, queries the server name separator from L<DBI>,
79 and sets the datetime parser to L<DateTime::Format::DB2>.
80  
81 Uses L<DBIO::DB2::SQLMaker> for SQL generation with DB2-specific LIMIT/OFFSET
82 support (C<ROW_NUMBER() OVER()> for OFFSET, C<FETCH FIRST n ROWS ONLY> otherwise).
83  
84 =head1 METHODS
85  
86 =head2 sql_name_sep
87  
88 Returns the name separator character used by this DB2 server (e.g. C<.>),
89 queried from the server via C<SQL_QUALIFIER_NAME_SEPARATOR> on first access.
90  
91 =head2 deploy_setup
92  
93 No-op stub for DB2. Present for API compatibility with other drivers
94 that need to allocate resources before a deploy operation.
95  
96 =head1 SEE ALSO
97  
98 =over
99  
100 =item * L<DBIO::DB2> - DB2 schema component
101  
102 =item * L<DBIO::Storage::DBI> - Base DBI storage class
103  
104 =back
105  
106 =head1 AUTHOR
107  
108 DBIO & DBIx::Class Authors
109  
110 =head1 COPYRIGHT AND LICENSE
111  
112 Copyright (C) 2026 DBIO Authors
113 Portions Copyright (C) 2005-2025 DBIx::Class Authors
114 Based on DBIx::Class, heavily modified.
115  
116 This is free software; you can redistribute it and/or modify it under
117 the same terms as the Perl 5 programming language system itself.
118  
119 =cut
« DB2/Diff/Index.pm ↑ Summary DB2/Diff/Table.pm »