diff options
author | unknown <serg@serg.mylan> | 2005-06-07 22:43:25 +0200 |
---|---|---|
committer | unknown <serg@serg.mylan> | 2005-06-07 22:43:25 +0200 |
commit | 575a46a1efe314b69c392482637af17c97c046e0 (patch) | |
tree | e07960b2ba95d59cf7149bd9b67a4e106472f51f /sql | |
parent | 062a1b8b4e09c6de8ab592d37567d40d13798875 (diff) | |
download | mariadb-git-575a46a1efe314b69c392482637af17c97c046e0.tar.gz |
bug#5373: handler READ NEXT w/o HANDLER READ [FIRST]
check table->file->inited to catch incorrect calling sequence.
mysql-test/r/innodb_handler.result:
bug#5373: handler READ NEXT w/o HANDLER READ [FIRST]
mysql-test/t/innodb_handler.test:
bug#5373: handler READ NEXT w/o HANDLER READ [FIRST]
sql/sql_handler.cc:
cleanup: call index_init *correctly*, not every time.
check table->file->inited to catch incorrect calling sequence.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_handler.cc | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index aa791276404..491b82c1c1d 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -429,12 +429,10 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, } tables->table=table; - if (cond && ((!cond->fixed && + if (cond && ((!cond->fixed && cond->fix_fields(thd, tables, &cond)) || cond->check_cols(1))) goto err0; - table->file->init_table_handle_for_HANDLER(); // Only InnoDB requires it - if (keyname) { if ((keyno=find_type(keyname, &table->keynames, 1+2)-1)<0) @@ -443,8 +441,6 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, keyname,tables->alias); goto err0; } - table->file->ha_index_or_rnd_end(); - table->file->ha_index_init(keyno); } if (insert_fields(thd,tables,tables->db,tables->alias,&it)) @@ -471,9 +467,22 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, for (num_rows=0; num_rows < select_limit; ) { switch (mode) { + case RNEXT: + if (table->file->inited != handler::NONE) + { + err=keyname ? + table->file->index_next(table->record[0]) : + table->file->rnd_next(table->record[0]); + break; + } + /* else fall through */ case RFIRST: if (keyname) + { + table->file->ha_index_or_rnd_end(); + table->file->ha_index_init(keyno); err=table->file->index_first(table->record[0]); + } else { table->file->ha_index_or_rnd_end(); @@ -482,20 +491,21 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, } mode=RNEXT; break; + case RPREV: + DBUG_ASSERT(keyname != 0); + if (table->file->inited != handler::NONE) + { + err=table->file->index_prev(table->record[0]); + break; + } + /* else fall through */ case RLAST: DBUG_ASSERT(keyname != 0); + table->file->ha_index_or_rnd_end(); + table->file->ha_index_init(keyno); err=table->file->index_last(table->record[0]); mode=RPREV; break; - case RNEXT: - err=keyname ? - table->file->index_next(table->record[0]) : - table->file->rnd_next(table->record[0]); - break; - case RPREV: - DBUG_ASSERT(keyname != 0); - err=table->file->index_prev(table->record[0]); - break; case RNEXT_SAME: /* Continue scan on "(keypart1,keypart2,...)=(c1, c2, ...) */ DBUG_ASSERT(keyname != 0); @@ -517,7 +527,7 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, for (key_len=0 ; (item=it_ke++) ; key_part++) { // 'item' can be changed by fix_fields() call - if ((!item->fixed && + if ((!item->fixed && item->fix_fields(thd, tables, it_ke.ref())) || (item= *it_ke.ref())->check_cols(1)) goto err; @@ -535,6 +545,8 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, goto err; } key_copy(key, table, keyno, key_len); + table->file->ha_index_or_rnd_end(); + table->file->ha_index_init(keyno); err=table->file->index_read(table->record[0], key,key_len,ha_rkey_mode); mode=rkey_to_rnext[(int)ha_rkey_mode]; |