MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:November 27 2008 1:59pm
Subject:bzr commit into mysql-5.0-bugteam branch (Sergey.Glukhov:2716)
Bug#37460
View as plain text  
#At file:///home/gluh/MySQL/mysql-5.0-bugteam/ based on revid:sergey.glukhov@stripped

 2716 Sergey Glukhov	2008-11-27
      Bug#37460 Assertion failed: !table->file || table->file->inited == handler::NONE
      enable uncacheable flag if we update a view with check option
      and check option has a subselect, otherwise, the check option
      can be evaluated after the subselect was freed as independent
      (See full_local in JOIN::join_free())
modified:
  mysql-test/r/subselect.result
  mysql-test/t/subselect.test
  sql/mysql_priv.h
  sql/sql_update.cc

per-file messages:
  mysql-test/r/subselect.result
    test result
  mysql-test/t/subselect.test
    test case
  sql/mysql_priv.h
    added UNCACHEABLE_CHECKOPTION flag
  sql/sql_update.cc
    enable uncacheable flag if we update a view with check option
    and check option has a subselect, otherwise, the check option
    can be evaluated after the subselect was freed as independent
    (See full_local in JOIN::join_free())
=== modified file 'mysql-test/r/subselect.result'
--- a/mysql-test/r/subselect.result	2008-11-21 12:39:59 +0000
+++ b/mysql-test/r/subselect.result	2008-11-27 13:57:34 +0000
@@ -4422,4 +4422,34 @@ id
 2
 3
 DROP TABLE t1, t2;
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int, c int);
+INSERT INTO t1 (id) VALUES (1);
+INSERT INTO t2 (id) VALUES (1);
+INSERT INTO t1 (id) VALUES (1);
+INSERT INTO t2 (id) VALUES (1);
+CREATE VIEW v1 AS
+SELECT t2.c AS c FROM t1, t2
+WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
+UPDATE v1 SET c=1;
+CREATE VIEW v2 (a,b) AS
+SELECT t2.id, t2.c AS c FROM t1, t2
+WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
+INSERT INTO v2(a,b) VALUES (2,2);
+ERROR HY000: CHECK OPTION failed 'test.v2'
+INSERT INTO v2(a,b) VALUES (1,2);
+SELECT * FROM v1;
+c
+1
+1
+1
+1
+2
+2
+CREATE VIEW v3 AS
+SELECT t2.c AS c FROM t2
+WHERE 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
+DELETE FROM v3;
+DROP VIEW v1,v2,v3;
+DROP TABLE t1,t2;
 End of 5.0 tests.

=== modified file 'mysql-test/t/subselect.test'
--- a/mysql-test/t/subselect.test	2008-11-21 12:39:59 +0000
+++ b/mysql-test/t/subselect.test	2008-11-27 13:57:34 +0000
@@ -3325,4 +3325,39 @@ INSERT INTO t2 VALUES (2,1),(3,1);
 SELECT * FROM t1 i WHERE 1 IN (SELECT l.id2 FROM t2 l WHERE i.id=l.id1);
 DROP TABLE t1, t2;
 
+#
+# Bug#37460 Assertion failed:
+# !table->file || table->file->inited == handler::NONE
+#
+CREATE TABLE t1 (id int);
+CREATE TABLE t2 (id int, c int);
+
+INSERT INTO t1 (id) VALUES (1);
+INSERT INTO t2 (id) VALUES (1);
+INSERT INTO t1 (id) VALUES (1);
+INSERT INTO t2 (id) VALUES (1);
+
+CREATE VIEW v1 AS
+  SELECT t2.c AS c FROM t1, t2
+ WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
+UPDATE v1 SET c=1;
+
+CREATE VIEW v2 (a,b) AS
+  SELECT t2.id, t2.c AS c FROM t1, t2
+ WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
+
+--error 1369
+INSERT INTO v2(a,b) VALUES (2,2);
+INSERT INTO v2(a,b) VALUES (1,2);
+SELECT * FROM v1;
+
+CREATE VIEW v3 AS
+  SELECT t2.c AS c FROM t2
+ WHERE 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
+
+DELETE FROM v3;
+
+DROP VIEW v1,v2,v3;
+DROP TABLE t1,t2;
+
 --echo End of 5.0 tests.

=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h	2008-10-02 11:57:52 +0000
+++ b/sql/mysql_priv.h	2008-11-27 13:57:34 +0000
@@ -435,6 +435,7 @@ MY_LOCALE *my_locale_by_number(uint numb
 #define UNCACHEABLE_PREPARE    16
 /* For uncorrelated SELECT in an UNION with some correlated SELECTs */
 #define UNCACHEABLE_UNITED     32
+#define UNCACHEABLE_CHECKOPTION   64
 
 /* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
 #define UNDEF_POS (-1)

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2008-10-09 15:24:31 +0000
+++ b/sql/sql_update.cc	2008-11-27 13:57:34 +0000
@@ -1249,6 +1249,32 @@ multi_update::initialize_tables(JOIN *jo
       }
     }
 
+    /*
+      enable uncacheable flag if we update a view with check option
+      and check option has a subselect, otherwise, the check option
+      can be evaluated after the subselect was freed as independent
+      (See full_local in JOIN::join_free()).
+    */
+    if (table_ref->check_option && !join->select_lex->uncacheable)
+    {
+      SELECT_LEX_UNIT *tmp_unit;
+      SELECT_LEX *sl;
+      for (tmp_unit= join->select_lex->first_inner_unit();
+           tmp_unit;
+           tmp_unit= tmp_unit->next_unit())
+      {
+        for (sl= tmp_unit->first_select(); sl; sl= sl->next_select())
+        {
+          if (sl->master_unit()->item)
+          {
+            join->select_lex->uncacheable|= UNCACHEABLE_CHECKOPTION;
+            goto loop_end;
+          }
+        }
+      }
+    }
+loop_end:
+
     if (table == first_table_for_update && table_ref->check_option)
     {
       table_map unupdated_tables= table_ref->check_option->used_tables() &

Thread
bzr commit into mysql-5.0-bugteam branch (Sergey.Glukhov:2716)Bug#37460Sergey Glukhov27 Nov