Skip to content

Commit 353464b

Browse files
harinvadodariadahlerlend
authored andcommitted
Bug#31462844: ASSERTION `INITED == NONE || TABLE->OPEN_BY_HANDLER' FAILED.
Description: If an entry is deleted from mysql.user table using DELETE statement, subsequent SHOW CREATE USER for the same user would cause server to halt. SHOW CREATE USER opens mysql.user table to read user comment. It performs index scan on the table to find the matching user entry. Upon success, comment is retrieved and SE is notified about end of index scan operation by calling ha_index_end(). However, if an entry is deleted from mysql.user using DELETE and if FLUSH PRIVILEGES is not executed yet, index scan would fail. In that case, a call to ha_index_end() was missing. This later lead to assertion failure when all opened tables are being closed. Fix: Fixed the issue by adding missing ha_index_end() call. RB: 24616
1 parent 059ddfa commit 353464b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sql/auth/acl_table_user.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2397,9 +2397,11 @@ bool read_user_application_user_metadata_from_table(
23972397
key_copy(user_key, table->record[0], table->key_info,
23982398
table->key_info->key_length);
23992399
if (table->file->ha_index_read_idx_map(table->record[0], 0, user_key,
2400-
HA_WHOLE_KEY, HA_READ_KEY_EXACT))
2400+
HA_WHOLE_KEY, HA_READ_KEY_EXACT)) {
2401+
table->file->ha_index_end();
24012402
return false; // technically we fail, but result should be an empty out
24022403
// string
2404+
}
24032405
char *attributes_field =
24042406
get_field(&tmp_mem, table->field[MYSQL_USER_FIELD_USER_ATTRIBUTES]);
24052407
/*

0 commit comments

Comments
 (0)