List:Commits« Previous MessageNext Message »
From:Gleb Shchepa Date:July 11 2009 6:44pm
Subject:bzr commit into mysql-5.1-bugteam branch (gshchepa:3017) Bug#41156
View as plain text  
#At file:///work/bzr/mysql-5.1-bugteam/ based on revid:staale.smedseng@stripped

 3017 Gleb Shchepa	2009-07-11
      Bug #41156: List of derived tables acts like a chain of
                  mutually-nested subqueries
      
      Queries of the form
      
        SELECT * FROM (SELECT 1) AS t1,
                      (SELECT 2) AS t2,...
                      (SELECT 32) AS t32
      
      caused the "Too high level of nesting for select" error
      as if the query has a form
      
        SELECT * FROM (SELECT 1 FROM (SELECT 2 FROM (SELECT 3 FROM...
      
      
      The table_factor parser rule has been modified to adjust
      the LEX::nest_level variable value after every derived table.
     @ mysql-test/r/derived.result
        Added test case for bug #41156.
     @ mysql-test/t/derived.test
        Added test case for bug #41156.
     @ sql/sql_yacc.yy
        Bug #41156: List of derived tables acts like a chain of
                    mutually-nested subqueries
        
        The select_derived2 parser rule calls mysql_new_select()
        calls push_context() and nest_level++, however only
        the pop_context() was called at the end of derived table
        parsing at the table_factor rule.
        
        The table_factor parser rule has been modified to adjust
        the LEX::nest_level variable value after every derived table.

    modified:
      mysql-test/r/derived.result
      mysql-test/t/derived.test
      sql/sql_yacc.yy
=== modified file 'mysql-test/r/derived.result'
--- a/mysql-test/r/derived.result	2007-10-29 14:47:37 +0000
+++ b/mysql-test/r/derived.result	2009-07-11 18:44:29 +0000
@@ -383,3 +383,21 @@ select t2.* from (select * from t1) as A
 ID	DATA	FID
 drop table t1, t2;
 drop user mysqltest_1;
+# End of 4.1 tests
+SELECT 0 FROM
+(SELECT 0) t01, (SELECT 0) t02, (SELECT 0) t03, (SELECT 0) t04, (SELECT 0) t05,
+(SELECT 0) t06, (SELECT 0) t07, (SELECT 0) t08, (SELECT 0) t09, (SELECT 0) t10,
+(SELECT 0) t11, (SELECT 0) t12, (SELECT 0) t13, (SELECT 0) t14, (SELECT 0) t15,
+(SELECT 0) t16, (SELECT 0) t17, (SELECT 0) t18, (SELECT 0) t19, (SELECT 0) t20,
+(SELECT 0) t21, (SELECT 0) t22, (SELECT 0) t23, (SELECT 0) t24, (SELECT 0) t25,
+(SELECT 0) t26, (SELECT 0) t27, (SELECT 0) t28, (SELECT 0) t29, (SELECT 0) t30,
+(SELECT 0) t31, (SELECT 0) t32, (SELECT 0) t33, (SELECT 0) t34, (SELECT 0) t35,
+(SELECT 0) t36, (SELECT 0) t37, (SELECT 0) t38, (SELECT 0) t39, (SELECT 0) t40,
+(SELECT 0) t41, (SELECT 0) t42, (SELECT 0) t43, (SELECT 0) t44, (SELECT 0) t45,
+(SELECT 0) t46, (SELECT 0) t47, (SELECT 0) t48, (SELECT 0) t49, (SELECT 0) t50,
+(SELECT 0) t51, (SELECT 0) t52, (SELECT 0) t53, (SELECT 0) t54, (SELECT 0) t55,
+(SELECT 0) t56, (SELECT 0) t57, (SELECT 0) t58, (SELECT 0) t59, (SELECT 0) t60,
+(SELECT 0) t61;
+0
+0
+# End of 5.0 tests

=== modified file 'mysql-test/t/derived.test'
--- a/mysql-test/t/derived.test	2009-05-15 10:15:56 +0000
+++ b/mysql-test/t/derived.test	2009-07-11 18:44:29 +0000
@@ -279,4 +279,26 @@ disconnect con1;
 connection default;
 drop user mysqltest_1;
 
-# End of 4.1 tests
+--echo # End of 4.1 tests
+
+#
+# Bug #41156: List of derived tables acts like a chain of
+#             mutually-nested subqueries
+#
+
+SELECT 0 FROM
+(SELECT 0) t01, (SELECT 0) t02, (SELECT 0) t03, (SELECT 0) t04, (SELECT 0) t05,
+(SELECT 0) t06, (SELECT 0) t07, (SELECT 0) t08, (SELECT 0) t09, (SELECT 0) t10,
+(SELECT 0) t11, (SELECT 0) t12, (SELECT 0) t13, (SELECT 0) t14, (SELECT 0) t15,
+(SELECT 0) t16, (SELECT 0) t17, (SELECT 0) t18, (SELECT 0) t19, (SELECT 0) t20,
+(SELECT 0) t21, (SELECT 0) t22, (SELECT 0) t23, (SELECT 0) t24, (SELECT 0) t25,
+(SELECT 0) t26, (SELECT 0) t27, (SELECT 0) t28, (SELECT 0) t29, (SELECT 0) t30,
+(SELECT 0) t31, (SELECT 0) t32, (SELECT 0) t33, (SELECT 0) t34, (SELECT 0) t35,
+(SELECT 0) t36, (SELECT 0) t37, (SELECT 0) t38, (SELECT 0) t39, (SELECT 0) t40,
+(SELECT 0) t41, (SELECT 0) t42, (SELECT 0) t43, (SELECT 0) t44, (SELECT 0) t45,
+(SELECT 0) t46, (SELECT 0) t47, (SELECT 0) t48, (SELECT 0) t49, (SELECT 0) t50,
+(SELECT 0) t51, (SELECT 0) t52, (SELECT 0) t53, (SELECT 0) t54, (SELECT 0) t55,
+(SELECT 0) t56, (SELECT 0) t57, (SELECT 0) t58, (SELECT 0) t59, (SELECT 0) t60,
+(SELECT 0) t61; # 61 == MAX_TABLES
+
+--echo # End of 5.0 tests

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2009-06-17 14:56:44 +0000
+++ b/sql/sql_yacc.yy	2009-07-11 18:44:29 +0000
@@ -8493,6 +8493,7 @@ table_factor:
                 MYSQL_YYABORT;
               sel->add_joined_table($$);
               lex->pop_context();
+              lex->nest_level--;
             }
             else if ($4 || $6)
             {
@@ -8501,7 +8502,11 @@ table_factor:
               MYSQL_YYABORT;
             }
             else
+            {
+              /* nested join: FROM (t1 JOIN t2 ...),
+                 nest_level is the same as in the outer query */
               $$= $3;
+            }
           }
         ;
 


Attachment: [text/bzr-bundle] bzr/gshchepa@mysql.com-20090711184429-lsksu70kgft05r8j.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (gshchepa:3017) Bug#41156Gleb Shchepa11 Jul