1 package DBIx::Class::Storage::DBI::Sybase;
7 use base qw/DBIx::Class::Storage::DBI/;
11 DBIx::Class::Storage::DBI::Sybase - Base class for drivers using
16 This is the base class/dispatcher for Storage's designed to work with
28 $dbtype = @{$self->_get_dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2]
30 $self->throw_exception("Unable to estable connection to determine database type: $_")
37 $dbtype = 'ASE' if $dbtype eq 'SQL_Server';
39 my $subclass = __PACKAGE__ . "::$dbtype";
40 if ($self->load_optional_class($subclass)) {
41 bless $self, $subclass;
50 my $dbh = $self->_dbh or return 0;
52 local $dbh->{RaiseError} = 1;
53 local $dbh->{PrintError} = 0;
55 if ($dbh->{syb_no_child_con}) {
56 # if extra connections are not allowed, then ->ping is reliable
57 my $ping = eval { $dbh->ping };
58 return $@ ? 0 : $ping;
63 # XXX if the main connection goes stale, does opening another for this statement
64 # really determine anything?
73 sub _set_max_connect {
75 my $val = shift || 256;
77 my $dsn = $self->_dbi_connect_info->[0];
79 return if ref($dsn) eq 'CODE';
81 if ($dsn !~ /maxConnect=/) {
82 $self->_dbi_connect_info->[0] = "$dsn;maxConnect=$val";
83 my $connected = defined $self->_dbh;
85 $self->ensure_connected if $connected;
91 Whether or not L<DBD::Sybase> was compiled against FreeTDS. If false, it means
92 the Sybase OpenClient libraries were used.
99 return $self->_get_dbh->{syb_oc_version} =~ /freetds/i;
104 When using FreeTDS and/or MSSQL, C<< $dbh->{LongReadLen} >> is not available,
105 use this function instead. It does:
107 $dbh->do("SET TEXTSIZE $bytes");
109 Takes the number of bytes, or uses the C<LongReadLen> value from your
110 L<connect_info|DBIx::Class::Storage::DBI/connect_info> if omitted, lastly falls
111 back to the C<32768> which is the L<DBD::Sybase> default.
117 my $text_size = shift ||
118 eval { $self->_dbi_connect_info->[-1]->{LongReadLen} } ||
119 32768; # the DBD::Sybase default
121 return unless defined $text_size;
123 $self->_dbh->do("SET TEXTSIZE $text_size");
130 See L<DBIx::Class/CONTRIBUTORS>.
134 You may distribute this code under the same terms as Perl itself.