[MDEV-6879] Dereference of NULL primary_file->table in DsMrr_impl::get_disk_sweep_mrr_cost() Created: 2014-10-16 Updated: 2014-10-28 Resolved: 2014-10-16 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.0.12 |
| Fix Version/s: | 10.0.15 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Jeremy Cole | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | derived, ds-mrr, optimizer | ||
| Description |
|
When joining against a derived table where MRR is chosen by the optimizer, in DsMrr_impl::get_disk_sweep_mrr_cost, primary_file->table (accessed as table) is NULL but is dereferenced.
Unfortunately I don't have a non-sensitive reproducible test case to provide, but the following patch fixes the problem for us by disabling MRR for joins against derived tables. It's unclear if this is the right solution or if it's a "big hammer" approach – alternate approaches are welcome. Patch follows:
|
| Comments |
| Comment by Sergei Petrunia [ 2014-10-16 ] | ||||||||||||||||||
|
Testcase:
| ||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-10-16 ] | ||||||||||||||||||
|
The TABLE object is present of course:
The problem is that temporary tables do not have handler->table set. I think, the fix is to just set handler->table in create_tmp_table. I'll check with others. | ||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-10-16 ] | ||||||||||||||||||
|
For normal tables, handler::table is set in handler::ha_open(). For temporary tables, the following happens:
That way, DS-MRR functions are called before table->ha_open() is called. | ||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-10-16 ] | ||||||||||||||||||
|
Another question is: if DsMrr_impl::get_disk_sweep_mrr_cost() is called for a table that is not opened (and not filled) yet, it can't return a meaningful value. On the other hand, there could be a benefit in using linked MRR. | ||||||||||||||||||
| Comment by Jeremy Cole [ 2014-10-16 ] | ||||||||||||||||||
|
psergey: My patch was "inspired" by these two checks, by the way: From sql/sql_select.cc:
From sql/opt_range.cc:
| ||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-10-16 ] | ||||||||||||||||||
|
Discussed with igor. | ||||||||||||||||||
| Comment by Sergei Petrunia [ 2014-10-16 ] | ||||||||||||||||||
|
(seeing the comment above) .. especially since similar decision was already made in other locations. |