diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/handler.cc | 5 | ||||
-rw-r--r-- | sql/handler.h | 1 | ||||
-rw-r--r-- | sql/sql_handler.cc | 17 |
3 files changed, 20 insertions, 3 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index 5bba6034a4d..2190ab1776c 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2724,7 +2724,10 @@ void handler::print_error(int error, myf errflag) textno=ER_DUP_UNIQUE; break; case HA_ERR_RECORD_CHANGED: - SET_FATAL_ERROR; + /* + This is not fatal error when using HANDLER interface + SET_FATAL_ERROR; + */ textno=ER_CHECKREAD; break; case HA_ERR_CRASHED: diff --git a/sql/handler.h b/sql/handler.h index 862da3d2ca7..52828d4f149 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1593,6 +1593,7 @@ public: { return(NULL);} /* gets tablespace name from handler */ /** used in ALTER TABLE; 1 if changing storage engine is allowed */ virtual bool can_switch_engines() { return 1; } + virtual int can_continue_handler_scan() { return 0; } /** used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */ virtual int get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) { return 0; } diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index bbc3d0b27a4..ccc6d2b57f0 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -548,6 +548,12 @@ retry: mode= RLAST; } } + else if (table->file->inited != handler::RND) + { + /* Convert RNEXT to RFIRST if we haven't started row scan */ + if (mode == RNEXT) + mode= RFIRST; + } if (insert_fields(thd, &thd->lex->select_lex.context, tables->db, tables->alias, &it, 0)) @@ -569,6 +575,8 @@ retry: case RNEXT: if (table->file->inited != handler::NONE) { + if ((error= table->file->can_continue_handler_scan())) + break; if (keyname) { /* Check if we read from the same index. */ @@ -603,6 +611,8 @@ retry: DBUG_ASSERT((uint) keyno == table->file->get_index()); if (table->file->inited != handler::NONE) { + if ((error= table->file->can_continue_handler_scan())) + break; error=table->file->index_prev(table->record[0]); break; } @@ -673,8 +683,11 @@ retry: continue; if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) { - sql_print_error("mysql_ha_read: Got error %d when reading table '%s'", - error, tables->table_name); + /* Don't give error in the log file for some expected problems */ + if (error != HA_ERR_RECORD_CHANGED && error != HA_ERR_WRONG_COMMAND) + sql_print_error("mysql_ha_read: Got error %d when reading " + "table '%s'", + error, tables->table_name); table->file->print_error(error,MYF(0)); goto err; } |