diff options
author | unknown <bell@laptop.sanja.is.com.ua> | 2003-10-07 16:22:48 +0300 |
---|---|---|
committer | unknown <bell@laptop.sanja.is.com.ua> | 2003-10-07 16:22:48 +0300 |
commit | fae46f7c9f1be65c5bf5604cd1f91dea3c8be9c7 (patch) | |
tree | 2b25cac2a29311fee2e74d727d07ee234b83ea71 /sql/item_subselect.cc | |
parent | 4d9cbc266a57812d8016e918c8b0ba84196b9d52 (diff) | |
parent | bcf562fcf9dbbad15b5be1929a2244c297b5dd1f (diff) | |
download | mariadb-git-fae46f7c9f1be65c5bf5604cd1f91dea3c8be9c7.tar.gz |
merge
sql/item_subselect.h:
Auto merged
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r-- | sql/item_subselect.cc | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 9f60331f996..3070fb43b27 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -36,7 +36,7 @@ inline Item * and_items(Item* cond, Item *item) Item_subselect::Item_subselect(): Item_result_field(), engine_owner(1), value_assigned(0), substitution(0), - have_to_be_excluded(0), engine_changed(0) + engine(0), have_to_be_excluded(0), engine_changed(0) { reset(); /* @@ -46,6 +46,7 @@ Item_subselect::Item_subselect(): null_value= 1; } + void Item_subselect::init(st_select_lex *select_lex, select_subselect *result) { @@ -61,6 +62,7 @@ void Item_subselect::init(st_select_lex *select_lex, DBUG_VOID_RETURN; } + Item_subselect::~Item_subselect() { if (engine_owner) @@ -763,6 +765,7 @@ Item_in_subselect::row_value_transformer(JOIN *join, DBUG_RETURN(RES_OK); } + Item_subselect::trans_res Item_in_subselect::select_transformer(JOIN *join) { @@ -772,6 +775,7 @@ Item_in_subselect::select_transformer(JOIN *join) return row_value_transformer(join, left_expr); } + Item_subselect::trans_res Item_allany_subselect::select_transformer(JOIN *join) { @@ -798,6 +802,7 @@ subselect_single_select_engine(st_select_lex *select, this->select_lex= select_lex; } + subselect_union_engine::subselect_union_engine(st_select_lex_unit *u, select_subselect *result, Item_subselect *item) @@ -991,6 +996,7 @@ int subselect_union_engine::exec() return res; } + int subselect_uniquesubquery_engine::exec() { DBUG_ENTER("subselect_uniquesubquery_engine::exec"); @@ -1012,34 +1018,22 @@ int subselect_uniquesubquery_engine::exec() { error= 0; table->null_row= 0; - if (table->status) - ((Item_in_subselect *) item)->value= 0; - else - ((Item_in_subselect *) item)->value= (!cond || cond->val_int()?1:0); + ((Item_in_subselect *) item)->value= (!table->status && + (!cond || cond->val_int()) ? 1 : + 0); } } - DBUG_RETURN(end_exec(table) || (error != 0)); + DBUG_RETURN(error != 0); } -int subselect_uniquesubquery_engine::end_exec(TABLE *table) + +subselect_uniquesubquery_engine::~subselect_uniquesubquery_engine() { - DBUG_ENTER("subselect_uniquesubquery_engine::end_exec"); - int error=0, tmp; - 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", ("index_end() failed")); - error= 1; - } - if (error == 1) - table->file->print_error(tmp, MYF(0)); - DBUG_RETURN(error != 0); + /* Tell handler we don't need the index anymore */ + tab->table->file->index_end(); } + int subselect_indexsubquery_engine::exec() { DBUG_ENTER("subselect_indexsubselect_engine::exec"); @@ -1048,9 +1042,11 @@ int subselect_indexsubquery_engine::exec() TABLE *table= tab->table; ((Item_in_subselect *) item)->value= 0; + if (check_null) { - *tab->null_ref_key= 0; + /* We need to check for NULL if there wasn't a matching value */ + *tab->null_ref_key= 0; // Search first for not null ((Item_in_subselect *) item)->was_null= 0; } @@ -1068,7 +1064,7 @@ int subselect_indexsubquery_engine::exec() error= report_error(table, error); else { - for(;;) + for (;;) { error= 0; table->null_row= 0; @@ -1080,7 +1076,7 @@ int subselect_indexsubquery_engine::exec() ((Item_in_subselect *) item)->was_null= 1; else ((Item_in_subselect *) item)->value= 1; - goto finish; + break; } error= table->file->index_next_same(table->record[0], tab->ref.key_buff, @@ -1088,25 +1084,26 @@ int subselect_indexsubquery_engine::exec() if (error && error != HA_ERR_END_OF_FILE) { error= report_error(table, error); - goto finish; + break; } } else { if (!check_null || null_finding) - goto finish; + break; /* We don't need to check nulls */ *tab->null_ref_key= 1; null_finding= 1; - if (safe_index_read(tab)) - goto finish; + /* Check if there exists a row with a null value in the index */ + if ((error= safe_index_read(tab))) + break; } } } } -finish: - DBUG_RETURN(end_exec(table) || (error != 0)); + DBUG_RETURN(error != 0); } + uint subselect_single_select_engine::cols() { return select_lex->item_list.elements; |