|
on debug versions:
|
10.2 8afcc37c685a0b78c3da2b8
|
#4 0x000055de58ffa5b5 in TABLE::insert_all_rows_into_tmp_table (this=0x7fe5f4032e50, thd=thd@entry=0x7fe5f4000c08, tmp_table=0x7fe5f4035630, tmp_table_param=0x7fe5f4091b08, with_cleanup=with_cleanup@entry=true) at /10.2/sql/table.cc:8006
|
#5 0x000055de58f1e851 in TABLE_LIST::fill_recursive (this=this@entry=0x7fe5f41722b0, thd=thd@entry=0x7fe5f4000c08) at /10.2/sql/sql_derived.cc:1008
|
#6 0x000055de58f1eb93 in mysql_derived_fill (thd=0x7fe5f4000c08, lex=0x7fe5f4004598, derived=0x7fe5f41722b0) at /10.2/sql/sql_derived.cc:1069
|
#7 0x000055de58f1e6eb in mysql_handle_single_derived (lex=0x7fe5f4004598, derived=derived@entry=0x7fe5f41722b0, phases=phases@entry=96) at /10.2/sql/sql_derived.cc:198
|
#8 0x000055de58f79d30 in st_join_table::preread_init (this=0x7fe5f403ce20) at /10.2/sql/sql_select.cc:12105
|
#9 0x000055de58f7a008 in sub_select (join=0x7fe5f4036990, join_tab=0x7fe5f403ce20, end_of_records=<optimized out>) at /10.2/sql/sql_select.cc:18840
|
#10 0x000055de58f9d210 in do_select (procedure=<optimized out>, join=0x7fe5f4036990) at /10.2/sql/sql_select.cc:18416
|
#11 JOIN::exec_inner (this=this@entry=0x7fe5f4036990) at /10.2/sql/sql_select.cc:3638
|
#12 0x000055de58f9d413 in JOIN::exec (this=this@entry=0x7fe5f4036990) at /10.2/sql/sql_select.cc:3433
|
#13 0x000055de58f9b93b in mysql_select (thd=thd@entry=0x7fe5f4000c08, tables=0x7fe5f41722b0, wild_num=0, fields=..., conds=<optimized out>, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2416184064, result=0x7fe5f41896d0, unit=0x7fe5f4171b20, select_lex=0x7fe5f4090a80) at /10.2/sql/sql_select.cc:3833
|
#14 0x000055de58f1e98a in mysql_derived_fill (thd=0x7fe5f4000c08, lex=0x7fe5f4004598, derived=0x7fe5f4039120) at /10.2/sql/sql_derived.cc:1097
|
#15 0x000055de58f1e6eb in mysql_handle_single_derived (lex=0x7fe5f4004598, derived=derived@entry=0x7fe5f4039120, phases=phases@entry=96) at /10.2/sql/sql_derived.cc:198
|
#16 0x000055de58f79d30 in st_join_table::preread_init (this=0x7fe5f4031340) at /10.2/sql/sql_select.cc:12105
|
#17 0x000055de58f7a008 in sub_select (join=0x7fe5f4175700, join_tab=0x7fe5f4031340, end_of_records=<optimized out>) at /10.2/sql/sql_select.cc:18840
|
#18 0x000055de58f7256e in evaluate_join_record (join=join@entry=0x7fe5f4175700, join_tab=join_tab@entry=0x7fe5f4030f90, error=<optimized out>) at /10.2/sql/sql_select.cc:19092
|
#19 0x000055de58f79eb9 in sub_select (join=0x7fe5f4175700, join_tab=0x7fe5f4030f90, end_of_records=<optimized out>) at /10.2/sql/sql_select.cc:18872
|
#20 0x000055de58f9d210 in do_select (procedure=<optimized out>, join=0x7fe5f4175700) at /10.2/sql/sql_select.cc:18416
|
#21 JOIN::exec_inner (this=this@entry=0x7fe5f4175700) at /10.2/sql/sql_select.cc:3638
|
#22 0x000055de58f9d413 in JOIN::exec (this=this@entry=0x7fe5f4175700) at /10.2/sql/sql_select.cc:3433
|
#23 0x000055de58f9b93b in mysql_select (thd=thd@entry=0x7fe5f4000c08, tables=0x7fe5f4038ad0, wild_num=0, fields=..., conds=<optimized out>, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7fe5f4091a90, unit=0x7fe5f4004658, select_lex=0x7fe5f4004db8) at /10.2/sql/sql_select.cc:3833
|
#24 0x000055de58f9c2cf in handle_select (thd=thd@entry=0x7fe5f4000c08, lex=lex@entry=0x7fe5f4004598, result=result@entry=0x7fe5f4091a90, setup_tables_done_option=setup_tables_done_option@entry=0) at /10.2/sql/sql_select.cc:373
|
#25 0x000055de58e77c8d in execute_sqlcom_select (thd=thd@entry=0x7fe5f4000c08, all_tables=0x7fe5f4038ad0) at /10.2/sql/sql_parse.cc:6226
|
#26 0x000055de58f44995 in mysql_execute_command (thd=thd@entry=0x7fe5f4000c08) at /10.2/sql/sql_parse.cc:3532
|
#27 0x000055de58f4b21a in mysql_parse (thd=thd@entry=0x7fe5f4000c08, rawbuf=<optimized out>, length=500, parser_state=parser_state@entry=0x7fe605224570, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /10.2/sql/sql_parse.cc:7741
|
#28 0x000055de58f4caf6 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7fe5f4000c08, packet=packet@entry=0x7fe5f41771d9 "", packet_length=packet_length@entry=500, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /10.2/sql/sql_parse.cc:1832
|
#29 0x000055de58f4e8dc in do_command (thd=0x7fe5f4000c08) at /10.2/sql/sql_parse.cc:1386
|
#30 0x000055de59020042 in do_handle_one_connection (connect=connect@entry=0x55de5c612038) at /10.2/sql/sql_connect.cc:1336
|
#31 0x000055de5902019d in handle_one_connection (arg=arg@entry=0x55de5c612038) at /10.2/sql/sql_connect.cc:1241
|
#32 0x000055de59613e01 in pfs_spawn_thread (arg=0x55de5c5b9598) at /10.2/storage/perfschema/pfs.cc:1869
|
#33 0x00007fe60c55d6db in start_thread (arg=0x7fe605225700) at pthread_create.c:463
|
#34 0x00007fe60bb5f88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
|
|
10.3 ecc7f305dde85d704a37e584
|
#3 <signal handler called>
|
#4 0x000055e4b367a43f in base_list_iterator::next_fast (this=0x7f1c109a8d60) at /10.3/sql/sql_list.h:442
|
#5 0x000055e4b38a2c91 in List_iterator_fast<TABLE>::operator++ (this=0x7f1c109a8d60) at /10.3/sql/sql_list.h:562
|
#6 0x000055e4b39bbee6 in With_element::instantiate_tmp_tables (this=0x7f1c00017360) at /10.3/sql/sql_cte.cc:1460
|
#7 0x000055e4b3752443 in TABLE_LIST::fill_recursive (this=0x7f1c00018390, thd=0x7f1c00000d50) at /10.3/sql/sql_derived.cc:1050
|
#8 0x000055e4b3752854 in mysql_derived_fill (thd=0x7f1c00000d50, lex=0x7f1c00004b58, derived=0x7f1c00018390) at /10.3/sql/sql_derived.cc:1141
|
#9 0x000055e4b375023c in mysql_handle_single_derived (lex=0x7f1c00004b58, derived=0x7f1c00018390, phases=96) at /10.3/sql/sql_derived.cc:199
|
#10 0x000055e4b380820d in st_join_table::preread_init (this=0x7f1c0004ca88) at /10.3/sql/sql_select.cc:12831
|
#11 0x000055e4b3819d93 in sub_select (join=0x7f1c0003ccc8, join_tab=0x7f1c0004ca88, end_of_records=false) at /10.3/sql/sql_select.cc:19655
|
#12 0x000055e4b38193cf in do_select (join=0x7f1c0003ccc8, procedure=0x0) at /10.3/sql/sql_select.cc:19227
|
#13 0x000055e4b37f02b9 in JOIN::exec_inner (this=0x7f1c0003ccc8) at /10.3/sql/sql_select.cc:4107
|
#14 0x000055e4b37ef68c in JOIN::exec (this=0x7f1c0003ccc8) at /10.3/sql/sql_select.cc:3901
|
#15 0x000055e4b37f0993 in mysql_select (thd=0x7f1c00000d50, tables=0x7f1c00018390, wild_num=0, fields=..., conds=0x7f1c0009a8e0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2416184064, result=0x7f1c0003cbe0, unit=0x7f1c000178b0, select_lex=0x7f1c00017498) at /10.3/sql/sql_select.cc:4306
|
#16 0x000055e4b375299a in mysql_derived_fill (thd=0x7f1c00000d50, lex=0x7f1c00004b58, derived=0x7f1c0009e590) at /10.3/sql/sql_derived.cc:1169
|
#17 0x000055e4b375023c in mysql_handle_single_derived (lex=0x7f1c00004b58, derived=0x7f1c0009e590, phases=96) at /10.3/sql/sql_derived.cc:199
|
#18 0x000055e4b380820d in st_join_table::preread_init (this=0x7f1c00054760) at /10.3/sql/sql_select.cc:12831
|
#19 0x000055e4b3819d93 in sub_select (join=0x7f1c000a00f8, join_tab=0x7f1c00054760, end_of_records=false) at /10.3/sql/sql_select.cc:19655
|
#20 0x000055e4b381a66d in evaluate_join_record (join=0x7f1c000a00f8, join_tab=0x7f1c000543d0, error=0) at /10.3/sql/sql_select.cc:19907
|
#21 0x000055e4b3819f31 in sub_select (join=0x7f1c000a00f8, join_tab=0x7f1c000543d0, end_of_records=false) at /10.3/sql/sql_select.cc:19687
|
#22 0x000055e4b38193cf in do_select (join=0x7f1c000a00f8, procedure=0x0) at /10.3/sql/sql_select.cc:19227
|
#23 0x000055e4b37f02b9 in JOIN::exec_inner (this=0x7f1c000a00f8) at /10.3/sql/sql_select.cc:4107
|
#24 0x000055e4b37ef68c in JOIN::exec (this=0x7f1c000a00f8) at /10.3/sql/sql_select.cc:3901
|
#25 0x000055e4b37f0993 in mysql_select (thd=0x7f1c00000d50, tables=0x7f1c0009df38, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x7f1c0009de50, unit=0x7f1c00004c18, select_lex=0x7f1c000053a0) at /10.3/sql/sql_select.cc:4306
|
#26 0x000055e4b37e1f7a in handle_select (thd=0x7f1c00000d50, lex=0x7f1c00004b58, result=0x7f1c0009de50, setup_tables_done_option=0) at /10.3/sql/sql_select.cc:382
|
#27 0x000055e4b37a96b1 in execute_sqlcom_select (thd=0x7f1c00000d50, all_tables=0x7f1c0009df38) at /10.3/sql/sql_parse.cc:6294
|
#28 0x000055e4b379fe3c in mysql_execute_command (thd=0x7f1c00000d50) at /10.3/sql/sql_parse.cc:3820
|
#29 0x000055e4b37ad9ea in mysql_parse (thd=0x7f1c00000d50, rawbuf=0x7f1c00012a78 "WITH RECURSIVE \ncte AS\n(SELECT YEAR(t1.d1) AS YEAR, t1.d1 AS st, t1.d1 + INTERVAL 1 MONTH AS fn FROM t1\nUNION ALL \nSELECT YEAR(cte.st + INTERVAL 1 MONTH), cte.st + INTERVAL 1 MONTH, t1.d2 + INTERVAL"..., length=500, parser_state=0x7f1c109aa540, is_com_multi=false, is_next_command=false) at /10.3/sql/sql_parse.cc:7818
|
#30 0x000055e4b379a1cf in dispatch_command (command=COM_QUERY, thd=0x7f1c00000d50, packet=0x7f1c00008ed1 "", packet_length=500, is_com_multi=false, is_next_command=false) at /10.3/sql/sql_parse.cc:1856
|
#31 0x000055e4b3798aad in do_command (thd=0x7f1c00000d50) at /10.3/sql/sql_parse.cc:1402
|
#32 0x000055e4b39120a7 in do_handle_one_connection (connect=0x55e4b729d470) at /10.3/sql/sql_connect.cc:1403
|
#33 0x000055e4b3911de3 in handle_one_connection (arg=0x55e4b729d470) at /10.3/sql/sql_connect.cc:1308
|
#34 0x000055e4b42c9b24 in pfs_spawn_thread (arg=0x55e4b72b7e80) at /10.3/storage/perfschema/pfs.cc:1869
|
#35 0x00007f1c17e166db in start_thread (arg=0x7f1c109ab700) at pthread_create.c:463
|
#36 0x00007f1c1720088f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
|
On 10.2 it is sporadic, I get the crash only on every second execution of the test, but on 10.3-10.5 test fails every time
|
|
Observation
The following query in which specification of cte2 follows specification of cte3 returns a proper result set:
WITH RECURSIVE
|
cte AS
|
(SELECT YEAR(t1.d1) AS YEAR, t1.d1 AS st, t1.d1 + INTERVAL 1 MONTH AS fn FROM t1
|
UNION ALL
|
SELECT YEAR(cte.st + INTERVAL 1 MONTH), cte.st + INTERVAL 1 MONTH, t1.d2 + INTERVAL 1 DAY
|
FROM cte JOIN t1
|
WHERE cte.st + INTERVAL 1 MONTH < t1.d2 ),
|
cte3 AS (SELECT YEAR, COUNT(*)
|
FROM cte JOIN t3 ON t3.tm BETWEEN cte.st AND cte.fn),
|
cte2 AS (SELECT YEAR, COUNT(*)
|
FROM cte JOIN t2 ON t2.tm BETWEEN cte.st AND cte.fn)
|
SELECT 1 FROM t1 JOIN cte2 USING (YEAR) JOIN cte3 USING (YEAR);
|
MariaDB [test]> WITH RECURSIVE
|
-> cte AS
|
-> (SELECT YEAR(t1.d1) AS YEAR, t1.d1 AS st, t1.d1 + INTERVAL 1 MONTH AS fn FROM t1
|
-> UNION ALL
|
-> SELECT YEAR(cte.st + INTERVAL 1 MONTH), cte.st + INTERVAL 1 MONTH, t1.d2 + INTERVAL 1 DAY
|
-> FROM cte JOIN t1
|
-> WHERE cte.st + INTERVAL 1 MONTH < t1.d2 ),
|
-> cte3 AS (SELECT YEAR, COUNT(*)
|
-> FROM cte JOIN t3 ON t3.tm BETWEEN cte.st AND cte.fn),
|
-> cte2 AS (SELECT YEAR, COUNT(*)
|
-> FROM cte JOIN t2 ON t2.tm BETWEEN cte.st AND cte.fn)
|
-> SELECT 1 FROM t1 JOIN cte2 USING (YEAR) JOIN cte3 USING (YEAR);
|
+---+
|
| 1 |
|
+---+
|
| 1 |
|
+---+
|
Why?
The analysis for this query shows that the specification of cte is attached now to the specification of cte2 (not to the sp ecification for cte3 as for the first query). However cte2 and cte3 are populated in the same order: first cte3, then cte2. So the code
for (SELECT_LEX_UNIT *lex_unit= first_inner_unit(); lex_unit ;
|
lex_unit= lex_unit->next_unit())
|
{
|
error= (bool) ((uint) error | (uint) lex_unit->cleanup());
|
}
|
has no effect when after cte3 has been filled.
|