diff options
author | bell@sanja.is.com.ua <> | 2003-07-08 00:08:00 +0300 |
---|---|---|
committer | bell@sanja.is.com.ua <> | 2003-07-08 00:08:00 +0300 |
commit | 8279740af4bd4011ca4a624794eac0310c20b05b (patch) | |
tree | 15369eeb1264a3f2e01ca55f8de3f5c12459ff2d /sql/item_subselect.cc | |
parent | acece34bcea32b50bd90e6130324c0e885993346 (diff) | |
download | mariadb-git-8279740af4bd4011ca4a624794eac0310c20b05b.tar.gz |
new IN subquery engine added for simple IN with non-primary index but without NULL returning
(SCRUM) (part of WL#818)
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r-- | sql/item_subselect.cc | 77 |
1 files changed, 65 insertions, 12 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index e3f7d157ecd..894173f4575 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -972,22 +972,75 @@ int subselect_simplein_engine::exec() ((Item_in_subselect *) item)->value= (!cond || cond->val_int()?1:0); } } + DBUG_RETURN(end_exec(table) || (error != 0)); +} + +int subselect_simplein_engine::end_exec(TABLE *table) +{ + DBUG_ENTER("subselect_simplein_engine::end_exec"); + int error=0, tmp; + if ((tmp= table->file->extra(HA_EXTRA_NO_CACHE))) { - int tmp= 0; - if ((tmp= table->file->extra(HA_EXTRA_NO_CACHE))) - { - DBUG_PRINT("error", ("extra(HA_EXTRA_NO_CACHE) failed")); - error= 1; - } - if ((tmp= table->file->index_end())) + DBUG_PRINT("error", ("extra(HA_EXTRA_NO_CACHE) failed")); + error= 1; + } + if ((tmp= table->file->index_end())) + { + DBUG_PRINT("error", ("index_end() failed")); + error= 1; + } + if (error == 1) + table->file->print_error(tmp, MYF(0)); + DBUG_RETURN(error != 0); +} + +int subselect_indexin_engine::exec() +{ + DBUG_ENTER("subselect_indexin_engine::exec"); + int error; + TABLE *table= tab->table; + ((Item_in_subselect *) item)->value= 0; + if ((tab->ref.key_err= (*tab->ref.key_copy)->copy())) + { + table->status= STATUS_NOT_FOUND; + error= -1; + } + else + { + error= table->file->index_read(table->record[0], + tab->ref.key_buff, + tab->ref.key_length,HA_READ_KEY_EXACT); + if (error && error != HA_ERR_KEY_NOT_FOUND) + error= report_error(table, error); + else { - DBUG_PRINT("error", ("index_end() failed")); - error= 1; + for(;;) + { + error= 0; + table->null_row= 0; + if (!table->status) + { + if (!cond || cond->val_int()) + { + ((Item_in_subselect *) item)->value= 1; + goto finish; + } + } + else + goto finish; + error= table->file->index_next_same(table->record[0], + tab->ref.key_buff, + tab->ref.key_length); + if (error && error != HA_ERR_KEY_NOT_FOUND) + { + error= report_error(table, error); + goto finish; + } + } } - if (error == 1) - table->file->print_error(tmp, MYF(0)); } - DBUG_RETURN(error != 0) +finish: + DBUG_RETURN(end_exec(table) || (error != 0)); } uint subselect_single_select_engine::cols() |