Skip to content

Commit f3d8a54

Browse files
committed
MDEV-30345 DML does not find rows it is supposed to
This only happens with 'timestamp_column IN (select ...) The reason was a missing assignment in Item_cache_timestamp::cache_value()
1 parent fdcfc25 commit f3d8a54

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

mysql-test/main/cache_temporal_4265.result

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,21 @@ select (select max(m2.ut) from t1 m2 where m1.id <> 0) from t1 m1;
2020
2001-01-01 00:00:00.200000
2121
2001-01-01 00:00:00.200000
2222
drop table t1;
23+
#
24+
# MDEV-30345 DML does not find rows it is supposed to
25+
#
26+
CREATE TABLE t1 (f timestamp);
27+
INSERT INTO t1 VALUES ('2022-01-01 00:00:00'),('2022-12-12 12:12:12');
28+
CREATE TABLE t2 (f timestamp);
29+
INSERT INTO t2 VALUES ('2022-01-01 00:00:00'),('2022-12-12 12:12:12');
30+
SELECT * FROM t2 WHERE f IN ( SELECT f FROM t1 ) ;
31+
f
32+
2022-01-01 00:00:00
33+
2022-12-12 12:12:12
34+
DELETE FROM t2 WHERE f IN ( SELECT f FROM t1 ) ;
35+
SELECT * FROM t2 WHERE f IN ( SELECT f FROM t1 ) ;
36+
f
37+
DROP TABLE t1,t2;
38+
#
39+
# End of 10.4 tests
40+
#

mysql-test/main/cache_temporal_4265.test

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,21 @@ select * from t1;
2020
select (select max(m2.ut) from t1 m2 where m1.id <> 0) from t1 m1;
2121
drop table t1;
2222

23+
--echo #
24+
--echo # MDEV-30345 DML does not find rows it is supposed to
25+
--echo #
26+
27+
CREATE TABLE t1 (f timestamp);
28+
INSERT INTO t1 VALUES ('2022-01-01 00:00:00'),('2022-12-12 12:12:12');
29+
30+
CREATE TABLE t2 (f timestamp);
31+
INSERT INTO t2 VALUES ('2022-01-01 00:00:00'),('2022-12-12 12:12:12');
32+
33+
SELECT * FROM t2 WHERE f IN ( SELECT f FROM t1 ) ;
34+
DELETE FROM t2 WHERE f IN ( SELECT f FROM t1 ) ;
35+
SELECT * FROM t2 WHERE f IN ( SELECT f FROM t1 ) ;
36+
DROP TABLE t1,t2;
37+
38+
--echo #
39+
--echo # End of 10.4 tests
40+
--echo #

sql/item.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10225,8 +10225,8 @@ bool Item_cache_timestamp::cache_value()
1022510225
if (!example)
1022610226
return false;
1022710227
value_cached= true;
10228-
null_value= example->val_native_with_conversion_result(current_thd, &m_native,
10229-
type_handler());
10228+
null_value_inside= null_value=
10229+
example->val_native_with_conversion_result(current_thd, &m_native, type_handler());
1023010230
return true;
1023110231
}
1023210232

0 commit comments

Comments
 (0)