1 package DBIx::Class::Storage::DBI::Sybase;
7 DBIx::Class::Storage::DBI::Sybase::Common
8 DBIx::Class::Storage::DBI::AutoCast
11 use Carp::Clan qw/^DBIx::Class/;
15 __PACKAGE__->mk_group_accessors('simple' =>
16 qw/_identity _blob_log_on_update _writer_storage _is_extra_storage
17 _bulk_storage _is_bulk_storage _began_bulk_work
18 _bulk_disabled_due_to_coderef_connect_info_warned
22 my @also_proxy_to_extra_storages = qw/
23 disconnect _connect_info _sql_maker _sql_maker_opts disable_sth_caching
24 auto_savepoint unsafe cursor_class debug debugobj schema
29 DBIx::Class::Storage::DBI::Sybase - Sybase support for DBIx::Class
33 This subclass supports L<DBD::Sybase> for real Sybase databases. If you are
34 using an MSSQL database via L<DBD::Sybase>, your storage will be reblessed to
35 L<DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server>.
39 If your version of Sybase does not support placeholders, then your storage
40 will be reblessed to L<DBIx::Class::Storage::DBI::Sybase::NoBindVars>. You can
41 also enable that driver explicitly, see the documentation for more details.
43 With this driver there is unfortunately no way to get the C<last_insert_id>
44 without doing a C<SELECT MAX(col)>. This is done safely in a transaction
45 (locking the table.) See L</INSERTS WITH PLACEHOLDERS>.
47 A recommended L<DBIx::Class::Storage::DBI/connect_info> setting:
49 on_connect_call => [['datetime_setup'], ['blob_setup', log_on_update => 0]]
58 if (ref($self) eq 'DBIx::Class::Storage::DBI::Sybase') {
60 @{$self->_get_dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2]
65 my $subclass = "DBIx::Class::Storage::DBI::Sybase::${dbtype}";
67 if (!$exception && $dbtype && $self->load_optional_class($subclass)) {
68 bless $self, $subclass;
70 } else { # real Sybase
71 my $no_bind_vars = 'DBIx::Class::Storage::DBI::Sybase::NoBindVars';
73 if ($self->using_freetds) {
74 carp <<'EOF' unless $ENV{DBIC_SYBASE_FREETDS_NOWARN};
76 You are using FreeTDS with Sybase.
78 We will do our best to support this configuration, but please consider this
81 TEXT/IMAGE columns will definitely not work.
83 You are encouraged to recompile DBD::Sybase with the Sybase Open Client libraries
86 See perldoc DBIx::Class::Storage::DBI::Sybase for more details.
88 To turn off this warning set the DBIC_SYBASE_FREETDS_NOWARN environment
91 if (not $self->_typeless_placeholders_supported) {
92 if ($self->_placeholders_supported) {
95 $self->ensure_class_loaded($no_bind_vars);
96 bless $self, $no_bind_vars;
101 elsif (not $self->_get_dbh->{syb_dynamic_supported}) {
102 # not necessarily FreeTDS, but no placeholders nevertheless
103 $self->ensure_class_loaded($no_bind_vars);
104 bless $self, $no_bind_vars;
106 } elsif (not $self->_typeless_placeholders_supported) {
107 # this is highly unlikely, but we check just in case
116 $self->_set_max_connect(256);
118 # based on LongReadLen in connect_info
119 $self->set_textsize if $self->using_freetds;
121 # create storage for insert/(update blob) transactions,
122 # unless this is that storage
123 return if $self->_is_extra_storage;
125 my $writer_storage = (ref $self)->new;
127 $writer_storage->_is_extra_storage(1);
128 $writer_storage->connect_info($self->connect_info);
130 $self->_writer_storage($writer_storage);
132 # create a bulk storage unless connect_info is a coderef
134 if (Scalar::Util::reftype($self->_dbi_connect_info->[0])||'') eq 'CODE';
136 my $bulk_storage = (ref $self)->new;
138 $bulk_storage->_is_extra_storage(1);
139 $bulk_storage->_is_bulk_storage(1); # for special ->disconnect acrobatics
140 $bulk_storage->connect_info($self->connect_info);
143 $bulk_storage->_dbi_connect_info->[0] .= ';bulkLogin=1';
145 $self->_bulk_storage($bulk_storage);
148 for my $method (@also_proxy_to_extra_storages) {
150 no warnings 'redefine';
152 my $replaced = __PACKAGE__->can($method);
154 *{$method} = Sub::Name::subname $method => sub {
156 $self->_writer_storage->$replaced(@_) if $self->_writer_storage;
157 $self->_bulk_storage->$replaced(@_) if $self->_bulk_storage;
158 return $self->$replaced(@_);
165 # Even though we call $sth->finish for uses off the bulk API, there's still an
166 # "active statement" warning on disconnect, which we throw away here.
167 # This is due to the bug described in insert_bulk.
168 # Currently a noop because 'prepare' is used instead of 'prepare_cached'.
169 local $SIG{__WARN__} = sub {
170 warn $_[0] unless $_[0] =~ /active statement/i;
171 } if $self->_is_bulk_storage;
173 # so that next transaction gets a dbh
174 $self->_began_bulk_work(0) if $self->_is_bulk_storage;
179 # Make sure we have CHAINED mode turned on if AutoCommit is off in non-FreeTDS
180 # DBD::Sybase (since we don't know how DBD::Sybase was compiled.) If however
181 # we're using FreeTDS, CHAINED mode turns on an implicit transaction which we
182 # only want when AutoCommit is off.
186 $self->next::method(@_);
188 if ($self->_is_bulk_storage) {
189 # this should be cleared on every reconnect
190 $self->_began_bulk_work(0);
194 if (not $self->using_freetds) {
195 $self->_dbh->{syb_chained_txn} = 1;
197 if ($self->_dbh_autocommit) {
198 $self->_dbh->do('SET CHAINED OFF');
200 $self->_dbh->do('SET CHAINED ON');
205 =head2 connect_call_blob_setup
209 on_connect_call => [ [ 'blob_setup', log_on_update => 0 ] ]
211 Does C<< $dbh->{syb_binary_images} = 1; >> to return C<IMAGE> data as raw binary
212 instead of as a hex string.
216 Also sets the C<log_on_update> value for blob write operations. The default is
217 C<1>, but C<0> is better if your database is configured for it.
220 L<DBD::Sybase/Handling_IMAGE/TEXT_data_with_syb_ct_get_data()/syb_ct_send_data()>.
224 sub connect_call_blob_setup {
227 my $dbh = $self->_dbh;
228 $dbh->{syb_binary_images} = 1;
230 $self->_blob_log_on_update($args{log_on_update})
231 if exists $args{log_on_update};
237 $type && $type =~ /(?:text|image|lob|bytea|binary|memo)/i;
240 sub _prep_for_execute {
242 my ($op, $extra_bind, $ident, $args) = @_;
244 my ($sql, $bind) = $self->next::method (@_);
246 if ($op eq 'insert') {
247 my $table = $ident->from;
249 my $bind_info = $self->_resolve_column_info(
250 $ident, [map $_->[0], @{$bind}]
252 my $identity_col = List::Util::first
253 { $bind_info->{$_}{is_auto_increment} }
259 "SET IDENTITY_INSERT $table ON",
261 "SET IDENTITY_INSERT $table OFF",
265 $identity_col = List::Util::first
266 { $ident->column_info($_)->{is_auto_increment} }
274 $self->_fetch_identity_sql($ident, $identity_col);
278 return ($sql, $bind);
281 # Stolen from SQLT, with some modifications. This is a makeshift
282 # solution before a sane type-mapping library is available, thus
283 # the 'our' for easy overrides.
284 our %TYPE_MAPPING = (
287 varchar => 'varchar',
288 varchar2 => 'varchar',
289 timestamp => 'datetime',
291 real => 'double precision',
294 tinyint => 'smallint',
295 float => 'double precision',
297 bigserial => 'numeric',
298 boolean => 'varchar',
302 sub _native_data_type {
303 my ($self, $type) = @_;
306 $type =~ s/\s* identity//x;
308 return uc($TYPE_MAPPING{$type} || $type);
311 sub _fetch_identity_sql {
312 my ($self, $source, $col) = @_;
314 return sprintf ("SELECT MAX(%s) FROM %s",
315 map { $self->sql_maker->_quote ($_) } ($col, $source->from)
323 my ($rv, $sth, @bind) = $self->dbh_do($self->can('_dbh_execute'), @_);
325 if ($op eq 'insert') {
326 $self->_identity($sth->fetchrow_array);
330 return wantarray ? ($rv, $sth, @bind) : $rv;
333 sub last_insert_id { shift->_identity }
335 # handles TEXT/IMAGE and transaction for last_insert_id
338 my ($source, $to_insert) = @_;
340 my $blob_cols = $self->_remove_blob_cols($source, $to_insert);
342 my $identity_col = List::Util::first
343 { $source->column_info($_)->{is_auto_increment} }
346 # do we need the horrific SELECT MAX(COL) hack?
347 my $dumb_last_insert_id =
349 && (not exists $to_insert->{$identity_col})
350 && ($self->_identity_method||'') ne '@@IDENTITY';
352 my $next = $self->next::can;
354 # we are already in a transaction, or there are no blobs
355 # and we don't need the PK - just (try to) do it
356 if ($self->{transaction_depth}
357 || (!$blob_cols && !$dumb_last_insert_id)
359 return $self->_insert (
360 $next, $source, $to_insert, $blob_cols, $identity_col
364 # otherwise use the _writer_storage to do the insert+transaction on another
366 my $guard = $self->_writer_storage->txn_scope_guard;
368 my $updated_cols = $self->_writer_storage->_insert (
369 $next, $source, $to_insert, $blob_cols, $identity_col
372 $self->_identity($self->_writer_storage->_identity);
376 return $updated_cols;
380 my ($self, $next, $source, $to_insert, $blob_cols, $identity_col) = @_;
382 my $updated_cols = $self->$next ($source, $to_insert);
385 $identity_col => $self->last_insert_id($source, $identity_col),
390 $self->_insert_blobs ($source, $blob_cols, $final_row) if $blob_cols;
392 return $updated_cols;
397 my ($source, $fields, $where) = @_;
399 my $wantarray = wantarray;
400 my $blob_cols = $self->_remove_blob_cols($source, $fields);
402 if (not $blob_cols) {
403 return $self->next::method(@_);
406 # update+blob update(s) done atomically on separate connection
407 $self = $self->_writer_storage;
409 my $guard = $self->txn_scope_guard;
413 @res = $self->next::method(@_);
415 elsif (defined $wantarray) {
416 $res[0] = $self->next::method(@_);
419 $self->next::method(@_);
422 $self->_update_blobs($source, $blob_cols, $where);
426 return $wantarray ? @res : $res[0];
429 ### the insert_bulk partially stolen from DBI/MSSQL.pm
431 sub _set_identity_insert {
432 my ($self, $table) = @_;
435 'SET IDENTITY_INSERT %s ON',
436 $self->sql_maker->_quote ($table),
439 my $dbh = $self->_get_dbh;
440 eval { $dbh->do ($sql) };
442 $self->throw_exception (sprintf "Error executing '%s': %s",
449 sub _unset_identity_insert {
450 my ($self, $table) = @_;
453 'SET IDENTITY_INSERT %s OFF',
454 $self->sql_maker->_quote ($table),
457 my $dbh = $self->_get_dbh;
461 ## XXX add blob support
464 my ($source, $cols, $data) = @_;
466 my $is_identity_insert = (List::Util::first
467 { $source->column_info ($_)->{is_auto_increment} } @{$cols}
470 my @source_columns = $source->columns;
473 $self->_bulk_storage &&
474 $self->_get_dbh->{syb_has_blk};
476 if ((not $use_bulk_api) &&
477 (Scalar::Util::reftype($self->_dbi_connect_info->[0])||'') eq 'CODE' &&
478 (not $self->_bulk_disabled_due_to_coderef_connect_info_warned)) {
480 Bulk API support disabled due to use of a CODEREF connect_info. Reverting to
483 $self->_bulk_disabled_due_to_coderef_connect_info_warned(1);
486 if (not $use_bulk_api) {
487 if ($is_identity_insert) {
488 $self->_set_identity_insert ($source->name);
491 $self->next::method(@_);
493 if ($is_identity_insert) {
494 $self->_unset_identity_insert ($source->name);
500 # otherwise, use the bulk API
502 # rearrange @$data so that columns are in database order
504 @orig_idx{@$cols} = 0..$#$cols;
507 @new_idx{@source_columns} = 0..$#source_columns;
510 for my $datum (@$data) {
512 for my $col (@source_columns) {
513 # identity data will be 'undef' if not $is_identity_insert
514 # columns with defaults will also be 'undef'
515 $new_datum->[ $new_idx{$col} ] =
516 exists $orig_idx{$col} ? $datum->[ $orig_idx{$col} ] : undef;
518 push @new_data, $new_datum;
521 my $identity_col = List::Util::first
522 { $source->column_info($_)->{is_auto_increment} } @source_columns;
524 # bcp identity index is 1-based
525 my $identity_idx = exists $new_idx{$identity_col} ?
526 $new_idx{$identity_col} + 1 : 0;
528 ## Set a client-side conversion error handler, straight from DBD::Sybase docs.
529 # This ignores any data conversion errors detected by the client side libs, as
530 # they are usually harmless.
531 my $orig_cslib_cb = DBD::Sybase::set_cslib_cb(
532 Sub::Name::subname insert_bulk => sub {
533 my ($layer, $origin, $severity, $errno, $errmsg, $osmsg, $blkmsg) = @_;
535 return 1 if $errno == 36;
538 "Layer: $layer, Origin: $origin, Severity: $severity, Error: $errno" .
539 ($errmsg ? "\n$errmsg" : '') .
540 ($osmsg ? "\n$osmsg" : '') .
541 ($blkmsg ? "\n$blkmsg" : '');
547 my $bulk = $self->_bulk_storage;
549 my $guard = $bulk->txn_scope_guard;
551 ## XXX get this to work instead of our own $sth
552 ## will require SQLA or *Hacks changes for ordered columns
553 # $bulk->next::method($source, \@source_columns, \@new_data, {
554 # syb_bcp_attribs => {
555 # identity_flag => $is_identity_insert,
556 # identity_column => $identity_idx,
559 my $sql = 'INSERT INTO ' .
560 $bulk->sql_maker->_quote($source->name) . ' (' .
561 # colname list is ignored for BCP, but does no harm
562 (join ', ', map $bulk->sql_maker->_quote($_), @source_columns) . ') '.
563 ' VALUES ('. (join ', ', ('?') x @source_columns) . ')';
565 ## XXX there's a bug in the DBD::Sybase bulk support that makes $sth->finish for
566 ## a prepare_cached statement ineffective. Replace with ->sth when fixed, or
567 ## better yet the version above. Should be fixed in DBD::Sybase .
568 my $sth = $bulk->_get_dbh->prepare($sql,
572 identity_flag => $is_identity_insert,
573 identity_column => $identity_idx,
578 $bulk->_query_start($sql);
580 for my $datum (@new_data) {
581 $sth->execute(@$datum);
582 die $sth->errstr if $sth->errstr; # just in case
588 $bulk->_query_end($sql);
591 if ($exception =~ /-Y option/) {
594 Sybase bulk API operation failed due to character set incompatibility, reverting
595 to regular array inserts:
597 *** Try unsetting the LANG environment variable.
601 $self->_bulk_storage(undef);
602 DBD::Sybase::set_cslib_cb($orig_cslib_cb);
607 DBD::Sybase::set_cslib_cb($orig_cslib_cb);
608 # rollback makes the bulkLogin connection unusable
609 $self->_bulk_storage->disconnect;
610 $self->throw_exception($exception) if $exception;
613 DBD::Sybase::set_cslib_cb($orig_cslib_cb);
616 sub _remove_blob_cols {
617 my ($self, $source, $fields) = @_;
621 for my $col (keys %$fields) {
622 if ($self->_is_lob_type($source->column_info($col)->{data_type})) {
623 $blob_cols{$col} = delete $fields->{$col};
624 $fields->{$col} = \"''";
628 return keys %blob_cols ? \%blob_cols : undef;
632 my ($self, $source, $blob_cols, $where) = @_;
634 my (@primary_cols) = $source->primary_columns;
636 croak "Cannot update TEXT/IMAGE column(s) without a primary key"
637 unless @primary_cols;
639 # check if we're updating a single row by PK
640 my $pk_cols_in_where = 0;
641 for my $col (@primary_cols) {
642 $pk_cols_in_where++ if defined $where->{$col};
646 if ($pk_cols_in_where == @primary_cols) {
648 @row_to_update{@primary_cols} = @{$where}{@primary_cols};
649 @rows = \%row_to_update;
651 my $cursor = $self->select ($source, \@primary_cols, $where, {});
653 my %row; @row{@primary_cols} = @$_; \%row
657 for my $row (@rows) {
658 $self->_insert_blobs($source, $blob_cols, $row);
663 my ($self, $source, $blob_cols, $row) = @_;
664 my $dbh = $self->_get_dbh;
666 my $table = $source->from;
669 my (@primary_cols) = $source->primary_columns;
671 croak "Cannot update TEXT/IMAGE column(s) without a primary key"
672 unless @primary_cols;
674 if ((grep { defined $row{$_} } @primary_cols) != @primary_cols) {
675 croak "Cannot update TEXT/IMAGE column(s) without primary key values";
678 for my $col (keys %$blob_cols) {
679 my $blob = $blob_cols->{$col};
681 my %where = map { ($_, $row{$_}) } @primary_cols;
683 my $cursor = $self->select ($source, [$col], \%where, {});
685 my $sth = $cursor->sth;
689 $sth->func('CS_GET', 1, 'ct_data_info') or die $sth->errstr;
692 $sth->func('ct_prepare_send') or die $sth->errstr;
694 my $log_on_update = $self->_blob_log_on_update;
695 $log_on_update = 1 if not defined $log_on_update;
697 $sth->func('CS_SET', 1, {
698 total_txtlen => length($blob),
699 log_on_update => $log_on_update
700 }, 'ct_data_info') or die $sth->errstr;
702 $sth->func($blob, length($blob), 'ct_send_data') or die $sth->errstr;
704 $sth->func('ct_finish_send') or die $sth->errstr;
707 $sth->finish if $sth;
709 if ($self->using_freetds) {
711 'TEXT/IMAGE operation failed, probably because you are using FreeTDS: '
721 =head2 connect_call_datetime_setup
725 on_connect_call => 'datetime_setup'
727 In L<DBIx::Class::Storage::DBI/connect_info> to set:
729 $dbh->syb_date_fmt('ISO_strict'); # output fmt: 2004-08-21T14:36:48.080Z
730 $dbh->do('set dateformat mdy'); # input fmt: 08/13/1979 18:08:55.080
732 On connection for use with L<DBIx::Class::InflateColumn::DateTime>, using
733 L<DateTime::Format::Sybase>, which you will need to install.
735 This works for both C<DATETIME> and C<SMALLDATETIME> columns, although
736 C<SMALLDATETIME> columns only have minute precision.
741 my $old_dbd_warned = 0;
743 sub connect_call_datetime_setup {
745 my $dbh = $self->_dbh;
747 if ($dbh->can('syb_date_fmt')) {
748 # amazingly, this works with FreeTDS
749 $dbh->syb_date_fmt('ISO_strict');
750 } elsif (not $old_dbd_warned) {
751 carp "Your DBD::Sybase is too old to support ".
752 "DBIx::Class::InflateColumn::DateTime, please upgrade!";
756 $dbh->do('SET DATEFORMAT mdy');
762 sub datetime_parser_type { "DateTime::Format::Sybase" }
764 # ->begin_work and such have no effect with FreeTDS but we run them anyway to
765 # let the DBD keep any state it needs to.
767 # If they ever do start working, the extra statements will do no harm (because
768 # Sybase supports nested transactions.)
770 sub _dbh_begin_work {
773 # bulkLogin=1 connections are always in a transaction, and can only call BEGIN
774 # TRAN once. However, we need to make sure there's a $dbh.
775 return if $self->_is_bulk_storage && $self->_dbh && $self->_began_bulk_work;
777 $self->next::method(@_);
779 if ($self->using_freetds) {
780 $self->_get_dbh->do('BEGIN TRAN');
783 $self->_began_bulk_work(1) if $self->_is_bulk_storage;
788 if ($self->using_freetds) {
789 $self->_dbh->do('COMMIT');
791 return $self->next::method(@_);
796 if ($self->using_freetds) {
797 $self->_dbh->do('ROLLBACK');
799 return $self->next::method(@_);
802 # savepoint support using ASE syntax
805 my ($self, $name) = @_;
807 $self->_get_dbh->do("SAVE TRANSACTION $name");
810 # A new SAVE TRANSACTION with the same name releases the previous one.
811 sub _svp_release { 1 }
814 my ($self, $name) = @_;
816 $self->_get_dbh->do("ROLLBACK TRANSACTION $name");
821 =head1 Schema::Loader Support
823 There is an experimental branch of L<DBIx::Class::Schema::Loader> that will
824 allow you to dump a schema from most (if not all) versions of Sybase.
826 It is available via subversion from:
828 http://dev.catalyst.perl.org/repos/bast/branches/DBIx-Class-Schema-Loader/current/
832 This driver supports L<DBD::Sybase> compiled against FreeTDS
833 (L<http://www.freetds.org/>) to the best of our ability, however it is
834 recommended that you recompile L<DBD::Sybase> against the Sybase Open Client
835 libraries. They are a part of the Sybase ASE distribution:
837 The Open Client FAQ is here:
838 L<http://www.isug.com/Sybase_FAQ/ASE/section7.html>.
840 Sybase ASE for Linux (which comes with the Open Client libraries) may be
841 downloaded here: L<http://response.sybase.com/forms/ASE_Linux_Download>.
843 To see if you're using FreeTDS check C<< $schema->storage->using_freetds >>, or run:
845 perl -MDBI -le 'my $dbh = DBI->connect($dsn, $user, $pass); print $dbh->{syb_oc_version}'
847 Some versions of the libraries involved will not support placeholders, in which
848 case the storage will be reblessed to
849 L<DBIx::Class::Storage::DBI::Sybase::NoBindVars>.
851 In some configurations, placeholders will work but will throw implicit type
852 conversion errors for anything that's not expecting a string. In such a case,
853 the C<auto_cast> option from L<DBIx::Class::Storage::DBI::AutoCast> is
854 automatically set, which you may enable on connection with
855 L<DBIx::Class::Storage::DBI::AutoCast/connect_call_set_auto_cast>. The type info
856 for the C<CAST>s is taken from the L<DBIx::Class::ResultSource/data_type>
857 definitions in your Result classes, and are mapped to a Sybase type (if it isn't
858 already) using a mapping based on L<SQL::Translator>.
860 In other configurations, placeholers will work just as they do with the Sybase
861 Open Client libraries.
863 Inserts or updates of TEXT/IMAGE columns will B<NOT> work with FreeTDS.
865 =head1 INSERTS WITH PLACEHOLDERS
867 With placeholders enabled, inserts are done in a transaction so that there are
868 no concurrency issues with getting the inserted identity value using
869 C<SELECT MAX(col)>, which is the only way to get the C<IDENTITY> value in this
872 In addition, they are done on a separate connection so that it's possible to
873 have active cursors when doing an insert.
875 When using C<DBIx::Class::Storage::DBI::Sybase::NoBindVars> transactions are
876 disabled, as there are no concurrency issues with C<SELECT @@IDENTITY> as it's a
881 Due to limitations of the TDS protocol, L<DBD::Sybase>, or both; you cannot
882 begin a transaction while there are active cursors. An active cursor is, for
883 example, a L<ResultSet|DBIx::Class::ResultSet> that has been executed using
884 C<next> or C<first> but has not been exhausted or
885 L<reset|DBIx::Class::ResultSet/reset>.
887 For example, this will not work:
889 $schema->txn_do(sub {
890 my $rs = $schema->resultset('Book');
891 while (my $row = $rs->next) {
892 $schema->resultset('MetaData')->create({
899 Transactions done for inserts in C<AutoCommit> mode when placeholders are in use
900 are not affected, as they are done on an extra database handle.
906 =item * use L<DBIx::Class::Storage::DBI::Replicated>
908 =item * L<connect|DBIx::Class::Schema/connect> another L<Schema|DBIx::Class::Schema>
910 =item * load the data from your cursor with L<DBIx::Class::ResultSet/all>
914 =head1 MAXIMUM CONNECTIONS
916 The TDS protocol makes separate connections to the server for active statements
917 in the background. By default the number of such connections is limited to 25,
918 on both the client side and the server side.
920 This is a bit too low for a complex L<DBIx::Class> application, so on connection
921 the client side setting is set to C<256> (see L<DBD::Sybase/maxConnect>.) You
922 can override it to whatever setting you like in the DSN.
925 L<http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.sag1/html/sag1/sag1272.htm>
926 for information on changing the setting on the server side.
930 See L</connect_call_datetime_setup> to setup date formats
931 for L<DBIx::Class::InflateColumn::DateTime>.
933 =head1 TEXT/IMAGE COLUMNS
935 L<DBD::Sybase> compiled with FreeTDS will B<NOT> allow you to insert or update
936 C<TEXT/IMAGE> columns.
938 Setting C<< $dbh->{LongReadLen} >> will also not work with FreeTDS use either:
940 $schema->storage->dbh->do("SET TEXTSIZE $bytes");
944 $schema->storage->set_textsize($bytes);
948 However, the C<LongReadLen> you pass in
949 L<DBIx::Class::Storage::DBI/connect_info> is used to execute the equivalent
950 C<SET TEXTSIZE> command on connection.
952 See L</connect_call_blob_setup> for a L<DBIx::Class::Storage::DBI/connect_info>
953 setting you need to work with C<IMAGE> columns.
957 The experimental L<DBD::Sybase> Bulk API support is used for
958 L<populate|DBIx::Class::ResultSet/populate> in B<void> context, in a transaction
959 on a separate connection.
961 To use this feature effectively, use a large number of rows for each
962 L<populate|DBIx::Class::ResultSet/populate> call, eg.:
964 while (my $rows = $data_source->get_100_rows()) {
965 $rs->populate($rows);
968 B<NOTE:> the L<add_columns|DBIx::Class::ResultSource/add_columns>
969 calls in your C<Result> classes B<must> list columns in database order for this
970 to work. Also, you may have to unset the C<LANG> environment variable before
971 loading your app, if it doesn't match the character set of your database.
975 See L<DBIx::Class/CONTRIBUTORS>.
979 You may distribute this code under the same terms as Perl itself.