List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:September 21 2010 11:33am
Subject:bzr commit into mysql-5.5-runtime branch (jon.hauglid:3141) Bug#54920
View as plain text  
#At file:///export/home/x/mysql-5.5-runtime-bug54920/ based on revid:jon.hauglid@stripped

 3141 Jon Olav Hauglid	2010-09-21
      Bug #54920 Stored functions are allowed in HANDLER statements,
                 but broken.
      
      Before this patch, it was allowed to use stored functions in
      HANDLER ... READ statements. The problem was that this functionality
      was not really supported by the code. Proper locking would for example
      not be performed, and it was also possible to break replication by
      having stored functions that performed updates.
      
      This patch disallows the use of stored functions in HANDLER ... READ.
      Any such statement will now give a syntax error. This is an incompatible
      change and should be reflected in the documentation.
      
      Test case added to handler_myisam/handler_innodb.test.

    modified:
      mysql-test/include/handler.inc
      mysql-test/r/handler_innodb.result
      mysql-test/r/handler_myisam.result
      sql/sql_yacc.yy
=== modified file 'mysql-test/include/handler.inc'
--- a/mysql-test/include/handler.inc	2010-08-12 13:50:23 +0000
+++ b/mysql-test/include/handler.inc	2010-09-21 11:33:55 +0000
@@ -1809,9 +1809,32 @@ CREATE TABLE t1(a INT);
 INSERT INTO t1 VALUES (1);
 HANDLER t1 OPEN;
 # This used to cause the assert
---error ER_NO_SUCH_TABLE
+--error ER_PARSE_ERROR
 HANDLER t1 READ FIRST WHERE f1() = 1;
 HANDLER t1 CLOSE;
 
 DROP FUNCTION f1;
 DROP TABLE t1;
+
+
+--echo #
+--echo # Bug#54920 Stored functions are allowed in HANDLER statements,
+--echo #           but broken.
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2);
+CREATE FUNCTION f1() RETURNS INT RETURN 1;
+HANDLER t1 OPEN;
+
+--error ER_PARSE_ERROR
+HANDLER t1 READ FIRST WHERE f1() = 1;
+
+HANDLER t1 CLOSE;
+DROP FUNCTION f1;
+DROP TABLE t1;

=== modified file 'mysql-test/r/handler_innodb.result'
--- a/mysql-test/r/handler_innodb.result	2010-07-05 11:59:34 +0000
+++ b/mysql-test/r/handler_innodb.result	2010-09-21 11:33:55 +0000
@@ -1726,7 +1726,22 @@ CREATE TABLE t1(a INT);
 INSERT INTO t1 VALUES (1);
 HANDLER t1 OPEN;
 HANDLER t1 READ FIRST WHERE f1() = 1;
-ERROR 42S02: Table 'test.t2' doesn't exist
+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 '' at line 1
+HANDLER t1 CLOSE;
+DROP FUNCTION f1;
+DROP TABLE t1;
+#
+# Bug#54920 Stored functions are allowed in HANDLER statements,
+#           but broken.
+#
+DROP TABLE IF EXISTS t1;
+DROP FUNCTION IF EXISTS f1;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2);
+CREATE FUNCTION f1() RETURNS INT RETURN 1;
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST WHERE f1() = 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 '' at line 1
 HANDLER t1 CLOSE;
 DROP FUNCTION f1;
 DROP TABLE t1;

=== modified file 'mysql-test/r/handler_myisam.result'
--- a/mysql-test/r/handler_myisam.result	2010-07-05 11:59:34 +0000
+++ b/mysql-test/r/handler_myisam.result	2010-09-21 11:33:55 +0000
@@ -1722,7 +1722,22 @@ CREATE TABLE t1(a INT);
 INSERT INTO t1 VALUES (1);
 HANDLER t1 OPEN;
 HANDLER t1 READ FIRST WHERE f1() = 1;
-ERROR 42S02: Table 'test.t2' doesn't exist
+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 '' at line 1
+HANDLER t1 CLOSE;
+DROP FUNCTION f1;
+DROP TABLE t1;
+#
+# Bug#54920 Stored functions are allowed in HANDLER statements,
+#           but broken.
+#
+DROP TABLE IF EXISTS t1;
+DROP FUNCTION IF EXISTS f1;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2);
+CREATE FUNCTION f1() RETURNS INT RETURN 1;
+HANDLER t1 OPEN;
+HANDLER t1 READ FIRST WHERE f1() = 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 '' at line 1
 HANDLER t1 CLOSE;
 DROP FUNCTION f1;
 DROP TABLE t1;

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2010-09-09 14:29:14 +0000
+++ b/sql/sql_yacc.yy	2010-09-21 11:33:55 +0000
@@ -13245,6 +13245,12 @@ handler:
           handler_read_or_scan where_clause opt_limit_clause
           {
             Lex->expr_allows_subselect= TRUE;
+            /* Stored functions are not supported for HANDLER READ. */
+            if (Lex->uses_stored_routines())
+            {
+              my_parse_error(ER(ER_SYNTAX_ERROR));
+              MYSQL_YYABORT;
+            }
           }
         ;
 


Attachment: [text/bzr-bundle] bzr/jon.hauglid@oracle.com-20100921113355-u5z1ifg7fvdqyu8j.bundle
Thread
bzr commit into mysql-5.5-runtime branch (jon.hauglid:3141) Bug#54920Jon Olav Hauglid21 Sep
  • Re: bzr commit into mysql-5.5-runtime branch (jon.hauglid:3141)Bug#54920Dmitry Lenev23 Sep