Sybase/Storage/FreeTDS.pm

filter: Statementstmt 45.2% 19 / 42 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 42.8% 6 / 14 Podpod 100% 1 / 1 totaltotal 36.1% 26 / 72 CC 7 SCAR 15.7
CC
7
Cov
35%
set_textsize
12.0
_set_autocommit
6.0
_exec_txn_begin
6.0
CRAP 4.8
« Sybase/Storage/ASE/IdentityRetrieval.pm ↑ Summary Sybase/Diff/Table.pm »
1 package DBIO::Sybase::Storage::FreeTDS;
2 # ABSTRACT: Base class for drivers using DBD::Sybase over FreeTDS.
3  
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use base qw/DBIO::Sybase::Storage/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 # The subclass storage driver defines _set_autocommit_stmt
13 # for MsSQL it is SET IMPLICIT_TRANSACTIONS ON/OFF
14 # for proper Sybase it's SET CHAINED ON/OFF
15 0 ▶sub _set_autocommit {
Subroutine _set_autocommit: not called CC=2 SCAR=17.9
16 0 my $self = shift;
17  
18 0 ▶ if ($self->_dbh_autocommit) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_dbh_autocommit) { } 0 0 0
19 0 $self->_dbh->do($self->_set_autocommit_stmt(1));
20 } else {
21 0 $self->_dbh->do($self->_set_autocommit_stmt(0));
22 }
23 }
24  
25 # Handle AutoCommit and SET TEXTSIZE because LongReadLen doesn't work.
26 #
27 0 ▶sub _run_connection_actions {
Subroutine _run_connection_actions: not called CC=1 SCAR=6.9
28 0 my $self = shift;
29  
30 # based on LongReadLen in connect_info
31 0 $self->set_textsize;
32  
33 0 $self->_set_autocommit;
34  
35 0 $self->next::method(@_);
36 }
37  
38  
39 0 ▶sub set_textsize {
Subroutine set_textsize: not called CC=3 SCAR=24.8
Pod documented
40 0 my $self = shift;
41 my $text_size =
42 shift
43 ||
44 0 ▶ try { $self->_dbio_connect_attributes->{LongReadLen} }
Subroutine __ANON__: not called CC=1 SCAR=6.9
45 ||
46 0 ▶ 32768; # the DBD::Sybase default
Condition0%0/5
shift() || &try(sub { || 32768
l!l
00
shift() or &try(sub {
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || &try(sub { $self->_dbio_connect_attributes->{'LongReadLen'}; } ) || 32768
shift() &try(sub { $self->_dbio_connect_attributes->{"LongReadLen"}; } )
Truth table0%0/3
A or B
A= shift()B= &try(sub { $self->_dbio_connect_attributes->{"LongReadLen"}; } )
ABresult
1X1
011
000
47  
48 0 $self->_dbh->do("SET TEXTSIZE $text_size");
49 }
50  
51 0 ▶sub _exec_txn_begin {
Subroutine _exec_txn_begin: not called CC=2 SCAR=17.9
52 0 my $self = shift;
53  
54 0 ▶ if ($self->{_in_do_block}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_in_do_block'}) { } 0 0 0
55 0 $self->_dbh->do('BEGIN TRAN');
56 }
57 else {
58 0 ▶ $self->dbh_do(sub { $_[1]->do('BEGIN TRAN') });
Subroutine __ANON__: not called CC=1 SCAR=6.9
59 }
60 }
61  
62 0 ▶sub _exec_txn_commit {
Subroutine _exec_txn_commit: not called CC=2 SCAR=17.9
63 0 my $self = shift;
64  
65 0 ▶ my $dbh = $self->_dbh
Branch: 1 branch
BranchTrueFalseTotal
my $dbh = $self->_dbh or $self->throw_exception("cannot COMMIT on a disconnected handle") 0 0 0
66 or $self->throw_exception('cannot COMMIT on a disconnected handle');
67  
68 0 $dbh->do('COMMIT');
69 }
70  
71 0 ▶sub _exec_txn_rollback {
Subroutine _exec_txn_rollback: not called CC=2 SCAR=17.9
72 0 my $self = shift;
73  
74 0 ▶ my $dbh = $self->_dbh
Branch: 1 branch
BranchTrueFalseTotal
my $dbh = $self->_dbh or $self->throw_exception("cannot ROLLBACK on a disconnected handle") 0 0 0
75 or $self->throw_exception('cannot ROLLBACK on a disconnected handle');
76  
77 0 $dbh->do('ROLLBACK');
78 }
79  
80  
81 2 1;
82  
83 __END__
84  
85 =pod
86  
87 =encoding UTF-8
88  
89 =head1 NAME
90  
91 DBIO::Sybase::Storage::FreeTDS - Base class for drivers using DBD::Sybase over FreeTDS.
92  
93 =head1 VERSION
94  
95 version 0.900001
96  
97 =head1 DESCRIPTION
98  
99 Base storage class for L<DBD::Sybase> connections using the FreeTDS library.
100 It is a subclass of L<DBIO::Sybase::Storage> and is mixed in automatically
101 by L<DBIO::Sybase::Storage> when FreeTDS is detected.
102  
103 Provides FreeTDS-specific transaction management (explicit C<BEGIN TRAN>,
104 C<COMMIT>, C<ROLLBACK>) and text size handling via C<SET TEXTSIZE>, since
105 C<< $dbh->{LongReadLen} >> is not available under FreeTDS.
106  
107 =head1 METHODS
108  
109 =head2 set_textsize
110  
111 When using DBD::Sybase with FreeTDS, C<< $dbh->{LongReadLen} >> is not available,
112 use this function instead. It does:
113  
114 $dbh->do("SET TEXTSIZE $bytes");
115  
116 Takes the number of bytes, or uses the C<LongReadLen> value from your
117 L<connect_info|DBIO::Storage::DBI/connect_info> if omitted, lastly falls
118 back to the C<32768> which is the L<DBD::Sybase> default.
119  
120 =head1 SEE ALSO
121  
122 =over
123  
124 =item * L<DBIO::Sybase::Storage> - Sybase storage dispatcher (mixes this in)
125  
126 =item * L<DBIO::Sybase::Storage::ASE> - Sybase ASE storage
127  
128 =item * L<DBIO::MSSQL::Storage::Sybase> - MSSQL via L<DBD::Sybase>
129  
130 =back
131  
132 =head1 AUTHOR
133  
134 DBIO & DBIx::Class Authors
135  
136 =head1 COPYRIGHT AND LICENSE
137  
138 Copyright (C) 2026 DBIO Authors
139 Portions Copyright (C) 2005-2025 DBIx::Class Authors
140 Based on DBIx::Class, heavily modified.
141  
142 This is free software; you can redistribute it and/or modify it under
143 the same terms as the Perl 5 programming language system itself.
144  
145 =cut
« Sybase/Storage/ASE/IdentityRetrieval.pm ↑ Summary Sybase/Diff/Table.pm »