• unknown's avatar
    Bug#26231 - select count(*) on myisam table returns wrong value · 396f84aa
    unknown authored
                when index is used
    
    When the table contained TEXT columns with empty contents
    ('', zero length, but not NULL) _and_ strings starting with
    control characters like tabulator or newline, the empty values
    were not found in a "records in range" estimate. Hence count(*)
    missed these records.
    
    The reason was a different set of search flags used for key
    insert and key range estimation.
    
    I decided to fix the set of flags used in range estimation.
    Otherwise millions of databases around the world would require
    a repair after an upgrade.
    
    The consequence is that the manual must be fixed, which claims
    that TEXT columns are compared with "end space padding". This
    is true for CHAR/VARCHAR but wrong for TEXT. See also bug 21335.
    
    
    myisam/mi_range.c:
      Bug#26231 - select count(*) on myisam table returns wrong value
                  when index is used
      Added SEARCH_UPDATE to the search flags so that it compares
      like write/update/delete operations do. Only so it expects
      the keys at the place where they have been inserted.
    myisam/mi_search.c:
      Bug#26231 - select count(*) on myisam table returns wrong value
                  when index is used
      Added some comments to explain how _mi_get_binary_pack_key()
      works.
    mysql-test/r/myisam.result:
      Bug#26231 - select count(*) on myisam table returns wrong value
                  when index is used
      Added a test.
    mysql-test/t/myisam.test:
      Bug#26231 - select count(*) on myisam table returns wrong value
                  when index is used
      Added test result.
    396f84aa
mi_range.c 9.49 KB