X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FSybase.pm;h=68c2e20eef6a4c316caedb25b4cd36546b3e2133;hb=51ac7136944f82aa2675cc133a8d080c5fb367b1;hp=7995334798ed7032ba006e16f3d0d22d445d1ad5;hpb=44e538d00c41e69899b48178c9dede95e2ef7e77;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 7995334..68c2e20 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -4,14 +4,15 @@ use strict; use warnings; use base qw/ - DBIx::Class::Storage::DBI::Sybase::Base + 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 unsafe_insert _insert_dbh/ ); =head1 NAME @@ -31,7 +32,10 @@ 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, or you don't need the C value, see +L. But your queries will be cached. @@ -48,7 +52,7 @@ sub _rebless { if (ref($self) eq 'DBIx::Class::Storage::DBI::Sybase') { my $dbtype = eval { - @{$self->last_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 = $@; @@ -61,10 +65,6 @@ sub _rebless { } else { # real Sybase my $no_bind_vars = 'DBIx::Class::Storage::DBI::Sybase::NoBindVars'; -# This is reset to 0 in ::NoBindVars, only necessary because we use max(col) to -# get the identity. - $self->_insert_txn(1); - if ($self->using_freetds) { carp <<'EOF' unless $ENV{DBIC_SYBASE_FREETDS_NOWARN}; @@ -83,8 +83,8 @@ 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 ($self->placeholders_supported) { + if (not $self->_typeless_placeholders_supported) { + if ($self->_placeholders_supported) { $self->auto_cast(1); } else { $self->ensure_class_loaded($no_bind_vars); @@ -95,13 +95,17 @@ EOF $self->set_textsize; # based on LongReadLen in connect_info - } elsif (not $self->dbh->{syb_dynamic_supported}) { -# not necessarily FreeTDS, but no placeholders nevertheless + } + elsif (not $self->_get_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); } } @@ -156,31 +160,30 @@ sub connect_call_blob_setup { if exists $args{log_on_update}; } -=head2 connect_call_set_auto_cast +=head2 connect_call_unsafe_insert -In some configurations (usually with L) statements with values bound -to columns or conditions that are not strings will throw implicit type -conversion errors. For L this is automatically detected, and this -option is set. +With placeholders enabled, inserts are done in a transaction so that there are +no concurrency issues with getting the inserted identity value using +C