From: Ken Youens-Clark Date: Thu, 16 Feb 2006 14:59:19 +0000 (+0000) Subject: Changes to make more efficient use of memory with large tables. X-Git-Tag: v0.11008~469 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ea378e7694925d212b06651c666682dbb42fbaea;p=dbsrgits%2FSQL-Translator.git Changes to make more efficient use of memory with large tables. --- diff --git a/lib/SQL/Translator/Producer/Dumper.pm b/lib/SQL/Translator/Producer/Dumper.pm index 27f27ba..fe8f962 100644 --- a/lib/SQL/Translator/Producer/Dumper.pm +++ b/lib/SQL/Translator/Producer/Dumper.pm @@ -1,9 +1,9 @@ package SQL::Translator::Producer::Dumper; # ------------------------------------------------------------------- -# $Id: Dumper.pm,v 1.8 2004-07-23 15:38:20 kycl4rk Exp $ +# $Id: Dumper.pm,v 1.9 2006-02-16 14:59:19 kycl4rk Exp $ # ------------------------------------------------------------------- -# Copyright (C) 2002-4 SQLFairy Authors +# Copyright (C) 2002-6 SQLFairy Authors # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -61,7 +61,7 @@ use vars qw($VERSION); use Data::Dumper; -$VERSION = sprintf "%d.%02d", q$Revision: 1.8 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.9 $ =~ /(\d+)\.(\d+)/; sub produce { my $t = shift; @@ -243,12 +243,13 @@ for my $table ( @tables ) { print "TRUNCATE TABLE $table_name;\n"; } - my $data = $db->selectall_arrayref( - 'select ' . join(', ', @{ $table->{'fields'} } ) . " from $table_name", - { Columns => {} } - ); + my $sql = + 'select ' . join(', ', @{ $table->{'fields'} } ) . " from $table_name" + ; + my $sth = $db->prepare( $sql ); + $sth->execute; - for my $rec ( @{ $data } ) { + while ( my $rec = $sth->fetchrow_hashref ) { my @vals; for my $fld ( @{ $table->{'fields'} } ) { my $val = $rec->{ $fld }; @@ -300,6 +301,6 @@ EOF =head1 AUTHOR -Ken Y. Clark Ekclark@cpan.orgE. +Ken Youens-Clark Ekclark@cpan.orgE. =cut