[MDEV-9754] Window functions: assertion failure in with --ps-protocol Created: 2016-03-17  Updated: 2016-04-14  Resolved: 2016-03-18

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - Window functions
Fix Version/s: N/A

Type: Task Priority: Major
Reporter: Sergei Petrunia Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
PartOf
is part of MDEV-6115 window functions as in the SQL standard Closed

 Description   

Another PS-only crash found by buildbot:
http://buildbot.askmonty.org/buildbot/builders/kvm-fulltest/builds/5646/steps/test_9/logs/stdio

  mysqld: /home/psergey/dev-git/10.2-window-funcs-r10/sql/item_windowfunc.cc:10: bool 
Item_window_func::resolve_window_name(THD*): Assertion `window_name != __null && window_spec == __null' failed.
(gdb) print window_name
  $18 = (LEX_STRING *) 0x7fff5c00e1b8
(gdb) print window_spec
  $20 = (Window_spec *) 0x7fff5c00ed18
(gdb)  
(gdb) wher
  #0  0x00007ffff5f90425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
  #1  0x00007ffff5f93b8b in __GI_abort () at abort.c:91
  #2  0x00007ffff5f890ee in __assert_fail_base (fmt=<optimized out>, assertion=0x5555564cb5b8 "window_name != __null && window_spec == __null", file=0x5555564cb570 "/home/psergey/dev-git/10.2-window-funcs-r10/sql/item_windowfunc.cc", line=<optimized out>, function=<optimized out>) at assert.c:94
  #3  0x00007ffff5f89192 in __GI___assert_fail (assertion=0x5555564cb5b8 "window_name != __null && window_spec == __null", file=0x5555564cb570 "/home/psergey/dev-git/10.2-window-funcs-r10/sql/item_windowfunc.cc", line=10, function=0x5555564cb700 "bool Item_window_func::resolve_window_name(THD*)") at assert.c:103
  #4  0x0000555555e5e9bc in Item_window_func::resolve_window_name (this=0x7fff5c00e1c8, thd=0x55555aaffbb0) at /home/psergey/dev-git/10.2-window-funcs-r10/sql/item_windowfunc.cc:10
  #5  0x0000555555e5eb4e in Item_window_func::fix_fields (this=0x7fff5c00e1c8, thd=0x55555aaffbb0, ref=0x7fff5c00e290) at /home/psergey/dev-git/10.2-window-funcs-r10/sql/item_windowfunc.cc:47
  #6  0x0000555555a1ea07 in setup_fields (thd=0x55555aaffbb0, ref_pointer_array=..., fields=..., mark_used_columns=MARK_COLUMNS_READ, sum_func_list=0x7fff5c0057b0, allow_sum_func=true) at /home/psergey/dev-git/10.2-window-funcs-r10/sql/sql_base.cc:7955
  #7  0x0000555555ab5a9d in JOIN::prepare (this=0x7fff5c0054a0, tables_init=0x7fff5c00e2d8, wild_num=0, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7fff5c00cf58, unit_arg=0x7fff5c00c868) at /home/psergey/dev-git/10.2-window-funcs-r10/sql/sql_select.cc:794
  #8  0x0000555555abec1e in mysql_select (thd=0x55555aaffbb0, tables=0x7fff5c00e2d8, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2416184064, result=0x7fff5c00ed60, unit=0x7fff5c00c868, select_lex=0x7fff5c00cf58) at /home/psergey/dev-git/10.2-window-funcs-r10/sql/sql_select.cc:3467
  #9  0x0000555555ab4997 in handle_select (thd=0x55555aaffbb0, lex=0x7fff5c00c7a0, result=0x7fff5c00ed60, setup_tables_done_option=0) at /home/psergey/dev-git/10.2-window-funcs-r10/sql/sql_select.cc:376
  #10 0x0000555555a8521a in execute_sqlcom_select (thd=0x55555aaffbb0, all_tables=0x7fff5c00e2d8) at /home/psergey/dev-git/10.2-window-funcs-r10/sql/sql_parse.cc:5902
  #11 0x0000555555a7b0e0 in mysql_execute_command (thd=0x55555aaffbb0) at /home/psergey/dev-git/10.2-window-funcs-r10/sql/sql_parse.cc:2961
  #12 0x0000555555aa287a in Prepared_statement::execute (this=0x7fff5c00c380, expanded_query=0x7ffff4300560, open_cursor=false) at /home/psergey/dev-git/10.2-window-funcs-r10/sql/sql_prepare.cc:4009
  #13 0x0000555555aa175e in Prepared_statement::execute_loop (this=0x7fff5c00c380, expanded_query=0x7ffff4300560, open_cursor=false, packet=0x0, packet_end=0x0) at /home/psergey/dev-git/10.2-window-funcs-r10/sql/sql_prepare.cc:3641
  #14 0x0000555555a9f891 in mysql_sql_stmt_execute (thd=0x55555aaffbb0) at /home/psergey/dev-git/10.2-window-funcs-r10/sql/sql_prepare.cc:2773
  #15 0x0000555555a7b111 in mysql_execute_command (thd=0x55555aaffbb0) at /home/psergey/dev-git/10.2-window-funcs-r10/sql/sql_parse.cc:2972
  #16 0x0000555555a88882 in mysql_parse (thd=0x55555aaffbb0, rawbuf=0x7fff5c005258 "execute s", length=9, parser_state=0x7ffff4301100) at /home/psergey/dev-git/10.2-window-funcs-r10/sql/sql_parse.cc:7302

Testcase:

create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
 
create table t1 (pk int, c int);
insert into t1 select a+1,1 from t0;
update t1 set c=2 where pk not in (1,2,3,4);
select * from t1;
 
prepare s from 
'select 
  pk, c, 
  count(*) over w1 as CNT
from t1
window w1 as (partition by c order by pk 
              rows between 2 preceding and 2 following)'
 
execute s;


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