diff options
Diffstat (limited to 'sql/sql_handler.cc')
-rw-r--r-- | sql/sql_handler.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 97703cd6b20..0d8af46dbf6 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -109,6 +109,10 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, if (cond && (cond->check_cols(1) || cond->fix_fields(thd, tables, &cond))) return -1; + /* InnoDB needs to know that this table handle is used in the HANDLER */ + + table->file->init_table_handle_for_HANDLER(); + if (keyname) { if ((keyno=find_type(keyname, &table->keynames, 1+2)-1)<0) @@ -131,8 +135,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, insert_fields(thd,tables,tables->db,tables->alias,&it); - table->file->init_table_handle_for_HANDLER(); // Only InnoDB requires it - select_limit+=offset_limit; protocol->send_fields(&list,1); @@ -142,6 +144,12 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, if (!lock) goto err0; // mysql_lock_tables() printed error message already + /* In ::external_lock InnoDB resets the fields which tell it that + the handle is used in the HANDLER interface. Tell it again that + we are using it for HANDLER. */ + + table->file->init_table_handle_for_HANDLER(); + for (num_rows=0; num_rows < select_limit; ) { switch (mode) { |