[MDEV-4341] LevelDB (actually optimizer): Wrong result (duplicate rows) with FROM subquery, range access Created: 2013-03-30 Updated: 2021-12-06 Resolved: 2021-12-06 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | None |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Sergei Petrunia |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | leveldb | ||
| Attachments: |
|
||||
| Issue Links: |
|
||||
| Description |
|
MyISAM produces the expected result:
|
| Comments |
| Comment by Sergei Petrunia [ 2013-04-11 ] |
|
The problem is not repeatable on MyISAM or InnoDB, because they return different statistics. If I take cost data that is returned by ha_leveldb and make ha_innobase return it, the bug is repeatable with innodb. |
| Comment by Sergei Petrunia [ 2013-04-11 ] |
|
The problem is in JOIN::set_access_methods(), in this piece of code: if (!keyuse) { tab->type= JT_ALL; if (tableno > const_tables) full_join= true; }else if (tab->position->sj_strategy == SJ_OPT_LOOSE_SCAN) { DBUG_ASSERT(tab->keys.is_set(tab->position->loosescan_key)); tab->type= JT_ALL; // @todo is this consistent for a LooseScan table ? tab->index= tab->position->loosescan_key; }When it is executed for the second time (i.e. for the main query, not for the tab->quick->index=1 // correct, index `i`. When keyuse!=NULL, this function does the assigment: tab->index= tab->position->loosescan_key; and then the execution part (sub_select() in particular) uses that information If I force the assignment of tab->index= tab->position->loosescan_key; then the wrong result disappears. (The only remaining question is whether this if (tab->position->sj_strategy == SJ_OPT_LOOSE_SCAN && tab->quick) or is it LooseScan code in sub_select() that should use tab->quick->index |