Bug #86254 Assertion `0' failed in Item::tmp_table_field_from_field_type
Submitted: 10 May 2017 4:39 Modified: 29 Aug 2017 10:25
Reporter: Roel Van de Paar Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S1 (Critical)
Version:5.7.17 OS:Any
Assigned to: CPU Architecture:Any

[10 May 2017 4:39] Roel Van de Paar
Description:
mysql> DROP DATABASE test;CREATE DATABASE test;USE test;
Query OK, 0 rows affected (0.01 sec)

Query OK, 1 row affected (0.00 sec)

Database changed
mysql> CREATE TABLE t1 (a DATETIME NOT NULL, b TINYINT);
Query OK, 0 rows affected (0.11 sec)

mysql> (SELECT b,a FROM t1 ORDER BY a,b) ORDER BY b,a;
ERROR 2013 (HY000): Lost connection to MySQL server during query

=========================

Core was generated by `/sda/MS010217-mysql-5.7.17-linux-x86_64-debug/bin/mysqld --no-defaults --sql_mo'.
Program terminated with signal 6, Aborted.
#0  0x00007fd51dde3741 in __pthread_kill (threadid=<optimized out>, signo=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  0x00007fd51dde3741 in __pthread_kill (threadid=<optimized out>, signo=6) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
#1  0x0000000001826d71 in my_write_core (sig=6) at /git/mysql-server_dbg/mysys/stacktrace.c:249
#2  0x0000000000e75574 in handle_fatal_signal (sig=6) at /git/mysql-server_dbg/sql/signal_handler.cc:220
#3  <signal handler called>
#4  0x00007fd51c1771d7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#5  0x00007fd51c1788c8 in __GI_abort () at abort.c:90
#6  0x00007fd51c170146 in __assert_fail_base (fmt=0x7fd51c2c13a8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x1d7e836 "0", file=file@entry=0x1d7eac0 "/git/mysql-server_dbg/sql/item.cc", line=line@entry=6593, 
    function=function@entry=0x1d81ee0 <Item::tmp_table_field_from_field_type(TABLE*, bool)::__PRETTY_FUNCTION__> "Field* Item::tmp_table_field_from_field_type(TABLE*, bool)") at assert.c:92
#7  0x00007fd51c1701f2 in __GI___assert_fail (assertion=0x1d7e836 "0", file=0x1d7eac0 "/git/mysql-server_dbg/sql/item.cc", line=6593, 
    function=0x1d81ee0 <Item::tmp_table_field_from_field_type(TABLE*, bool)::__PRETTY_FUNCTION__> "Field* Item::tmp_table_field_from_field_type(TABLE*, bool)") at assert.c:101
#8  0x0000000000f18edf in Item::tmp_table_field_from_field_type (this=0x7fd4e0491828, table=0x7fd4e04a6030, fixed_length=false)
    at /git/mysql-server_dbg/sql/item.cc:6593
#9  0x0000000000f25213 in Item_type_holder::make_field_by_type (this=0x7fd4e0491828, table=0x7fd4e04a6030)
    at /git/mysql-server_dbg/sql/item.cc:10724
#10 0x0000000001597acf in create_tmp_field (thd=0x7fd4e0419000, table=0x7fd4e04a6030, item=0x7fd4e0491828, type=Item::TYPE_HOLDER, 
    copy_func=0x7fd4e04aac30, from_field=0x7fd4e04a6dc0, default_field=0x7fd4e04a6d98, group=false, modify_item=false, 
    table_cant_handle_bit_fields=false, make_copy_field=false) at /git/mysql-server_dbg/sql/sql_tmp_table.cc:394
#11 0x00000000015993e2 in create_tmp_table (thd=0x7fd4e0419000, param=0x7fd4e0491450, fields=..., group=0x0, distinct=false, 
    save_sum_fields=true, select_options=2416188160, rows_limit=18446744073709551615, table_alias=0x1f54dd3 "")
    at /git/mysql-server_dbg/sql/sql_tmp_table.cc:959
#12 0x00000000015a390b in Query_result_union::create_result_table (this=0x7fd4e0491430, thd_arg=0x7fd4e0419000, 
    column_types=0x7fd4e042b958, is_union_distinct=false, options=2416188160, table_alias=0x1f54dd3 "", bit_fields_as_long=false, 
    create_table=true) at /git/mysql-server_dbg/sql/sql_union.cc:132
#13 0x00000000015a4bca in st_select_lex_unit::prepare (this=0x7fd4e042b370, thd_arg=0x7fd4e0419000, sel_result=0x7fd4e042cfd0, 
    added_options=268435456, removed_options=0) at /git/mysql-server_dbg/sql/sql_union.cc:617
#14 0x0000000001544639 in handle_query (thd=0x7fd4e0419000, lex=0x7fd4e041b2f8, result=0x7fd4e042cfd0, added_options=0, 
    removed_options=0) at /git/mysql-server_dbg/sql/sql_select.cc:139
#15 0x00000000014fa6e6 in execute_sqlcom_select (thd=0x7fd4e0419000, all_tables=0x7fd4e042c618)
    at /git/mysql-server_dbg/sql/sql_parse.cc:5195
#16 0x00000000014f3df9 in mysql_execute_command (thd=0x7fd4e0419000, first_level=true) at /git/mysql-server_dbg/sql/sql_parse.cc:2794
#17 0x00000000014fb5f5 in mysql_parse (thd=0x7fd4e0419000, parser_state=0x7fd51e3d5550) at /git/mysql-server_dbg/sql/sql_parse.cc:5611
#18 0x00000000014f0c1d in dispatch_command (thd=0x7fd4e0419000, com_data=0x7fd51e3d5cb0, command=COM_QUERY)
    at /git/mysql-server_dbg/sql/sql_parse.cc:1461
#19 0x00000000014efa44 in do_command (thd=0x7fd4e0419000) at /git/mysql-server_dbg/sql/sql_parse.cc:999
#20 0x000000000161f9d0 in handle_connection (arg=0x7fd4f3388960)
    at /git/mysql-server_dbg/sql/conn_handler/connection_handler_per_thread.cc:300
#21 0x00000000018534f9 in pfs_spawn_thread (arg=0x7fd501a76220) at /git/mysql-server_dbg/storage/perfschema/pfs.cc:2188
#22 0x00007fd51dddedc5 in start_thread (arg=0x7fd51e3d6700) at pthread_create.c:308
#23 0x00007fd51c23973d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

How to repeat:
DROP DATABASE test;CREATE DATABASE test;USE test;
CREATE TABLE t1 (a DATETIME NOT NULL, b TINYINT);
(SELECT b,a FROM t1 ORDER BY a,b) ORDER BY b,a;
[10 May 2017 4:42] Roel Van de Paar
Correcting title & category
[10 May 2017 6:23] MySQL Verification Team
same as my internal
Bug 16833464 - PRESENCE OF ORDER BY CHANGES DATA TYPE OF COLUMN IN CREATE TABLE SELECT
[10 May 2017 6:34] MySQL Verification Team
Hello Roel,

Thank you for the report.
As our Shane pointed out, this is duplicate of internal bug.

Thanks,
Umesh
[24 May 2017 9:58] Erlend Dahl
Fixed in 8.0.2 under the heading of

Bug#16833464 PRESENCE OF ORDER BY CHANGES DATA TYPE OF COLUMN IN CREATE TABLE SELECT
[29 Aug 2017 10:25] Roel Van de Paar
Bug 87577 was marked a duplicate