diff options
author | unknown <timour@askmonty.org> | 2011-07-14 00:15:07 +0300 |
---|---|---|
committer | unknown <timour@askmonty.org> | 2011-07-14 00:15:07 +0300 |
commit | 1e6bd6b4df9d1302ce37a7b30af4e3ade8acce78 (patch) | |
tree | 3e29a2157293bcc720b6e7eaf6fa98bf75d135bf /sql/item_subselect.h | |
parent | 61eb3423b4117e3c64d1c42c1a5358905ad40c7d (diff) | |
download | mariadb-git-1e6bd6b4df9d1302ce37a7b30af4e3ade8acce78.tar.gz |
Fix bug lp:809266
Analysis:
This is a bug in MWL#68, where it was incorrectly assumed
that if there is a match in the only non-null key, then
if there is a covering NULL row on all remaining NULL-able
columns there is a partial match. However, this is not the case,
because even if there is such a null-only sub-row, it is not
guaranteed to be part of the matched sub-row. The matched sub-row
and the NULL-only sub-row may be parts of different rows.
In fact there are two cases:
- there is a complete row with only NULL values, and
- all nullable columns contain only NULL values.
These two cases were incorrectly mixed up in the class member
subselect_partial_match_engine::covering_null_row_width.
Solution:
The solution is to:
- split covering_null_row_width into two members:
has_covering_null_row, and has_covering_null_columns, and
- take into account each state during initialization and
execution.
Diffstat (limited to 'sql/item_subselect.h')
-rw-r--r-- | sql/item_subselect.h | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 42be1635b6f..8a84d446208 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -1131,11 +1131,18 @@ protected: /* A list of equalities between each pair of IN operands. */ List<Item> *equi_join_conds; /* - If there is a row, such that all its NULL-able components are NULL, this - member is set to the number of covered columns. If there is no covering - row, then this is 0. + True if there is an all NULL row in tmp_table. If so, then if there is + no complete match, there is a guaranteed partial match. */ - uint covering_null_row_width; + bool has_covering_null_row; + + /* + True if all nullable columns of tmp_table consist of only NULL values. + If so, then if there is a match in the non-null columns, there is a + guaranteed partial match. + */ + bool has_covering_null_columns; + protected: virtual bool partial_match()= 0; public: @@ -1144,7 +1151,8 @@ public: TABLE *tmp_table_arg, Item_subselect *item_arg, select_result_interceptor *result_arg, List<Item> *equi_join_conds_arg, - uint covering_null_row_width_arg); + bool has_covering_null_row_arg, + bool has_covering_null_columns_arg); int prepare() { return 0; } int exec(); void fix_length_and_dec(Item_cache**) {} @@ -1232,13 +1240,15 @@ public: subselect_rowid_merge_engine(THD *thd_arg, subselect_uniquesubquery_engine *engine_arg, TABLE *tmp_table_arg, uint merge_keys_count_arg, - uint covering_null_row_width_arg, + bool has_covering_null_row_arg, + bool has_covering_null_columns_arg, Item_subselect *item_arg, select_result_interceptor *result_arg, List<Item> *equi_join_conds_arg) :subselect_partial_match_engine(thd_arg, engine_arg, tmp_table_arg, item_arg, result_arg, equi_join_conds_arg, - covering_null_row_width_arg), + has_covering_null_row_arg, + has_covering_null_columns_arg), merge_keys_count(merge_keys_count_arg), non_null_key(NULL) {} ~subselect_rowid_merge_engine(); @@ -1258,7 +1268,8 @@ public: TABLE *tmp_table_arg, Item_subselect *item_arg, select_result_interceptor *result_arg, List<Item> *equi_join_conds_arg, - uint covering_null_row_width_arg); + bool has_covering_null_row_arg, + bool has_covering_null_columns_arg); void cleanup(); virtual enum_engine_type engine_type() { return TABLE_SCAN_ENGINE; } }; |