[MDEV-24529] Assertion `0' failed in vers_select_conds_t::print upon DELETE HISTORY from view with optimizer trace Created: 2021-01-05  Updated: 2022-04-19  Resolved: 2022-04-18

Status: Closed
Project: MariaDB Server
Component/s: Optimizer, Versioned Tables, Views
Affects Version/s: 10.4, 10.5, 10.6, 10.7
Fix Version/s: 10.4.25, 10.5.16, 10.6.8, 10.7.4, 10.8.3

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Oleg Smirnov
Resolution: Fixed Votes: 0
Labels: None


 Description   

CREATE TABLE t (a INT) WITH SYSTEM VERSIONING;
CREATE ALGORITHM=TEMPTABLE VIEW v AS SELECT * FROM t;
SET optimizer_trace= 'enabled=on';
--error ER_NON_UPDATABLE_TABLE
DELETE HISTORY FROM v BEFORE SYSTEM_TIME '2021-01-01';
 
# Cleanup
DROP VIEW v;
DROP TABLE t;

10.4 d67e17bb

mysqld: /data/src/10.4/sql/sql_select.cc:758: void vers_select_conds_t::print(String*, enum_query_type) const: Assertion `0' failed.
210105 20:35:21 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f5fd67bff36 in __GI___assert_fail (assertion=0x56214eb9448c "0", file=0x56214eb95928 "/data/src/10.4/sql/sql_select.cc", line=758, function=0x56214eb95bd0 "void vers_select_conds_t::print(String*, enum_query_type) const") at assert.c:101
#8  0x000056214ded0b58 in vers_select_conds_t::print (this=0x7f5fc00166d8, str=0x7f5fd078c840, query_type=1037) at /data/src/10.4/sql/sql_select.cc:758
#9  0x000056214df1eb7b in TABLE_LIST::print (this=0x7f5fc00160d8, thd=0x7f5fc0000d90, eliminated_tables=0, str=0x7f5fd078c840, query_type=1037) at /data/src/10.4/sql/sql_select.cc:27363
#10 0x000056214df1dc8e in print_table_array (thd=0x7f5fc0000d90, eliminated_tables=0, str=0x7f5fd078c840, table=0x7f5fc0018268, end=0x7f5fc0018270, query_type=1037) at /data/src/10.4/sql/sql_select.cc:27052
#11 0x000056214df1e384 in print_join (thd=0x7f5fc0000d90, eliminated_tables=0, str=0x7f5fd078c840, tables=0x7f5fc0015c68, query_type=1037) at /data/src/10.4/sql/sql_select.cc:27208
#12 0x000056214df1f325 in st_select_lex::print (this=0x7f5fc0015aa8, thd=0x7f5fc0000d90, str=0x7f5fd078c840, query_type=1037) at /data/src/10.4/sql/sql_select.cc:27508
#13 0x000056214e0e8417 in opt_trace_print_expanded_query (thd=0x7f5fc0000d90, select_lex=0x7f5fc0015aa8, writer=0x7f5fd078cde0) at /data/src/10.4/sql/opt_trace.cc:115
#14 0x000056214ded452d in JOIN::prepare (this=0x7f5fc00176d0, tables_init=0x7f5fc00160d8, 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=0x7f5fc0015aa8, unit_arg=0x7f5fc0014000) at /data/src/10.4/sql/sql_select.cc:1495
#15 0x000056214df970a8 in st_select_lex_unit::prepare_join (this=0x7f5fc0014000, thd_arg=0x7f5fc0000d90, sl=0x7f5fc0015aa8, tmp_result=0x7f5fc00175e8, additional_options=0, is_union_select=false) at /data/src/10.4/sql/sql_union.cc:646
#16 0x000056214df987a4 in st_select_lex_unit::prepare (this=0x7f5fc0014000, derived_arg=0x7f5fc0013568, sel_result=0x7f5fc00175e8, additional_options=0) at /data/src/10.4/sql/sql_union.cc:993
#17 0x000056214de318b5 in mysql_derived_prepare (thd=0x7f5fc0000d90, lex=0x7f5fc0004c00, derived=0x7f5fc0013568) at /data/src/10.4/sql/sql_derived.cc:817
#18 0x000056214de2feda in mysql_handle_single_derived (lex=0x7f5fc0004c00, derived=0x7f5fc0013568, phases=2) at /data/src/10.4/sql/sql_derived.cc:206
#19 0x000056214dfcc596 in TABLE_LIST::handle_derived (this=0x7f5fc0013568, lex=0x7f5fc0004c00, phases=2) at /data/src/10.4/sql/table.cc:8844
#20 0x000056214de4b96a in LEX::handle_list_of_derived (this=0x7f5fc0004c00, table_list=0x7f5fc0013568, phases=2) at /data/src/10.4/sql/sql_lex.h:4339
#21 0x000056214e3cbde2 in mysql_delete (thd=0x7f5fc0000d90, table_list=0x7f5fc0013568, conds=0x0, order_list=0x7f5fc0005750, limit=18446744073709551615, options=0, result=0x0) at /data/src/10.4/sql/sql_delete.cc:362
#22 0x000056214de8e0af in mysql_execute_command (thd=0x7f5fc0000d90) at /data/src/10.4/sql/sql_parse.cc:4770
#23 0x000056214de98d19 in mysql_parse (thd=0x7f5fc0000d90, rawbuf=0x7f5fc0013458 "DELETE HISTORY FROM v BEFORE SYSTEM_TIME '2021-01-01'", length=53, parser_state=0x7f5fd078f550, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:7958
#24 0x000056214de85041 in dispatch_command (command=COM_QUERY, thd=0x7f5fc0000d90, packet=0x7f5fc00087b1 "DELETE HISTORY FROM v BEFORE SYSTEM_TIME '2021-01-01'", packet_length=53, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1855
#25 0x000056214de838a9 in do_command (thd=0x7f5fc0000d90) at /data/src/10.4/sql/sql_parse.cc:1373
#26 0x000056214e012b93 in do_handle_one_connection (connect=0x5621510d10f0) at /data/src/10.4/sql/sql_connect.cc:1412
#27 0x000056214e0128dc in handle_one_connection (arg=0x5621510d10f0) at /data/src/10.4/sql/sql_connect.cc:1316
#28 0x000056214ea33768 in pfs_spawn_thread (arg=0x56215101e920) at /data/src/10.4/storage/perfschema/pfs.cc:1869
#29 0x00007f5fd7040609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#30 0x00007f5fd68ab293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Reproducible on 10.4-10.5 with at least InnoDB, MyISAM, Aria.
The test case is not applicable to 10.3 community server due to the use of optimizer trace.
No obvious problem on a non-debug build.



 Comments   
Comment by Oleg Smirnov [ 2022-04-03 ]

Pushed to the branch bb-10.4-MDEV-24529, waiting for review.

Comment by Sergei Petrunia [ 2022-04-15 ]

Ok to push.

Comment by Oleg Smirnov [ 2022-04-18 ]

Pushed to 10.4: https://github.com/MariaDB/server/commit/39cc2545af9d209d39e2e547016a9bf1be605a61

Generated at Thu Feb 08 09:30:41 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.