X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FSybase.pm;h=eeb4f01edf2a3806495f10925641a7d166d036b6;hb=6862815907d42aa2f5fcc70afd4ff2dbc9b48f79;hp=9cfc047aa729f1a25b4474e34d62cdfebbed7845;hpb=63d46bb3853faf51e05d39311c87b6aa7e44110d;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 9cfc047..eeb4f01 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -3,17 +3,65 @@ package DBIx::Class::Storage::DBI::Sybase; use strict; use warnings; -use Class::C3; -use base qw/DBIx::Class::Storage::DBI/; - +use base qw/ + DBIx::Class::Storage::DBI::Sybase::Common + DBIx::Class::Storage::DBI::AutoCast +/; +use mro 'c3'; use Carp::Clan qw/^DBIx::Class/; +use List::Util(); +use Sub::Name(); +use Data::Dumper::Concise(); + +__PACKAGE__->mk_group_accessors('simple' => + qw/_identity _blob_log_on_update _writer_storage _is_extra_storage + _bulk_storage _is_bulk_storage _began_bulk_work + _bulk_disabled_due_to_coderef_connect_info_warned + _identity_method/ +); + +my @also_proxy_to_extra_storages = qw/ + connect_call_set_auto_cast auto_cast connect_call_blob_setup + connect_call_datetime_setup + + disconnect _connect_info _sql_maker _sql_maker_opts disable_sth_caching + auto_savepoint unsafe cursor_class debug debugobj schema +/; + +=head1 NAME + +DBIx::Class::Storage::DBI::Sybase - Sybase support for DBIx::Class + +=head1 SYNOPSIS + +This subclass supports L for real Sybase databases. If you are +using an MSSQL database via L, your storage will be reblessed to +L. + +=head1 DESCRIPTION + +If your version of Sybase does not support placeholders, then your storage +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. +The Open Client FAQ is here: +L. + +Sybase ASE for Linux (which comes with the Open Client libraries) may be +downloaded here: L. + +To see if you're using FreeTDS check C<< $schema->storage->using_freetds >>, or run: + + perl -MDBI -le 'my $dbh = DBI->connect($dsn, $user, $pass); print $dbh->{syb_oc_version}' + +Some versions of the libraries involved will not support placeholders, in which +case the storage will be reblessed to +L. + +In some configurations, placeholders will work but will throw implicit type +conversion errors for anything that's not expecting a string. In such a case, +the C option from L is +automatically set, which you may enable on connection with +L. The type info +for the Cs is taken from the L +definitions in your Result classes, and are mapped to a Sybase type (if it isn't +already) using a mapping based on L. + +In other configurations, placeholers will work just as they do with the Sybase +Open Client libraries. + +Inserts or updates of TEXT/IMAGE columns will B work with FreeTDS. + +=head1 INSERTS WITH PLACEHOLDERS + +With placeholders enabled, inserts are done in a transaction so that there are +no concurrency issues with getting the inserted identity value using +C as it's a +session variable. + +=head1 TRANSACTIONS -But your queries will be cached. +Due to limitations of the TDS protocol, L, or both; you cannot +begin a transaction while there are active cursors; nor can you use multiple +active cursors within a transaction. An active cursor is, for example, a +L that has been executed using C or +C but has not been exhausted or L. + +For example, this will not work: + + $schema->txn_do(sub { + my $rs = $schema->resultset('Book'); + while (my $row = $rs->next) { + $schema->resultset('MetaData')->create({ + book_id => $row->id, + ... + }); + } + }); + +This won't either: + + my $first_row = $large_rs->first; + $schema->txn_do(sub { ... }); + +Transactions done for inserts in C mode when placeholders are in use +are not affected, as they are done on an extra database handle. + +Some workarounds: + +=over 4 + +=item * use L + +=item * L another L + +=item * load the data from your cursor with L + +=back + +=head1 MAXIMUM CONNECTIONS + +The TDS protocol makes separate connections to the server for active statements +in the background. By default the number of such connections is limited to 25, +on both the client side and the server side. + +This is a bit too low for a complex L application, so on connection +the client side setting is set to C<256> (see L.) You +can override it to whatever setting you like in the DSN. + +See +L +for information on changing the setting on the server side. =head1 DATES See L to setup date formats for L. -=head1 IMAGE COLUMNS +=head1 TEXT/IMAGE COLUMNS + +L compiled with FreeTDS will B allow you to insert or update +C columns. + +Setting C<< $dbh->{LongReadLen} >> will also not work with FreeTDS use either: + + $schema->storage->dbh->do("SET TEXTSIZE $bytes"); + +or + + $schema->storage->set_textsize($bytes); + +instead. + +However, the C you pass in +L is used to execute the equivalent +C command on connection. See L for a L setting you need to work with C columns. -=head1 AUTHORS +=head1 BULK API + +The experimental L Bulk API support is used for +L in B context, in a transaction +on a separate connection. + +To use this feature effectively, use a large number of rows for each +L call, eg.: + + while (my $rows = $data_source->get_100_rows()) { + $rs->populate($rows); + } + +B the L +calls in your C classes B list columns in database order for this +to work. Also, you may have to unset the C environment variable before +loading your app, if it doesn't match the character set of your database. + +When inserting IMAGE columns using this method, you'll need to use +L as well. + +=head1 TODO + +=over + +=item * + +Transitions to AutoCommit=0 (starting a transaction) mode by exhausting +any active cursors, using eager cursors. + +=item * + +Real limits and limited counts using stored procedures deployed on startup. + +=item * + +Adaptive Server Anywhere (ASA) support, with possible SQLA::Limit support. + +=item * + +Blob update with a LIKE query on a blob, without invalidating the WHERE condition. + +=item * + +bulk_insert using prepare_cached (see comments.) + +=back + +=head1 AUTHOR See L.