[MDEV-19569] Assertion `table_list->table' failed in find_field_in_table_ref and Assertion `table_ref->table || table_ref->view' in Field_iterator_table_ref::set_field_iterator Created: 2019-05-23  Updated: 2022-10-25  Resolved: 2022-10-20

Status: Closed
Project: MariaDB Server
Component/s: Partitioning, Protocol
Affects Version/s: 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9
Fix Version/s: 10.3.37, 10.4.27, 10.5.18, 10.6.11, 10.7.7, 10.8.6

Type: Bug Priority: Critical
Reporter: Alice Sherepa Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: affects-tests, regression-10.3

Issue Links:
Blocks
blocks MDEV-26634 Feature request: add STATEMENT_DIGEST... Closed
Relates
relates to MDEV-18136 Server crashes in Item_func_dyncol_cr... Closed
relates to MDEV-25012 Server crash in find_field_in_tables,... Confirmed
relates to MDEV-28510 SIGSEGV in get_sort_by_table and SIGS... Closed
relates to MDEV-18163 Assertion `table_share->tmp_table != ... Closed
relates to MDEV-28505 Server crash in sql/sql_select.cc:198... Closed

 Description   

--source include/have_partition.inc
create table t1 (i int); 
create table t2 (i int); 
 
ALTER TABLE t1 PARTITION BY system_time 
    INTERVAL (SELECT i FROM t2) DAY (PARTITION p1 HISTORY, PARTITION pn CURRENT) ;

10.3 592dc59d7a5f9bd80bffdd9d

 
/10.3/sql/sql_base.cc:5955: Field* find_field_in_table_ref(THD*, TABLE_LIST*, const char*, size_t, const char*, const char*, const char*, Item**, bool, bool, uint*, bool, TABLE_LIST**): Assertion `table_list->table' failed.
 
linux/raise.c:54(__GI_raise)[0x7f9e7674f428]
stdlib/abort.c:91(__GI_abort)[0x7f9e7675102a]
assert/assert.c:92(__assert_fail_base)[0x7f9e76747bd7]
/lib/x86_64-linux-gnu/libc.so.6(+0x2dc82)[0x7f9e76747c82]
sql/sql_base.cc:5956(find_field_in_table_ref(THD*, TABLE_LIST*, char const*, unsigned long, char const*, char const*, char const*, Item**, bool, bool, unsigned int*, bool, TABLE_LIST**))[0x564e28719709]
sql/sql_base.cc:6257(find_field_in_tables(THD*, Item_ident*, TABLE_LIST*, TABLE_LIST*, Item**, find_item_error_report_type, bool, bool))[0x564e2871af41]
sql/item.cc:6053(Item_field::fix_fields(THD*, Item**))[0x564e28fa49ab]
sql/item.h:825(Item::fix_fields_if_needed(THD*, Item**))[0x564e2862d15b]
sql/item.h:828(Item::fix_fields_if_needed_for_scalar(THD*, Item**))[0x564e2862d189]
sql/sql_base.cc:7463(setup_fields(THD*, Bounds_checked_array<Item*>, List<Item>&, enum_column_usage, List<Item>*, List<Item>*, bool))[0x564e2872146e]
sql/sql_select.cc:1102(JOIN::prepare(TABLE_LIST*, unsigned int, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*))[0x564e288e6e26]
sql/item_subselect.cc:3676(subselect_single_select_engine::prepare(THD*))[0x564e2913d628]
sql/item_subselect.cc:276(Item_subselect::fix_fields(THD*, Item**))[0x564e2911d633]
sql/item.h:825(Item::fix_fields_if_needed(THD*, Item**))[0x564e2862d15b]
sql/item.h:828(Item::fix_fields_if_needed_for_scalar(THD*, Item**))[0x564e2862d189]
sql/partition_info.h:404(partition_info::vers_set_interval(THD*, Item*, interval_type, long))[0x564e28de3599]
sql/sql_yacc.yy:6067(MYSQLparse(THD*))[0x564e28d77cb5]
sql/sql_parse.cc:10093(parse_sql(THD*, Parser_state*, Object_creation_ctx*, bool))[0x564e2887bc40]
sql/sql_parse.cc:8051(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x564e2886f99c]
sql/sql_parse.cc:1860(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x564e2884a90e]
sql/sql_parse.cc:1404(do_command(THD*))[0x564e28847a72]
sql/sql_connect.cc:1402(do_handle_one_connection(CONNECT*))[0x564e28b9db16]
sql/sql_connect.cc:1309(handle_one_connection)[0x564e28b9d4f3]
perfschema/pfs.cc:1864(pfs_spawn_thread)[0x564e29ec536d]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7f9e7738c6ba]
x86_64/clone.S:111(clone)[0x7f9e7682141d]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x62b000000288): ALTER TABLE t1 PARTITION BY system_time  INTERVAL (SELECT i FROM t2) DAY (PARTITION p1 HISTORY, PARTITION pn CURRENT)

non-debug build fails with sig 11

201002 16:04:18 [ERROR] mysqld got signal 11 ;
 
Server version: 10.5.5-MariaDB
 
sql/sql_base.cc:5933(find_field_in_table(THD*, TABLE*, char const*, unsigned long, bool, unsigned int*))[0x5578c6e3d4ec]
sql/sql_base.cc:6091(find_field_in_table_ref(THD*, TABLE_LIST*, char const*, unsigned long, char const*, char const*, char const*, Item**, bool, bool, unsigned int*, bool, TABLE_LIST**))[0x5578c6e3d90c]
sql/sql_base.cc:6394(find_field_in_tables(THD*, Item_ident*, TABLE_LIST*, TABLE_LIST*, Item**, find_item_error_report_type, bool, bool))[0x5578c70c8ca7]
sql/item.cc:5817(Item_field::fix_fields(THD*, Item**))[0x5578c6e3e099]
sql/item.h:986(setup_fields(THD*, Bounds_checked_array<Item*>, List<Item>&, enum_column_usage, List<Item>*, List<Item>*, bool))[0x5578c6ee6eea]
sql/sql_select.cc:1250(JOIN::prepare(TABLE_LIST*, Item*, unsigned int, st_order*, bool, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*))[0x5578c715b788]
sql/item_subselect.cc:3775(subselect_single_select_engine::prepare(THD*))[0x5578c715aa95]
sql/item_subselect.cc:285(Item_subselect::fix_fields(THD*, Item**))[0x5578c6f7bd98]
sql/item.h:986(partition_info::vers_set_interval(THD*, Item*, interval_type, Item*, char const*))[0x5578c702a9b2]
sql/sql_yacc.yy:5341(MYSQLparse(THD*))[0x5578c6ea530d]
sql/sql_parse.cc:10352(parse_sql(THD*, Parser_state*, Object_creation_ctx*, bool))[0x5578c6ea5576]
sql/sql_parse.cc:7949(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x5578c6ea76d2]
sql/sql_parse.cc:1927(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x5578c6ea8b5b]
sql/sql_parse.cc:1353(do_command(THD*))[0x5578c6f90b92]
sql/sql_connect.cc:1410(do_handle_one_connection(CONNECT*, bool))[0x5578c6f90e44]
sql/sql_connect.cc:1318(handle_one_connection)[0x5578c730e02d]
nptl/pthread_create.c:487(start_thread)[0x7f50bbc1afa3]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f)[0x7f50bb7f44cf]
 
Query (0x7f505c011c30): ALTER TABLE t1 PARTITION BY system_time      INTERVAL (SELECT i FROM t2) DAY (PARTITION p1 HISTORY, PARTITION pn CURRENT)



 Comments   
Comment by Roel Van de Paar [ 2021-06-07 ]

The server will crash even with a malformed statement:

