From: <mjd...@us...> - 2009-07-01 20:56:34
|
Revision: 154 http://treebase.svn.sourceforge.net/treebase/?rev=154&view=rev Author: mjdominus Date: 2009-07-01 20:56:13 +0000 (Wed, 01 Jul 2009) Log Message: ----------- when table is empty, write a comment instead of an empty file Modified Paths: -------------- trunk/treebase-core/src/main/perl/dump/sqldump trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm Modified: trunk/treebase-core/src/main/perl/dump/sqldump =================================================================== --- trunk/treebase-core/src/main/perl/dump/sqldump 2009-06-28 11:56:30 UTC (rev 153) +++ trunk/treebase-core/src/main/perl/dump/sqldump 2009-07-01 20:56:13 UTC (rev 154) @@ -164,6 +164,7 @@ $sth->execute(); my $row; + my $rows_printed = 0; # if --progress is provided, print out progress counter if ($with_progress_meter) { @@ -177,7 +178,7 @@ my $percent = int(0.5 + $count / $total_records * 100); print STDERR "\r$percent%" if $percent ne $old_percent; $old_percent = $percent; - last if defined($nrecs) && (--$nrecs == 0); + last if defined($nrecs) && ++$rows_printed >= $nrecs; } } @@ -185,10 +186,14 @@ else { while ( $row = $sth->fetchrow_arrayref ) { $dumper->rec(@$row); - last if defined($nrecs) && (--$nrecs == 0); + last if defined($nrecs) && ++$rows_printed >= $nrecs; } } + if ($rows_printed == 0) { + $dumper->print("-- empty table\n"); + } + # finish the statement handler $sth->finish(); Modified: trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm =================================================================== --- trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm 2009-06-28 11:56:30 UTC (rev 153) +++ trunk/treebase-core/src/main/perl/lib/CIPRES/TreeBase/RecDumper.pm 2009-07-01 20:56:13 UTC (rev 154) @@ -33,6 +33,12 @@ return; } +# Print some text literally +sub print { + my $self = shift; + return print {$self->{'OUT'}} @_; +} + # Format data into an insert statement and return (or write) the result sub rec { my $self = shift; @@ -56,7 +62,6 @@ return $create; } -# XXX UNFINISHED !!!! sub quote_data { my $self = shift; my @d = @_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |