summaryrefslogtreecommitdiff
path: root/mysql-test/t/insert_update.test
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@macbook.gmz>2006-09-08 10:24:14 +0300
committerunknown <gkodinov/kgeorge@macbook.gmz>2006-09-08 10:24:14 +0300
commit54caf667ca45de1e81d306177147b53aab03fdff (patch)
treee893633ca30173920f8516931dde0ccf0c3831ad /mysql-test/t/insert_update.test
parentb527a75e01b128f9e171e144c7658f8d8c5f0716 (diff)
downloadmariadb-git-54caf667ca45de1e81d306177147b53aab03fdff.tar.gz
Bug#21555: incorrect behavior with INSERT ... ON DUPL KEY UPDATE and VALUES
VALUES() was considered a constant. This caused replacing (or pre-calculating) it using uninitialized values before the actual execution takes place. Mark it as a non-constant (still not dependent of tables) to prevent the pre-calculation. mysql-test/r/insert_update.result: Bug#21555: incorrect behavior with INSERT ... ON DUPL KEY UPDATE and VALUES - test case. - EXPLAIN output changed due to VALUES() not being considered a constant anymore mysql-test/t/insert_update.test: Bug#21555: incorrect behavior with INSERT ... ON DUPL KEY UPDATE and VALUES - test case. sql/item.h: Bug#21555: incorrect behavior with INSERT ... ON DUPL KEY UPDATE and VALUES - mark Item_insert_value as non-constant to prevent early calculation.
Diffstat (limited to 'mysql-test/t/insert_update.test')
-rw-r--r--mysql-test/t/insert_update.test23
1 files changed, 23 insertions, 0 deletions
diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test
index 8038bd7bfe7..56885a555fd 100644
--- a/mysql-test/t/insert_update.test
+++ b/mysql-test/t/insert_update.test
@@ -115,4 +115,27 @@ INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a) ;
DROP TABLE t1;
+#
+# Bug#21555: incorrect behavior with INSERT ... ON DUPL KEY UPDATE and VALUES
+#
+
+
# End of 4.1 tests
+CREATE TABLE t1
+(
+ a BIGINT UNSIGNED,
+ b BIGINT UNSIGNED,
+ PRIMARY KEY (a)
+);
+
+INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
+ IF(VALUES(b) > t1.b, VALUES(b), t1.b);
+SELECT * FROM t1;
+INSERT INTO t1 VALUES (45, 2) ON DUPLICATE KEY UPDATE b =
+ IF(VALUES(b) > t1.b, VALUES(b), t1.b);
+SELECT * FROM t1;
+INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
+ IF(VALUES(b) > t1.b, VALUES(b), t1.b);
+SELECT * FROM t1;
+
+DROP TABLE t1;