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
24 sub _rebless { shift->_determine_connector_driver('Sybase') }
30 my $name = $self->_get_dbh->selectrow_arrayref('sp_server_info @attribute_id=1')->[2];
36 $name = 'ASE' if $name eq 'SQL_Server';
41 $self->throw_exception("Unable to establish connection to determine database type: $_")
46 # once the driver is determined see if we need to insert the DBD::Sybase w/ FreeTDS fixups
47 # this is a dirty version of "instance role application", \o/ DO WANT Moo \o/
49 if (! $self->isa('DBIx::Class::Storage::DBI::Sybase::FreeTDS') and $self->_using_freetds) {
50 require DBIx::Class::Storage::DBI::Sybase::FreeTDS;
52 my @isa = @{mro::get_linear_isa(ref $self)};
53 my $class = shift @isa; # this is our current ref
55 my $trait_class = $class . '::FreeTDS';
56 mro::set_mro ($trait_class, 'c3');
58 @{"${trait_class}::ISA"} = ($class, 'DBIx::Class::Storage::DBI::Sybase::FreeTDS', @isa);
60 bless ($self, $trait_class);
62 Class::C3->reinitialize() if DBIx::Class::_ENV_::OLD_MRO;
67 $self->next::method(@_);
73 my $dbh = $self->_dbh or return 0;
75 local $dbh->{RaiseError} = 1;
76 local $dbh->{PrintError} = 0;
78 # FIXME if the main connection goes stale, does opening another for this statement
79 # really determine anything?
81 if ($dbh->{syb_no_child_con}) {
83 $self->_connect->do('select 1');
100 sub _set_max_connect {
102 my $val = shift || 256;
104 my $dsn = $self->_dbi_connect_info->[0];
106 return if ref($dsn) eq 'CODE';
108 if ($dsn !~ /maxConnect=/) {
109 $self->_dbi_connect_info->[0] = "$dsn;maxConnect=$val";
110 my $connected = defined $self->_dbh;
112 $self->ensure_connected if $connected;
116 # Whether or not DBD::Sybase was compiled against FreeTDS. If false, it means
117 # the Sybase OpenClient libraries were used.
120 return ($self->_get_dbh->{syb_oc_version}||'') =~ /freetds/i;
123 # Either returns the FreeTDS version against which DBD::Sybase was compiled,
124 # 0 if can't be determined, or undef otherwise
125 sub _using_freetds_version {
126 my $inf = shift->_get_dbh->{syb_oc_version};
127 return undef unless ($inf||'') =~ /freetds/i;
128 return $inf =~ /v([0-9\.]+)/ ? $1 : 0;
131 =head1 FURTHER QUESTIONS?
133 Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
135 =head1 COPYRIGHT AND LICENSE
137 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
138 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
139 redistribute it and/or modify it under the same terms as the
140 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.