[MDEV-19186] Assertion `field->table == table' failed in create_tmp_table Created: 2019-04-05  Updated: 2019-04-05  Resolved: 2019-04-05

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 10.4
Fix Version/s: 10.4.4

Type: Bug Priority: Major
Reporter: Alice Sherepa Assignee: Galina Shalygina (Inactive)
Resolution: Fixed Votes: 0
Labels: None


 Description   

create table t1 ( pk int not null primary key, x varchar(10));
insert into t1 values  (1,'y'),(2,'s'),(3,'aaa'),(4,'bbb'),(5,'ccc'),(6,'ddd');
create view v1 as select * from t1;
 
create table t2 ( pk int not null primary key, x varchar(10));
insert into `t2` values (1,'aa'),(2,'t'),(3,'bb'),(4,'cc'),(5,'c'),(6,'dd'),(7,'ee'),(8,'x');
 
create table tmp1
select v1.pk 
from v1 right join t2 on v1.x = t2.x
group by v1.pk 
having (v1.pk = 1);

10.4 5da6944ea3a592efefd1ad

/10.4/sql/sql_select.cc:18381: TABLE* create_tmp_table(THD*, TMP_TABLE_PARAM*, List<Item>&, ORDER*, bool, bool, ulonglong, ha_rows, const LEX_CSTRING*, bool, bool): Assertion `field->table == table' failed.
190405 12:31:49 [ERROR] mysqld got signal 6 ;
 
linux/raise.c:54(__GI_raise)[0x7f05869bbc82]
sql/sql_select.cc:18382(create_tmp_table(THD*, TMP_TABLE_PARAM*, List<Item>&, st_order*, bool, bool, unsigned long long, unsigned long long, st_mysql_const_lex_string const*, bool, bool))[0x5587244df154]
sql/sql_select.cc:3668(JOIN::create_postjoin_aggr_table(st_join_table*, List<Item>*, st_order*, bool, bool, bool))[0x5587244d91c9]
sql/sql_select.cc:3265(JOIN::make_aggr_tables_info())[0x5587244f60f5]
sql/sql_select.cc:2207(JOIN::optimize_inner())[0x5587244cd25c]
sql/sql_select.cc:1561(JOIN::optimize())[0x55872444168d]
sql/sql_select.cc:4578(mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x55872445a914]
sql/sql_parse.cc:4359(mysql_execute_command(THD*))[0x5587244335c4]
sql/sql_parse.cc:8154(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x558724430503]
sql/sql_parse.cc:1834(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x5587247a3f97]
sql/sql_parse.cc:1365(do_command(THD*))[0x5587247a3961]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7f05878046ba]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f0586a9541d]

10.4 non-debug c84dde148f8d8223

190405 18:07:33 [ERROR] mysqld got signal 11 ;
 
sql/signal_handler.cc:168(handle_fatal_signal)[0x55e477581727]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f074347d390]
/10.4/sql/mysqld(+0xc58570)[0x55e477a0c570]
heap/hp_hash.c:341(hp_rec_hashnr)[0x55e477a0f9a2]
heap/hp_write.c:352(hp_write_key)[0x55e477a0f4e2]
heap/hp_write.c:52(heap_write)[0x55e477a0aa98]
heap/ha_heap.cc:240(ha_heap::write_row(unsigned char*))[0x55e4773e92d2]
sql/sql_class.h:6620(handler::ha_write_tmp_row(unsigned char*))[0x55e4773d662d]
sql/sql_select.cc:21455(end_write(JOIN*, st_join_table*, bool))[0x55e477491365]
sql/sql_join_cache.cc:2401(JOIN_CACHE::generate_full_extensions(unsigned char*))[0x55e477491957]
sql/sql_join_cache.cc:2549(JOIN_CACHE::join_null_complements(bool))[0x55e47749104f]
sql/sql_join_cache.cc:2123(JOIN_CACHE::join_records(bool))[0x55e4773c81a3]
sql/sql_select.cc:19806(sub_select_cache(JOIN*, st_join_table*, bool))[0x55e4773e7a25]
sql/sql_select.cc:19567(do_select)[0x55e4773e7ac9]
sql/sql_select.cc:4161(JOIN::exec())[0x55e4773e5e30]
sql/sql_select.cc:4594(mysql_select(THD*, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*))[0x55e4773e679e]
sql/sql_select.cc:424(handle_select(THD*, LEX*, select_result*, unsigned long))[0x55e477398710]
sql/sql_parse.cc:4359(mysql_execute_command(THD*))[0x55e477398eb9]
sql/sql_parse.cc:8154(mysql_parse(THD*, char*, unsigned int, Parser_state*, bool, bool))[0x55e47739b156]
sql/sql_parse.cc:1896(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool, bool))[0x55e47739c789]
sql/sql_parse.cc:1365(do_command(THD*))[0x55e477469b04]
sql/sql_connect.cc:1398(do_handle_one_connection(CONNECT*))[0x55e477469c24]
sql/sql_connect.cc:1303(handle_one_connection)[0x55e4779ffbc4]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7f07434736ba]
x86_64/clone.S:111(clone)[0x7f074270441d]



 Comments   
Comment by Igor Babaev [ 2019-04-05 ]

This query cause crashing (an assertion failure):

create table tmp1 select v1.pk  from t2, v1 where v1.x = t2.x group by v1.pk  having (v1.pk = 1);

If I perform manual pushdown from HAVING the query works fine:

MariaDB [test]> create table tmp1 select v1.pk  from t2, v1 where v1.x = t2.x and v1.pk = 1 group by v1.pk;
Query OK, 0 rows affected (5.575 sec)
Records: 0  Duplicates: 0  Warnings: 0

Comment by Galina Shalygina (Inactive) [ 2019-04-05 ]

Pushed in 10.4

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