MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:mhansson Date:March 10 2008 9:23am
Subject:bk commit into 6.0 tree (mhansson:1.2609) BUG#35020
View as plain text  
Below is the list of changes that have just been committed into a local
6.0 repository of mhansson.  When mhansson does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-03-10 10:22:24+01:00, mhansson@riffraff.(none) +8 -0
  Bug#35020: illegal sql_cache select syntax
  
  The select option flags SQL_CACHE and SQL_NO_CACHE were available
  for use in subqueries, which they're not supposed to.
  
  Fixed by creating special parser rules for select options in
  subqueries. 

  mysql-test/r/query_cache.result@stripped, 2008-03-10 10:22:21+01:00, mhansson@riffraff.(none) +6 -24
    Bug#35020: Changed test result.

  mysql-test/r/subselect.result@stripped, 2008-03-10 10:22:21+01:00, mhansson@riffraff.(none) +14 -0
    Bug#35020: Test result.

  mysql-test/r/subselect_no_mat.result@stripped, 2008-03-10 10:22:21+01:00, mhansson@riffraff.(none) +14 -0
    Bug#35020: This test case includes subselect.test and hence is dependent.

  mysql-test/r/subselect_no_opts.result@stripped, 2008-03-10 10:22:21+01:00, mhansson@riffraff.(none) +14 -0
    Bug#35020: This test case includes subselect.test and hence is dependent.

  mysql-test/r/subselect_no_semijoin.result@stripped, 2008-03-10 10:22:21+01:00, mhansson@riffraff.(none) +14 -0
    Bug#35020: This test case includes subselect.test and hence is dependent.

  mysql-test/t/query_cache.test@stripped, 2008-03-10 10:22:21+01:00, mhansson@riffraff.(none) +6 -0
    Bug#35020: Changed test cases.

  mysql-test/t/subselect.test@stripped, 2008-03-10 10:22:21+01:00, mhansson@riffraff.(none) +25 -0
    Bug#35020: Test case.

  sql/sql_yacc.yy@stripped, 2008-03-10 10:22:21+01:00, mhansson@riffraff.(none) +40 -26
    Bug#35020: Added new rule set to differentiate subquery options from 
    top-level query options:
    
    - opt_query_expression_options
    - query_expression_option_list
    - query_expression_option
    
    As an added benefit, we got rid of a shift/reduce conflict.

diff -Nrup a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
--- a/mysql-test/r/query_cache.result	2008-01-07 21:11:41 +01:00
+++ b/mysql-test/r/query_cache.result	2008-03-10 10:22:21 +01:00
@@ -182,15 +182,9 @@ a
 2
 3
 select * from t1 where a IN (select sql_cache a from t1);
-a
-1
-2
-3
+ERROR 42S22: Unknown column 'sql_cache' in 'field list'
 select * from t1 where a IN (select a from t1 union select sql_cache a from t1);
-a
-1
-2
-3
+ERROR 42S22: Unknown column 'sql_cache' in 'field list'
 show status like "Qcache_hits";
 Variable_name	Value
 Qcache_hits	4
@@ -213,15 +207,9 @@ a
 2
 3
 select * from t1 where a IN (select sql_no_cache a from t1);
-a
-1
-2
-3
+ERROR 42S22: Unknown column 'sql_no_cache' in 'field list'
 select * from t1 where a IN (select a from t1 union select sql_no_cache a from t1);
-a
-1
-2
-3
+ERROR 42S22: Unknown column 'sql_no_cache' in 'field list'
 select sql_cache sql_no_cache * from t1;
 a
 1
@@ -233,15 +221,9 @@ a
 2
 3
 select sql_cache * from t1 where a IN (select sql_no_cache a from t1);
-a
-1
-2
-3
+ERROR 42S22: Unknown column 'sql_no_cache' in 'field list'
 select sql_cache * from t1 where a IN (select a from t1 union select sql_no_cache a from t1);
