Firebird/Storage/ODBC.pm

filter: Statementstmt 82.3% 28 / 34 Branchbran 50.0% 2 / 4 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 64.2% 9 / 14 Podpod 100% 1 / 1 totaltotal 76.7% 43 / 56 CC 4 SCAR 7.8
CC
4
Cov
80%
__ANON__
6.0
_run_connection_actions
3.0
_exec_svp_release
2.0
CRAP 2.2
« Firebird/Introspect/ForeignKeys.pm ↑ Summary Firebird.pm »
1 package DBIO::Firebird::Storage::ODBC;
2 # ABSTRACT: Driver for the Firebird RDBMS via L<DBD::ODBC>
3  
4 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 16 our $VERSION = '0.900007';
8  
9 16 ▶use base qw/
Subroutine BEGIN: called CC=1 SCAR=0.0
10 DBIO::Storage::DBI::ODBC
11 DBIO::Firebird::Storage::Common
12 16 /;
13 16 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 16 __PACKAGE__->datetime_parser_type('DBIO::Firebird::DateTime::Format');
16  
17 16 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 16 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20  
21 # karr k50 (core k276) -- a HostBound view cannot be bound into an ODBC DSN
22 # here. The Firebird ODBC driver takes the server inside the database name
23 # (DBNAME=host/port:path) and knows no host= or port= key, which core's
24 # default would write into the connect string for the driver to ignore --
25 # the replicant connecting to whatever the database name says. Declined,
26 # naming the form; the view's refusal never quotes the DSN.
27 3 ▶sub _bind_host_into_dsn {
Subroutine _bind_host_into_dsn: called CC=1 SCAR=0.0
28 3 return (undef, 'an ODBC DSN: the Firebird ODBC driver takes the server '
29 . 'inside DBNAME=host/port:path, which is not translated');
30 }
31  
32 # Upstream DBIx::Class finding, kept: batch operations in DBD::ODBC 1.35 do not
33 # work with the official Firebird ODBC driver, which identifies itself as
34 # OdbcFb. _disable_odbc_array_ops comes from core's ODBC storage and picks the
35 # attribute spelling that matches the installed DBD::ODBC.
36 14 ▶sub _run_connection_actions {
Subroutine _run_connection_actions: called CC=3 SCAR=11.0
37 14 my $self = shift;
38  
39 14 ▶ if (($self->_dbh_get_info('SQL_DRIVER_NAME') || '') eq 'OdbcFb') {
Branch: 1 branch
BranchTrueFalseTotal
if (($self->_dbh_get_info("SQL_DRIVER_NAME") || "") eq "OdbcFb") 12 2 14
Condition100%2/2
$self->_dbh_get_info('SQL_DRIVER_NAME') || ''
l!l
122
MC/DC100%1/1
$self->_dbh_get_info('SQL_DRIVER_NAME') || ''
$self->_dbh_get_info('SQL_DRIVER_NAME')
Truth table100%2/2
A
A= $self->_dbh_get_info('SQL_DRIVER_NAME')
Aresult
11
00
40 12 $self->_disable_odbc_array_ops;
41 }
42  
43 14 return $self->next::method(@_);
44 }
45  
46 # Upstream DBIx::Class finding, kept: RELEASE SAVEPOINT does not work through
47 # this driver. Not releasing is safe -- the savepoint stays on the transaction
48 # until it commits or rolls back -- whereas issuing it fails the surrounding
49 # txn_do for a statement whose only effect would have been to free a name.
50 0 ▶sub _exec_svp_release { 1 }
Subroutine _exec_svp_release: not called CC=1 SCAR=6.9
51  
52 # ... and the other half of the same bug: the ROLLBACK TO SAVEPOINT works, but
53 # the driver reports an error it cannot describe afterwards. Anything else is
54 # rethrown.
55 0 ▶sub _exec_svp_rollback {
Subroutine _exec_svp_rollback: not called CC=1 SCAR=6.9
56 0 my ($self, $name) = @_;
57  
58 0 ▶ try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
59 0 $self->_dbh->do("ROLLBACK TO SAVEPOINT $name");
60 }
61 0 ▶ catch {
Subroutine __ANON__: not called CC=2 SCAR=17.9
62 0 ▶ $self->throw_exception($_)
Branch: 1 branch
BranchTrueFalseTotal
unless /Unable to fetch information about the error/ 0 0 0
63 unless /Unable to fetch information about the error/;
64 0 };
65 }
66  
67  
68 0 ▶sub connect_call_datetime_setup { 1 }
Subroutine connect_call_datetime_setup: not called CC=1 SCAR=6.9
Pod documented
69  
70 # ADR 0040 -- the whole operation of obtaining a query plan, which on this
71 # transport is: none. See the DESCRIPTION for why neither core's EXPLAIN nor
72 # the InterBase driver's func('ib_plan') is reachable from a DBD::ODBC handle.
73 # Refusing here is the ADR 0039 trade: a caller who asked for something this
74 # transport cannot do learns that from the method they called, instead of from
75 # a parse error several layers below it.
76 1 ▶sub _explain_query {
Subroutine _explain_query: called CC=1 SCAR=0.0
77 1 my $self = shift;
78  
79 1 $self->throw_exception(
80 'Firebird cannot produce a query plan over ODBC. The engine has no EXPLAIN '
81 . 'statement at all -- the token is not in the Firebird 5.0 Language '
82 . 'Reference, Appendix C, which lists every keyword reserved and '
83 . 'non-reserved -- and its plan is an attribute of the PREPARED statement '
84 . '(isc_dsql_sql_info / isc_info_sql_get_plan), which DBD::Firebird and '
85 . 'DBD::InterBase reach through the private $sth->func(\'ib_plan\') and '
86 . 'DBD::ODBC does not expose in any form. Connect through DBD::Firebird or '
87 . 'DBD::InterBase to explain a query on this engine.'
88 );
89 }
90  
91  
92 16 1;
93  
94 __END__
« Firebird/Introspect/ForeignKeys.pm ↑ Summary Firebird.pm »