Bug #88749 Assertion `item->type() == Item::FIELD_ITEM || (item->type() == Item::REF_ITEM &
Submitted: 5 Dec 2017 2:41 Modified: 5 Dec 2017 6:07
Reporter: Roel Van de Paar Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S6 (Debug Builds)
Version:5.5.58 OS:Any
Assigned to: CPU Architecture:Any

[5 Dec 2017 2:41] Roel Van de Paar
Description:
171205 13:10:51 [Note] /sda/MS091117-mysql-5.5.58-linux-x86_64-debug/bin/mysqld: ready for connections.
Version: '5.5.58-debug'  socket: '/sda/MS091117-mysql-5.5.58-linux-x86_64-debug/socket.sock'  port: 18611  MySQL Community Server (GPL)
mysqld: /git/mysql-server_dbg/sql/sql_select.cc:14713: SORT_FIELD* make_unireg_sortorder(ORDER*, uint*, SORT_FIELD*): Assertion `item->type() == Item::FIELD_ITEM || (item->type() == Item::REF_ITEM && static_cast<Item_ref*>(item)->ref_type() == Item_ref::VIEW_REF)' failed.
02:10:58 UTC - mysqld got signal 6 ;

Core was generated by `/sda/MS091117-mysql-5.5.58-linux-x86_64-debug/bin/mysqld --no-defaults --core -'.
Program terminated with signal 6, Aborted.
#0  0x00007fc1000899b1 in __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
61	  val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
(gdb) bt
#0  0x00007fc1000899b1 in __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
#1  0x00000000007dffb8 in my_write_core (sig=6) at /git/mysql-server_dbg/mysys/stacktrace.c:433
#2  0x00000000006a2f16 in handle_fatal_signal (sig=6) at /git/mysql-server_dbg/sql/signal_handler.cc:247
#3  <signal handler called>
#4  0x00007fc0fe7bf1f7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#5  0x00007fc0fe7c08e8 in __GI_abort () at abort.c:90
#6  0x00007fc0fe7b8266 in __assert_fail_base (fmt=0x7fc0fe90ae68 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0xa58a08 "item->type() == Item::FIELD_ITEM || (item->type() == Item::REF_ITEM && static_cast<Item_ref*>(item)->ref_type() == Item_ref::VIEW_REF)", file=file@entry=0xa58690 "/git/mysql-server_dbg/sql/sql_select.cc", 
    line=line@entry=14713, 
    function=function@entry=0xa57b40 <make_unireg_sortorder(st_order*, unsigned int*, st_sort_field*)::__PRETTY_FUNCTION__> "SORT_FIELD* make_unireg_sortorder(ORDER*, uint*, SORT_FIELD*)") at assert.c:92
#7  0x00007fc0fe7b8312 in __GI___assert_fail (
    assertion=0xa58a08 "item->type() == Item::FIELD_ITEM || (item->type() == Item::REF_ITEM && static_cast<Item_ref*>(item)->ref_type() == Item_ref::VIEW_REF)", file=0xa58690 "/git/mysql-server_dbg/sql/sql_select.cc", line=14713, 
    function=0xa57b40 <make_unireg_sortorder(st_order*, unsigned int*, st_sort_field*)::__PRETTY_FUNCTION__> "SORT_FIELD* make_unireg_sortorder(ORDER*, uint*, SORT_FIELD*)") at assert.c:101
#8  0x00000000005c2a43 in make_unireg_sortorder (order=0x7fc0dd4209d8, order@entry=0x7fc0dd4208a8, 
    length=length@entry=0x7fc10067b2a4, sortorder=0x7fc0dd500eb8) at /git/mysql-server_dbg/sql/sql_select.cc:14710
#9  0x00000000005c2c82 in create_sort_index (thd=0x7fc0f0f89000, join=join@entry=0x7fc0dd4ff010, order=0x7fc0dd4208a8, 
    filesort_limit=18446744073709551615, select_limit=18446744073709551615, is_order_by=<optimized out>)
    at /git/mysql-server_dbg/sql/sql_select.cc:14268
#10 0x00000000005d57f7 in JOIN::exec (this=<optimized out>) at /git/mysql-server_dbg/sql/sql_select.cc:2369
#11 0x00000000007133d5 in subselect_single_select_engine::exec (this=0x7fc0dd420b08)
    at /git/mysql-server_dbg/sql/item_subselect.cc:2054
#12 0x0000000000712cef in Item_subselect::exec (this=0x7fc0dd420a18) at /git/mysql-server_dbg/sql/item_subselect.cc:277
#13 0x0000000000712418 in Item_singlerow_subselect::val_int (this=0x7fc0dd420a18) at /git/mysql-server_dbg/sql/item_subselect.cc:591
#14 0x00000000006a15fb in skip_record (skip_record=
    {bool (bool *, THD *, SQL_SELECT * const)} 0x6a15e5 <filesort(THD*, TABLE*, st_sort_field*, unsigned int, SQL_SELECT*, unsigned long long, bool, unsigned long long*)+5224>, thd=0x7fc0f0f89000, this=0x7fc0dd542010) at /git/mysql-server_dbg/sql/opt_range.h:888
