[MDEV-7052] MySQL#74646 - Assertion `((Item_result_field*)item)->result_field' failed in create_tmp_field Created: 2014-11-08  Updated: 2020-10-19  Resolved: 2020-10-19

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 5.5, 10.0
Fix Version/s: 10.1.5

Type: Bug Priority: Minor
Reporter: Elena Stepanova Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: upstream

Issue Links:
Relates
relates to MDEV-7057 Track most important upstream bugs wh... Closed
relates to MDEV-23984 Assertion `result_field' failed in It... Open

 Description   

Initially reported by Ramesh Sivaraman as http://bugs.mysql.com/bug.php?id=74646, refiling to make it searchable in JIRA and to preserve the test case.

DROP DATABASE test;CREATE DATABASE test;USE test;
create TEMPORARY TABLE t2(a int)engine=heap;
CREATE TABLE t2(a int KEY,b CHAR (1)) ENGINE=InnoDB PARTITION BY HASH (a) PARTITIONS 13;
DROP TABLE t2;
create view t1 as select a,6*a as b,7*a as c from t2;
SELECT SUM(b),COUNT(DISTINCT b),COUNT(*) FROM t1 GROUP BY a WITH ROLLUP;

sql/sql_select.cc:15582: Field* create_tmp_field(THD*, TABLE*, Item*, Item::Type, Item***, Field**, Field**, bool, bool, bool, bool, uint): Assertion `((Item_result_field*)item)->result_field' failed.
141108 21:03:14 [ERROR] mysqld got signal 6 ;

#6  0x00007f0e679bf6f1 in *__GI___assert_fail (assertion=0xf2a880 "((Item_result_field*)item)->result_field", file=<optimized out>, line=15582, function=0xf2c9a0 "Field* create_tmp_field(THD*, TABLE*, Item*, Item::Type, Item***, Field**, Field**, bool, bool, bool, bool, uint)") at assert.c:81
#7  0x00000000006d4b71 in create_tmp_field (thd=0x7f0e6170b070, table=0x7f0e5459f088, item=0x7f0e54580e08, type=Item::REF_ITEM, copy_func=0x7f0e69941fe0, from_field=0x7f0e545a0020, default_field=0x7f0e545a0010, group=false, modify_item=false, table_cant_handle_bit_fields=false, make_copy_field=true, convert_blob_length=0) at 10.0/sql/sql_select.cc:15582
#8  0x00000000006d5f45 in create_tmp_table (thd=0x7f0e6170b070, param=0x7f0e5459d678, fields=..., group=0x0, distinct=true, save_sum_fields=false, select_options=2147748608, rows_limit=18446744073709551615, table_alias=0x10070c6 "", do_not_open=false, keep_row_order=false) at 10.0/sql/sql_select.cc:15958
#9  0x00000000009171ee in Aggregator_distinct::setup (this=0x7f0e5459d038, thd=0x7f0e6170b070) at 10.0/sql/item_sum.cc:835
#10 0x00000000006ee970 in Item_sum::aggregator_setup (this=0x7f0e5459cd78, thd=0x7f0e6170b070) at 10.0/sql/item_sum.h:507
#11 0x00000000006e5dc5 in setup_sum_funcs (thd=0x7f0e6170b070, func_ptr=0x7f0e54581178) at 10.0/sql/sql_select.cc:22359
#12 0x00000000006b6b51 in JOIN::exec_inner (this=0x7f0e5457da00) at 10.0/sql/sql_select.cc:2913
#13 0x00000000006b4a90 in JOIN::exec (this=0x7f0e5457da00) at 10.0/sql/sql_select.cc:2370
#14 0x00000000006b7dfb in mysql_select (thd=0x7f0e6170b070, rref_pointer_array=0x7f0e6170f6e0, tables=0x7f0e5461d948, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f0e5461e040, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f0e5457d9e0, unit=0x7f0e6170ed80, select_lex=0x7f0e6170f468) at 10.0/sql/sql_select.cc:3308
#15 0x00000000006ae3f5 in handle_select (thd=0x7f0e6170b070, lex=0x7f0e6170ecb8, result=0x7f0e5457d9e0, setup_tables_done_option=0) at 10.0/sql/sql_select.cc:373
#16 0x00000000006830e4 in execute_sqlcom_select (thd=0x7f0e6170b070, all_tables=0x7f0e5461d948) at 10.0/sql/sql_parse.cc:5261
#17 0x000000000067b3e2 in mysql_execute_command (thd=0x7f0e6170b070) at 10.0/sql/sql_parse.cc:2545
#18 0x000000000068586f in mysql_parse (thd=0x7f0e6170b070, rawbuf=0x7f0e5461d088 "SELECT SUM(b),COUNT(DISTINCT b),COUNT(*) FROM t1 GROUP BY a WITH ROLLUP", length=71, parser_state=0x7f0e69943630) at 10.0/sql/sql_parse.cc:6407
#19 0x0000000000678652 in dispatch_command (command=COM_QUERY, thd=0x7f0e6170b070, packet=0x7f0e567f2071 "SELECT SUM(b),COUNT(DISTINCT b),COUNT(*) FROM t1 GROUP BY a WITH ROLLUP", packet_length=71) at 10.0/sql/sql_parse.cc:1299
#20 0x00000000006779f7 in do_command (thd=0x7f0e6170b070) at 10.0/sql/sql_parse.cc:996
#21 0x00000000007944aa in do_handle_one_connection (thd_arg=0x7f0e6170b070) at 10.0/sql/sql_connect.cc:1379
#22 0x00000000007941fd in handle_one_connection (arg=0x7f0e6170b070) at 10.0/sql/sql_connect.cc:1293
#23 0x0000000000ccb4a6 in pfs_spawn_thread (arg=0x7f0e617d9df0) at 10.0/storage/perfschema/pfs.cc:1860
#24 0x00007f0e69578b50 in start_thread (arg=<optimized out>) at pthread_create.c:304
#25 0x00007f0e67a7020d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

