• Sergei Golubchik's avatar
    MDEV-11605 Assertion `(longlong) thd->status_var.local_memory_used >= 0 ||... · 92aafebd
    Sergei Golubchik authored
    MDEV-11605 Assertion `(longlong) thd->status_var.local_memory_used >= 0 || !debug_assert_on_not_freed_memory' failed in my_malloc_size_cb_func
    
    MyISAM in compute_vcols() - which is used only in mi_check code -
    was computing indexed vcols into an internally allocated buffer
    (not record[0]) and the buffer was calculated to be long enough to fit
    every keyseg (a keyseg knows where its value in a record buffer is
    and the length of the value).
    
    This logic didn' work for prefix keys, because the keyseg length is the
    length of a prefix, but the record buffer needs to fit the complete
    value of a vcol. In this bug MyISAM was writing a 2K varchar
    into a buffer too short.
    
    Also it didn't work for repair-with-keycache, because that code
    recalculats all vcols, not only indexed ones.
    
    So, the buffer size (MYISAM_SHARE::vreclength) should include all
    vcols' full lengths. But it was calculated in mi_open and low-level
    MyISAM code has no knowledge of vcols.
    
    As a fix we now recalculate MYISAM_SHARE::vreclength in
    ha_myisam::setup_vcols_for_repair() which is always called
    before compute_vcols().
    92aafebd
myisam_repair_prefix_varchar.test 13.2 KB