From: Rafael Kitover Date: Mon, 24 Aug 2009 11:21:51 +0000 (+0000) Subject: make insert only use a txn if needed, add connect_call_unsafe_insert X-Git-Tag: v0.08112~14^2~52 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=310a0a0a7ccff74b1668a5009edd1f60a972f262;p=dbsrgits%2FDBIx-Class.git make insert only use a txn if needed, add connect_call_unsafe_insert --- diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 27e4b2a..c20a075 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -11,7 +11,7 @@ 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 auto_cast insert_txn/ ); =head1 NAME @@ -31,7 +31,9 @@ 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. @@ -63,7 +65,7 @@ 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) { carp <<'EOF' unless $ENV{DBIC_SYBASE_FREETDS_NOWARN}; @@ -100,6 +102,9 @@ EOF $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); @@ -183,6 +188,32 @@ sub connect_call_set_auto_cast { $self->auto_cast(1); } +=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