summaryrefslogtreecommitdiff
path: root/mysql-test/t/insert.test
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-01-22 15:14:38 +0300
committerunknown <evgen@moonbone.local>2007-01-22 15:14:38 +0300
commitdf0a08964718cf9ff8189e16fbee75397784596e (patch)
tree5adfda1a09692651c167ac57baa15ffbcaddd64a /mysql-test/t/insert.test
parentc6d4b94dd452d31f49430321a16690f7bec06d5c (diff)
downloadmariadb-git-df0a08964718cf9ff8189e16fbee75397784596e.tar.gz
Bug#25123: ON DUPLICATE KEY clause allows fields not from the insert table.
When inserting into a join-based view the update fields from the ON DUPLICATE KEY UPDATE wasn't checked to be from the table being inserted into and were silently ignored. The new check_view_single_update() function is added to check that insert/update fields are being from the same single table of the view. sql/sql_insert.cc: Bug#25123: ON DUPLICATE KEY clause allows fields not from the insert table. The new check_view_single_update() function is added to check that insert/update fields are being from the same single table of the view. mysql-test/r/insert.result: Added a test case for bug#25123: ON DUPLICATE KEY clause allows fields not from the insert table. mysql-test/t/insert.test: Added a test case for bug#25123: ON DUPLICATE KEY clause allows fields not from the insert table.
Diffstat (limited to 'mysql-test/t/insert.test')
-rw-r--r--mysql-test/t/insert.test18
1 files changed, 18 insertions, 0 deletions
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test
index 029c4d19e63..0a8e184ea5c 100644
--- a/mysql-test/t/insert.test
+++ b/mysql-test/t/insert.test
@@ -198,3 +198,21 @@ select row_count();
insert into t1 values (5, 5) on duplicate key update data= data + 10;
select row_count();
drop table t1;
+
+#
+# Bug#25123: ON DUPLICATE KEY clause allows fields not from the insert table
+#
+create table t1 (f1 int unique, f2 int);
+create table t2 (f3 int, f4 int);
+create view v1 as select * from t1, t2 where f1= f3;
+insert into t1 values (1,11), (2,22);
+insert into t2 values (1,12), (2,24);
+--error 1393
+insert into v1 (f1) values (3) on duplicate key update f3= f3 + 10;
+insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
+select * from t1;
+insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10;
+select * from t1;
+drop view v1;
+drop table t1,t2;
+