[MDEV-12293] Assertion `table->no_keyread || !table->covering_keys.is_set(tab->index) || table->file->keyread == tab->index' failed Created: 2017-03-17  Updated: 2017-05-08  Resolved: 2017-05-08

Status: Closed
Project: MariaDB Server
Component/s: Views
Affects Version/s: 10.2
Fix Version/s: 10.2.6

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: 10.2-ga


 Description   

The problem appeared in 10.2 with this commit:

commit 8d99166c697516ad9b4084c2bc10ba4acf8b9744
Author: Sergei Golubchik <serg@mariadb.org>
Date:   Mon Feb 6 23:52:47 2017 +0100
 
    MDEV-11640 gcol.gcol_select_myisam fails in buildbot on Power

10.2 a77ac6513e4ecc9

sql/sql_select.cc:19389: int join_read_first(JOIN_TAB*): Assertion `table->no_keyread || !table->covering_keys.is_set(tab->index) || table->file->keyread == tab->index' failed.
170317 16:18:08 [ERROR] mysqld got signal 6 ;

#7  0x00007fc19d84e312 in __GI___assert_fail (assertion=0x7fc1a0b9d320 "table->no_keyread || !table->covering_keys.is_set(tab->index) || table->file->keyread == tab->index", file=0x7fc1a0b9b808 "/data/src/10.2/sql/sql_select.cc", line=19389, function=0x7fc1a0b9f850 <join_read_first(st_join_table*)::__PRETTY_FUNCTION__> "int join_read_first(JOIN_TAB*)") at assert.c:101
#8  0x00007fc1a019c37e in join_read_first (tab=0x7fc184921088) at /data/src/10.2/sql/sql_select.cc:19387
#9  0x00007fc1a0199fa9 in sub_select (join=0x7fc184867488, join_tab=0x7fc184921088, end_of_records=false) at /data/src/10.2/sql/sql_select.cc:18414
#10 0x00007fc1a01995a3 in do_select (join=0x7fc184867488, procedure=0x0) at /data/src/10.2/sql/sql_select.cc:17961
#11 0x00007fc1a01745b7 in JOIN::exec_inner (this=0x7fc184867488) at /data/src/10.2/sql/sql_select.cc:3463
#12 0x00007fc1a0173abc in JOIN::exec (this=0x7fc184867488) at /data/src/10.2/sql/sql_select.cc:3266
#13 0x00007fc1a0174c2f in mysql_select (thd=0x7fc184816070, tables=0x7fc184864280, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748609, result=0x7fc184867468, unit=0x7fc184819b50, select_lex=0x7fc18481a280) at /data/src/10.2/sql/sql_select.cc:3658
#14 0x00007fc1a0169710 in handle_select (thd=0x7fc184816070, lex=0x7fc184819a88, result=0x7fc184867468, setup_tables_done_option=0) at /data/src/10.2/sql/sql_select.cc:373
#15 0x00007fc1a0135b59 in execute_sqlcom_select (thd=0x7fc184816070, all_tables=0x7fc184864280) at /data/src/10.2/sql/sql_parse.cc:6415
#16 0x00007fc1a012bb86 in mysql_execute_command (thd=0x7fc184816070) at /data/src/10.2/sql/sql_parse.cc:3448
#17 0x00007fc1a013952c in mysql_parse (thd=0x7fc184816070, rawbuf=0x7fc184864088 "SELECT DISTINCT f1 FROM v1", length=26, parser_state=0x7fc1a12addd0, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:7858
#18 0x00007fc1a01275f2 in dispatch_command (command=COM_QUERY, thd=0x7fc184816070, packet=0x7fc184858071 "", packet_length=26, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1812
#19 0x00007fc1a0125f62 in do_command (thd=0x7fc184816070) at /data/src/10.2/sql/sql_parse.cc:1362
#20 0x00007fc1a026ef33 in do_handle_one_connection (connect=0x7fc19d0656b0) at /data/src/10.2/sql/sql_connect.cc:1354
#21 0x00007fc1a026ecc0 in handle_one_connection (arg=0x7fc19d0656b0) at /data/src/10.2/sql/sql_connect.cc:1260
#22 0x00007fc1a068760e in pfs_spawn_thread (arg=0x7fc1947ce870) at /data/src/10.2/storage/perfschema/pfs.cc:1862
#23 0x00007fc19f750064 in start_thread (arg=0x7fc1a12af300) at pthread_create.c:309
#24 0x00007fc19d90862d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Test case

--source include/have_innodb.inc
 
CREATE TABLE t1 (f1 INT NOT NULL, f2 INT, f3 INT, PRIMARY KEY (f1,f2), KEY(f2,f3)) ENGINE=InnoDB;
CREATE VIEW v1 AS SELECT * FROM t1 WHERE f2 = 1;
 
SELECT DISTINCT f1 FROM v1;
 
DROP VIEW v1;
DROP TABLE t1;

Plan

MariaDB [test]> EXPLAIN EXTENDED
    -> SELECT DISTINCT f1 FROM v1;
+------+-------------+-------+-------+---------------+---------+---------+------+------+----------+--------------------------+
| id   | select_type | table | type  | possible_keys | key     | key_len | ref  | rows | filtered | Extra                    |
+------+-------------+-------+-------+---------------+---------+---------+------+------+----------+--------------------------+
|    1 | SIMPLE      | t1    | index | f2            | PRIMARY | 8       | NULL |    1 |   100.00 | Using where; Using index |
+------+-------------+-------+-------+---------------+---------+---------+------+------+----------+--------------------------+
1 row in set, 1 warning (0.00 sec)
 
MariaDB [test]> SHOW WARNINGS;
+-------+------+--------------------------------------------------------------------------------------+
| Level | Code | Message                                                                              |
+-------+------+--------------------------------------------------------------------------------------+
| Note  | 1003 | select distinct `test`.`t1`.`f1` AS `f1` from `test`.`t1` where `test`.`t1`.`f2` = 1 |
+-------+------+--------------------------------------------------------------------------------------+
1 row in set (0.00 sec)


Generated at Thu Feb 08 07:56:36 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.