• Sergei Petrunia's avatar
    MDEV-33314: Crash in calculate_cond_selectivity_for_table() with many columns · 5972f5c2
    Sergei Petrunia authored
    Variant#3: moved the logic out of create_key_parts_for_pseudo_indexes
    
    Range Analyzer (get_mm_tree functions) can only process up to MAX_KEY=64
    indexes. The problem was that calculate_cond_selectivity_for_table used
    it to estimate selectivities for columns, and since a table can
    have > MAX_KEY columns, would invoke Range Analyzer with more than MAX_KEY
    "pseudo-indexes".
    
    Fixed by making calculate_cond_selectivity_for_table() to run Range
    Analyzer with at most MAX_KEY pseudo-indexes. If there are more
    columns to process, Range Analyzer will be invoked multiple times.
    
    Also made this change:
    -    param.real_keynr[0]= 0;
    +    MEM_UNDEFINED(&param.real_keynr, sizeof(param.real_keynr));
    
    Range Analyzer should have no use on real_keynr when it is run with
    pseudo-indexes.
    5972f5c2
selectivity_notembedded.test 5.52 KB