[MDEV-16722] Assertion `type() != NULL_ITEM' failed Created: 2018-07-10  Updated: 2018-08-12  Resolved: 2018-08-12

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.4
Fix Version/s: 10.4.0

Type: Bug Priority: Major
Reporter: Alice Sherepa Assignee: Varun Gupta (Inactive)
Resolution: Fixed Votes: 0
Labels: None


 Description   

SELECT AVG("") OVER () FROM dual ORDER BY NAME_CONST('u', NULL);

 10.4 29da7a1a9ab5033f
Thread 1 (Thread 0x7f8a1e02c700 (LWP 14506)):
#0  __pthread_kill (threadid=<optimized out>, signo=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:62
#1  0x000055ee168ae761 in my_write_core (sig=6) at /home/alice/git/10.4/mysys/stacktrace.c:481
#2  0x000055ee160f10d1 in handle_fatal_signal (sig=6) at /home/alice/git/10.4/sql/signal_handler.cc:305
#3  <signal handler called>
#4  0x00007f8a23e8e428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#5  0x00007f8a23e9002a in __GI_abort () at abort.c:89
#6  0x00007f8a23e86bd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x55ee16974b38 "type() != NULL_ITEM", file=file@entry=0x55ee16974ae0 "/home/alice/git/10.4/sql/item.h", line=line@entry=819, function=function@entry=0x55ee1697a060 <Item::create_tmp_field_ex_simple(TABLE*, Tmp_field_src*, Tmp_field_param const*)::__PRETTY_FUNCTION__> "Field* Item::create_tmp_field_ex_simple(TABLE*, Tmp_field_src*, const Tmp_field_param*)") at assert.c:92
#7  0x00007f8a23e86c82 in __GI___assert_fail (assertion=0x55ee16974b38 "type() != NULL_ITEM", file=0x55ee16974ae0 "/home/alice/git/10.4/sql/item.h", line=819, function=0x55ee1697a060 <Item::create_tmp_field_ex_simple(TABLE*, Tmp_field_src*, Tmp_field_param const*)::__PRETTY_FUNCTION__> "Field* Item::create_tmp_field_ex_simple(TABLE*, Tmp_field_src*, const Tmp_field_param*)") at assert.c:101
#8  0x000055ee15de7e57 in Item::create_tmp_field_ex_simple (this=0x7f8a0c015ad8, table=0x7f8a0c148c88, src=0x7f8a1e029e00, param=0x7f8a1e029df0) at /home/alice/git/10.4/sql/item.h:819
#9  0x000055ee1612a8c2 in Item_name_const::create_tmp_field_ex (this=0x7f8a0c015ad8, table=0x7f8a0c148c88, src=0x7f8a1e029e00, param=0x7f8a1e029df0) at /home/alice/git/10.4/sql/item.h:3032
#10 0x000055ee15e6f3f6 in create_tmp_field (table=0x7f8a0c148c88, item=0x7f8a0c015ad8, copy_func=0x7f8a1e029f50, from_field=0x7f8a0c149d90, default_field=0x7f8a0c149d70, group=false, modify_item=true, table_cant_handle_bit_fields=false, make_copy_field=false) at /home/alice/git/10.4/sql/sql_select.cc:16913
#11 0x000055ee15e708e8 in create_tmp_table (thd=0x7f8a0c000b00, param=0x7f8a0c017038, fields=..., group=0x0, distinct=false, save_sum_fields=false, select_options=2147748608, rows_limit=18446744073709551615, table_alias=0x55ee1723ff80 <empty_clex_str>, do_not_open=true, keep_row_order=false) at /home/alice/git/10.4/sql/sql_select.cc:17306
#12 0x000055ee15e4bf2f in JOIN::create_postjoin_aggr_table (this=0x7f8a0c016448, tab=0x7f8a0c016c88, table_fields=0x7f8a0c016768, table_group=0x0, save_sum_fields=false, distinct=false, keep_row_order=false) at /home/alice/git/10.4/sql/sql_select.cc:3378
#13 0x000055ee15e4a65c in JOIN::make_aggr_tables_info (this=0x7f8a0c016448) at /home/alice/git/10.4/sql/sql_select.cc:2975
#14 0x000055ee15e4923e in JOIN::optimize_stage2 (this=0x7f8a0c016448) at /home/alice/git/10.4/sql/sql_select.cc:2658
#15 0x000055ee15e46bcb in JOIN::optimize_inner (this=0x7f8a0c016448) at /home/alice/git/10.4/sql/sql_select.cc:1952
#16 0x000055ee15e44f33 in JOIN::optimize (this=0x7f8a0c016448) at /home/alice/git/10.4/sql/sql_select.cc:1448
#17 0x000055ee15e4ee43 in mysql_select (thd=0x7f8a0c000b00, tables=0x0, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x7f8a0c015b88, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f8a0c016428, unit=0x7f8a0c0049a8, select_lex=0x7f8a0c0150a0) at /home/alice/git/10.4/sql/sql_select.cc:4261
#18 0x000055ee15e409d6 in handle_select (thd=0x7f8a0c000b00, lex=0x7f8a0c0048e0, result=0x7f8a0c016428, setup_tables_done_option=0) at /home/alice/git/10.4/sql/sql_select.cc:382
#19 0x000055ee15e0b315 in execute_sqlcom_select (thd=0x7f8a0c000b00, all_tables=0x0) at /home/alice/git/10.4/sql/sql_parse.cc:6545
#20 0x000055ee15e0176e in mysql_execute_command (thd=0x7f8a0c000b00) at /home/alice/git/10.4/sql/sql_parse.cc:3768
#21 0x000055ee15e0f04d in mysql_parse (thd=0x7f8a0c000b00, rawbuf=0x7f8a0c014fc0 "SELECT AVG(\"\") OVER ()\nFROM dual\nORDER BY NAME_CONST('u', NULL)", length=63, parser_state=0x7f8a1e02b5f0, is_com_multi=false, is_next_command=false) at /home/alice/git/10.4/sql/sql_parse.cc:8063
#22 0x000055ee15dfc1d0 in dispatch_command (command=COM_QUERY, thd=0x7f8a0c000b00, packet=0x7f8a0c00b441 "SELECT AVG(\"\") OVER ()\nFROM dual\nORDER BY NAME_CONST('u', NULL)", packet_length=63, is_com_multi=false, is_next_command=false) at /home/alice/git/10.4/sql/sql_parse.cc:1847
#23 0x000055ee15dfabed in do_command (thd=0x7f8a0c000b00) at /home/alice/git/10.4/sql/sql_parse.cc:1392
#24 0x000055ee15f61613 in do_handle_one_connection (connect=0x55ee19d34b20) at /home/alice/git/10.4/sql/sql_connect.cc:1402
#25 0x000055ee15f61364 in handle_one_connection (arg=0x55ee19d34b20) at /home/alice/git/10.4/sql/sql_connect.cc:1308
#26 0x000055ee1683ebaa in pfs_spawn_thread (arg=0x55ee19d3cc10) at /home/alice/git/10.4/storage/perfschema/pfs.cc:1862
#27 0x00007f8a24acb6ba in start_thread (arg=0x7f8a1e02c700) at pthread_create.c:333
#28 0x00007f8a23f6041d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109



 Comments   
Comment by Varun Gupta (Inactive) [ 2018-08-08 ]

Patch
http://lists.askmonty.org/pipermail/commits/2018-August/012784.html

Comment by Alexander Barkov [ 2018-08-08 ]

The patch http://lists.askmonty.org/pipermail/commits/2018-August/012784.html is OK to push.

Comment by Varun Gupta (Inactive) [ 2018-08-10 ]

Updated the patch
http://lists.askmonty.org/pipermail/commits/2018-August/012789.html

Comment by Alexander Barkov [ 2018-08-10 ]

Instead of:

inline bool is_cond_and(Item *item)
  {
    Item_func *func_item= item->get_item_func();
    return func_item && func_item->type() == Item::COND_ITEM && func_item->functype() == Item_func::COND_AND_FUNC;
}

it should probably be:

inline bool is_cond_and(Item *item)
  {
    Item_func *func_item= item->get_item_func();
    return func_item && func_item->functype() == Item_func::COND_AND_FUNC;
}

I.e. the test for Item::COND_ITEM looks redundant.

The same in is_cond_or().

Otherwise looks fine for me. Thanks!

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