Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
5.3.12, 5.5.36, 10.0.10
-
None
-
None
Description
name resolution issues with views and multi-update in ps-protocol
Attachments
Issue Links
- blocks
-
MDEV-6139 UPDATE w/ join against MRG_MyISAM table with read-only sub-table fails
-
- Closed
-
Activity
Preliminary analysis:
The cause for the ASSERT is that Item_field::fix_fields calls Item_field::fix_outer_field while it shouldn't call it at all. There is no outer context in this statement.
The reason for this call is that in the following block in Item_field::fix_fields:
table_list= (cached_table ? cached_table :
|
from_field != view_ref_found ?
|
from_field->table->pos_in_table_list : 0);
|
if (!outer_fixed && table_list && table_list->select_lex &&
|
context->select_lex &&
|
table_list->select_lex != context->select_lex &&
|
!context->select_lex->is_merged_child_of(table_list->select_lex) &&
|
is_outer_table(table_list, context->select_lex))
|
{
|
int ret;
|
if ((ret= fix_outer_field(thd, &from_field, reference)) < 0)
|
goto error;
|
outer_fixed= 1;
|
if (!ret)
|
goto mark_non_agg_field;
|
}
|
The sub-condition:
table_list->select_lex != context->select_lex
|
is TRUE.
The following comparison of the prepare/execution of MariaDB with and without prepared statement, and MySQL
makes me think that the reason for this discrepancy is in either:
- some of the name resolution state is lost (e.g. not saved/restored) between prepare and execute, or
- the execute phase doesn't repeat correctly some the name resolution steps needed to reproduce the same result that was produced during prepare.
Let's follow the execution state of MySQL just at the questionable condition above. The below trace shows that both during prepare and execute:
- All tables considered during name resolution belong to the top-most select_lex (parent == NULL),
- (cached_table->select_lex == context->select_lex) is always true.
====================================== BEGIN PREPARE ======================================(gdb) echo
|
(gdb) c
|
Continuing.
|
|
Breakpoint 1, Item_field::fix_fields (this=0x3d79dd0, thd=0x3557470, reference=0x3d7c8e0) at /home/tsk/mprog/src/mysql-server/sql/item.cc:5441
|
8: context->select_lex->master->master = (SELECT_LEX *) 0x0
|
7: cached_table->select_lex->master->master = (SELECT_LEX *) 0x0
|
5: cached_table->select_lex = (st_select_lex *) 0x3d77378
|
4: (from_field == view_ref_found) = false
|
3: item_name->m_str = 0x3d79ef0 "val2v2"
|
2: (cached_table->select_lex == context->select_lex) = true
|
1: cached_table->alias = 0x3d79f30 "t2"
|
(gdb) c
|
Continuing.
|
|
Breakpoint 1, Item_field::fix_fields (this=0x3d78240, thd=0x3557470, reference=0x3d78400) at /home/tsk/mprog/src/mysql-server/sql/item.cc:5441
|
8: context->select_lex->master->master = (SELECT_LEX *) 0x0
|
7: cached_table->select_lex->master->master = (SELECT_LEX *) 0x0
|
5: cached_table->select_lex = (st_select_lex *) 0x3d77378
|
4: (from_field == view_ref_found) = true
|
3: item_name->m_str = 0x3d78238 "val2v2"
|
2: (cached_table->select_lex == context->select_lex) = true
|
1: cached_table->alias = 0x3d77ca8 "v2"
|
(gdb)
|
Continuing.
|
|
Breakpoint 1, Item_field::fix_fields (this=0x3d7a550, thd=0x3557470, reference=0x3d7a810) at /home/tsk/mprog/src/mysql-server/sql/item.cc:5441
|
8: context->select_lex->master->master = (SELECT_LEX *) 0x0
|
7: cached_table->select_lex->master->master = (SELECT_LEX *) 0x0
|
5: cached_table->select_lex = (st_select_lex *) 0x3d77378
|
4: (from_field == view_ref_found) = false
|
3: item_name->m_str = 0x3d7a548 "id2"
|
2: (cached_table->select_lex == context->select_lex) = true
|
1: cached_table->alias = 0x3d79f30 "t2"
|
(gdb)
|
Continuing.
|
|
Breakpoint 1, Item_field::fix_fields (this=0x3d7c5d0, thd=0x3557470, reference=0x3d7c8b0) at /home/tsk/mprog/src/mysql-server/sql/item.cc:5441
|
8: context->select_lex->master->master = (SELECT_LEX *) 0x0
|
7: cached_table->select_lex->master->master = (SELECT_LEX *) 0x0
|
5: cached_table->select_lex = (st_select_lex *) 0x3d77378
|
4: (from_field == view_ref_found) = false
|
3: item_name->m_str = 0x3d7c6f0 "id1v1"
|
2: (cached_table->select_lex == context->select_lex) = true
|
1: cached_table->alias = 0x3d7c870 "t1"
|
(gdb)
|
Continuing.
|
|
Breakpoint 1, Item_field::fix_fields (this=0x3d7a668, thd=0x3557470, reference=0x3d7a818) at /home/tsk/mprog/src/mysql-server/sql/item.cc:5441
|
8: context->select_lex->master->master = (SELECT_LEX *) 0x0
|
7: cached_table->select_lex->master->master = (SELECT_LEX *) 0x0
|
5: cached_table->select_lex = (st_select_lex *) 0x3d77378
|
4: (from_field == view_ref_found) = true
|
3: item_name->m_str = 0x3d7a660 "id1v1"
|
2: (cached_table->select_lex == context->select_lex) = true
|
1: cached_table->alias = 0x3d7a4f0 "v1"
|
(gdb)
|
Continuing.
|
|
Breakpoint 1, Item_field::fix_fields (this=0x3d79c90, thd=0x3557470, reference=0x3d7c8d0) at /home/tsk/mprog/src/mysql-server/sql/item.cc:5441
|
8: context->select_lex->master->master = (SELECT_LEX *) 0x0
|
7: cached_table->select_lex->master->master = (SELECT_LEX *) 0x0
|
5: cached_table->select_lex = (st_select_lex *) 0x3d77378
|
4: (from_field == view_ref_found) = false
|
3: item_name->m_str = 0x3d79db0 "id2v2"
|
2: (cached_table->select_lex == context->select_lex) = true
|
1: cached_table->alias = 0x3d79f30 "t2"
|
(gdb)
|
Continuing.
|
|
Breakpoint 1, Item_field::fix_fields (this=0x3d784c8, thd=0x3557470, reference=0x3d78678) at /home/tsk/mprog/src/mysql-server/sql/item.cc:5441
|
8: context->select_lex->master->master = (SELECT_LEX *) 0x0
|
7: cached_table->select_lex->master->master = (SELECT_LEX *) 0x0
|
5: cached_table->select_lex = (st_select_lex *) 0x3d77378
|
4: (from_field == view_ref_found) = true
|
3: item_name->m_str = 0x3d784c0 "id2v2"
|
2: (cached_table->select_lex == context->select_lex) = true
|
1: cached_table->alias = 0x3d77ca8 "v2"
|
(gdb)
|
Continuing.
|
C-c C-c
|
Program received signal SIGINT, Interrupt.
|
0x00007f2060f93f7d in poll () from /lib/x86_64-linux-gnu/libc.so.6
|
|
|
====================================== BEGIN EXEC ======================================(gdb) echo
|
(gdb) c
|
Continuing.
|
|
Breakpoint 1, Item_field::fix_fields (this=0x3d79dd0, thd=0x3557470, reference=0x3d7c8e0) at /home/tsk/mprog/src/mysql-server/sql/item.cc:5441
|
8: context->select_lex->master->master = (SELECT_LEX *) 0x0
|
7: cached_table->select_lex->master->master = (SELECT_LEX *) 0x0
|
5: cached_table->select_lex = (st_select_lex *) 0x3d77378
|
4: (from_field == view_ref_found) = false
|
3: item_name->m_str = 0x3d79ef0 "val2v2"
|
2: (cached_table->select_lex == context->select_lex) = true
|
1: cached_table->alias = 0x3d79f30 "t2"
|
(gdb) c
|
Continuing.
|
|
Breakpoint 1, Item_field::fix_fields (this=0x3d78240, thd=0x3557470, reference=0x3d78400) at /home/tsk/mprog/src/mysql-server/sql/item.cc:5441
|
8: context->select_lex->master->master = (SELECT_LEX *) 0x0
|
7: cached_table->select_lex->master->master = (SELECT_LEX *) 0x0
|
5: cached_table->select_lex = (st_select_lex *) 0x3d77378
|
4: (from_field == view_ref_found) = true
|
3: item_name->m_str = 0x3d78238 "val2v2"
|
2: (cached_table->select_lex == context->select_lex) = true
|
1: cached_table->alias = 0x3d77ca8 "v2"
|
(gdb)
|
Continuing.
|
|
Breakpoint 1, Item_field::fix_fields (this=0x3d79c90, thd=0x3557470, reference=0x3d7c8d0) at /home/tsk/mprog/src/mysql-server/sql/item.cc:5441
|
8: context->select_lex->master->master = (SELECT_LEX *) 0x0
|
7: cached_table->select_lex->master->master = (SELECT_LEX *) 0x0
|
5: cached_table->select_lex = (st_select_lex *) 0x3d77378
|
4: (from_field == view_ref_found) = false
|
3: item_name->m_str = 0x3d79db0 "id2v2"
|
2: (cached_table->select_lex == context->select_lex) = true
|
1: cached_table->alias = 0x3d79f30 "t2"
|
(gdb)
|
Continuing.
|
|
Breakpoint 1, Item_field::fix_fields (this=0x3d784c8, thd=0x3557470, reference=0x3d78678) at /home/tsk/mprog/src/mysql-server/sql/item.cc:5441
|
8: context->select_lex->master->master = (SELECT_LEX *) 0x0
|
7: cached_table->select_lex->master->master = (SELECT_LEX *) 0x0
|
5: cached_table->select_lex = (st_select_lex *) 0x3d77378
|
4: (from_field == view_ref_found) = true
|
3: item_name->m_str = 0x3d784c0 "id2v2"
|
2: (cached_table->select_lex == context->select_lex) = true
|
1: cached_table->alias = 0x3d77ca8 "v2"
|
(gdb)
|
Continuing.
|
|
Breakpoint 1, Item_field::fix_fields (this=0x3d7a550, thd=0x3557470, reference=0x3d7a810) at /home/tsk/mprog/src/mysql-server/sql/item.cc:5441
|
8: context->select_lex->master->master = (SELECT_LEX *) 0x0
|
7: cached_table->select_lex->master->master = (SELECT_LEX *) 0x0
|
5: cached_table->select_lex = (st_select_lex *) 0x3d77378
|
4: (from_field == view_ref_found) = false
|
3: item_name->m_str = 0x3d7a548 "id2"
|
2: (cached_table->select_lex == context->select_lex) = true
|
1: cached_table->alias = 0x3d79f30 "t2"
|
(gdb)
|
Continuing.
|
|
Breakpoint 1, Item_field::fix_fields (this=0x3d7c5d0, thd=0x3557470, reference=0x3d7c8b0) at /home/tsk/mprog/src/mysql-server/sql/item.cc:5441
|
8: context->select_lex->master->master = (SELECT_LEX *) 0x0
|
7: cached_table->select_lex->master->master = (SELECT_LEX *) 0x0
|
5: cached_table->select_lex = (st_select_lex *) 0x3d77378
|
4: (from_field == view_ref_found) = false
|
3: item_name->m_str = 0x3d7c6f0 "id1v1"
|
2: (cached_table->select_lex == context->select_lex) = true
|
1: cached_table->alias = 0x3d7c870 "t1"
|
(gdb)
|
Continuing.
|
|
Breakpoint 1, Item_field::fix_fields (this=0x3d7a668, thd=0x3557470, reference=0x3d7a818) at /home/tsk/mprog/src/mysql-server/sql/item.cc:5441
|
8: context->select_lex->master->master = (SELECT_LEX *) 0x0
|
7: cached_table->select_lex->master->master = (SELECT_LEX *) 0x0
|
5: cached_table->select_lex = (st_select_lex *) 0x3d77378
|
4: (from_field == view_ref_found) = true
|
3: item_name->m_str = 0x3d7a660 "id1v1"
|
2: (cached_table->select_lex == context->select_lex) = true
|
1: cached_table->alias = 0x3d7a4f0 "v1"
|
(gdb)
|
Continuing.
|
Let's follow the prepare/execute state at the same point in MariaDB. Notice that execute stops already at the first field "id1v1" to be resolved because of the failing assert.
Also notice that:
- (table_list->select_lex == context->select_lex) is TRUE during the prepare phase for all considered tables/contexts.
- However during execute the above condition is wrong already for the first found field, and this is the cause for the bug.
- Unlike MySQL the select_lex-es where the considered tables/contexts belong are not at the top-level, they have a parent.
- Even more, during the execute phase
cached_table->select_lex->master->master == context->select_lex
(which seems wrong, and inconsistent with all other traces).
The above states are very different from MySQL, and it seems MariaDB has diverged in the shape of the select_lex tree for merged views. Therefore I think it makes little sense to try to apply patches from MySQL.
====================================== BEGIN PREPARE ======================================
|
Breakpoint 9, Item_field::fix_fields (this=0x7f3835eef6e8, thd=0x7f383cbd2070, reference=0x7f3835eef7f8) at /home/tsk/mprog/src/10.0-lp/sql/item.cc:5206
|
12: cached_table->select_lex = (st_select_lex *) 0x7f3835eee9f8
|
11: context->select_lex = (st_select_lex *) 0x7f3835eee9f8
|
10: context = (Name_resolution_context *) 0x7f3835eeea48
|
9: context->select_lex->master->master = (st_select_lex *) 0x7f3835ef1840
|
8: cached_table->select_lex->master->master = (st_select_lex *) 0x7f3835ef1840
|
7: (from_field == view_ref_found) = false
|
6: cached_table->alias = 0x7f3835eef978 "t2"
|
5: field_name = 0x7f3835eef6e0 "id2"
|
4: (table_list->select_lex == context->select_lex) = true
|
3: table_list->alias = 0x7f3835eef978 "t2"
|
2: name = 0x7f3835eef800 "id2v2"
|
(gdb) c
|
Continuing.
|
|
Breakpoint 9, Item_field::fix_fields (this=0x7f3835eef820, thd=0x7f383cbd2070, reference=0x7f3835eef930) at /home/tsk/mprog/src/10.0-lp/sql/item.cc:5206
|
12: cached_table->select_lex = (st_select_lex *) 0x7f3835eee9f8
|
11: context->select_lex = (st_select_lex *) 0x7f3835eee9f8
|
10: context = (Name_resolution_context *) 0x7f3835eeea48
|
9: context->select_lex->master->master = (st_select_lex *) 0x7f3835ef1840
|
8: cached_table->select_lex->master->master = (st_select_lex *) 0x7f3835ef1840
|
7: (from_field == view_ref_found) = false
|
6: cached_table->alias = 0x7f3835eef978 "t2"
|
5: field_name = 0x7f3835eef818 "val2"
|
4: (table_list->select_lex == context->select_lex) = true
|
3: table_list->alias = 0x7f3835eef978 "t2"
|
2: name = 0x7f3835eef938 "val2v2"
|
(gdb)
|
Continuing.
|
|
Breakpoint 9, Item_field::fix_fields (this=0x7f3835eebca0, thd=0x7f383cbd2070, reference=0x7f3835eebf30) at /home/tsk/mprog/src/10.0-lp/sql/item.cc:5206
|
12: cached_table->select_lex = (st_select_lex *) 0x7f3835eee9f8
|
11: context->select_lex = (st_select_lex *) 0x7f3835eee9f8
|
10: context = (Name_resolution_context *) 0x7f3835eeea48
|
9: context->select_lex->master->master = (st_select_lex *) 0x7f3835ef1840
|
8: cached_table->select_lex->master->master = (st_select_lex *) 0x7f3835ef1840
|
7: (from_field == view_ref_found) = false
|
6: cached_table->alias = 0x7f3835eef978 "t2"
|
5: field_name = 0x7f3835eefff8 "id2"
|
4: (table_list->select_lex == context->select_lex) = true
|
3: table_list->alias = 0x7f3835eef978 "t2"
|
2: name = 0x7f3835eefff8 "id2"
|
(gdb)
|
Continuing.
|
|
Breakpoint 9, Item_field::fix_fields (this=0x7f3835eec728, thd=0x7f383cbd2070, reference=0x7f3835eecfd0) at /home/tsk/mprog/src/10.0-lp/sql/item.cc:5206
|
12: cached_table->select_lex = (st_select_lex *) 0x7f3835ef4838
|
11: context->select_lex = (st_select_lex *) 0x7f3835ef4838
|
10: context = (Name_resolution_context *) 0x7f3835ef4888
|
9: context->select_lex->master->master = (st_select_lex *) 0x7f3835eee9f8
|
8: cached_table->select_lex->master->master = (st_select_lex *) 0x7f3835eee9f8
|
7: (from_field == view_ref_found) = false
|
6: cached_table->alias = 0x7f3835eec9b8 "t1"
|
5: field_name = 0x7f3835eec720 "id1"
|
4: (table_list->select_lex == context->select_lex) = true
|
3: table_list->alias = 0x7f3835eec9b8 "t1"
|
2: name = 0x7f3835eec840 "id1v1"
|
(gdb)
|
Continuing.
|
|
Breakpoint 9, Item_field::fix_fields (this=0x7f3835eebda0, thd=0x7f383cbd2070, reference=0x7f3835eebf38) at /home/tsk/mprog/src/10.0-lp/sql/item.cc:5206
|
12: cached_table->select_lex = (st_select_lex *) 0x7f3835eee9f8
|
11: context->select_lex = (st_select_lex *) 0x7f3835eee9f8
|
10: context = (Name_resolution_context *) 0x7f3835eeea48
|
9: context->select_lex->master->master = (st_select_lex *) 0x7f3835ef1840
|
8: cached_table->select_lex->master->master = (st_select_lex *) 0x7f3835ef1840
|
7: (from_field == view_ref_found) = true
|
6: cached_table->alias = 0x7f3835eeffa0 "v1"
|
5: field_name = 0x7f3835ef0008 "id1v1"
|
4: (table_list->select_lex == context->select_lex) = true
|
3: table_list->alias = 0x7f3835eeffa0 "v1"
|
2: name = 0x7f3835ef0008 "id1v1"
|
(gdb)
|
Continuing.
|
|
Breakpoint 9, Item_field::fix_fields (this=0x7f3835ef2b80, thd=0x7f383cbd2070, reference=0x7f3835ef2d28) at /home/tsk/mprog/src/10.0-lp/sql/item.cc:5206
|
12: cached_table->select_lex = (st_select_lex *) 0x7f3835ef1840
|
11: context->select_lex = (st_select_lex *) 0x7f3835ef1840
|
10: context = (Name_resolution_context *) 0x7f3835ef1890
|
9: context->select_lex->master->master = (st_select_lex_node *) 0x0
|
8: cached_table->select_lex->master->master = (st_select_lex_node *) 0x0
|
7: (from_field == view_ref_found) = true
|
6: cached_table->alias = 0x7f3835ef2580 "v2"
|
5: field_name = 0x7f3835ef2b78 "val2v2"
|
4: (table_list->select_lex == context->select_lex) = true
|
3: table_list->alias = 0x7f3835ef2580 "v2"
|
2: name = 0x7f3835ef2b78 "val2v2"
|
(gdb)
|
Continuing.
|
|
Breakpoint 9, Item_field::fix_fields (this=0x7f3835ef2de0, thd=0x7f383cbd2070, reference=0x7f3835ef2f78) at /home/tsk/mprog/src/10.0-lp/sql/item.cc:5206
|
12: cached_table->select_lex = (st_select_lex *) 0x7f3835ef1840
|
11: context->select_lex = (st_select_lex *) 0x7f3835ef1840
|
10: context = (Name_resolution_context *) 0x7f3835ef1890
|
9: context->select_lex->master->master = (st_select_lex_node *) 0x0
|
8: cached_table->select_lex->master->master = (st_select_lex_node *) 0x0
|
7: (from_field == view_ref_found) = true
|
6: cached_table->alias = 0x7f3835ef2580 "v2"
|
5: field_name = 0x7f3835ef2dd8 "id2v2"
|
4: (table_list->select_lex == context->select_lex) = true
|
3: table_list->alias = 0x7f3835ef2580 "v2"
|
2: name = 0x7f3835ef2dd8 "id2v2"
|
(gdb)
|
Continuing.
|
|
====================================== BEGIN EXEC ======================================
|
Breakpoint 9, Item_field::fix_fields (this=0x7f3835eec728, thd=0x7f383cbd2070, reference=0x7f3835eec838) at /home/tsk/mprog/src/10.0-lp/sql/item.cc:5206
|
12: cached_table->select_lex = (st_select_lex *) 0x7f3835ef4838
|
11: context->select_lex = (st_select_lex *) 0x7f3835ef1840
|
10: context = (Name_resolution_context *) 0x7f3835ef7480
|
9: context->select_lex->master->master = (st_select_lex_node *) 0x0
|
8: cached_table->select_lex->master->master = (st_select_lex *) 0x7f3835ef1840
|
7: (from_field == view_ref_found) = false
|
6: cached_table->alias = 0x7f3835eec9b8 "t1"
|
5: field_name = 0x7f3835eec720 "id1"
|
4: (table_list->select_lex == context->select_lex) = false
|
3: table_list->alias = 0x7f3835eec9b8 "t1"
|
2: name = 0x7f3835eec840 "id1v1"
|
Finally, let's follow the state at the same point when the statement is executed directly in MariaDB. A comparison of these states with the recoreded steps of the prepare phase for MariaDB, it is clear that prepare and direct execution work the same.
====================================== BEGIN ======================================
|
Breakpoint 8, Item_field::fix_fields (this=0x7f3bd8a99f68, thd=0x7f3bdf7c1070, reference=0x7f3bd8a9a078) at /home/tsk/mprog/src/10.0-lp/sql/item.cc:5206
|
12: cached_table->select_lex = (st_select_lex *) 0x7f3bd8af2838
|
11: context->select_lex = (st_select_lex *) 0x7f3bd8af2838
|
10: context = (Name_resolution_context *) 0x7f3bd8af2888
|
9: field_name = 0x7f3bd8a99f60 "id2"
|
8: context->select_lex->master->master = (st_select_lex *) 0x7f3bdf7c5460
|
7: cached_table->select_lex->master->master = (st_select_lex *) 0x7f3bdf7c5460
|
6: (table_list->select_lex == context->select_lex) = true
|
5: (from_field == view_ref_found) = false
|
2: table_list->alias = 0x7f3bd8a9a1f8 "t2"
|
1: name = 0x7f3bd8a9a080 "id2v2"
|
(gdb) c
|
Continuing.
|
|
Breakpoint 8, Item_field::fix_fields (this=0x7f3bd8a9a0a0, thd=0x7f3bdf7c1070, reference=0x7f3bd8a9a1b0) at /home/tsk/mprog/src/10.0-lp/sql/item.cc:5206
|
12: cached_table->select_lex = (st_select_lex *) 0x7f3bd8af2838
|
11: context->select_lex = (st_select_lex *) 0x7f3bd8af2838
|
10: context = (Name_resolution_context *) 0x7f3bd8af2888
|
9: field_name = 0x7f3bd8a9a098 "val2"
|
8: context->select_lex->master->master = (st_select_lex *) 0x7f3bdf7c5460
|
7: cached_table->select_lex->master->master = (st_select_lex *) 0x7f3bdf7c5460
|
6: (table_list->select_lex == context->select_lex) = true
|
5: (from_field == view_ref_found) = false
|
2: table_list->alias = 0x7f3bd8a9a1f8 "t2"
|
1: name = 0x7f3bd8a9a1b8 "val2v2"
|
(gdb)
|
Continuing.
|
|
Breakpoint 8, Item_field::fix_fields (this=0x7f3bd8a9ae58, thd=0x7f3bdf7c1070, reference=0x7f3bd8af3b40) at /home/tsk/mprog/src/10.0-lp/sql/item.cc:5206
|
12: cached_table->select_lex = (st_select_lex *) 0x7f3bd8af2838
|
11: context->select_lex = (st_select_lex *) 0x7f3bd8af2838
|
10: context = (Name_resolution_context *) 0x7f3bd8af2888
|
9: field_name = 0x7f3bd8a9ae50 "id2"
|
8: context->select_lex->master->master = (st_select_lex *) 0x7f3bdf7c5460
|
7: cached_table->select_lex->master->master = (st_select_lex *) 0x7f3bdf7c5460
|
6: (table_list->select_lex == context->select_lex) = true
|
5: (from_field == view_ref_found) = false
|
2: table_list->alias = 0x7f3bd8a9a1f8 "t2"
|
1: name = 0x7f3bd8a9ae50 "id2"
|
(gdb)
|
Continuing.
|
|
Breakpoint 8, Item_field::fix_fields (this=0x7f3bd8af3e10, thd=0x7f3bdf7c1070, reference=0x7f3bd8b08018) at /home/tsk/mprog/src/10.0-lp/sql/item.cc:5206
|
12: cached_table->select_lex = (st_select_lex *) 0x7f3bd8b06d70
|
11: context->select_lex = (st_select_lex *) 0x7f3bd8b06d70
|
10: context = (Name_resolution_context *) 0x7f3bd8b06dc0
|
9: field_name = 0x7f3bd8af3e08 "id1"
|
8: context->select_lex->master->master = (st_select_lex *) 0x7f3bd8af2838
|
7: cached_table->select_lex->master->master = (st_select_lex *) 0x7f3bd8af2838
|
6: (table_list->select_lex == context->select_lex) = true
|
5: (from_field == view_ref_found) = false
|
2: table_list->alias = 0x7f3bd8b07a00 "t1"
|
1: name = 0x7f3bd8af3f28 "id1v1"
|
(gdb)
|
Continuing.
|
|
Breakpoint 8, Item_field::fix_fields (this=0x7f3bd8a9af68, thd=0x7f3bdf7c1070, reference=0x7f3bd8af3b48) at /home/tsk/mprog/src/10.0-lp/sql/item.cc:5206
|
12: cached_table->select_lex = (st_select_lex *) 0x7f3bd8af2838
|
11: context->select_lex = (st_select_lex *) 0x7f3bd8af2838
|
10: context = (Name_resolution_context *) 0x7f3bd8af2888
|
9: field_name = 0x7f3bd8a9af60 "id1v1"
|
8: context->select_lex->master->master = (st_select_lex *) 0x7f3bdf7c5460
|
7: cached_table->select_lex->master->master = (st_select_lex *) 0x7f3bdf7c5460
|
6: (table_list->select_lex == context->select_lex) = true
|
5: (from_field == view_ref_found) = true
|
2: table_list->alias = 0x7f3bd8a9a820 "v1"
|
1: name = 0x7f3bd8a9af60 "id1v1"
|
(gdb)
|
Continuing.
|
|
Breakpoint 8, Item_field::fix_fields (this=0x7f3bd8a99788, thd=0x7f3bdf7c1070, reference=0x7f3bd8a99930) at /home/tsk/mprog/src/10.0-lp/sql/item.cc:5206
|
12: cached_table->select_lex = (st_select_lex *) 0x7f3bdf7c5460
|
11: context->select_lex = (st_select_lex *) 0x7f3bdf7c5460
|
10: context = (Name_resolution_context *) 0x7f3bdf7c54b0
|
9: field_name = 0x7f3bd8a99780 "val2v2"
|
8: context->select_lex->master->master = (st_select_lex_node *) 0x0
|
7: cached_table->select_lex->master->master = (st_select_lex_node *) 0x0
|
6: (table_list->select_lex == context->select_lex) = true
|
5: (from_field == view_ref_found) = true
|
2: table_list->alias = 0x7f3bd8a99188 "v2"
|
1: name = 0x7f3bd8a99780 "val2v2"
|
(gdb)
|
Continuing.
|
|
Breakpoint 8, Item_field::fix_fields (this=0x7f3bd8a999e8, thd=0x7f3bdf7c1070, reference=0x7f3bd8a99b80) at /home/tsk/mprog/src/10.0-lp/sql/item.cc:5206
|
12: cached_table->select_lex = (st_select_lex *) 0x7f3bdf7c5460
|
11: context->select_lex = (st_select_lex *) 0x7f3bdf7c5460
|
10: context = (Name_resolution_context *) 0x7f3bdf7c54b0
|
9: field_name = 0x7f3bd8a999e0 "id2v2"
|
8: context->select_lex->master->master = (st_select_lex_node *) 0x0
|
7: cached_table->select_lex->master->master = (st_select_lex_node *) 0x0
|
6: (table_list->select_lex == context->select_lex) = true
|
5: (from_field == view_ref_found) = true
|
2: table_list->alias = 0x7f3bd8a99188 "v2"
|
1: name = 0x7f3bd8a999e0 "id2v2"
|
It is outer table detection fix
=== modified file 'sql/item.cc'
— sql/item.cc 2014-03-16 20:03:01 +0000
+++ sql/item.cc 2014-04-16 19:24:35 +0000
@@ -4336,6 +4336,10 @@ bool is_outer_table(TABLE_LIST *table, S
DBUG_ASSERT(table->select_lex != select);
TABLE_LIST *tl;
+ if (table->belong_to_view &&
+ table->belong_to_view->select_lex == select)
+ return FALSE;
+
for (tl= select->master_unit()->derived;
tl && tl->is_merged_derived();
select= tl->select_lex, tl= select->master_unit()->derived)
But there is second problem with checking unique tables (in the same test suite)...
On second check (first execution after prepare) table t1 (part of v1) some how got the same table map (1) as t2/v2 which cause the false positive of the same table detection.
#Test case that fails with --ps-protocol
drop database if exists test;
create database test;
use test;
create table t1 (id1 int primary key, val1 varchar(20));
insert into t1 values (1, 'test1');
create table t2 (id2 int primary key, val2 varchar(20));
insert into t2 values (1, 'test2');
create algorithm=merge view v1 as select id1 as id1v1, val1 as val1v1 from t1;
create algorithm=merge view v2 as
select t2.id2 as id2v2, t2.val2 as val2v2
from t2, v1
where t2.id2 = v1.id1v1;
– The crash query
prepare stmt1 from "update v2 set val2v2 = 'test19' where 1 = id2v2";
execute stmt1;
– A similar select that works
prepare stmt2 from "select val2v2 from v2 where val2v2 = 'test19' and 1 = id2v2";
execute stmt2;