Bug #44215 Cannot run 32+ union of two levels nested subquery
Submitted: 11 Apr 2009 12:57 Modified: 4 Jun 2013 6:03
Reporter: Edrick Duero Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.67,5.0.90,5.1.33,6.0 OS:Windows (Windows XP SP3)
Assigned to: CPU Architecture:Any
Tags: subquery, too high level of of nesting, UNION

[11 Apr 2009 12:57] Edrick Duero
Description:
If a query with 32+ union of two levels nested subquery generates an error of "Too high level of nesting for select".

It works in 5.0.45 with exact result but does not work anymore in 5.0.77 & 5.1.33

How to repeat:
create table tbl(id integer primary key);

select
  *
from
  tbl
left join
  (
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t2
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t3
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t4
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t5
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t6
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t7
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t8
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t9
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t10
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t11
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t12
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t13
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t14
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t15
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t16
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t17
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t18
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t19
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t20
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t21
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t22
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t23
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t24
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t25
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t26
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t27
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t28
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t9
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t30
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t31
    union
    select
      *
    from
      (
        select
          *
        from
          tbl
      ) t32
  ) t1
  on t1.id=tbl.id;
[11 Apr 2009 15:02] MySQL Verification Team
Thank you for the bug report. Verified as described.
[18 Jul 2009 0:21] Edrick Duero
Hi!

Is there any update to this bug report?

Cheers,
Edrick.
[16 Sep 2009 7:30] Le Nghia
I'm in the same problem. Does anyone have a solution. I wonder if MySql developers will fix this bug.
[16 Feb 2010 8:31] MySQL Verification Team
5.0.90 still has the problem.
5.1.34 fails.
5.1.37 works.
5.1.39 works.
5.1.43 works.  

I'm thinking this bug is a duplicate of bug #41156
[4 Jun 2013 6:03] Roy Lyseng
Closing as duplicate, verified fixed in 5.5 and 5.6.