MDEV-30143 Segfault on select query using index for group-by and filesort
The problem was trying to access JOIN_TAB::select which is set to NULL when using the filesort. The correct way is accessing either JOIN_TAB::select or JOIN_TAB::filesort->select depending on whether the filesort is used. This commit introduces member function JOIN_TAB::get_sql_select() encapsulating that check so the code duplication is eliminated. The new condition (s->table->quick_keys.is_set(best_key->key)) was added to best_access_path() to eliminate a Valgrind error. The cause of that error was using TRASH_ALLOC(quick_key_parts) instead of bzero(quick_key_parts); hence, accessing s->table->quick_key_parts[best_key->key]) without prior checking for quick_keys.is_set() might have caused reading "dirty" memory
Showing
Please register or sign in to comment