• marko's avatar
    branches/zip: Fix a critical bug in fast index creation that could · 4e0ad399
    marko authored
    corrupt the created indexes.
    
    row_merge(): Make "half" an in/out parameter. Determine the offset of
    half the output file. Copy the last blocks record-by-record instead of
    block-by-block, so that the records can be counted. Check that the
    input and output have matching n_rec.
    
    row_merge_sort(): Do not assume that two blocks of size N are merged
    into a block of size 2*N. The output block can be shorter than the
    input if the last page of each input block is almost empty. Use an
    accurate termination condition, based on the "half" computed by
    row_merge().
    
    row_merge_read(), row_merge_write(), row_merge_blocks(): Add debug output.
    
    merge_file_t, row_merge_file_create(): Add n_rec, the number of records
    in the merge file.
    
    row_merge_read_clustered_index(): Update n_rec.
    
    row_merge_blocks(): Update and check n_rec.
    
    row_merge_blocks_copy(): New function, for copying the last blocks in
    row_merge().  Update and check n_rec.
    
    This bug was discovered with a user-supplied test case that creates an
    index where the initial temporary file is 249 one-megabyte blocks and
    the merged files become smaller. In the test, possible merge record
    sizes are 10, 18, and 26 bytes.
    
    rb://150 approved by Sunny Bains.  This addresses Issue #320.
    4e0ad399
row0merge.c 65.8 KB