• Sergei Petrunia's avatar
    MDEV-27529 Wrong result upon query using index_merge with DESC key (#2) · fca37e49
    Sergei Petrunia authored
    ROR-index_merge relies on Rowid-ordered-retrieval property: a ROR scan,
    e.g. a scan on equality range
    
      tbl.key=const
    
    should return rows ordered by their Rowid. Also, handler->cmp_ref() should
    compare rowids according to the Rowid ordering.
    
    When the table's primary key uses DESC keyparts, ROR scans return rows
    according to the PK's ordering.
    
    But ha_innobase::cmp_ref() compared rowids as if PK used ASC keyparts.
    This caused wrong query results with index_merge.
    
    Fixed this by making ha_innobase::cmp_ref() compare according to the PK
    defintion, including keypart's DESC property.
    fca37e49
ha_innodb.cc 605 KB