[MDEV-3987] uninitialized read in Item_cond::fix_fields leads to crash: select .. where .. in ( select ... ) Created: 2012-12-28 Updated: 2013-01-09 Resolved: 2013-01-09 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 10.0.0, 5.5.28a |
| Fix Version/s: | 10.0.2, 5.5.29 |
| Type: | Bug | Priority: | Major |
| Reporter: | sbester1 | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
windows, linux |
||
| Attachments: |
|
| Description |
|
How to repeat:
Windows call stack:
See attached file for full valgrind outputs. |
| Comments |
| Comment by Elena Stepanova [ 2012-12-28 ] |
|
On a debug version, causes assertion `0' failure in bool subselect_hash_sj_engine::init(List<Item>*, uint). SET optimizer_switch = 'materialization=on'; create table `t1`(`a` char(1) character set utf8) engine=myisam; select 1 from `t1` where `a` in (select group_concat(a) from t1); Minimal optimizer_switch: materialization=on. |
| Comment by Timour Katchaounov (Inactive) [ 2013-01-07 ] |
|
Analysis:
Adds an assert that makes sure that if non-SJ materialization was chosen, then the temporary table for the materialized subquery was created successfully. This assumes that subquery_types_allow_materialization() is complete, and it would reject all cases when a unique index cannot be created over the materialized subquery. However, if the subquery to be materialized selects group_concat(), and the collation is utf-8, the test in subquery_types_allow_materialization() is not consistent with the corresponding logic in Item_func_group_concat::make_string_field(). The latter function would create a field of type BLOB for the temporary table if (max_length / collation.collation->mbminlen > CONVERT_IF_BIGGER_TO_BLOB) This field is not unique-indexable, so the temporary table for the subquery cannot be used to perform lookups and to compute the IN predicate. At the same time subquery_types_allow_materialization() tests for (inner->max_length / inner->collation.collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB) and thus it decides that materialization is possible. |
| Comment by Timour Katchaounov (Inactive) [ 2013-01-07 ] |
|
The fix is to correct Item_func_group_concat::make_string_field() to use collation.collation->mbmaxlen instead of collation.collation->mbminlen. After a discussion with Serg, he said that he created a patch that that removes almost all comparisons with CONVERT_IF_BIGGER_TO_BLOB, and fixes all such inconsistencies. |
| Comment by Patryk Pomykalski [ 2013-01-07 ] |
|
A quick and dirty solution:
As a side effect some tests output changes from text to varchar(1024). |
| Comment by Timour Katchaounov (Inactive) [ 2013-01-09 ] |
|
I approve serg's patch: |