Commit | Line | Data |
---|---|---|
98464041 | 1 | package DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
2ad62d97 | 5 | |
528accab | 6 | use base qw/ |
95787afe | 7 | DBIx::Class::Storage::DBI::Sybase |
5a77aa8b | 8 | DBIx::Class::Storage::DBI::MSSQL |
528accab | 9 | /; |
2ad62d97 | 10 | use mro 'c3'; |
98464041 | 11 | |
9b3dabe0 | 12 | sub _rebless { |
13 | my $self = shift; | |
9ae966b9 | 14 | my $dbh = $self->_get_dbh; |
7379eb67 | 15 | |
918ab8ae | 16 | return if ref $self ne __PACKAGE__; |
17 | ||
e33b954c | 18 | if (not $self->_typeless_placeholders_supported) { |
918ab8ae | 19 | require |
20 | DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars; | |
7379eb67 | 21 | bless $self, |
22 | 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars'; | |
23 | $self->_rebless; | |
24 | } | |
d867eeda | 25 | } |
4966150b | 26 | |
f244a815 | 27 | sub _run_connection_actions { |
d867eeda | 28 | my $self = shift; |
4966150b | 29 | |
d867eeda | 30 | # LongReadLen doesn't work with MSSQL through DBD::Sybase, and the default is |
31 | # huge on some versions of SQL server and can cause memory problems, so we | |
95787afe | 32 | # fix it up here (see ::DBI::Sybase.pm) |
d867eeda | 33 | $self->set_textsize; |
f244a815 | 34 | |
35 | $self->next::method(@_); | |
37b17a93 | 36 | } |
37 | ||
b90d7eba | 38 | sub _dbh_begin_work { |
39 | my $self = shift; | |
40 | ||
41 | $self->_get_dbh->do('BEGIN TRAN'); | |
42 | } | |
43 | ||
44 | sub _dbh_commit { | |
45 | my $self = shift; | |
6db5bdc6 | 46 | my $dbh = $self->_dbh |
47 | or $self->throw_exception('cannot COMMIT on a disconnected handle'); | |
48 | $dbh->do('COMMIT'); | |
b90d7eba | 49 | } |
50 | ||
51 | sub _dbh_rollback { | |
52 | my $self = shift; | |
6db5bdc6 | 53 | my $dbh = $self->_dbh |
54 | or $self->throw_exception('cannot ROLLBACK on a disconnected handle'); | |
55 | $dbh->do('ROLLBACK'); | |
b90d7eba | 56 | } |
57 | ||
6d766626 | 58 | sub _get_server_version { |
ff153e24 | 59 | my $self = shift; |
60 | ||
ff153e24 | 61 | my $product_version = $self->_get_dbh->selectrow_hashref('xp_msver ProductVersion'); |
62 | ||
89f85d82 | 63 | if ((my $version = $product_version->{Character_Value}) =~ /^(\d+)\./) { |
6d766626 | 64 | return $version; |
65 | } | |
66 | else { | |
67 | $self->throw_exception( | |
68 | "MSSQL Version Retrieval Failed, Your ProductVersion's Character_Value is missing or malformed!" | |
89f85d82 | 69 | ); |
ff153e24 | 70 | } |
ff153e24 | 71 | } |
72 | ||
98464041 | 73 | 1; |
74 | ||
75 | =head1 NAME | |
76 | ||
5a77aa8b | 77 | DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server - Support for Microsoft |
78 | SQL Server via DBD::Sybase | |
98464041 | 79 | |
80 | =head1 SYNOPSIS | |
81 | ||
5608593e | 82 | This subclass supports MSSQL server connections via L<DBD::Sybase>. |
98464041 | 83 | |
7379eb67 | 84 | =head1 DESCRIPTION |
d4483998 | 85 | |
7379eb67 | 86 | This driver tries to determine whether your version of L<DBD::Sybase> and |
87 | supporting libraries (usually FreeTDS) support using placeholders, if not the | |
88 | storage will be reblessed to | |
89 | L<DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars>. | |
98464041 | 90 | |
7379eb67 | 91 | The MSSQL specific functionality is provided by |
92 | L<DBIx::Class::Storage::DBI::MSSQL>. | |
7e8cecc1 | 93 | |
5a77aa8b | 94 | =head1 AUTHOR |
98464041 | 95 | |
b7505130 | 96 | See L<DBIx::Class/CONTRIBUTORS>. |
98464041 | 97 | |
98 | =head1 LICENSE | |
99 | ||
100 | You may distribute this code under the same terms as Perl itself. | |
101 | ||
102 | =cut |