MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Kristofer Pettersson Date:March 24 2010 4:37pm
Subject:bzr commit into mysql-5.1-bugteam branch (kristofer.pettersson:3368)
Bug#46615
View as plain text  
#At file:///home/thek/bzr/51-bug46615/ based on revid:staale.smedseng@stripped

 3368 Kristofer Pettersson	2010-03-24
      Bug#46615 Assertion in Query_cache::invalidate in INSERT in a VIEW of a MERGE table
      
      If the listed columns in the view definition of 
      the table used in a 'INSERT .. SELECT ..'
      statement mismatched, a debug assertion would
      trigger in the cache invalidation code
      following the failing statement.
      
      Although the find_field_in_view() function
      correctly generated ER_BAD_FIELD_ERROR during
      setup_fields(), the error failed to propagate
      further than handle_select(). This patch fixes
      the issue by adding a check for the return
      value.
     @ mysql-test/r/query_cache_with_views.result
        * added test for bug 46615
     @ mysql-test/t/query_cache_with_views.test
        * added test for bug 46615
     @ sql/sql_parse.cc
        * added check for handle_select() return code before attempting to invalidate the cache.

    modified:
      mysql-test/r/query_cache_with_views.result
      mysql-test/t/query_cache_with_views.test
      sql/sql_parse.cc
=== modified file 'mysql-test/r/query_cache_with_views.result'
--- a/mysql-test/r/query_cache_with_views.result	2007-08-21 11:43:09 +0000
+++ b/mysql-test/r/query_cache_with_views.result	2010-03-24 16:37:41 +0000
@@ -193,4 +193,17 @@ show status like "Qcache_hits";
 Variable_name	Value
 Qcache_hits	2
 drop table t1;
+#
+# Bug46615 Assertion in Query_cache::invalidate in INSERT in a VIEW of a MERGE table
+#
+CREATE TABLE t1 (c1 INT, c2 INT);
+CREATE TABLE t2 LIKE t1;
+SET AUTOCOMMIT=OFF;
+CREATE VIEW t1_view AS SELECT c1 FROM t1 NATURAL JOIN t2 ;
+INSERT INTO t1_view (c1, c2) SELECT c1, c2 FROM t1;
+ERROR 42S22: Unknown column 'c2' in 'field list'
+DROP TABLE t1;
+DROP TABLE t2;
+DROP VIEW t1_view;
+SET AUTOCOMMIT=DEFAULT;
 set GLOBAL query_cache_size=default;

=== modified file 'mysql-test/t/query_cache_with_views.test'
--- a/mysql-test/t/query_cache_with_views.test	2007-08-21 11:43:09 +0000
+++ b/mysql-test/t/query_cache_with_views.test	2010-03-24 16:37:41 +0000
@@ -126,5 +126,22 @@ show status like "Qcache_inserts";
 show status like "Qcache_hits";
 drop table t1;
 
+--echo #
+--echo # Bug46615 Assertion in Query_cache::invalidate in INSERT in a VIEW of a MERGE table
+--echo #
+CREATE TABLE t1 (c1 INT, c2 INT);
+CREATE TABLE t2 LIKE t1;
+SET AUTOCOMMIT=OFF;
+CREATE VIEW t1_view AS SELECT c1 FROM t1 NATURAL JOIN t2 ;
+# Before the bug patch the below INSERT stmt used to 
+# crash when other fields than the ones listed in the
+# view definition were used.
+--error ER_BAD_FIELD_ERROR
+INSERT INTO t1_view (c1, c2) SELECT c1, c2 FROM t1; 
+DROP TABLE t1;
+DROP TABLE t2;
+DROP VIEW t1_view;
+SET AUTOCOMMIT=DEFAULT;
+
 # Reset default environment.
 set GLOBAL query_cache_size=default;

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2010-02-25 15:12:15 +0000
+++ b/sql/sql_parse.cc	2010-03-24 16:37:41 +0000
@@ -3241,7 +3241,7 @@ end_with_restore_list:
           TODO: this is workaround. right way will be move invalidating in
           the unlock procedure.
         */
-        if (first_table->lock_type ==  TL_WRITE_CONCURRENT_INSERT &&
+        if (!res && first_table->lock_type ==  TL_WRITE_CONCURRENT_INSERT &&
             thd->lock)
         {
           /* INSERT ... SELECT should invalidate only the very first table */


Attachment: [text/bzr-bundle]
Thread
bzr commit into mysql-5.1-bugteam branch (kristofer.pettersson:3368)Bug#46615Kristofer Pettersson24 Mar