Create NibbleIterator. Cleanup TableNibbler. Fix bug in SchemaIterator.

This commit is contained in:
Daniel Nichter
2011-09-09 11:50:19 -06:00
parent 43aebffad1
commit 7fde36a65b
5 changed files with 439 additions and 8 deletions

View File

@@ -65,28 +65,26 @@ sub generate_asc_stmt {
die "I need a $arg argument" unless defined $args{$arg};
}
my ($tbl_struct, $index) = @args{@required_args};
my @cols = $args{cols} ? @{$args{cols}} : @{$tbl_struct->{cols}};
my @cols = $args{cols} ? @{$args{cols}} : @{$tbl_struct->{cols}};
my $q = $self->{Quoter};
# This shouldn't happen. TableSyncNibble shouldn't call us with
# a nonexistent index.
die "Index '$index' does not exist in table"
unless exists $tbl_struct->{keys}->{$index};
my @asc_cols = @{$tbl_struct->{keys}->{$index}->{cols}};
my @asc_slice;
MKDEBUG && _d('Will ascend index', $index);
# These are the columns we'll ascend.
@asc_cols = @{$tbl_struct->{keys}->{$index}->{cols}};
MKDEBUG && _d('Will ascend index', $index);
MKDEBUG && _d('Will ascend columns', join(', ', @asc_cols));
my @asc_cols = @{$tbl_struct->{keys}->{$index}->{cols}};
if ( $args{asc_first} ) {
@asc_cols = $asc_cols[0];
MKDEBUG && _d('Ascending only first column');
}
MKDEBUG && _d('Will ascend columns', join(', ', @asc_cols));
# We found the columns by name, now find their positions for use as
# array slices, and make sure they are included in the SELECT list.
my @asc_slice;
my %col_posn = do { my $i = 0; map { $_ => $i++ } @cols };
foreach my $col ( @asc_cols ) {
if ( !exists $col_posn{$col} ) {