Bug #92775 wrong figure in comment of class SELECT_LEX_UNIT
Submitted: 13 Oct 2018 8:59 Modified: 16 Oct 2018 12:12
Reporter: Kang Xia (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:8.0.12 OS:Any
Assigned to: CPU Architecture:Any
Tags: SELECT_LEX_UNIT, sql_lex.h

[13 Oct 2018 8:59] Kang Xia
Description:
mysql-boost-8.0.12/sql/sql_lex.h(line 566) show the structure of SELECT_LEX_UNIT for example query:
select *
     from table1
     where table1.field IN (select * from table1_1_1 union
                            select * from table1_1_2)
     union
   select *
     from table2
     where table2.field=(select (select f1 from table2_1_1_1_1
                                   where table2_1_1_1_1.f2=table2_1_1.f3)
                           from table2_1_1
                           where table2_1_1.f1=table2.f2)
     union
   select * from table3;

As follow:
     main unit
     fake0
     select1 select2 select3
     |^^     |^
    s|||     ||master
    l|||     |+---------------------------------+
    a|||     +---------------------------------+|
    v|||master                         slave   ||
    e||+-------------------------+             ||
     V|            neighbor      |             V|
     unit1.1<+==================>unit1.2       unit2.1
     fake1.1
     select1.1.1 select 1.1.2    select1.2.1   select2.1.1
                                               |^
                                               ||
                                               V|
                                               unit2.1.1.1
                                               select2.1.1.1.1

Actually, there is no unit1.2.

How to repeat:
(1) create tables in the example SQL as (field int, f1 int, f2 int, f3 int)
(2) gdb attach mysqld, and set a breakpoint at JOIN::exec
(3) execute example query
(4) (gdb) p thd->lex->unit->slave->slave->next
output: (SELECT_LEX_UNIT *)0x0
unit1.1 has no neighbor
[15 Oct 2018 13:13] MySQL Verification Team
Hi,

Thank you for your bug report.

First of all, could you pinpoint the subchapter and paragraph in our Reference Manual where we have drawn the graph that you have presented. If there is no graph like that, then our documentation is fine.

Second, next_1.2 is available from master as well. You do not need to traverse two slaves but only one, since two paths lead to that node. Node is the correct expression, BTW ...

Last, but not least, that node is NULL in your example, but it could be a valid pointer in some other SQL statement.
[16 Oct 2018 1:31] Kang Xia
Hello,

    Thanks for your reply.

    The SQL and the graph belong to a whole example, which is presented in source code mysql-boost-8.0.12/sql/sql_lex.h(line 566). I think source code comments are also important documentations. The graph illustrates the structure of THE SQL after parsing, and means nothing of any other SQL statements.

    Two slaves are needed to be traversed to arrive unit_1.2, one slave can only arrive a SELECT_LEX but not a SELECT_LEX_UNIT.
[16 Oct 2018 12:12] MySQL Verification Team
Hi,

I think that you are correct. Source code comments should also be changed to reflect properly the algorithms used.

Verified as reported.