#15 find_all_keys (tempfile=0x7fc10067b970, buffpek_pointers=0x7fc10067ba90, sort_keys=0x7fc0dd47d400, select=0x7fc0dd542010, 
    param=0x7fc10067b8f0) at /git/mysql-server_dbg/sql/filesort.cc:661
#16 filesort (thd=thd@entry=0x7fc0f0f89000, table=table@entry=0x7fc0dd501010, sortorder=<optimized out>, s_length=<optimized out>, 
    select=select@entry=0x7fc0dd542010, max_rows=max_rows@entry=18446744073709551615, sort_positions=sort_positions@entry=false, 
    examined_rows=examined_rows@entry=0x7fc10067c028) at /git/mysql-server_dbg/sql/filesort.cc:256
#17 0x00000000005c2e64 in create_sort_index (thd=0x7fc0f0f89000, join=join@entry=0x7fc0dd4fd010, order=<optimized out>, 
    filesort_limit=18446744073709551615, select_limit=18446744073709551615, is_order_by=<optimized out>)
    at /git/mysql-server_dbg/sql/sql_select.cc:14315
#18 0x00000000005d57f7 in JOIN::exec (this=this@entry=0x7fc0dd4fd010) at /git/mysql-server_dbg/sql/sql_select.cc:2369
#19 0x00000000005cf97d in mysql_select (thd=thd@entry=0x7fc0f0f89000, rref_pointer_array=rref_pointer_array@entry=0x7fc0f0f8b260, 
    tables=0x7fc0dd41f1e0, wild_num=0, fields=..., conds=<optimized out>, og_num=1, order=0x0, group=0x7fc0dd41f810, having=
    0x7fc0dd420a18, proc_param=0x0, select_options=select_options@entry=2147748608, result=result@entry=0x7fc0dd420bd8, 
    unit=unit@entry=0x7fc0f0f8aa58, select_lex=select_lex@entry=0x7fc0f0f8b078) at /git/mysql-server_dbg/sql/sql_select.cc:2619
#20 0x00000000005cfb74 in handle_select (thd=thd@entry=0x7fc0f0f89000, lex=lex@entry=0x7fc0f0f8a9a8, 
    result=result@entry=0x7fc0dd420bd8, setup_tables_done_option=setup_tables_done_option@entry=0)
    at /git/mysql-server_dbg/sql/sql_select.cc:297
#21 0x000000000058658e in execute_sqlcom_select (thd=thd@entry=0x7fc0f0f89000, all_tables=<optimized out>)
    at /git/mysql-server_dbg/sql/sql_parse.cc:4676
#22 0x000000000058ca4c in mysql_execute_command (thd=thd@entry=0x7fc0f0f89000) at /git/mysql-server_dbg/sql/sql_parse.cc:2213
#23 0x00000000005940f6 in mysql_parse (thd=thd@entry=0x7fc0f0f89000, rawbuf=<optimized out>, length=64, 
    parser_state=parser_state@entry=0x7fc10067d580) at /git/mysql-server_dbg/sql/sql_parse.cc:5831
#24 0x00000000005959f5 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7fc0f0f89000, 
    packet=packet@entry=0x7fc0f0f80001 "SELECT 1 FROM t2 GROUP BY a HAVING(SELECT a FROM g GROUP BY b,a)", 
    packet_length=packet_length@entry=64) at /git/mysql-server_dbg/sql/sql_parse.cc:1075
#25 0x0000000000597836 in do_command (thd=0x7fc0f0f89000) at /git/mysql-server_dbg/sql/sql_parse.cc:776
#26 0x000000000063fd82 in do_handle_one_connection (thd_arg=thd_arg@entry=0x7fc0f0f89000)
    at /git/mysql-server_dbg/sql/sql_connect.cc:870
#27 0x000000000063fe3f in handle_one_connection (arg=0x7fc0f0f89000) at /git/mysql-server_dbg/sql/sql_connect.cc:789
#28 0x00007fc100084e25 in start_thread (arg=0x7fc10067e700) at pthread_create.c:308
#29 0x00007fc0fe88234d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

How to repeat:
USE test;
CREATE TABLE g(b INT NOT NULL,UNIQUE(b)) ENGINE=RocksDB;
CREATE TABLE t2(a BINARY (1)NOT NULL DEFAULT'',b VARBINARY(1) NOT NULL DEFAULT'') ENGINE=RocksDB;
insert into t2 values(0,0);
SELECT 1 FROM t2 GROUP BY a HAVING(SELECT a FROM g GROUP BY b,a);
[5 Dec 2017 6:07] MySQL Verification Team
Hello Roel,

Thank you for the report and test case.
Observed that 5.5.58 debug build is affected.

Thanks,
Umesh