At 2002-05-21 09:07:46 (-0700), Jeff Zucker wrote:
> Wolfgang Weisselberg wrote:
> >Looking at the code it seems that get_undeleted_record() returns
> >a row as string,
> Yes, exactly. I fixed that a while back in my development version but
> haven't released it publicly yet because of other changes that still
> need debugging.
> Thanks for the patch, my fix does something similar but with a few if
> statements thrown in :-).
Now I see why. With my patch, zpack (which wipes the deleted
records) is broken -- it uses the degenerate case of 'Text' as
write out method, which just combines all the fields. So the new
patch works around that.
BTW, I think zpack could be done better by copying the original
to .bak, generate a new DB .new (as done in zpack) and then
atomically rename .new to be the database. But currently I lack
the time for a patch for that. :-/
So here's the new, less broken patch.
--- AnyData.pm-old Tue May 21 15:42:46 2002
+++ AnyData.pm Wed May 22 19:15:16 2002
@@ -352,6 +352,7 @@
}
sub get_undeleted_record {
my $self = shift;
+ my $as_line = shift || 0;
my $rec;
my $found=0;
return $self->fetch_row if $self->parser_type eq 'XML';
@@ -363,7 +364,9 @@
and $rec =~ $self->{parser}->{skip_pattern};
last;
}
- return $rec;
+ return $rec if $as_line;
+ my @fields = $self->{parser}->read_fields($rec);
+ return \@fields;
}
sub update_single_row {
my $self = shift;
@@ -543,7 +546,7 @@
#$bak_fh->seek(0,0) || die $!;
# while (my $line = $self->get_record) {
# next if $self->is_deleted($line);
- while (my $line = $self->get_undeleted_record) {
+ while (my $line = $self->get_undeleted_record("as line")) {
my $tmpstr = $bak->{parser}->write_fields($line)
. $self->{parser}->{record_sep};
$bak_fh->write($tmpstr,length $tmpstr);
-Wolfgang