-a
-1
-2
-3
+ERROR 42S22: Unknown column 'sql_no_cache' in 'field list'
 show status like "Qcache_queries_in_cache";
 Variable_name	Value
 Qcache_queries_in_cache	0
diff -Nrup a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
--- a/mysql-test/r/subselect.result	2008-03-06 09:20:49 +01:00
+++ b/mysql-test/r/subselect.result	2008-03-10 10:22:21 +01:00
@@ -4827,3 +4827,17 @@ ERROR 42000: You have an error in your S
 SELECT * FROM t1 WHERE a IN ( SELECT 1 INTO @v );
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
 DROP TABLE t1, t2;
+CREATE TABLE t1( a INT );
+SET @v = ( SELECT SQL_CACHE    1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 )' at line 1
+SET @v = ( SELECT SQL_NO_CACHE 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 )' at line 1
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_CACHE    a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_CACHE' in 'field list'
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_NO_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_NO_CACHE' in 'field list'
+SELECT ( SELECT SQL_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_CACHE' in 'field list'
+SELECT ( SELECT SQL_NO_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_NO_CACHE' in 'field list'
+DROP TABLE t1;
diff -Nrup a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result
--- a/mysql-test/r/subselect_no_mat.result	2008-03-06 09:20:50 +01:00
+++ b/mysql-test/r/subselect_no_mat.result	2008-03-10 10:22:21 +01:00
@@ -4831,6 +4831,20 @@ ERROR 42000: You have an error in your S
 SELECT * FROM t1 WHERE a IN ( SELECT 1 INTO @v );
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
 DROP TABLE t1, t2;
+CREATE TABLE t1( a INT );
+SET @v = ( SELECT SQL_CACHE    1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 )' at line 1
+SET @v = ( SELECT SQL_NO_CACHE 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 )' at line 1
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_CACHE    a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_CACHE' in 'field list'
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_NO_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_NO_CACHE' in 'field list'
+SELECT ( SELECT SQL_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_CACHE' in 'field list'
+SELECT ( SELECT SQL_NO_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_NO_CACHE' in 'field list'
+DROP TABLE t1;
 set optimizer_switch='';
 show variables like 'optimizer_switch';
 Variable_name	Value
diff -Nrup a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result
--- a/mysql-test/r/subselect_no_opts.result	2008-03-06 09:20:50 +01:00
+++ b/mysql-test/r/subselect_no_opts.result	2008-03-10 10:22:21 +01:00
@@ -4831,6 +4831,20 @@ ERROR 42000: You have an error in your S
 SELECT * FROM t1 WHERE a IN ( SELECT 1 INTO @v );
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
 DROP TABLE t1, t2;
+CREATE TABLE t1( a INT );
+SET @v = ( SELECT SQL_CACHE    1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 )' at line 1
+SET @v = ( SELECT SQL_NO_CACHE 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 )' at line 1
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_CACHE    a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_CACHE' in 'field list'
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_NO_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_NO_CACHE' in 'field list'
+SELECT ( SELECT SQL_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_CACHE' in 'field list'
+SELECT ( SELECT SQL_NO_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_NO_CACHE' in 'field list'
+DROP TABLE t1;
 set optimizer_switch='';
 show variables like 'optimizer_switch';
 Variable_name	Value
diff -Nrup a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result
--- a/mysql-test/r/subselect_no_semijoin.result	2008-03-06 09:20:50 +01:00
+++ b/mysql-test/r/subselect_no_semijoin.result	2008-03-10 10:22:21 +01:00
@@ -4831,6 +4831,20 @@ ERROR 42000: You have an error in your S
 SELECT * FROM t1 WHERE a IN ( SELECT 1 INTO @v );
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO @v )' at line 1
 DROP TABLE t1, t2;
+CREATE TABLE t1( a INT );
+SET @v = ( SELECT SQL_CACHE    1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 )' at line 1
+SET @v = ( SELECT SQL_NO_CACHE 1 );
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 )' at line 1
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_CACHE    a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_CACHE' in 'field list'
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_NO_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_NO_CACHE' in 'field list'
+SELECT ( SELECT SQL_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_CACHE' in 'field list'
+SELECT ( SELECT SQL_NO_CACHE a FROM t1 );
+ERROR 42S22: Unknown column 'SQL_NO_CACHE' in 'field list'
+DROP TABLE t1;
 set optimizer_switch='';
 show variables like 'optimizer_switch';
 Variable_name	Value
diff -Nrup a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
--- a/mysql-test/t/query_cache.test	2008-01-07 21:11:41 +01:00
+++ b/mysql-test/t/query_cache.test	2008-03-10 10:22:21 +01:00
@@ -96,7 +96,9 @@ select sql_cache * from t1 union select 
 
 # all sql_cache statements, except for the first select, are ignored.
 select * from t1 union select sql_cache * from t1;
+--error ER_BAD_FIELD_ERROR
 select * from t1 where a IN (select sql_cache a from t1);
+--error ER_BAD_FIELD_ERROR
 select * from t1 where a IN (select a from t1 union select sql_cache a from t1);
 show status like "Qcache_hits";
 show status like "Qcache_queries_in_cache";
@@ -113,11 +115,15 @@ select sql_no_cache * from t1;
 # sql_no_cache can occur in any nested select to turn on cacheing for the whole
 # expression and it will always override a sql_cache statement.
 select * from t1 union select sql_no_cache * from t1;
+--error ER_BAD_FIELD_ERROR
 select * from t1 where a IN (select sql_no_cache a from t1);
+--error ER_BAD_FIELD_ERROR
 select * from t1 where a IN (select a from t1 union select sql_no_cache a from t1);
 select sql_cache sql_no_cache * from t1;
 select sql_cache  * from t1 union select sql_no_cache * from t1;
+--error ER_BAD_FIELD_ERROR
 select sql_cache * from t1 where a IN (select sql_no_cache a from t1);
+--error ER_BAD_FIELD_ERROR
 select sql_cache * from t1 where a IN (select a from t1 union select sql_no_cache a from t1);
 show status like "Qcache_queries_in_cache";
 drop table t1;
diff -Nrup a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
--- a/mysql-test/t/subselect.test	2008-03-06 09:20:50 +01:00
+++ b/mysql-test/t/subselect.test	2008-03-10 10:22:21 +01:00
@@ -3680,3 +3680,28 @@ SELECT * FROM t1 WHERE EXISTS ( SELECT 1
 SELECT * FROM t1 WHERE a IN ( SELECT 1 INTO @v );
 
 DROP TABLE t1, t2;
+
+#
+# Bug#35020: illegal sql_cache select syntax
+#
+CREATE TABLE t1( a INT );
+
+--error ER_PARSE_ERROR
+SET @v = ( SELECT SQL_CACHE    1 );
+--error ER_PARSE_ERROR
+SET @v = ( SELECT SQL_NO_CACHE 1 );
+
+#
+# Keywords 'SQL_CACHE' and 'SQL_NO_CACHE' are allowed as column names.
+# Hence the error messages are not intuitive.
+#
+--error ER_BAD_FIELD_ERROR 
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_CACHE    a FROM t1 );
+--error ER_BAD_FIELD_ERROR 
+SELECT a FROM t1 WHERE a IN ( SELECT SQL_NO_CACHE a FROM t1 );
+--error ER_BAD_FIELD_ERROR
+SELECT ( SELECT SQL_CACHE a FROM t1 );
+--error ER_BAD_FIELD_ERROR
+SELECT ( SELECT SQL_NO_CACHE a FROM t1 );
+
+DROP TABLE t1;
diff -Nrup a/sql/sql_yacc.yy b/sql/sql_yacc.yy
--- a/sql/sql_yacc.yy	2008-03-06 09:20:50 +01:00
+++ b/sql/sql_yacc.yy	2008-03-10 10:22:21 +01:00
@@ -589,10 +589,10 @@ bool my_yyoverflow(short **a, YYSTYPE **
 
 %pure_parser                                    /* We have threads */
 /*
-  Currently there are 174 shift/reduce conflicts.
+  Currently there are 173 shift/reduce conflicts.
   We should not introduce new conflicts any more.
 */
-%expect 174
+%expect 173
 
 /*
    Comments for TOKENS.
@@ -6578,28 +6578,7 @@ select_option_list:
         ;
 
 select_option:
-          STRAIGHT_JOIN { Select->options|= SELECT_STRAIGHT_JOIN; }
-        | HIGH_PRIORITY
-          {
-            if (check_simple_select())
-              MYSQL_YYABORT;
-            Lex->lock_option= TL_READ_HIGH_PRIORITY;
-          }
-        | DISTINCT         { Select->options|= SELECT_DISTINCT; }
-        | SQL_SMALL_RESULT { Select->options|= SELECT_SMALL_RESULT; }
-        | SQL_BIG_RESULT   { Select->options|= SELECT_BIG_RESULT; }
-        | SQL_BUFFER_RESULT
-          {
-            if (check_simple_select())
-              MYSQL_YYABORT;
-            Select->options|= OPTION_BUFFER_RESULT;
-          }
-        | SQL_CALC_FOUND_ROWS
-          {
-            if (check_simple_select())
-              MYSQL_YYABORT;
-            Select->options|= OPTION_FOUND_ROWS;
-          }
+          query_expression_option
         | SQL_NO_CACHE_SYM
           {
             Lex->safe_to_cache_query=0;
@@ -6620,7 +6599,6 @@ select_option:
               Lex->select_lex.sql_cache= SELECT_LEX::SQL_CACHE;
             }
           }
-        | ALL { Select->options|= SELECT_ALL; }
         ;
 
 select_lock_type:
@@ -8124,7 +8102,7 @@ select_part2_derived:
               mysql_init_select(lex);
             lex->current_select->parsing_place= SELECT_LIST;
           }
-          select_options select_item_list
+          opt_query_expression_options select_item_list
           {
             Select->parsing_place= NO_MATTER;
           }
@@ -12257,6 +12235,42 @@ subselect_end:
             lex->current_select->select_n_where_fields+=
             child->select_n_where_fields;
           }
+        ;
+
+opt_query_expression_options:
+          /* empty */
+        | query_expression_option_list
+        ;
+
+query_expression_option_list:
+          query_expression_option_list query_expression_option
+        | query_expression_option
+        ;
+
+query_expression_option:
+          STRAIGHT_JOIN { Select->options|= SELECT_STRAIGHT_JOIN; }
+        | HIGH_PRIORITY
+          {
+            if (check_simple_select())
+              MYSQL_YYABORT;
+            Lex->lock_option= TL_READ_HIGH_PRIORITY;
+          }
+        | DISTINCT         { Select->options|= SELECT_DISTINCT; }
+        | SQL_SMALL_RESULT { Select->options|= SELECT_SMALL_RESULT; }
+        | SQL_BIG_RESULT   { Select->options|= SELECT_BIG_RESULT; }
+        | SQL_BUFFER_RESULT
+          {
+            if (check_simple_select())
+              MYSQL_YYABORT;
+            Select->options|= OPTION_BUFFER_RESULT;
+          }
+        | SQL_CALC_FOUND_ROWS
+          {
+            if (check_simple_select())
+              MYSQL_YYABORT;
+            Select->options|= OPTION_FOUND_ROWS;
+          }
+        | ALL { Select->options|= SELECT_ALL; }
         ;
 
 /**************************************************************************
Thread
bk commit into 6.0 tree (mhansson:1.2609) BUG#35020mhansson10 Mar
  • Re: bk commit into 6.0 tree (mhansson:1.2609) BUG#35020Marc Alff13 Mar
  • Re: bk commit into 6.0 tree (mhansson:1.2609) BUG#35020Georgi Kodinov31 Mar