[MDEV-30033] Assertion `0' failed in Field_new_decimal::get_equal_const_item Created: 2022-11-18  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: Server
Affects Version/s: 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
Labels: None


 Description   

CREATE TABLE t (a DECIMAL(5,2), b INT);
SELECT * FROM t WHERE a <= SOME (SELECT 8 UNION SELECT 5) AND a = (SELECT SUM(b) FROM t);
 
# Cleanup
DROP TABLE t;

10.3 df4c3d96

mysqld: /src/sql/field.cc:3624: virtual Item* Field_new_decimal::get_equal_const_item(THD*, const Value_source::Context&, Item*): Assertion `0' failed.
221118 16:32:15 [ERROR] mysqld got signal 6 ;
 
#7  0x00007fcd5cbae662 in __GI___assert_fail (assertion=0x55a51741fa20 "0", file=0x55a517421fc0 "/src/sql/field.cc", line=3624, function=0x55a517424620 "virtual Item* Field_new_decimal::get_equal_const_item(THD*, const Value_source::Context&, Item*)") at assert.c:101
#8  0x000055a515b95126 in Field_new_decimal::get_equal_const_item (this=0x619000081700, thd=0x62a000060208, ctx=..., const_item=0x62b000003e28) at /src/sql/field.cc:3624
#9  0x000055a515ca30f1 in Item_field::propagate_equal_fields (this=0x62b000000ba8, thd=0x62a000060208, ctx=..., arg=0x62b000004260) at /src/sql/item.cc:6552
#10 0x000055a515caaa91 in Item::propagate_equal_fields_and_change_item_tree (this=0x62b000000ba8, thd=0x62a000060208, ctx=..., cond=0x62b000004260, place=0x62b0000056f8) at /src/sql/item.cc:7593
#11 0x000055a515d690b0 in Item_args::propagate_equal_fields (this=0x62b0000056f0, thd=0x62a000060208, ctx=..., cond=0x62b000004260) at /src/sql/item_func.cc:561
#12 0x000055a515392d02 in Item_func::propagate_equal_fields (this=0x62b000005668, thd=0x62a000060208, ctx=..., cond=0x62b000004260) at /src/sql/item_func.h:324
#13 0x000055a515caaa91 in Item::propagate_equal_fields_and_change_item_tree (this=0x62b000005668, thd=0x62a000060208, ctx=..., cond=0x62b000004260, place=0x62b0000025f8) at /src/sql/item.cc:7593
#14 0x000055a515d690b0 in Item_args::propagate_equal_fields (this=0x62b0000025f0, thd=0x62a000060208, ctx=..., cond=0x62b000004260) at /src/sql/item_func.cc:561
#15 0x000055a515392d02 in Item_func::propagate_equal_fields (this=0x62b000002568, thd=0x62a000060208, ctx=..., cond=0x62b000004260) at /src/sql/item_func.h:324
#16 0x000055a5155e274f in Item_func::build_equal_items (this=0x62b000002568, thd=0x62a000060208, inherited=0x62b000004260, link_item_fields=false, cond_equal_ref=0x0) at /src/sql/sql_select.cc:14649
#17 0x000055a5155e117e in Item_cond_and::build_equal_items (this=0x62b000004178, thd=0x62a000060208, inherited=0x62b000004260, link_item_fields=true, cond_equal_ref=0x62b000004830) at /src/sql/sql_select.cc:14504
#18 0x000055a5155e2c99 in build_equal_items (join=0x62b0000043f8, cond=0x62b000004178, inherited=0x0, join_list=0x62a000064a20, ignore_on_conds=false, cond_equal_ref=0x62b000004830, link_equal_fields=true) at /src/sql/sql_select.cc:14751
#19 0x000055a5155ec18e in optimize_cond (join=0x62b0000043f8, conds=0x62b000004178, join_list=0x62a000064a20, ignore_on_conds=false, cond_value=0x62b000004708, cond_equal=0x62b000004830, flags=1) at /src/sql/sql_select.cc:16397
#20 0x000055a51557fc27 in JOIN::optimize_inner (this=0x62b0000043f8) at /src/sql/sql_select.cc:1787
#21 0x000055a51557d256 in JOIN::optimize (this=0x62b0000043f8) at /src/sql/sql_select.cc:1542
#22 0x000055a51559a56b in mysql_select (thd=0x62a000060208, tables=0x62b0000004e0, wild_num=1, fields=..., conds=0x62b000004178, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x62b0000043c8, unit=0x62a0000640c0, select_lex=0x62a000064880) at /src/sql/sql_select.cc:4368
#23 0x000055a515570f0b in handle_select (thd=0x62a000060208, lex=0x62a000064000, result=0x62b0000043c8, setup_tables_done_option=0) at /src/sql/sql_select.cc:372
#24 0x000055a5154e5d79 in execute_sqlcom_select (thd=0x62a000060208, all_tables=0x62b0000004e0) at /src/sql/sql_parse.cc:6340
#25 0x000055a5154d3e4a in mysql_execute_command (thd=0x62a000060208) at /src/sql/sql_parse.cc:3871
#26 0x000055a5154ef676 in mysql_parse (thd=0x62a000060208, rawbuf=0x62b000000228 "SELECT * FROM t WHERE a <= SOME (SELECT 8 UNION SELECT 5) AND a = (SELECT SUM(b) FROM t)", length=88, parser_state=0x7fcd51fc4950, is_com_multi=false, is_next_command=false) at /src/sql/sql_parse.cc:7855
#27 0x000055a5154c6cc4 in dispatch_command (command=COM_QUERY, thd=0x62a000060208, packet=0x6290000eb209 "SELECT * FROM t WHERE a <= SOME (SELECT 8 UNION SELECT 5) AND a = (SELECT SUM(b) FROM t)", packet_length=88, is_com_multi=false, is_next_command=false) at /src/sql/sql_parse.cc:1852
#28 0x000055a5154c387c in do_command (thd=0x62a000060208) at /src/sql/sql_parse.cc:1398
#29 0x000055a515887236 in do_handle_one_connection (connect=0x608000000ca8) at /src/sql/sql_connect.cc:1403
#30 0x000055a515886b32 in handle_one_connection (arg=0x608000000ca8) at /src/sql/sql_connect.cc:1308
#31 0x000055a516e3388d in pfs_spawn_thread (arg=0x615000004e08) at /src/storage/perfschema/pfs.cc:1869
#32 0x00007fcd5cd59ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
#33 0x00007fcd5cc79aef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Reproducible on all 10.3+ (also previous minor releases), with at least MyISAM and InnoDB.



 Comments   
Comment by Oleksandr Byelkin [ 2023-09-26 ]

bar as author of e7dcec5471eb708b658c163813f0b67a32b564c3 you maybe better know what is wrong, if it is not related to you bug just explain what is wrong and return

Comment by Alexander Barkov [ 2023-09-27 ]

It's also reproducible with a slightly simpler script:

CREATE OR REPLACE TABLE t1 (a DECIMAL(5,2), b INT);
SELECT * FROM t1 WHERE a < a*2 AND a = (SELECT SUM(b) FROM t1);

Generated at Thu Feb 08 10:13:08 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.