ALTER TABLE t PARTITION BY SYSTEM_TIME INTERVAL (SELECT i FROM t2) DAY (PARTITION p HISTORY;

10.6.2 06dd151bb86ad5b87d4d46011f36da1289c01074 (Debug)

10.6.2-dbg>ALTER TABLE t PARTITION BY SYSTEM_TIME INTERVAL (SELECT i FROM t2) DAY (PARTITION p HISTORY;
ERROR 2013 (HY000): Lost connection to server during query

Leads to:

10.6.2 06dd151bb86ad5b87d4d46011f36da1289c01074 (Debug)

mysqld: /test/10.6_dbg/sql/sql_base.cc:6172: Field* find_field_in_table_ref(THD*, TABLE_LIST*, const char*, size_t, const char*, const char*, const char*, ignored_tables_list_t, Item**, bool, bool, field_index_t*, bool, TABLE_LIST**): Assertion `table_list->table' failed.

10.6.2 06dd151bb86ad5b87d4d46011f36da1289c01074 (Debug)

Core was generated by `/test/MD050621-mariadb-10.6.2-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x14bd844c8700 (LWP 3566169))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000014bd87086859 in __GI_abort () at abort.c:79
#2  0x000014bd87086729 in __assert_fail_base (fmt=0x14bd8721c588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x556dd5a5dda7 "table_list->table", file=0x556dd5a5b1a0 "/test/10.6_dbg/sql/sql_base.cc", line=6172, function=<optimized out>) at assert.c:92
#3  0x000014bd87097f36 in __GI___assert_fail (assertion=assertion@entry=0x556dd5a5dda7 "table_list->table", file=file@entry=0x556dd5a5b1a0 "/test/10.6_dbg/sql/sql_base.cc", line=line@entry=6172, function=function@entry=0x556dd5a5ce38 "Field* find_field_in_table_ref(THD*, TABLE_LIST*, const char*, size_t, const char*, const char*, const char*, ignored_tables_list_t, Item**, bool, bool, field_index_t*, bool, TABLE_LIST**)") at assert.c:101
#4  0x0000556dd4d42872 in find_field_in_table_ref (thd=thd@entry=0x14bd40000db8, table_list=table_list@entry=0x14bd400151e0, name=name@entry=0x14bd40015078 "i", length=length@entry=1, item_name=0x14bd40015078 "i", db_name=db_name@entry=0x0, table_name=0x0, ignored_tables=0x0, ref=0x14bd400151a0, check_privileges=true, allow_rowid=true, cached_field_index_ptr=0x14bd40015168, register_tree_change=true, actual_table=0x14bd844c5d48) at /test/10.6_dbg/sql/sql_base.cc:6172
#5  0x0000556dd4d438c0 in find_field_in_tables (thd=thd@entry=0x14bd40000db8, item=item@entry=0x14bd40015080, first_table=<optimized out>, last_table=0x0, ignored_tables=0x0, ref=ref@entry=0x14bd400151a0, report_error=IGNORE_EXCEPT_NON_UNIQUE, check_privileges=true, register_tree_change=true) at /test/10.6_dbg/sql/sql_base.cc:6483
#6  0x0000556dd50de3d9 in Item_field::fix_fields (this=0x14bd40015080, thd=0x14bd40000db8, reference=0x14bd400151a0) at /test/10.6_dbg/sql/item.cc:5890
#7  0x0000556dd4d4456d in Item::fix_fields_if_needed (ref=0x14bd400151a0, thd=0x14bd40000db8, this=0x14bd40015080) at /test/10.6_dbg/sql/item.h:1148
#8  Item::fix_fields_if_needed_for_scalar (ref=0x14bd400151a0, thd=0x14bd40000db8, this=0x14bd40015080) at /test/10.6_dbg/sql/item.h:1148
#9  setup_fields (thd=0x14bd40000db8, ref_pointer_array=<optimized out>, fields=<optimized out>, column_usage=column_usage@entry=MARK_COLUMNS_READ, sum_func_list=sum_func_list@entry=0x14bd40016600, pre_fix=0x14bd40014eb8, allow_sum_func=true) at /test/10.6_dbg/sql/sql_base.cc:7682
#10 0x0000556dd4e37a5a in JOIN::prepare (this=0x14bd400162a8, tables_init=<optimized out>, conds_init=<optimized out>, og_num=<optimized out>, order_init=<optimized out>, skip_order_by=skip_order_by@entry=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x14bd40014c00, unit_arg=0x14bd400158e8) at /test/10.6_dbg/sql/sql_select.cc:1395
#11 0x0000556dd51aaaed in subselect_single_select_engine::prepare (this=0x14bd40016268, thd=0x14bd40000db8) at /test/10.6_dbg/sql/sql_lex.h:1377
#12 0x0000556dd51a9f37 in Item_subselect::fix_fields (this=0x14bd400160e0, thd_param=<optimized out>, ref=0x14bd844c6368) at /test/10.6_dbg/sql/item_subselect.cc:293
#13 0x0000556dd4f150e0 in Item::fix_fields_if_needed (ref=0x14bd844c6368, thd=0x14bd40000db8, this=0x14bd400160e0) at /test/10.6_dbg/sql/item.h:1148
#14 Item::fix_fields_if_needed_for_scalar (ref=0x14bd844c6368, thd=0x14bd40000db8, this=0x14bd400160e0) at /test/10.6_dbg/sql/item.h:1148
#15 partition_info::vers_set_interval (this=0x14bd40014958, thd=thd@entry=0x14bd40000db8, interval=<optimized out>, int_type=INTERVAL_DAY, starts=<optimized out>, table_name=0x14bd40014238 "t") at /test/10.6_dbg/sql/partition_info.cc:2658
#16 0x0000556dd501283e in MYSQLparse (thd=thd@entry=0x14bd40000db8) at /test/10.6_dbg/sql/sql_yacc.yy:5398
#17 0x0000556dd4dc3392 in parse_sql (thd=thd@entry=0x14bd40000db8, parser_state=parser_state@entry=0x14bd844c7400, creation_ctx=creation_ctx@entry=0x0, do_pfs_digest=do_pfs_digest@entry=true) at /test/10.6_dbg/sql/sql_parse.cc:10396
#18 0x0000556dd4dbd93b in mysql_parse (thd=thd@entry=0x14bd40000db8, rawbuf=<optimized out>, length=91, parser_state=parser_state@entry=0x14bd844c7400) at /test/10.6_dbg/sql/sql_parse.cc:7968
#19 0x0000556dd4dcc646 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14bd40000db8, packet=packet@entry=0x14bd4000b769 "ALTER TABLE t PARTITION BY SYSTEM_TIME INTERVAL (SELECT i FROM t2) DAY (PARTITION p HISTORY", packet_length=packet_length@entry=91, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_class.h:1340
#20 0x0000556dd4dcfa26 in do_command (thd=0x14bd40000db8, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_parse.cc:1406
#21 0x0000556dd4f33ec2 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x556dd8e12978, put_in_cache=put_in_cache@entry=true) at /test/10.6_dbg/sql/sql_connect.cc:1410
#22 0x0000556dd4f344c7 in handle_one_connection (arg=arg@entry=0x556dd8e12978) at /test/10.6_dbg/sql/sql_connect.cc:1312
#23 0x0000556dd53e003a in pfs_spawn_thread (arg=0x556dd8cfb678) at /test/10.6_dbg/storage/perfschema/pfs.cc:2201
#24 0x000014bd87594609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#25 0x000014bd87183293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

10.6.2 06dd151bb86ad5b87d4d46011f36da1289c01074 (Optimized)

Core was generated by `/test/MD050621-mariadb-10.6.2-linux-x86_64-opt/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055b92a2806f1 in find_field_in_table (thd=thd@entry=0x14c0c8000c58, 
    table=0x0, name=name@entry=0x14c0c8011918 "i", length=length@entry=1, 
    allow_rowid=true, 
    cached_field_index_ptr=cached_field_index_ptr@entry=0x14c0c8011a08)
    at /test/10.6_opt/sql/sql_base.cc:6007
[Current thread is 1 (Thread 0x14c118e02700 (LWP 3586172))]
(gdb) bt
#0  0x000055b92a2806f1 in find_field_in_table (thd=thd@entry=0x14c0c8000c58, table=0x0, name=name@entry=0x14c0c8011918 "i", length=length@entry=1, allow_rowid=true, cached_field_index_ptr=cached_field_index_ptr@entry=0x14c0c8011a08) at /test/10.6_opt/sql/sql_base.cc:6007
#1  0x000055b92a280ea7 in find_field_in_table_ref (thd=thd@entry=0x14c0c8000c58, table_list=table_list@entry=0x14c0c8011a80, name=name@entry=0x14c0c8011918 "i", length=length@entry=1, item_name=0x14c0c8011918 "i", db_name=db_name@entry=0x0, table_name=0x0, ignored_tables=0x0, ref=0x14c0c8011a40, check_privileges=true, allow_rowid=true, cached_field_index_ptr=0x14c0c8011a08, register_tree_change=true, actual_table=0x14c118dffde8) at /test/10.6_opt/sql/sql_base.cc:6173
#2  0x000055b92a2814f2 in find_field_in_tables (thd=thd@entry=0x14c0c8000c58, item=item@entry=0x14c0c8011920, first_table=<optimized out>, last_table=last_table@entry=0x0, ignored_tables=0x0, ref=ref@entry=0x14c0c8011a40, report_error=IGNORE_EXCEPT_NON_UNIQUE, check_privileges=true, register_tree_change=true) at /test/10.6_opt/sql/sql_base.cc:6483
#3  0x000055b92a531caf in Item_field::fix_fields (this=0x14c0c8011920, thd=0x14c0c8000c58, reference=0x14c0c8011a40) at /test/10.6_opt/sql/item.cc:5890
#4  0x000055b92a28200b in Item::fix_fields_if_needed (ref=0x14c0c8011a40, thd=0x14c0c8000c58, this=0x14c0c8011920) at /test/10.6_opt/sql/item.h:1142
#5  Item::fix_fields_if_needed (ref=0x14c0c8011a40, thd=0x14c0c8000c58, this=0x14c0c8011920) at /test/10.6_opt/sql/item.h:1142
#6  Item::fix_fields_if_needed_for_scalar (ref=0x14c0c8011a40, thd=0x14c0c8000c58, this=0x14c0c8011920) at /test/10.6_opt/sql/item.h:1148
#7  setup_fields (thd=0x14c0c8000c58, ref_pointer_array=<optimized out>, fields=<optimized out>, column_usage=column_usage@entry=MARK_COLUMNS_READ, sum_func_list=sum_func_list@entry=0x14c0c8012ea0, pre_fix=0x14c0c8011758, allow_sum_func=true) at /test/10.6_opt/sql/sql_base.cc:7682
#8  0x000055b92a33d7a8 in JOIN::prepare (this=0x14c0c8012b48, tables_init=<optimized out>, conds_init=<optimized out>, og_num=<optimized out>, order_init=<optimized out>, skip_order_by=skip_order_by@entry=false, group_init=<optimized out>, having_init=<optimized out>, proc_param_init=<optimized out>, select_lex_arg=<optimized out>, unit_arg=<optimized out>) at /test/10.6_opt/sql/sql_select.cc:1395
#9  0x000055b92a5cf408 in subselect_single_select_engine::prepare (this=0x14c0c8012b08, thd=0x14c0c8000c58) at /test/10.6_opt/sql/sql_lex.h:1377
#10 0x000055b92a5ceaba in Item_subselect::fix_fields (this=0x14c0c8012980, thd_param=<optimized out>, ref=0x14c118e003b8) at /test/10.6_opt/sql/item_subselect.cc:293
#11 0x000055b92a3e38da in Item::fix_fields_if_needed (ref=0x14c118e003b8, thd=0x14c0c8000c58, this=0x14c0c8012980) at /test/10.6_opt/sql/item.h:1142
#12 Item::fix_fields_if_needed (ref=0x14c118e003b8, thd=0x14c0c8000c58, this=0x14c0c8012980) at /test/10.6_opt/sql/item.h:1142
#13 Item::fix_fields_if_needed_for_scalar (ref=0x14c118e003b8, thd=0x14c0c8000c58, this=0x14c0c8012980) at /test/10.6_opt/sql/item.h:1148
#14 partition_info::vers_set_interval (this=0x14c0c80111f8, thd=thd@entry=0x14c0c8000c58, interval=<optimized out>, int_type=INTERVAL_DAY, starts=<optimized out>, table_name=0x14c0c8010ad8 "t") at /test/10.6_opt/sql/partition_info.cc:2658
#15 0x000055b92a49e4db in MYSQLparse (thd=<optimized out>) at /test/10.6_opt/sql/sql_yacc.yy:5398
#16 0x000055b92a2e0cf5 in parse_sql (thd=thd@entry=0x14c0c8000c58, parser_state=parser_state@entry=0x14c118e01430, creation_ctx=creation_ctx@entry=0x0, do_pfs_digest=do_pfs_digest@entry=true) at /test/10.6_opt/include/mysql/psi/mysql_statement.h:159
#17 0x000055b92a2dc427 in mysql_parse (thd=0x14c0c8000c58, rawbuf=0x14c0c80109b0 "ALTER TABLE t PARTITION BY SYSTEM_TIME INTERVAL (SELECT i FROM t2) DAY (PARTITION p HISTORY", length=<optimized out>, parser_state=0x14c118e01430) at /test/10.6_opt/sql/sql_parse.cc:7968
#18 0x000055b92a2e83c5 in dispatch_command (command=COM_QUERY, thd=0x14c0c8000c58, packet=<optimized out>, packet_length=<optimized out>, blocking=<optimized out>) at /test/10.6_opt/sql/sql_class.h:1340
#19 0x000055b92a2ea327 in do_command (thd=0x14c0c8000c58, blocking=blocking@entry=true) at /test/10.6_opt/sql/sql_parse.cc:1406
#20 0x000055b92a3f8167 in do_handle_one_connection (connect=<optimized out>, put_in_cache=true) at /test/10.6_opt/sql/sql_connect.cc:1410
#21 0x000055b92a3f84cd in handle_one_connection (arg=arg@entry=0x55b92d5a4e58) at /test/10.6_opt/sql/sql_connect.cc:1312
#22 0x000055b92a7808e8 in pfs_spawn_thread (arg=0x55b92d5419b8) at /test/10.6_opt/storage/perfschema/pfs.cc:2201
#23 0x000014c11be94609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#24 0x000014c11ba83293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.3.29 (dbg), 10.3.29 (opt), 10.4.19 (dbg), 10.4.19 (opt), 10.5.10 (dbg), 10.6.2 (dbg), 10.6.2 (opt)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.38 (dbg), 10.2.38 (opt), 10.5.10 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.34 (dbg), 5.7.34 (opt), 8.0.24 (dbg), 8.0.24 (opt)

Comment by Roel Van de Paar [ 2021-11-13 ]

ALTER TABLE t PARTITION BY SYSTEM_TIME INTERVAL (SELECT c FROM t) DAY (PARTITION p HISTORY;

Leads to:

10.8.0 bc57ff7cf79504a198d4752b4748340a4afd886c (Debug)

mysqld: /test/10.8_dbg/sql/sql_base.cc:6194: Field* find_field_in_table_ref(THD*, TABLE_LIST*, const char*, size_t, const char*, const char*, const char*, ignored_tables_list_t, Item**, bool, bool, field_index_t*, bool, TABLE_LIST**): Assertion `table_list->table' failed.

10.8.0 bc57ff7cf79504a198d4752b4748340a4afd886c (Debug)

Core was generated by `/test/MD121121-mariadb-10.8.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x154b404bb700 (LWP 505916))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x0000154b41940859 in __GI_abort () at abort.c:79
#2  0x0000154b41940729 in __assert_fail_base (fmt=0x154b41ad6588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x560a00e0dadf "table_list->table", file=0x560a00e0af58 "/test/10.8_dbg/sql/sql_base.cc", line=6194, function=<optimized out>) at assert.c:92
#3  0x0000154b41951f36 in __GI___assert_fail (assertion=assertion@entry=0x560a00e0dadf "table_list->table", file=file@entry=0x560a00e0af58 "/test/10.8_dbg/sql/sql_base.cc", line=line@entry=6194, function=function@entry=0x560a00e0cb58 "Field* find_field_in_table_ref(THD*, TABLE_LIST*, const char*, size_t, const char*, const char*, const char*, ignored_tables_list_t, Item**, bool, bool, field_index_t*, bool, TABLE_LIST**)") at assert.c:101
#4  0x0000560a000bf58a in find_field_in_table_ref (thd=thd@entry=0x154ae8000db8, table_list=table_list@entry=0x154ae8014ff8, name=name@entry=0x154ae8014e90 "c", length=length@entry=1, item_name=0x154ae8014e90 "c", db_name=db_name@entry=0x0, table_name=0x0, ignored_tables=0x0, ref=0x154ae8014fb8, check_privileges=true, allow_rowid=true, cached_field_index_ptr=0x154ae8014f80, register_tree_change=true, actual_table=0x154b404b8d08) at /test/10.8_dbg/sql/sql_base.cc:6194
#5  0x0000560a000c0567 in find_field_in_tables (thd=thd@entry=0x154ae8000db8, item=item@entry=0x154ae8014e98, first_table=<optimized out>, last_table=0x0, ignored_tables=0x0, ref=ref@entry=0x154ae8014fb8, report_error=IGNORE_EXCEPT_NON_UNIQUE, check_privileges=true, register_tree_change=true) at /test/10.8_dbg/sql/sql_base.cc:6505
#6  0x0000560a0048b279 in Item_field::fix_fields (this=0x154ae8014e98, thd=0x154ae8000db8, reference=0x154ae8014fb8) at /test/10.8_dbg/sql/item.cc:6004
#7  0x0000560a000c130c in Item::fix_fields_if_needed (ref=0x154ae8014fb8, thd=0x154ae8000db8, this=0x154ae8014e98) at /test/10.8_dbg/sql/item.h:1148
#8  Item::fix_fields_if_needed_for_scalar (ref=0x154ae8014fb8, thd=0x154ae8000db8, this=0x154ae8014e98) at /test/10.8_dbg/sql/item.h:1148
#9  setup_fields (thd=0x154ae8000db8, ref_pointer_array=<optimized out>, fields=<optimized out>, column_usage=column_usage@entry=MARK_COLUMNS_READ, sum_func_list=sum_func_list@entry=0x154ae8016428, pre_fix=0x154ae8014cd0, allow_sum_func=true) at /test/10.8_dbg/sql/sql_base.cc:7716
#10 0x0000560a001cf8ab in JOIN::prepare (this=0x154ae80160c0, tables_init=<optimized out>, conds_init=<optimized out>, og_num=<optimized out>, order_init=<optimized out>, skip_order_by=skip_order_by@entry=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x154ae8014a18, unit_arg=0x154ae8015700) at /test/10.8_dbg/sql/sql_select.cc:1397
#11 0x0000560a0056d0df in subselect_single_select_engine::prepare (this=0x154ae8016080, thd=0x154ae8000db8) at /test/10.8_dbg/sql/sql_lex.h:1363
#12 0x0000560a0056c503 in Item_subselect::fix_fields (this=0x154ae8015ef8, thd_param=<optimized out>, ref=0x154b404b9368) at /test/10.8_dbg/sql/item_subselect.cc:295
#13 0x0000560a002adeb8 in Item::fix_fields_if_needed (ref=0x154b404b9368, thd=0x154ae8000db8, this=0x154ae8015ef8) at /test/10.8_dbg/sql/item.h:1148
#14 Item::fix_fields_if_needed_for_scalar (ref=0x154b404b9368, thd=0x154ae8000db8, this=0x154ae8015ef8) at /test/10.8_dbg/sql/item.h:1148
#15 partition_info::vers_set_interval (this=0x154ae8014788, thd=thd@entry=0x154ae8000db8, interval=<optimized out>, int_type=INTERVAL_DAY, starts=<optimized out>, table_name=0x154ae8014068 "t") at /test/10.8_dbg/sql/partition_info.cc:2654
#16 0x0000560a003be67e in MYSQLparse (thd=thd@entry=0x154ae8000db8) at /test/10.8_dbg/sql/sql_yacc.yy:5097
#17 0x0000560a00146569 in parse_sql (thd=thd@entry=0x154ae8000db8, parser_state=parser_state@entry=0x154b404ba400, creation_ctx=creation_ctx@entry=0x0, do_pfs_digest=do_pfs_digest@entry=true) at /test/10.8_dbg/sql/sql_parse.cc:10406
#18 0x0000560a00140b07 in mysql_parse (thd=thd@entry=0x154ae8000db8, rawbuf=<optimized out>, length=90, parser_state=parser_state@entry=0x154b404ba400) at /test/10.8_dbg/sql/sql_parse.cc:7980
#19 0x0000560a0014f949 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x154ae8000db8, packet=packet@entry=0x154ae800b879 "ALTER TABLE t PARTITION BY SYSTEM_TIME INTERVAL (SELECT c FROM t) DAY (PARTITION p HISTORY", packet_length=packet_length@entry=90, blocking=blocking@entry=true) at /test/10.8_dbg/sql/sql_class.h:1360
#20 0x0000560a00152d83 in do_command (thd=0x154ae8000db8, blocking=blocking@entry=true) at /test/10.8_dbg/sql/sql_parse.cc:1402
#21 0x0000560a002cce2a in do_handle_one_connection (connect=<optimized out>, connect@entry=0x560a03b2e088, put_in_cache=put_in_cache@entry=true) at /test/10.8_dbg/sql/sql_connect.cc:1418
#22 0x0000560a002cd42f in handle_one_connection (arg=arg@entry=0x560a03b2e088) at /test/10.8_dbg/sql/sql_connect.cc:1312
#23 0x0000560a0074d4ce in pfs_spawn_thread (arg=0x560a03a426b8) at /test/10.8_dbg/storage/perfschema/pfs.cc:2201
#24 0x0000154b41e4f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#25 0x0000154b41a3d293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.3.33 (dbg), 10.3.33 (opt), 10.4.23 (dbg), 10.4.23 (opt), 10.5.14 (dbg), 10.5.14 (opt) 10.6.6 (dbg), 10.6.6 (opt), 10.7.2 (dbg), 10.7.2 (opt), 10.8.0 (dbg), 10.8.0 (opt)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.42 (dbg), 10.2.42 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.36 (dbg), 5.7.36 (opt), 8.0.27 (dbg), 8.0.27 (opt)

Comment by Roel Van de Paar [ 2021-11-13 ]

ALTER TABLE t PARTITION BY SYSTEM_TIME INTERVAL (SELECT * FROM t) DAY;

Leads to:

10.8.0 bc57ff7cf79504a198d4752b4748340a4afd886c (Debug)

mysqld: /test/10.8_dbg/sql/table.cc:6977: void Field_iterator_table_ref::set_field_iterator(): Assertion `table_ref->table || table_ref->view' failed.

10.8.0 bc57ff7cf79504a198d4752b4748340a4afd886c (Debug)

Core was generated by `/test/MD121121-mariadb-10.8.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x14a118075700 (LWP 872841))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000014a11bc54859 in __GI_abort () at abort.c:79
#2  0x000014a11bc54729 in __assert_fail_base (fmt=0x14a11bdea588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55e0af84fb88 "table_ref->table || table_ref->view", file=0x55e0af84d881 "/test/10.8_dbg/sql/table.cc", line=6977, function=<optimized out>) at assert.c:92
#3  0x000014a11bc65f36 in __GI___assert_fail (assertion=assertion@entry=0x55e0af84fb88 "table_ref->table || table_ref->view", file=file@entry=0x55e0af84d881 "/test/10.8_dbg/sql/table.cc", line=line@entry=6977, function=function@entry=0x55e0af84f978 "void Field_iterator_table_ref::set_field_iterator()") at assert.c:101
#4  0x000055e0aec90a77 in Field_iterator_table_ref::set_field_iterator (this=this@entry=0x14a118072ce0) at /test/10.8_dbg/sql/table.cc:6977
#5  0x000055e0aec90b5c in Field_iterator_table_ref::set (this=this@entry=0x14a118072ce0, table=table@entry=0x14a0cc014fc0) at /test/10.8_dbg/sql/table.cc:6994
#6  0x000055e0aead03ce in insert_fields (thd=thd@entry=0x14a0cc000db8, context=<optimized out>, db_name=0x0, table_name=0x0, it=it@entry=0x14a1180730b0, any_privileges=any_privileges@entry=false, hidden_bit_fields=0x14a0cc014da8, returning_field=false) at /test/10.8_dbg/sql/sql_base.cc:8162
#7  0x000055e0aead0d63 in setup_wild (thd=0x14a0cc000db8, tables=<optimized out>, fields=@0x14a0cc014c88: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14a0cc014f78, last = 0x14a0cc014f78, elements = 1}, <No data fields>}, sum_func_list=sum_func_list@entry=0x14a0cc0163f0, select_lex=0x14a0cc0149e8, returning_field=returning_field@entry=false) at /test/10.8_dbg/sql/sql_base.cc:7609
#8  0x000055e0aebdd67f in JOIN::prepare (this=0x14a0cc016088, tables_init=<optimized out>, conds_init=<optimized out>, og_num=<optimized out>, order_init=<optimized out>, skip_order_by=skip_order_by@entry=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x14a0cc0149e8, unit_arg=0x14a0cc0156c8) at /test/10.8_dbg/sql/sql_select.cc:1376
#9  0x000055e0aef7b0df in subselect_single_select_engine::prepare (this=0x14a0cc016048, thd=0x14a0cc000db8) at /test/10.8_dbg/sql/sql_lex.h:1363
#10 0x000055e0aef7a503 in Item_subselect::fix_fields (this=0x14a0cc015ec0, thd_param=<optimized out>, ref=0x14a118073368) at /test/10.8_dbg/sql/item_subselect.cc:295
#11 0x000055e0aecbbeb8 in Item::fix_fields_if_needed (ref=0x14a118073368, thd=0x14a0cc000db8, this=0x14a0cc015ec0) at /test/10.8_dbg/sql/item.h:1148
#12 Item::fix_fields_if_needed_for_scalar (ref=0x14a118073368, thd=0x14a0cc000db8, this=0x14a0cc015ec0) at /test/10.8_dbg/sql/item.h:1148
#13 partition_info::vers_set_interval (this=0x14a0cc014758, thd=thd@entry=0x14a0cc000db8, interval=<optimized out>, int_type=INTERVAL_DAY, starts=<optimized out>, table_name=0x14a0cc014038 "t") at /test/10.8_dbg/sql/partition_info.cc:2654
#14 0x000055e0aedcc67e in MYSQLparse (thd=thd@entry=0x14a0cc000db8) at /test/10.8_dbg/sql/sql_yacc.yy:5097
#15 0x000055e0aeb54569 in parse_sql (thd=thd@entry=0x14a0cc000db8, parser_state=parser_state@entry=0x14a118074400, creation_ctx=creation_ctx@entry=0x0, do_pfs_digest=do_pfs_digest@entry=true) at /test/10.8_dbg/sql/sql_parse.cc:10406
#16 0x000055e0aeb4eb07 in mysql_parse (thd=thd@entry=0x14a0cc000db8, rawbuf=<optimized out>, length=69, parser_state=parser_state@entry=0x14a118074400) at /test/10.8_dbg/sql/sql_parse.cc:7980
#17 0x000055e0aeb5d949 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14a0cc000db8, packet=packet@entry=0x14a0cc00b879 "ALTER TABLE t PARTITION BY SYSTEM_TIME INTERVAL (SELECT * FROM t) DAY", packet_length=packet_length@entry=69, blocking=blocking@entry=true) at /test/10.8_dbg/sql/sql_class.h:1360
#18 0x000055e0aeb60d83 in do_command (thd=0x14a0cc000db8, blocking=blocking@entry=true) at /test/10.8_dbg/sql/sql_parse.cc:1402
#19 0x000055e0aecdae2a in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55e0b217cf38, put_in_cache=put_in_cache@entry=true) at /test/10.8_dbg/sql/sql_connect.cc:1418
#20 0x000055e0aecdb42f in handle_one_connection (arg=arg@entry=0x55e0b217cf38) at /test/10.8_dbg/sql/sql_connect.cc:1312
#21 0x000055e0af15b4ce in pfs_spawn_thread (arg=0x55e0b2091568) at /test/10.8_dbg/storage/perfschema/pfs.cc:2201
#22 0x000014a11c163609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#23 0x000014a11bd51293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.3.33 (dbg), 10.3.33 (opt), 10.4.23 (dbg), 10.4.23 (opt), 10.5.14 (dbg), 10.5.14 (opt), 10.6.6 (dbg), 10.6.6 (opt), 10.7.2 (dbg), 10.7.2 (opt), 10.8.0 (dbg), 10.8.0 (opt)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.42 (dbg), 10.2.42 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.36 (dbg), 5.7.36 (opt), 8.0.27 (dbg), 8.0.27 (opt)

Comment by Roel Van de Paar [ 2021-11-13 ]

All stacks/uniqueID's seen, one per line:

SIGSEGV|Field_iterator_table::set|insert_fields|setup_wild|JOIN::prepare
table_ref->table || table_ref->view|SIGABRT|Field_iterator_table_ref::set_field_iterator|Field_iterator_table_ref::set|insert_fields|setup_wild
SIGSEGV|find_field_in_table|find_field_in_table_ref|find_field_in_tables|Item_field::fix_fields
table_list->table|SIGABRT|find_field_in_table_ref|find_field_in_tables|Item_field::fix_fields|Item::fix_fields_if_needed

Comment by Roel Van de Paar [ 2022-01-19 ]

This bug is regularly seen in testing. A fix would be appreciated to avoid individual test trials terminating early. Thank you

Comment by Roel Van de Paar [ 2022-02-20 ]

ALTER TABLE t PARTITION BY SYSTEM_TIME INTERVAL (SELECT c FROM t) DAY (PARTITION p HISTINg QUERY;

Comment by Roel Van de Paar [ 2022-03-03 ]

PREPARE p FROM 'ALTER TABLE t1 PARTITION BY system_time INTERVAL (SELECT i FROM t2) DAY (PARTITION p1 HISTORY, PARTITION pn CURRENT) ;';

Comment by Alexey Botchkov [ 2022-10-13 ]

https://github.com/MariaDB/server/commit/84ba517435eecbd9db06dfb14637298354f69fa9

Comment by Sergei Golubchik [ 2022-10-15 ]

better use clause_that_disallows_subselect to disable subqueries. And please fix append_interval() to allow complex intervals like DAY_HOUR (with a test).

Comment by Alexey Botchkov [ 2022-10-17 ]

https://github.com/MariaDB/server/commit/0ec622eded17e41385041892ee22c3d39f4c4688

Comment by Marko Mäkelä [ 2022-10-25 ]

serg, clause_that_disallows_subselect was added in MDEV-20634 in 10.4; it does not exist in 10.3.
The error reporting in 10.4 would seem a bit strange at first sight:

CURRENT_TEST: versioning.partition
--- /mariadb/10.4/mysql-test/suite/versioning/r/partition.result	2022-10-25 09:48:41.729943471 +0300
+++ /mariadb/10.4/mysql-test/suite/versioning/r/partition.reject	2022-10-25 09:55:41.178528704 +0300
@@ -1162,12 +1162,12 @@
 create table t2 (i int);
 alter table t1 partition by system_time 
 interval (select i from t2) day (partition p1 history, partition pn current);
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'select i from t2) day (partition p1 history, partition pn current)' at line 2
+ERROR 42000: INTERVAL does not support subqueries or stored functions

But, I realize that there in fact is a subquery after the INTERVAL keyword.

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