Added looper around to make sure that we don't overflow buffers.
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / mysql.pm
index 8dc49ad..db249f3 100644 (file)
@@ -11,6 +11,7 @@ use mro 'c3';
 
 __PACKAGE__->sql_maker_class('DBIx::Class::SQLMaker::MySQL');
 __PACKAGE__->sql_limit_dialect ('LimitXY');
+__PACKAGE__->sql_quote_char ('`');
 
 sub with_deferred_fk_checks {
   my ($self, $sub) = @_;
@@ -59,7 +60,7 @@ sub sql_maker {
     my $maker = $self->next::method (@_);
 
     # mysql 3 does not understand a bare JOIN
-    my $mysql_ver = $self->_get_dbh->get_info(18);
+    my $mysql_ver = $self->_dbh_get_info(18);
     $maker->{_default_jointype} = 'INNER' if $mysql_ver =~ /^3/;
   }
 
@@ -120,6 +121,26 @@ sub _subq_update_delete {
   return shift->_per_row_update_delete (@_);
 }
 
+my $INSERT_BULK_SIZE = 80;
+sub _insert_bulk {
+  my ($self, $source, $cols, $colvalues, $data) = @_;
+
+  my $bind_attrs = $self->source_bind_attributes($source);
+
+  # Organize this way to make context sensitivity easier to code up.
+  while ( @$data > $INSERT_BULK_SIZE ) {
+    my @this_data = splice @$data, 0, $INSERT_BULK_SIZE;
+    $self->_execute(
+      'insert_bulk' => [], $source, $bind_attrs, \@this_data, $cols,
+    );
+  }
+
+  # Don't put this in the while-loop above.
+  return $self->_execute(
+    'insert_bulk' => [], $source, $bind_attrs, $data, $cols,
+  );
+}
+
 1;
 
 =head1 NAME