MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Georgi Kodinov Date:October 26 2009 10:02am
Subject:bzr commit into mysql-5.1-bugteam branch (joro:3198) Bug#47788
View as plain text  
#At file:///home/kgeorge/mysql/work/B47788-5.1-bugteam/ based on revid:joro@stripped

 3198 Georgi Kodinov	2009-10-19
      Bug #47788: Crash in TABLE_LIST::hide_view_error on 
        UPDATE + VIEW + SP + MERGE + ALTER
      
      When cleaning up the stored procedure's internal 
      structures the flag to ignore the errors for 
      INSERT/UPDATE IGNORE was not cleaned up.
      As a result error ignoring was on during name 
      resolution. And this is an abnormal situation : the
      SELECT_LEX flag can be on only during query execution.
      
      Fixed by correctly cleaning up the SELECT_LEX flag 
      when reusing the SELECT_LEX in a second execution.

    modified:
      mysql-test/r/sp-error.result
      mysql-test/t/sp-error.test
      sql/sql_prepare.cc
=== modified file 'mysql-test/r/sp-error.result'
--- a/mysql-test/r/sp-error.result	2009-05-27 15:19:44 +0000
+++ b/mysql-test/r/sp-error.result	2009-10-19 13:55:04 +0000
@@ -1670,3 +1670,19 @@ NULL
 SELECT non_existent (a) FROM t1 WHERE b = 999999;
 ERROR 42000: FUNCTION test.non_existent does not exist
 DROP TABLE t1;
+#
+# Bug #47788: Crash in TABLE_LIST::hide_view_error on UPDATE + VIEW + 
+#   SP + MERGE + ALTER
+#
+CREATE TABLE t1 (pk INT, b INT, KEY (b));
+CREATE ALGORITHM = TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+CREATE PROCEDURE p1 (a int) UPDATE IGNORE v1 SET b = a;
+CALL p1(5);
+ERROR HY000: The target table v1 of the UPDATE is not updatable
+ALTER TABLE t1 CHANGE COLUMN b b2 INT;
+CALL p1(7);
+ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
+DROP PROCEDURE p1;
+DROP VIEW v1;
+DROP TABLE t1;
+End of 5.1 tests

=== modified file 'mysql-test/t/sp-error.test'
--- a/mysql-test/t/sp-error.test	2009-05-27 15:19:44 +0000
+++ b/mysql-test/t/sp-error.test	2009-10-19 13:55:04 +0000
@@ -2448,3 +2448,27 @@ SELECT AVG (a) FROM t1 WHERE b = 999999;
 --error ER_SP_DOES_NOT_EXIST
 SELECT non_existent (a) FROM t1 WHERE b = 999999;
 DROP TABLE t1;
+
+--echo #
+--echo # Bug #47788: Crash in TABLE_LIST::hide_view_error on UPDATE + VIEW + 
+--echo #   SP + MERGE + ALTER
+--echo #
+
+CREATE TABLE t1 (pk INT, b INT, KEY (b));
+CREATE ALGORITHM = TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+
+CREATE PROCEDURE p1 (a int) UPDATE IGNORE v1 SET b = a; 
+
+--error ER_NON_UPDATABLE_TABLE
+CALL p1(5);
+
+ALTER TABLE t1 CHANGE COLUMN b b2 INT;
+
+--error ER_VIEW_INVALID
+CALL p1(7);
+
+DROP PROCEDURE p1;
+DROP VIEW v1;
+DROP TABLE t1;
+
+--echo End of 5.1 tests

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2009-10-16 10:29:42 +0000
+++ b/sql/sql_prepare.cc	2009-10-19 13:55:04 +0000
@@ -2342,6 +2342,9 @@ void reinit_stmt_before_use(THD *thd, LE
       /* Fix ORDER list */
       for (order= (ORDER *)sl->order_list.first; order; order= order->next)
         order->item= &order->item_ptr;
+
+      /* clear the no_error flag for INSERT/UPDATE IGNORE */
+      sl->no_error= FALSE;
     }
     {
       SELECT_LEX_UNIT *unit= sl->master_unit();


Attachment: [text/bzr-bundle] bzr/joro@sun.com-20091019135504-e6fmhf4xyy0wdymb.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (joro:3198) Bug#47788Georgi Kodinov26 Oct