From: Rafael Kitover Date: Sun, 22 Nov 2009 12:27:43 +0000 (+0000) Subject: override _run_connection_actions for internal connection setup in sybase stuff, much... X-Git-Tag: v0.08116~134 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f244a81505f81087d4bd9a435081aa40b5f32435;p=dbsrgits%2FDBIx-Class.git override _run_connection_actions for internal connection setup in sybase stuff, much cleaner this way --- diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index a111d4e..4b1c8d6 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -120,9 +120,6 @@ sub _init { my $self = shift; $self->_set_max_connect(256); -# this is also done on _populate_dbh, but storage may not be reblessed yet - $self->_syb_setup_connection; - # create storage for insert/(update blob) transactions, # unless this is that storage return if $self->_is_extra_storage; @@ -182,26 +179,17 @@ sub disconnect { $self->next::method; } -sub _populate_dbh { - my $self = shift; - - $self->next::method(@_); - - $self->_syb_setup_connection; -} - -# Set up session settings for Sybase databases for the connection, called from -# _populate_dbh and _init (before _driver_determined .) +# Set up session settings for Sybase databases for the connection. # # Make sure we have CHAINED mode turned on if AutoCommit is off in non-FreeTDS # DBD::Sybase (since we don't know how DBD::Sybase was compiled.) If however # we're using FreeTDS, CHAINED mode turns on an implicit transaction which we # only want when AutoCommit is off. -sub _syb_setup_connection { +# +# Also SET TEXTSIZE for FreeTDS because LongReadLen doesn't work. +sub _run_connection_actions { my $self = shift; - return unless $self->_driver_determined; # otherwise we screw up MSSQL - if ($self->_is_bulk_storage) { # this should be cleared on every reconnect $self->_began_bulk_work(0); @@ -220,6 +208,8 @@ sub _syb_setup_connection { $self->_dbh->do('SET CHAINED ON'); } } + + $self->next::method(@_); } =head2 connect_call_blob_setup diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/Common.pm b/lib/DBIx/Class/Storage/DBI/Sybase/Common.pm index af4c916..400aefa 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/Common.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/Common.pm @@ -31,7 +31,7 @@ sub _ping { local $dbh->{PrintError} = 0; if ($dbh->{syb_no_child_con}) { -# ping is impossible with an active statement, we return false if so +# if extra connections are not allowed, then ->ping is reliable my $ping = eval { $dbh->ping }; return $@ ? 0 : $ping; } diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm b/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm index 5cd5aa1..f762385 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm @@ -20,13 +20,15 @@ sub _rebless { } } -sub _init { +sub _run_connection_actions { my $self = shift; # LongReadLen doesn't work with MSSQL through DBD::Sybase, and the default is # huge on some versions of SQL server and can cause memory problems, so we # fix it up here (see Sybase/Common.pm) $self->set_textsize; + + $self->next::method(@_); } sub _dbh_begin_work {