X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FSybase.pm;h=886308d0fad35a0f5f90c4f38b07c2f4a204788b;hb=58e3556d625168736ee3548b60bd0833cb99e69e;hp=555f0d5ef8003f2b0dbe529287592677236d4d52;hpb=a3a526ccbf65e59361a29b753f4bdd9495ad6dd5;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 555f0d5..886308d 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -4,15 +4,15 @@ use strict; use warnings; use base qw/ - DBIx::Class::Storage::DBI::Sybase::Base - DBIx::Class::Storage::DBI + DBIx::Class::Storage::DBI::Sybase::Common + DBIx::Class::Storage::DBI::AutoCast /; use mro 'c3'; use Carp::Clan qw/^DBIx::Class/; use List::Util (); __PACKAGE__->mk_group_accessors('simple' => - qw/_identity _blob_log_on_update _auto_cast _insert_txn/ + qw/_identity _blob_log_on_update insert_txn/ ); =head1 NAME @@ -32,14 +32,12 @@ will be reblessed to L. You can also enable that driver explicitly, see the documentation for more details. With this driver there is unfortunately no way to get the C -without doing a C. This is done safely in a transaction +(locking the table.) The transaction can be turned off if concurrency is not an +issue, see L. But your queries will be cached. -You need a version of L compiled with the Sybase OpenClient -libraries, B FreeTDS, for placeholder support. Otherwise your storage will -be automatically reblessed into C<::NoBindVars>. - A recommended L setting: on_connect_call => [['datetime_setup'], ['blob_setup', log_on_update => 0]] @@ -53,7 +51,7 @@ sub _rebless { if (ref($self) eq 'DBIx::Class::Storage::DBI::Sybase') { my $dbtype = eval { - @{$self->dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2] + @{$self->_get_dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2] } || ''; my $exception = $@; @@ -68,9 +66,9 @@ sub _rebless { # This is reset to 0 in ::NoBindVars, only necessary because we use max(col) to # get the identity. - $self->_insert_txn(1); + $self->insert_txn(1); - if ($self->_using_freetds) { + if ($self->using_freetds) { carp <<'EOF' unless $ENV{DBIC_SYBASE_FREETDS_NOWARN}; You are using FreeTDS with Sybase. @@ -80,7 +78,7 @@ support experimental. TEXT/IMAGE columns will definitely not work. -You are encouraged to recompile DBD::Sybase with the Sybase OpenClient libraries +You are encouraged to recompile DBD::Sybase with the Sybase Open Client libraries instead. See perldoc DBIx::Class::Storage::DBI::Sybase for more details. @@ -88,23 +86,29 @@ See perldoc DBIx::Class::Storage::DBI::Sybase for more details. To turn off this warning set the DBIC_SYBASE_FREETDS_NOWARN environment variable. EOF - if (not $self->_placeholders_with_type_conversion_supported) { + if (not $self->_typeless_placeholders_supported) { if ($self->_placeholders_supported) { - $self->_auto_cast(1); + $self->auto_cast(1); } else { $self->ensure_class_loaded($no_bind_vars); bless $self, $no_bind_vars; $self->_rebless; } } - } - if (not $self->dbh->{syb_dynamic_supported}) { + $self->set_textsize; # based on LongReadLen in connect_info + + } + elsif (not $self->dbh->{syb_dynamic_supported}) { + # not necessarily FreeTDS, but no placeholders nevertheless $self->ensure_class_loaded($no_bind_vars); bless $self, $no_bind_vars; $self->_rebless; + } elsif (not $self->_typeless_placeholders_supported) { +# this is highly unlikely, but we check just in case + $self->auto_cast(1); } - + $self->_set_max_connect(256); } } @@ -119,7 +123,7 @@ sub _populate_dbh { $self->next::method(@_); - if (not $self->_using_freetds) { + if (not $self->using_freetds) { $self->_dbh->{syb_chained_txn} = 1; } else { if ($self->_dbh_autocommit) { @@ -159,61 +163,67 @@ sub connect_call_blob_setup { if exists $args{log_on_update}; } +=head2 connect_call_unsafe_insert + +With placeholders enabled, inserts are done in a transaction so that there are +no concurrency issues with getting the inserted identity value using +C