summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristofer Pettersson <kristofer.pettersson@sun.com>2010-03-25 13:26:48 +0100
committerKristofer Pettersson <kristofer.pettersson@sun.com>2010-03-25 13:26:48 +0100
commit61b9ce16fd9dcf180fa8109682b75b1494bf09ee (patch)
tree95859f02174fee49bc73ec902502aabc7d0b375f
parent5a9bad95a9c2db05f2e10b432ef52f5dc65e9b9b (diff)
parentea7d830ad2c5715597d2d7e55215263f0fd8ba7c (diff)
downloadmariadb-git-61b9ce16fd9dcf180fa8109682b75b1494bf09ee.tar.gz
Automerge
-rw-r--r--mysql-test/r/query_cache_with_views.result13
-rw-r--r--mysql-test/t/query_cache_with_views.test17
-rw-r--r--sql/sql_parse.cc2
3 files changed, 31 insertions, 1 deletions
diff --git a/mysql-test/r/query_cache_with_views.result b/mysql-test/r/query_cache_with_views.result
index 03430bd504b..7f0417a60c7 100644
--- a/mysql-test/r/query_cache_with_views.result
+++ b/mysql-test/r/query_cache_with_views.result
@@ -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;
diff --git a/mysql-test/t/query_cache_with_views.test b/mysql-test/t/query_cache_with_views.test
index d4ebe45b7ac..97e37c53aa3 100644
--- a/mysql-test/t/query_cache_with_views.test
+++ b/mysql-test/t/query_cache_with_views.test
@@ -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;
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 168b16c61bf..5228a37f490 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -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 */