Stack trace from

revision-id: sergii@pisem.net-20141103164737-457hfby1eg82zol9
date: 2014-11-03 17:47:37 +0100
build-date: 2014-11-08 21:11:45 +0400
revno: 4471
branch-nick: 10.0



 Comments   
Comment by Daniel Black [ 2017-12-30 ]

Seems fixed (no backtrace) in 10.3.4

Server version: 10.3.4-MariaDB Source distribution
 
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [test]> create TEMPORARY TABLE t2(a int)engine=heap;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]> CREATE TABLE t2(a int KEY,b CHAR (1)) ENGINE=InnoDB PARTITION BY HASH (a) PARTITIONS 13;
Query OK, 0 rows affected (0.015 sec)
 
MariaDB [test]> DROP TABLE t2;
Query OK, 0 rows affected (0.000 sec)
 
MariaDB [test]> create view t1 as select a,6*a as b,7*a as c from t2;
Query OK, 0 rows affected (0.002 sec)
 
MariaDB [test]> SELECT SUM(b),COUNT(DISTINCT b),COUNT(*) FROM t1 GROUP BY a WITH ROLLUP;
Empty set (0.001 sec)

Comment by Elena Stepanova [ 2020-10-19 ]

The failure disappeared after this commit in 10.1:

commit 22a7b4dee0bad4ec2c7fd235a0f46fe745ace71a (HEAD)
Author: Alexander Barkov <bar@mariadb.org>
Date:   Fri Apr 17 16:26:08 2015 +0400
 
    Removing duplicate code/declarations:
    
    Removing "Field *result_field" from Item_field and Item_ref,
    and deriving Item_ident and Item_ref from Item_result_field
    instead.

Generated at Thu Feb 08 07:16:35 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.