From 3fc85580c9bc1e585de752697e3ae7ad02a64957 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 Apr 2010 17:27:06 +0300 Subject: [PATCH] MWL#68: Subquery optimization: Efficient NOT IN execution with NULLs Fixed an error where the priority queue for the indexes used for partial matching was not emptied after each execution in all cases. --- sql/item_subselect.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 741cd2e3e85..fbfc89a1919 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -3882,8 +3882,9 @@ subselect_hash_sj_engine::make_unique_engine() cur_ref_buff + test(maybe_null), we could use that information instead. */ + cur_ref_buff + null_count, - null_count ? tab->ref.key_buff : 0, + null_count ? cur_ref_buff : 0, cur_key_part->length, tab->ref.items[i]); cur_ref_buff+= cur_key_part->store_length; } @@ -4908,6 +4909,8 @@ bool subselect_rowid_merge_engine::partial_match() /* If there is a non-NULL key, it must be the first key in the keys array. */ DBUG_ASSERT(!non_null_key || (non_null_key && merge_keys[0] == non_null_key)); + /* The prioryty queue for keys must be empty. */ + DBUG_ASSERT(!pq.elements); /* All data accesses during execution are via handler::ha_rnd_pos() */ tmp_table->file->ha_rnd_init(0); @@ -5031,6 +5034,7 @@ bool subselect_rowid_merge_engine::partial_match() DBUG_ASSERT(FALSE); end: + queue_remove_all(&pq); tmp_table->file->ha_rnd_end(); return res; }