[MDEV-5781] Item_sum_std::val_real(): Assertion `nr >= 0.0' fails on query with STDDEV_POP, ROUND and variable Created: 2014-03-04  Updated: 2016-08-03  Resolved: 2014-03-23

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.8
Fix Version/s: 10.0.10

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-10467 [5.5] Assertion `nr >= 0.0' failed in... Closed
relates to MDEV-10468 [all versions] Assertion `nr >= 0.0' ... Closed

 Description   

# Note: the subquery with union is not necessary, there can be a normal table instead
SELECT STDDEV_POP( ROUND( 0, @A := 2009 ) ) FROM ( SELECT 1 UNION SELECT 2 ) fake_table;
 

10.0/sql/item_sum.cc:1781: virtual double Item_sum_std::val_real(): Assertion `nr >= 0.0' failed.
140304  3:23:42 [ERROR] mysqld got signal 6 ;

#6  0x00007f5bddbac621 in *__GI___assert_fail (assertion=0xfcc526 "nr >= 0.0", file=<optimized out>, line=1781, function=0xfcd940 "virtual double Item_sum_std::val_real()") at assert.c:81
#7  0x000000000090b406 in Item_sum_std::val_real (this=0x7f5bcbdde878) at 10.0/sql/item_sum.cc:1781
#8  0x000000000087c671 in Item::send (this=0x7f5bcbdde878, protocol=0x7f5bd6f7d5f8, buffer=0x7f5bdfacce90) at 10.0/sql/item.cc:6603
#9  0x00000000005ccb24 in Protocol::send_result_set_row (this=0x7f5bd6f7d5f8, row_items=0x7f5bcbf51450) at 10.0/sql/protocol.cc:900
#10 0x0000000000638d6d in select_send::send_data (this=0x7f5bcbde0038, items=...) at 10.0/sql/sql_class.cc:2552
#11 0x00000000006d3f03 in end_send_group (join=0x7f5bcbf51088, join_tab=0x7f5bcbf53448, end_of_records=true) at 10.0/sql/sql_select.cc:18660
#12 0x00000000006d0c4c in sub_select (join=0x7f5bcbf51088, join_tab=0x7f5bcbf53120, end_of_records=true) at 10.0/sql/sql_select.cc:17370
#13 0x00000000006d0734 in do_select (join=0x7f5bcbf51088, fields=0x7f5bcbf51450, table=0x0, procedure=0x0) at 10.0/sql/sql_select.cc:17081
#14 0x00000000006ae2be in JOIN::exec_inner (this=0x7f5bcbf51088) at 10.0/sql/sql_select.cc:3065
#15 0x00000000006ab7d0 in JOIN::exec (this=0x7f5bcbf51088) at 10.0/sql/sql_select.cc:2355
#16 0x00000000006aeb4f in mysql_select (thd=0x7f5bd6f7d070, rref_pointer_array=0x7f5bd6f816a0, tables=0x7f5bcbf50a28, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f5bcbde0038, unit=0x7f5bd6f80d48, select_lex=0x7f5bd6f81428) at 10.0/sql/sql_select.cc:3292
#17 0x00000000006a527f in handle_select (thd=0x7f5bd6f7d070, lex=0x7f5bd6f80c88, result=0x7f5bcbde0038, setup_tables_done_option=0) at 10.0/sql/sql_select.cc:372
#18 0x000000000067a251 in execute_sqlcom_select (thd=0x7f5bd6f7d070, all_tables=0x7f5bcbf50a28) at 10.0/sql/sql_parse.cc:5301
#19 0x00000000006725fc in mysql_execute_command (thd=0x7f5bd6f7d070) at 10.0/sql/sql_parse.cc:2587
#20 0x000000000067c9db in mysql_parse (thd=0x7f5bd6f7d070, rawbuf=0x7f5bcbdde088 "SELECT STDDEV_POP( ROUND( 0, @A := 2009 ) ) FROM ( SELECT 1 UNION SELECT 2 ) fake_table", length=87, parser_state=0x7f5bdface630) at 10.0/sql/sql_parse.cc:6447
#21 0x000000000066f7a9 in dispatch_command (command=COM_QUERY, thd=0x7f5bd6f7d070, packet=0x7f5bd23e0071 "", packet_length=87) at 10.0/sql/sql_parse.cc:1308
#22 0x000000000066eb4b in do_command (thd=0x7f5bd6f7d070) at 10.0/sql/sql_parse.cc:1005
#23 0x00000000007880ed in do_handle_one_connection (thd_arg=0x7f5bd6f7d070) at 10.0/sql/sql_connect.cc:1379
#24 0x0000000000787e40 in handle_one_connection (arg=0x7f5bd6f7d070) at 10.0/sql/sql_connect.cc:1293
#25 0x0000000000a2cac5 in pfs_spawn_thread (arg=0x7f5bd5bebdb0) at 10.0/storage/perfschema/pfs.cc:1853
#26 0x00007f5bdf750b50 in start_thread (arg=<optimized out>) at pthread_create.c:304
#27 0x00007f5bddc5ba7d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112

revision-id: sergii@pisem.net-20140228200458-2nzjwfzn554m5aja
revno: 4017
branch-nick: 10.0



 Comments   
Comment by Alexander Barkov [ 2014-03-22 ]

There is a difference in how ROUND works in integer and real context:

mysql> SELECT ROUND(0, @A := 2009);
+----------------------+
| ROUND(0, @A := 2009) |
+----------------------+
|                    0 |
+----------------------+
1 row in set (0.85 sec)
 
mysql> SELECT ROUND(0, @A := 2009)+0e0;
ERROR 1690 (22003): DOUBLE value is out of range in '(round(0,(@A:=2009)) + 0e0)'
mysql> SELECT ROUND(0, @A := 2009);
+----------------------+
| ROUND(0, @A := 2009) |
+----------------------+
|                    0 |
+----------------------+
1 row in set (1.24 sec)
 
mysql> SELECT ROUND(0, @A := 2009)+0e0;
ERROR 1690 (22003): DOUBLE value is out of range in '(round(0,(@A:=2009)) + 0e0)'

Which seems to be the source of the crashing problem.

Comment by Alexander Barkov [ 2014-03-23 ]

Pushed into 10.0.

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