Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-15212

server crashed, query using ORDER BY (expression with window function)

    XMLWordPrintable

Details

    Description

      CREATE TABLE t1(i int, j int);
      INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(10,1),(20,2),(30,3),(20,1),(40,2),(60,3),(30,1),(60,2),(90,3);
       
      SELECT SUM(i) OVER (PARTITION BY j ORDER BY i) as k, i, j FROM t1 order by k ;
       
      SELECT 1+ (SUM(i) OVER (PARTITION BY j ORDER BY i)) as k,i,j FROM t1 order by k ;  # results are not ordered by k
       
      # server crash:
      SELECT 1+ (SUM(i) OVER (PARTITION BY j ORDER BY i)) as k,i,j FROM t1 order by 1+ (SUM(i) OVER (PARTITION BY j ORDER BY i)) ;
      

      SELECT SUM(i) OVER (PARTITION BY j ORDER BY i) as k, i, j FROM t1 order by k ;
      k	i	j
      1	1	1
      2	2	2
      3	3	3
      11	10	1
      22	20	2
      31	20	1
      33	30	3
      61	30	1
      62	40	2
      93	60	3
      122	60	2
      183	90	3
      SELECT 1+ (SUM(i) OVER (PARTITION BY j ORDER BY i)) as k,i,j FROM t1 order by k ;
      k	i	j
      2	1	1
      184	90	3
      32	20	1
      3	2	2
      63	40	2
      4	3	3
      94	60	3
      12	10	1
      62	30	1
      23	20	2
      123	60	2
      34	30	3
      
      

      Thread 1 (Thread 0x7fcd90066700 (LWP 16924)):
      #0  __pthread_kill (threadid=<optimized out>, signo=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:62
      #1  0x0000565343fad403 in my_write_core (sig=11) at /home/alice/git/10.2/mysys/stacktrace.c:477
      #2  0x000056534383d6f1 in handle_fatal_signal (sig=11) at /home/alice/git/10.2/sql/signal_handler.cc:305
      #3  <signal handler called>
      #4  0x0000565343513c2e in Field::set_notnull (this=0x0, row_offset=0) at /home/alice/git/10.2/sql/field.h:1137
      #5  0x0000565343863782 in Item::save_in_field (this=0x7fcd7417ed90, field=0x0, no_conversions=true) at /home/alice/git/10.2/sql/item.cc:6456
      #6  0x00005653437926ec in save_window_function_values (window_functions=..., tbl=0x7fcd740605f0, rowid_buf=0x7fcd74066058 "\030\315\002t\315\177") at /home/alice/git/10.2/sql/sql_window.cc:2517
      #7  0x0000565343792b23 in compute_window_func (thd=0x7fcd74000a98, window_functions=..., cursor_managers=..., tbl=0x7fcd740605f0, filesort_result=0x7fcd74147e60) at /home/alice/git/10.2/sql/sql_window.cc:2636
      #8  0x0000565343792ed8 in Window_func_runner::exec (this=0x7fcd7406bb68, thd=0x7fcd74000a98, tbl=0x7fcd740605f0, filesort_result=0x7fcd74147e60) at /home/alice/git/10.2/sql/sql_window.cc:2742
      #9  0x0000565343792ff2 in Window_funcs_sort::exec (this=0x7fcd7406bb60, join=0x7fcd740fceb0) at /home/alice/git/10.2/sql/sql_window.cc:2767
      #10 0x00005653437934af in Window_funcs_computation::exec (this=0x7fcd74120be0, join=0x7fcd740fceb0) at /home/alice/git/10.2/sql/sql_window.cc:2886
      #11 0x0000565343650aaa in AGGR_OP::end_send (this=0x7fcd7406ac90) at /home/alice/git/10.2/sql/sql_select.cc:26540
      #12 0x000056534363bc26 in sub_select_postjoin_aggr (join=0x7fcd740fceb0, join_tab=0x7fcd740697d0, end_of_records=true) at /home/alice/git/10.2/sql/sql_select.cc:18379
      #13 0x000056534363bf4a in sub_select (join=0x7fcd740fceb0, join_tab=0x7fcd74069420, end_of_records=true) at /home/alice/git/10.2/sql/sql_select.cc:18615
      #14 0x000056534363b75b in do_select (join=0x7fcd740fceb0, procedure=0x0) at /home/alice/git/10.2/sql/sql_select.cc:18210
      #15 0x0000565343616185 in JOIN::exec_inner (this=0x7fcd740fceb0) at /home/alice/git/10.2/sql/sql_select.cc:3540
      #16 0x0000565343615626 in JOIN::exec (this=0x7fcd740fceb0) at /home/alice/git/10.2/sql/sql_select.cc:3335
      #17 0x00005653436167f6 in mysql_select (thd=0x7fcd74000a98, tables=0x7fcd74115de0, wild_num=0, fields=..., conds=0x0, og_num=1, order=0x7fcd740fc8b0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7fcd74010080, unit=0x7fcd74004638, select_lex=0x7fcd74004d90) at /home/alice/git/10.2/sql/sql_select.cc:3735
      #18 0x000056534360aeff in handle_select (thd=0x7fcd74000a98, lex=0x7fcd74004570, result=0x7fcd74010080, setup_tables_done_option=0) at /home/alice/git/10.2/sql/sql_select.cc:373
      #19 0x00005653435d6e82 in execute_sqlcom_select (thd=0x7fcd74000a98, all_tables=0x7fcd74115de0) at /home/alice/git/10.2/sql/sql_parse.cc:6456
      #20 0x00005653435ccc00 in mysql_execute_command (thd=0x7fcd74000a98) at /home/alice/git/10.2/sql/sql_parse.cc:3467
      #21 0x00005653435da81d in mysql_parse (thd=0x7fcd74000a98, rawbuf=0x7fcd7402bb50 "SELECT 1+ (SUM(i) OVER (PARTITION BY j ORDER BY i)) as k,i,j FROM t1 order by 1+ (SUM(i) OVER (PARTITION BY j ORDER BY i))", length=122, parser_state=0x7fcd900651f0, is_com_multi=false, is_next_command=false) at /home/alice/git/10.2/sql/sql_parse.cc:7897
      #22 0x00005653435c849f in dispatch_command (command=COM_QUERY, thd=0x7fcd74000a98, packet=0x7fcd74007fe9 "", packet_length=123, is_com_multi=false, is_next_command=false) at /home/alice/git/10.2/sql/sql_parse.cc:1806
      #23 0x00005653435c6dfb in do_command (thd=0x7fcd74000a98) at /home/alice/git/10.2/sql/sql_parse.cc:1360
      #24 0x000056534371501f in do_handle_one_connection (connect=0x565345e96d48) at /home/alice/git/10.2/sql/sql_connect.cc:1335
      #25 0x0000565343714d9f in handle_one_connection (arg=0x565345e96d48) at /home/alice/git/10.2/sql/sql_connect.cc:1241
      #26 0x0000565343a72bc4 in pfs_spawn_thread (arg=0x565345df6908) at /home/alice/git/10.2/storage/perfschema/pfs.cc:1862
      #27 0x00007fcd961cf6ba in start_thread (arg=0x7fcd90066700) at pthread_create.c:333
      #28 0x00007fcd9566441d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
      

      Attachments

        Issue Links

          Activity

            People

              varun Varun Gupta (Inactive)
              alice Alice Sherepa
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.