| 1 | package DBIx::Class::Storage::DBI::Sybase::FreeTDS; | ||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 5 | 2 | ▶ | use base qw/DBIx::Class::Storage::DBI::Sybase/; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 6 | 2 | ▶ | use mro 'c3'; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 7 | 2 | ▶ | use Try::Tiny; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 8 | 2 | ▶ | use namespace::clean; | ||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||
| 12 | DBIx::Class::Storage::DBI::Sybase::FreeTDS - Base class for drivers using | ||||||||||||||||||||||||
| 13 | DBD::Sybase over FreeTDS. | ||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||
| 17 | This is the base class for Storages designed to work with L<DBD::Sybase> over | ||||||||||||||||||||||||
| 18 | FreeTDS. | ||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||
| 20 | It is a subclass of L<DBIx::Class::Storage::DBI::Sybase>. | ||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||
| 22 | =head1 METHODS | ||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||
| 24 | =cut | ||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||
| 26 | # The subclass storage driver defines _set_autocommit_stmt | ||||||||||||||||||||||||
| 27 | # for MsSQL it is SET IMPLICIT_TRANSACTIONS ON/OFF | ||||||||||||||||||||||||
| 28 | # for proper Sybase it's SET CHAINED ON/OFF | ||||||||||||||||||||||||
| 29 | 0 | ▶ | sub _set_autocommit { | ||||||||||||||||||||||
|
Subroutine
_set_autocommit: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||
| 30 | 0 | my $self = shift; | |||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||
| 32 | 0 | ▶ | if ($self->_dbh_autocommit) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 33 | 0 | $self->_dbh->do($self->_set_autocommit_stmt(1)); | |||||||||||||||||||||||
| 34 | } else { | ||||||||||||||||||||||||
| 35 | 0 | $self->_dbh->do($self->_set_autocommit_stmt(0)); | |||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||
| 39 | # Handle AutoCommit and SET TEXTSIZE because LongReadLen doesn't work. | ||||||||||||||||||||||||
| 40 | # | ||||||||||||||||||||||||
| 41 | 0 | ▶ | sub _run_connection_actions { | ||||||||||||||||||||||
|
Subroutine
_run_connection_actions: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||
| 42 | 0 | my $self = shift; | |||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||
| 44 | # based on LongReadLen in connect_info | ||||||||||||||||||||||||
| 45 | 0 | $self->set_textsize; | |||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||
| 47 | 0 | $self->_set_autocommit; | |||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||
| 49 | 0 | $self->next::method(@_); | |||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||
| 52 | =head2 set_textsize | ||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||
| 54 | When using DBD::Sybase with FreeTDS, C<< $dbh->{LongReadLen} >> is not available, | ||||||||||||||||||||||||
| 55 | use this function instead. It does: | ||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||
| 57 | $dbh->do("SET TEXTSIZE $bytes"); | ||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||
| 59 | Takes the number of bytes, or uses the C<LongReadLen> value from your | ||||||||||||||||||||||||
| 60 | L<connect_info|DBIx::Class::Storage::DBI/connect_info> if omitted, lastly falls | ||||||||||||||||||||||||
| 61 | back to the C<32768> which is the L<DBD::Sybase> default. | ||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||
| 63 | =cut | ||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||
| 65 | 0 | ▶ | sub set_textsize { | ||||||||||||||||||||||
|
Subroutine
set_textsize: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||
| 66 | 0 | my $self = shift; | |||||||||||||||||||||||
| 67 | my $text_size = | ||||||||||||||||||||||||
| 68 | shift | ||||||||||||||||||||||||
| 69 | || | ||||||||||||||||||||||||
| 70 | 0 | ▶ | try { $self->_dbic_cinnect_attributes->{LongReadLen} } | ||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||
| 71 | || | ||||||||||||||||||||||||
| 72 | 0 | ▶ | 32768; # the DBD::Sybase default | ||||||||||||||||||||||
|
Condition0%0/5
shift() || &try(sub {
$self->_dbic_cinnect_attributes->{'LongReadLen'};
}
) || 32768
shift() or &try(sub {
$self->_dbic_cinnect_attributes->{"LongReadLen"};
}
)
MC/DC0%0/2
shift() || &try(sub {
$self->_dbic_cinnect_attributes->{'LongReadLen'};
}
) || 32768
shift()
&try(sub {
$self->_dbic_cinnect_attributes->{"LongReadLen"};
}
)
Truth table0%0/3
A or B
A= shift()B= &try(sub {
$self->_dbic_cinnect_attributes->{"LongReadLen"};
}
)
| |||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||
| 74 | 0 | $self->_dbh->do("SET TEXTSIZE $text_size"); | |||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||
| 77 | 0 | ▶ | sub _exec_txn_begin { | ||||||||||||||||||||||
|
Subroutine
_exec_txn_begin: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||
| 78 | 0 | my $self = shift; | |||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($self->{_in_do_block}) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 81 | 0 | $self->_dbh->do('BEGIN TRAN'); | |||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||
| 83 | else { | ||||||||||||||||||||||||
| 84 | 0 | ▶ | $self->dbh_do(sub { $_[1]->do('BEGIN TRAN') }); | ||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||
| 88 | 0 | ▶ | sub _exec_txn_commit { | ||||||||||||||||||||||
|
Subroutine
_exec_txn_commit: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||
| 89 | 0 | my $self = shift; | |||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||
| 91 | 0 | ▶ | my $dbh = $self->_dbh | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 92 | or $self->throw_exception('cannot COMMIT on a disconnected handle'); | ||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||
| 94 | 0 | $dbh->do('COMMIT'); | |||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||
| 97 | 0 | ▶ | sub _exec_txn_rollback { | ||||||||||||||||||||||
|
Subroutine
_exec_txn_rollback: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||
| 98 | 0 | my $self = shift; | |||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||
| 100 | 0 | ▶ | my $dbh = $self->_dbh | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 101 | or $self->throw_exception('cannot ROLLBACK on a disconnected handle'); | ||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||
| 103 | 0 | $dbh->do('ROLLBACK'); | |||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||
| 106 | =head1 FURTHER QUESTIONS? | ||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||
| 108 | Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>. | ||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||
| 110 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||
| 112 | This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE> | ||||||||||||||||||||||||
| 113 | by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can | ||||||||||||||||||||||||
| 114 | redistribute it and/or modify it under the same terms as the | ||||||||||||||||||||||||
| 115 | L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>. | ||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||
| 117 | =cut | ||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||
| 119 | 2 | 1; | |||||||||||||||||||||||