Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.1(EOL)
-
None
-
10.1.13
Description
CREATE TABLE t1 (i INT);
|
INSERT INTO t1 VALUES (1),(2);
|
SELECT DISTINCT VAR_POP(1) FROM t1 GROUP BY @a := 's';
|
Stack trace from 10.1 commit 66832b619510f5b9724d8db1eac48bdafb9225e9 |
mysqld: /src/10.1/sql/item_sum.h:1089: virtual Field* Item_sum_field::get_tmp_table_field(): Assertion `0' failed.
|
160228 23:21:27 [ERROR] mysqld got signal 6 ;
|
|
#7 0x00007f31f89261d2 in __assert_fail () from /lib64/libc.so.6
|
#8 0x000055a9aba0d999 in Item_sum_field::get_tmp_table_field (this=0x7f31ef0569f8) at /src/10.1/sql/item_sum.h:1089
|
#9 0x000055a9ab782ba1 in remove_duplicates (join=0x7f31ef055f18, table=0x7f31ef0b0088, fields=..., having=0x0) at /src/10.1/sql/sql_select.cc:21493
|
#10 0x000055a9ab754af5 in JOIN::exec_inner (this=0x7f31ef053e20) at /src/10.1/sql/sql_select.cc:2998
|
#11 0x000055a9ab752d13 in JOIN::exec (this=0x7f31ef053e20) at /src/10.1/sql/sql_select.cc:2518
|
#12 0x000055a9ab7562c6 in mysql_select (thd=0x7f31f47c9230, rref_pointer_array=0x7f31f47cd5c0, tables=0x7f31ef0531e0, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x0, group=0x7f31ef053cf0, having=0x0, proc_param=0x0, select_options=2147748609, result=0x7f31ef053e00, unit=0x7f31f47ccc48, select_lex=0x7f31f47cd348) at /src/10.1/sql/sql_select.cc:3451
|
#13 0x000055a9ab74bd6b in handle_select (thd=0x7f31f47c9230, lex=0x7f31f47ccb80, result=0x7f31ef053e00, setup_tables_done_option=0) at /src/10.1/sql/sql_select.cc:384
|
#14 0x000055a9ab71c096 in execute_sqlcom_select (thd=0x7f31f47c9230, all_tables=0x7f31ef0531e0) at /src/10.1/sql/sql_parse.cc:5936
|
#15 0x000055a9ab711e72 in mysql_execute_command (thd=0x7f31f47c9230) at /src/10.1/sql/sql_parse.cc:2962
|
#16 0x000055a9ab71f6de in mysql_parse (thd=0x7f31f47c9230, rawbuf=0x7f31ef052ec8 "SELECT DISTINCT VAR_POP(1) FROM t1 GROUP BY @a := 's'", length=53, parser_state=0x7f31fabf45e0) at /src/10.1/sql/sql_parse.cc:7336
|
#17 0x000055a9ab70e0d9 in dispatch_command (command=COM_QUERY, thd=0x7f31f47c9230, packet=0x7f31f39c9231 "SELECT DISTINCT VAR_POP(1) FROM t1 GROUP BY @a := 's'", packet_length=53) at /src/10.1/sql/sql_parse.cc:1488
|
#18 0x000055a9ab70ce0b in do_command (thd=0x7f31f47c9230) at /src/10.1/sql/sql_parse.cc:1109
|
#19 0x000055a9ab842bc0 in do_handle_one_connection (thd_arg=0x7f31f47c9230) at /src/10.1/sql/sql_connect.cc:1349
|
#20 0x000055a9ab842924 in handle_one_connection (arg=0x7f31f47c9230) at /src/10.1/sql/sql_connect.cc:1261
|
#21 0x000055a9abf4aafa in pfs_spawn_thread (arg=0x7f31f33b0bf0) at /src/10.1/storage/perfschema/pfs.cc:1860
|
#22 0x00007f31fa86f0a4 in start_thread () from /lib64/libpthread.so.0
|
#23 0x00007f31f89dd04d in clone () from /lib64/libc.so.6
|
The problem appeared in 10.1 tree with this commit:
commit 7091b7852d27e6c8a1875b2acc0d1adbfb29984f
|
Author: Alexander Barkov <bar@mariadb.org>
|
Date: Thu Oct 8 19:19:21 2015 +0400
|
|
MDEV-8918 Wrong result for CAST(AVG(bigint_column) AS SIGNED)
|
|
- Moving Item_xxx_field declarations after Item_sum_xxx declarations,
|
so Item_xxx_field constructors can be defined directly in item_sum.h
|
rather than item_sum.cc. This removes some duplicate code, e.g.
|
initialization of the following members at constructor time:
|
name, decimals, max_length, unsigned_flag, field, maybe_null.
|
- Adding Item_sum_field as a common parent for Item_avg_field and
|
Item_variance_field
|
- Deriving Item_sum_field directly from Item rather that Item_result_field,
|
as Item_sum_field descendants do not need anything from Item_result_field.
|
- Removing hybrid infrastructure from Item_avg_field,
|
adding Item_avg_field_decimal and Item_avg_field_double instead,
|
as desired result type is already known at constructor time
|
(not only at fix_fields time). This simplifies the code.
|
- Changing Item_avg_field_decimal::val_int() to call val_int_from_decimal()
|
instead of doing { return (longlong) rint(val_real()); }
|
This is the fix itself.
|