summaryrefslogtreecommitdiff
path: root/mysql-test/t/update.test
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2015-11-03 09:31:20 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2015-11-05 17:50:59 +0100
commit5041de97e15e4af05003a8c6c14bfff106da570b (patch)
tree4937735c3ae99e1df7732ffa9f12c94d18f2910e /mysql-test/t/update.test
parentd9119710c44d0cd785447080c43bf3c2ba2e4cac (diff)
downloadmariadb-git-5041de97e15e4af05003a8c6c14bfff106da570b.tar.gz
MDEV-8701 Crash on derived query
Make unique table check after setup_fields of update because unique table can materialize table and we do not need field resolving after materialization.
Diffstat (limited to 'mysql-test/t/update.test')
-rw-r--r--mysql-test/t/update.test41
1 files changed, 41 insertions, 0 deletions
diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test
index 05f9ce39bec..c0334a75bff 100644
--- a/mysql-test/t/update.test
+++ b/mysql-test/t/update.test
@@ -580,4 +580,45 @@ show status like 'Handler_read%';
drop table t1, t2;
+--echo #
+--echo #MDEV-8701: Crash on derived query
+--echo #
+
+CREATE TABLE t1 (
+ data_exit_entry_id int(11) NOT NULL,
+ data_entry_id int(11) NOT NULL,
+ data_entry_exit_id int(11) NOT NULL,
+ data_exit_entry_quantity double NOT NULL
+) DEFAULT CHARSET=utf8;
+
+CREATE TABLE t2 (
+ data_entry_id int(11) NOT NULL,
+ data_entry_cost double NOT NULL,
+ data_entry_quantity double NOT NULL
+) DEFAULT CHARSET=utf8;
+
+create algorithm=temptable view v1 as SELECT data_entry_exit_id, data_exit_entry_quantity, data_entry_cost
+ FROM t1 INNER JOIN t2 as dt ON dt.data_entry_id = t1.data_entry_id;
+
+UPDATE t2
+SET data_entry_cost
+ = ( ( SELECT SUM(data_exit_entry_quantity * data_entry_cost)
+ FROM
+ v1 AS query
+ WHERE data_entry_exit_id = t2.data_entry_id
+ )
+ );
+
+UPDATE t2
+SET data_entry_cost
+ = ( ( SELECT SUM(data_exit_entry_quantity * data_entry_cost)
+ FROM
+ ( SELECT data_entry_exit_id, data_exit_entry_quantity, data_entry_cost
+ FROM t1 INNER JOIN t2 as dt ON dt.data_entry_id = t1.data_entry_id) AS query
+ WHERE data_entry_exit_id = t2.data_entry_id
+ )
+ );
+
+drop view v1;
+drop table t1, t2;
--echo # End of MariaDB 10.0 tests