diff options
author | unknown <kostja@vajra.(none)> | 2007-04-06 02:57:38 +0400 |
---|---|---|
committer | unknown <kostja@vajra.(none)> | 2007-04-06 02:57:38 +0400 |
commit | 93e7a470826e62f2a851d2db435e9f9361b2fb01 (patch) | |
tree | aafe12e7f62f71bc0ed597a907db7de0efd62093 | |
parent | a06ff97656cf8882cd87f23b206a92646be4fa0e (diff) | |
download | mariadb-git-93e7a470826e62f2a851d2db435e9f9361b2fb01.tar.gz |
Fix events.test failure on manu pushbuild hosts (5.1-runtime).
sql/event_db_repository.cc:
Fix events.test failure on many pushbuild hosts (5.1-runtime).
Make sure that when reading mysql.event the key number matches
the field number that we're using to read by key.
Also, print an error in case of a handler error (to not return
'Unknown error' when a table is corrupted to the user).
-rw-r--r-- | sql/event_db_repository.cc | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index fcd48757957..e3b45d5e0b2 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -310,38 +310,52 @@ Event_db_repository::index_read_for_db_for_i_s(THD *thd, TABLE *schema_table, DBUG_PRINT("info", ("Using prefix scanning on PK")); event_table->file->ha_index_init(0, 1); - event_table->field[ET_FIELD_DB]->store(db, strlen(db), scs); key_info= event_table->key_info; + + if (key_info->key_parts == 0 || + key_info->key_part[0].field != event_table->field[ET_FIELD_DB]) + { + /* Corrupted table: no index or index on a wrong column */ + my_error(ER_CANNOT_LOAD_FROM_TABLE, MYF(0), "event"); + ret= 1; + goto end; + } + + event_table->field[ET_FIELD_DB]->store(db, strlen(db), scs); key_len= key_info->key_part[0].store_length; if (!(key_buf= (byte *)alloc_root(thd->mem_root, key_len))) { - ret= 1; /* Don't send error, it would be done by sql_alloc_error_handler() */ + ret= 1; + goto end; } - else + + key_copy(key_buf, event_table->record[0], key_info, key_len); + if (!(ret= event_table->file->index_read(event_table->record[0], key_buf, + (key_part_map)1, HA_READ_PREFIX))) { - key_copy(key_buf, event_table->record[0], key_info, key_len); - if (!(ret= event_table->file->index_read(event_table->record[0], key_buf, - (key_part_map)1, HA_READ_PREFIX))) + DBUG_PRINT("info",("Found rows. Let's retrieve them. ret=%d", ret)); + do { - DBUG_PRINT("info",("Found rows. Let's retrieve them. ret=%d", ret)); - do - { - ret= copy_event_to_schema_table(thd, schema_table, event_table); - if (ret == 0) - ret= event_table->file->index_next_same(event_table->record[0], - key_buf, key_len); - } while (ret == 0); - } - DBUG_PRINT("info", ("Scan finished. ret=%d", ret)); + ret= copy_event_to_schema_table(thd, schema_table, event_table); + if (ret == 0) + ret= event_table->file->index_next_same(event_table->record[0], + key_buf, key_len); + } while (ret == 0); } - event_table->file->ha_index_end(); + DBUG_PRINT("info", ("Scan finished. ret=%d", ret)); + /* ret is guaranteed to be != 0 */ if (ret == HA_ERR_END_OF_FILE || ret == HA_ERR_KEY_NOT_FOUND) - DBUG_RETURN(FALSE); + ret= 0; + else + event_table->file->print_error(ret, MYF(0)); - DBUG_RETURN(TRUE); +end: + event_table->file->ha_index_end(); + + DBUG_RETURN(test(ret)); } |