From 2b174c6da1dfab048d67a6788c5446d72dcd1572 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 13 Jan 2003 18:20:59 +0200 Subject: [PATCH] sql_handler.cc: Fix InnoDB HANDLER: InnoDB must know in each call that the handle is used by HANDLER; the previous implementation worked only by pure luck sql/sql_handler.cc: Fix InnoDB HANDLER: InnoDB must know in each call that the handle is used by HANDLER; the previous implementation worked only by pure luck --- sql/sql_handler.cc | 12 ++++++++++-- 1 file 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) {