• Martin Hansson's avatar
    Bug#53859: Valgrind: opt_sum_query(TABLE_LIST*, List<Item>&, · 5bace3f0
    Martin Hansson authored
    Item*) at opt_sum.cc:305
          
    Queries applying MIN/MAX functions to indexed columns are
    optimized to read directly from the index if all key parts
    of the index preceding the aggregated key part are bound to
    constants by the WHERE clause. A prefix length is also
    produced, equal to the total length of the bound key
    parts. If the aggregated column itself is bound to a
    constant, however, it is also included in the prefix.
    
    Such full search keys are read as closed intervals for
    reasons beyond the scope of this bug. However, the procedure
    missed one case where a key part meant for use as range
    endpoint was being overwritten with a NULL value destined
    for equality checking. In this case the key part was
    overwritten but the range flag remained, causing open
    interval reading to be performed.
    
    Bug was fixed by adding more stringent checking to the
    search key building procedure (matching_cond) and never
    allow overwrites of range predicates with non-range
    predicates.
    
    An assertion was added to make sure open intervals are never
    used with full search keys.
    5bace3f0
opt_sum.cc 32.8 KB