Below is the list of changes that have just been committed into a local
4.1 repository of kgeorge. When kgeorge does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-09-08 10:24:14+03:00, gkodinov@stripped +3 -0
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@stripped, 2006-09-08 10:24:07+03:00, gkodinov@stripped
+24 -2
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@stripped, 2006-09-08 10:24:07+03:00, gkodinov@stripped
+23 -0
Bug#21555: incorrect behavior with INSERT ... ON DUPL KEY UPDATE and VALUES
- test case.
sql/item.h@stripped, 2006-09-08 10:24:08+03:00, gkodinov@stripped +5 -1
Bug#21555: incorrect behavior with INSERT ... ON DUPL KEY UPDATE and VALUES
- mark Item_insert_value as non-constant to prevent early calculation.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: gkodinov
# Host: macbook.gmz
# Root: /Users/kgeorge/mysql/work/B21555-4.1-opt
--- 1.195/sql/item.h 2006-09-08 10:24:26 +03:00
+++ 1.196/sql/item.h 2006-09-08 10:24:26 +03:00
@@ -1241,7 +1241,11 @@ public:
{
return Item_field::save_in_field(field_arg, no_conversions);
}
- table_map used_tables() const { return (table_map)0L; }
+ /*
+ We use RAND_TABLE_BIT to prevent Item_insert_value from
+ being treated as a constant and precalculated before execution
+ */
+ table_map used_tables() const { return RAND_TABLE_BIT; }
bool walk(Item_processor processor, byte *args)
{
--- 1.16/mysql-test/r/insert_update.result 2006-09-08 10:24:26 +03:00
+++ 1.17/mysql-test/r/insert_update.result 2006-09-08 10:24:26 +03:00
@@ -63,9 +63,9 @@ Warnings:
Note 1003 select test.t1.a AS `a`,test.t1.b AS `b`,test.t1.c AS `c`,values(test.t1.a) AS
`VALUES(a)` from test.t1
explain extended select * from t1 where values(a);
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
Warnings:
-Note 1003 select test.t1.a AS `a`,test.t1.b AS `b`,test.t1.c AS `c` from test.t1
+Note 1003 select test.t1.a AS `a`,test.t1.b AS `b`,test.t1.c AS `c` from test.t1 where
values(test.t1.a)
DROP TABLE t1;
create table t1(a int primary key, b int);
insert into t1 values(1,1),(2,2),(3,3),(4,4),(5,5);
@@ -196,4 +196,26 @@ a BIGINT(20) NOT NULL DEFAULT 0,
PRIMARY KEY (a)
) ENGINE=MyISAM;
INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a) ;
+DROP TABLE t1;
+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;
+a b
+45 1
+INSERT INTO t1 VALUES (45, 2) ON DUPLICATE KEY UPDATE b =
+IF(VALUES(b) > t1.b, VALUES(b), t1.b);
+SELECT * FROM t1;
+a b
+45 2
+INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
+IF(VALUES(b) > t1.b, VALUES(b), t1.b);
+SELECT * FROM t1;
+a b
+45 2
DROP TABLE t1;
--- 1.17/mysql-test/t/insert_update.test 2006-09-08 10:24:26 +03:00
+++ 1.18/mysql-test/t/insert_update.test 2006-09-08 10:24:26 +03:00
@@ -115,4 +115,27 @@ INSERT INTO t1 ( a ) SELECT 0 ON DUPLICA
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;
| Thread |
|---|
| • bk commit into 4.1 tree (gkodinov:1.2566) BUG#21555 | kgeorge | 8 Sep |