Skip to content

Commit 1a3859f

Browse files
committed
MDEV-29924 Assertion `(((nr) % (1LL << 24)) % (int) log_10_int[6 - dec]) == 0' failed in my_time_packed_to_binary on SELECT when using TIME field
when assigning the cached item to the Item_cache for the first time make sure to use Item_cache::setup(), not Item_cache::store(). Because the former copies the metadata (and allocates memory, in case of Item_cache_row), and Item_cache::decimal must be set for comparisons to work correctly.
1 parent 29633dc commit 1a3859f

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

mysql-test/main/type_time_hires.result

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ select cast(1e-6 as time(6));
360360
cast(1e-6 as time(6))
361361
00:00:00.000001
362362
#
363-
# Start of 10.4 tests
363+
# End of 5.5 tests
364364
#
365365
#
366366
# MDEV-20397 Support TIMESTAMP, DATETIME, TIME in ROUND() and TRUNCATE()
@@ -907,3 +907,14 @@ a CEILING(a) CEILING_SP(a) CEILING(a)=CEILING_SP(a)
907907
DROP FUNCTION FLOOR_SP;
908908
DROP FUNCTION CEILING_SP;
909909
DROP TABLE t1;
910+
#
911+
# MDEV-29924 Assertion `(((nr) % (1LL << 24)) % (int) log_10_int[6 - dec]) == 0' failed in my_time_packed_to_binary on SELECT when using TIME field
912+
#
913+
create table t1 (c decimal(3,1),d time(6));
914+
insert into t1 values (null,0.1),(null,0.1), (0.1,0.2);
915+
select c from t1 where c<all (select d from t1);
916+
c
917+
drop table t1;
918+
#
919+
# End of 10.4 tests
920+
#

mysql-test/main/type_time_hires.test

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ drop table t1;
1111

1212
select cast(1e-6 as time(6));
1313

14-
1514
--echo #
16-
--echo # Start of 10.4 tests
15+
--echo # End of 5.5 tests
1716
--echo #
1817

1918
--echo #
@@ -196,3 +195,15 @@ DROP FUNCTION FLOOR_SP;
196195
DROP FUNCTION CEILING_SP;
197196

198197
DROP TABLE t1;
198+
199+
--echo #
200+
--echo # MDEV-29924 Assertion `(((nr) % (1LL << 24)) % (int) log_10_int[6 - dec]) == 0' failed in my_time_packed_to_binary on SELECT when using TIME field
201+
--echo #
202+
create table t1 (c decimal(3,1),d time(6));
203+
insert into t1 values (null,0.1),(null,0.1), (0.1,0.2);
204+
select c from t1 where c<all (select d from t1);
205+
drop table t1;
206+
207+
--echo #
208+
--echo # End of 10.4 tests
209+
--echo #

sql/sql_class.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3753,8 +3753,10 @@ int select_max_min_finder_subselect::send_data(List<Item> &items)
37533753
{
37543754
cache= val_item->get_cache(thd);
37553755
set_op(val_item->type_handler());
3756+
cache->setup(thd, val_item);
37563757
}
3757-
cache->store(val_item);
3758+
else
3759+
cache->store(val_item);
37583760
it->store(0, cache);
37593761
}
37603762
it->assigned(1);

0 commit comments

Comments
 (0)