[MDEV-26940] Assertion `0' failed in get_field_item_for_having Created: 2021-10-29  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: Optimizer, Views
Affects Version/s: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 11.0
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Sergei Petrunia
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates

 Description   

CREATE TABLE t (f INT);
INSERT INTO t VALUES (1),(2); # Optional, fails either way
CREATE VIEW v1 AS SELECT COUNT(*) as c FROM t;
CREATE VIEW v2 AS SELECT a2.c FROM v1 AS a1, v1 AS a2 WHERE a1.c = a2.c OR a2.c <= 10;
SELECT c FROM v2 WHERE c = 83;
 
# Cleanup
DROP VIEW v2;
DROP VIEW v1;
DROP TABLE t;

10.4 fcca0c67

mysqld: /data/src/10.4/sql/item.cc:7587: Item* get_field_item_for_having(THD*, Item*, st_select_lex*): Assertion `0' failed.
211029 19:39:28 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f3e40c09f36 in __GI___assert_fail (assertion=0x55c3ef657f07 "0", file=0x55c3ef658d34 "/data/src/10.4/sql/item.cc", line=7587, function=0x55c3ef65b0f0 "Item* get_field_item_for_having(THD*, Item*, st_select_lex*)") at assert.c:101
#8  0x000055c3eeb3b947 in get_field_item_for_having (thd=0x7f3de0000d90, item=0x7f3de00537a8, sel=0x7f3de0071be8) at /data/src/10.4/sql/item.cc:7587
#9  0x000055c3eeb3baac in Item_field::derived_field_transformer_for_having (this=0x7f3de00537a8, thd=0x7f3de0000d90, arg=0x7f3de0071be8 "") at /data/src/10.4/sql/item.cc:7606
#10 0x000055c3eeb25029 in Item::transform (this=0x7f3de00537a8, thd=0x7f3de0000d90, transformer=&virtual Item::derived_field_transformer_for_having(THD*, unsigned char*), arg=0x7f3de0071be8 "") at /data/src/10.4/sql/item.cc:602
#11 0x000055c3eeb9610d in Item_args::transform_args (this=0x7f3de00539d0, thd=0x7f3de0000d90, transformer=&virtual table offset 1312, arg=0x7f3de0071be8 "") at /data/src/10.4/sql/item_func.cc:462
#12 0x000055c3eeb96237 in Item_func::transform (this=0x7f3de0053948, thd=0x7f3de0000d90, transformer=&virtual table offset 1312, argument=0x7f3de0071be8 "") at /data/src/10.4/sql/item_func.cc:498
#13 0x000055c3ee73cacd in pushdown_cond_for_derived (thd=0x7f3de0000d90, cond=0x7f3de00534a8, derived=0x7f3de0018358) at /data/src/10.4/sql/sql_derived.cc:1593
#14 0x000055c3ee7e0d87 in JOIN::optimize_inner (this=0x7f3de00511a8) at /data/src/10.4/sql/sql_select.cc:2146
#15 0x000055c3ee7df077 in JOIN::optimize (this=0x7f3de00511a8) at /data/src/10.4/sql/sql_select.cc:1659
#16 0x000055c3ee7ea60e in mysql_select (thd=0x7f3de0000d90, tables=0x7f3de0014c08, wild_num=0, fields=..., conds=0x7f3de0015498, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f3de0050c20, unit=0x7f3de0004cc0, select_lex=0x7f3de0014620) at /data/src/10.4/sql/sql_select.cc:4741
#17 0x000055c3ee7d9ec6 in handle_select (thd=0x7f3de0000d90, lex=0x7f3de0004c00, result=0x7f3de0050c20, setup_tables_done_option=0) at /data/src/10.4/sql/sql_select.cc:436
#18 0x000055c3ee79e797 in execute_sqlcom_select (thd=0x7f3de0000d90, all_tables=0x7f3de0014c08) at /data/src/10.4/sql/sql_parse.cc:6449
#19 0x000055c3ee794f64 in mysql_execute_command (thd=0x7f3de0000d90) at /data/src/10.4/sql/sql_parse.cc:3963
#20 0x000055c3ee7a27c9 in mysql_parse (thd=0x7f3de0000d90, rawbuf=0x7f3de0014588 "SELECT c FROM v2 WHERE c = 83", length=29, parser_state=0x7f3e3286f520, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7995
#21 0x000055c3ee78ead1 in dispatch_command (command=COM_QUERY, thd=0x7f3de0000d90, packet=0x7f3de000abf1 "SELECT c FROM v2 WHERE c = 83", packet_length=29, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1857
#22 0x000055c3ee78d337 in do_command (thd=0x7f3de0000d90) at /data/src/10.4/sql/sql_parse.cc:1373
#23 0x000055c3ee91f9b2 in do_handle_one_connection (connect=0x55c3f1c6bc20) at /data/src/10.4/sql/sql_connect.cc:1420
#24 0x000055c3ee91f64b in handle_one_connection (arg=0x55c3f1c6bc20) at /data/src/10.4/sql/sql_connect.cc:1316
#25 0x00007f3e41122609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#26 0x00007f3e40cf5293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Reproducible on 10.4+.
Reproducible with at least MyISAM and InnoDB.
Not reproducible on 10.3.
No obvious immediate problem on a non-debug build.


Generated at Thu Feb 08 09:49:06 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.