1 package DBIx::Class::Storage::DBI::Sybase;
8 use base qw/DBIx::Class::Storage::DBI/;
12 DBIx::Class::Storage::DBI::Sybase - Base class for drivers using
17 This is the base class/dispatcher for Storage's designed to work with
29 $dbtype = @{$self->_get_dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2]
31 $self->throw_exception("Unable to establish connection to determine database type: $_")
38 $dbtype = 'ASE' if $dbtype eq 'SQL_Server';
40 my $subclass = __PACKAGE__ . "::$dbtype";
41 if ($self->load_optional_class($subclass)) {
42 bless $self, $subclass;
49 # once the driver is determined see if we need to insert the DBD::Sybase w/ FreeTDS fixups
50 # this is a dirty version of "instance role application", \o/ DO WANT Moo \o/
52 if (! $self->isa('DBIx::Class::Storage::DBI::Sybase::FreeTDS') and $self->_using_freetds) {
53 require DBIx::Class::Storage::DBI::Sybase::FreeTDS;
55 my @isa = @{mro::get_linear_isa(ref $self)};
56 my $class = shift @isa; # this is our current ref
58 my $trait_class = $class . '::FreeTDS';
59 mro::set_mro ($trait_class, 'c3');
61 @{"${trait_class}::ISA"} = ($class, 'DBIx::Class::Storage::DBI::Sybase::FreeTDS', @isa);
63 bless ($self, $trait_class);
65 Class::C3->reinitialize() if DBIx::Class::_ENV_::OLD_MRO;
70 $self->next::method(@_);
76 my $dbh = $self->_dbh or return 0;
78 local $dbh->{RaiseError} = 1;
79 local $dbh->{PrintError} = 0;
81 # FIXME if the main connection goes stale, does opening another for this statement
82 # really determine anything?
84 if ($dbh->{syb_no_child_con}) {
86 $self->_connect->do('select 1');
103 sub _set_max_connect {
105 my $val = shift || 256;
107 my $dsn = $self->_dbi_connect_info->[0];
109 return if ref($dsn) eq 'CODE';
111 if ($dsn !~ /maxConnect=/) {
112 $self->_dbi_connect_info->[0] = "$dsn;maxConnect=$val";
113 my $connected = defined $self->_dbh;
115 $self->ensure_connected if $connected;
119 # Whether or not DBD::Sybase was compiled against FreeTDS. If false, it means
120 # the Sybase OpenClient libraries were used.
123 return ($self->_get_dbh->{syb_oc_version}||'') =~ /freetds/i;
126 # Either returns the FreeTDS version against which DBD::Sybase was compiled,
127 # 0 if can't be determined, or undef otherwise
128 sub _using_freetds_version {
129 my $inf = shift->_get_dbh->{syb_oc_version};
130 return undef unless ($inf||'') =~ /freetds/i;
131 return $inf =~ /v([0-9\.]+)/ ? $1 : 0;
134 =head1 FURTHER QUESTIONS?
136 Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
138 =head1 COPYRIGHT AND LICENSE
140 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
141 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
142 redistribute it and/or modify it under the same terms as the
143 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.