summaryrefslogtreecommitdiff
path: root/sql/item_subselect.cc
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2011-10-03 22:48:15 +0300
committerunknown <timour@askmonty.org>2011-10-03 22:48:15 +0300
commitada0850c0473e21b3909922634d50a2989708827 (patch)
tree9240043038f4612d86e09c0eef94c25fc4ca5746 /sql/item_subselect.cc
parenta14071970794b6a00208b30a1c20cece38de3b2e (diff)
downloadmariadb-git-ada0850c0473e21b3909922634d50a2989708827.tar.gz
Fix bug lp:858038
Analysis: The cause of the bug was the changed meaning of subselect_partial_match_engine::has_covering_null_row. Previously it meant that there is row with NULLs in all nullable fields of the materialized subquery table. Later it was changed to mean a row with NULLs in all fields of this table. At the same time there was a shortcut in subselect_rowid_merge_engine::partial_match() that detected a special case where: - there is no match in any of the columns with NULLs, and - there is no NULL-only row that covers all columns with NULLs. With the change in the meaning of has_covering_null_row, the condition that detected this special case was incomplete. This resulted in an incorrect FALSE, when the result was a partial match. Solution: Expand the condition that detected the special case with the correct test for the existence of a row with NULL values in all columns that contain NULLs (a kind of parially covering NULL-row).
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r--sql/item_subselect.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index a79d035160c..324cdabf7f6 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -5533,6 +5533,8 @@ bool subselect_rowid_merge_engine::partial_match()
Ordered_key *cur_key;
rownum_t cur_row_num;
uint count_nulls_in_search_key= 0;
+ uint max_covering_null_row_len=
+ ((select_materialize_with_stats *) result)->get_max_nulls_in_row();
bool res= FALSE;
/* If there is a non-NULL key, it must be the first key in the keys array. */
@@ -5598,8 +5600,16 @@ bool subselect_rowid_merge_engine::partial_match()
If there is no NULL (sub)row that covers all NULL columns, and there is no
single match for any of the NULL columns, the result is FALSE.
*/
- if (pq.elements - test(non_null_key) == 0)
+ if ((pq.elements == 1 && non_null_key &&
+ max_covering_null_row_len < merge_keys_count - 1) ||
+ pq.elements == 0)
{
+ if (pq.elements == 0)
+ {
+ DBUG_ASSERT(!non_null_key); /* Must follow from the logic of this method */
+ /* This case must be handled by subselect_partial_match_engine::exec() */
+ DBUG_ASSERT(max_covering_null_row_len != tmp_table->s->fields);
+ }
res= FALSE;
goto end;
}