[MDEV-15475] Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed on EXPLAIN EXTENDED with constant table and view Created: 2018-03-06  Updated: 2018-08-21  Resolved: 2018-08-21

Status: Closed
Project: MariaDB Server
Component/s: Admin statements, Optimizer, Views
Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3
Fix Version/s: 5.5.62, 10.0.37, 10.1.36, 10.2.18, 10.3.10

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Oleksandr Byelkin
Resolution: Fixed Votes: 0
Labels: affects-tests


 Description   

CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=MyISAM;
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1);
EXPLAIN EXTENDED SELECT ISNULL(pk) FROM v1;
 
# Cleanup
DROP VIEW v1;
DROP TABLE t1;

5.5 ac3fd5acac6b3717c

mysqld: /data/src/5.5/sql/field.cc:3673: virtual String* Field_long::val_str(String*, String*): Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed.
180306  3:47:00 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f3b9fec8ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x000000000078d036 in Field_long::val_str (this=0x7f3b9a858f98, val_buffer=0x7f3ba193b460, val_ptr=0x7f3b9a949f10) at /data/src/5.5/sql/field.cc:3673
#9  0x00000000007c30de in Item_field::val_str (this=0x7f3b9a949ef8, str=0x7f3ba193b460) at /data/src/5.5/sql/item.cc:2613
#10 0x00000000007bdaae in Item::print_value (this=0x7f3b9a949ef8, str=0x7f3ba193b9a0) at /data/src/5.5/sql/item.cc:635
#11 0x00000000007ce39e in Item_field::print (this=0x7f3b9a949ef8, str=0x7f3ba193b9a0, query_type=QT_TO_SYSTEM_CHARSET) at /data/src/5.5/sql/item.cc:6845
#12 0x00000000007cf911 in Item_ref::print (this=0x7f3b9a93c078, str=0x7f3ba193b9a0, query_type=QT_TO_SYSTEM_CHARSET) at /data/src/5.5/sql/item.cc:7360
#13 0x000000000080a0db in Item_func::print_args (this=0x7f3b9a948288, str=0x7f3ba193b9a0, from=0, query_type=QT_TO_SYSTEM_CHARSET) at /data/src/5.5/sql/item_func.cc:481
#14 0x000000000080a049 in Item_func::print (this=0x7f3b9a948288, str=0x7f3ba193b9a0, query_type=QT_TO_SYSTEM_CHARSET) at /data/src/5.5/sql/item_func.cc:470
#15 0x00000000007bd9e1 in Item::print_item_w_name (this=0x7f3b9a948288, str=0x7f3ba193b9a0, query_type=QT_TO_SYSTEM_CHARSET) at /data/src/5.5/sql/item.cc:620
#16 0x000000000066a039 in st_select_lex::print (this=0x7f3b9ba67a68, thd=0x7f3b9ba64060, str=0x7f3ba193b9a0, query_type=QT_TO_SYSTEM_CHARSET) at /data/src/5.5/sql/sql_select.cc:23585
#17 0x00000000005f4e0e in st_select_lex_unit::print (this=0x7f3b9ba67388, str=0x7f3ba193b9a0, query_type=QT_TO_SYSTEM_CHARSET) at /data/src/5.5/sql/sql_lex.cc:2391
#18 0x0000000000607512 in execute_sqlcom_select (thd=0x7f3b9ba64060, all_tables=0x7f3b9a9483b8) at /data/src/5.5/sql/sql_parse.cc:4663
#19 0x00000000006009b3 in mysql_execute_command (thd=0x7f3b9ba64060) at /data/src/5.5/sql/sql_parse.cc:2224
#20 0x000000000060a1fe in mysql_parse (thd=0x7f3b9ba64060, rawbuf=0x7f3b9a948078 "EXPLAIN EXTENDED SELECT ISNULL(pk) FROM v1", length=42, parser_state=0x7f3ba193c640) at /data/src/5.5/sql/sql_parse.cc:5923
#21 0x00000000005fdf13 in dispatch_command (command=COM_QUERY, thd=0x7f3b9ba64060, packet=0x7f3b9f75b061 "", packet_length=42) at /data/src/5.5/sql/sql_parse.cc:1066
#22 0x00000000005fd105 in do_command (thd=0x7f3b9ba64060) at /data/src/5.5/sql/sql_parse.cc:793
#23 0x000000000070024f in do_handle_one_connection (thd_arg=0x7f3b9ba64060) at /data/src/5.5/sql/sql_connect.cc:1268
#24 0x00000000006fffdc in handle_one_connection (arg=0x7f3b9ba64060) at /data/src/5.5/sql/sql_connect.cc:1184
#25 0x0000000000a0e06b in pfs_spawn_thread (arg=0x7f3b9c776fc0) at /data/src/5.5/storage/perfschema/pfs.cc:1015
#26 0x00007f3ba156f494 in start_thread (arg=0x7f3ba193d700) at pthread_create.c:333
#27 0x00007f3b9ff8593f in clone () from /lib/x86_64-linux-gnu/libc.so.6

No visible problem on non-debug build.



 Comments   
Comment by Oleksandr Byelkin [ 2018-06-12 ]

It try to print value of const table which is not marked for read for extended explain representation.

Comment by Oleksandr Byelkin [ 2018-08-06 ]

Problem is that ISNULL do not need value of the argument, it is enough that it can not be NULL. So read flag removed and do not set because update_used_tables() do not called for ISNULL argument.

the question is why we print table by value...

Comment by Oleksandr Byelkin [ 2018-08-06 ]

It works with table (no view) only because the query is simple and used tables of the query is not updated (any query which try to recalculate used tables will fail)

Comment by Oleksandr Byelkin [ 2018-08-06 ]

revision-id: d1c90870ed114da62de8b12a71e2fba62724baa9 (mariadb-5.5.61-3-gd1c90870ed1)
parent(s): 68ebfb31f215247d2fa08c8ed97a320191afc179
author: Oleksandr Byelkin
committer: Oleksandr Byelkin
timestamp: 2018-08-06 15:50:22 +0200
message:

MDEV-15475: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed on EXPLAIN EXTENDED with constant table and view

Do not try to print value of the field in table if it is optimized out.
EXPLAIN output still looks a bit strange (field from dual table, because table optimized out) but we do not indicate optimisations of ISNULL.

Comment by Oleksandr Byelkin [ 2018-08-08 ]

revision-id: 017adbeb3940ac162dcb8dd99478375a37edec02 (mariadb-5.5.61-3-g017adbeb394)
parent(s): 68ebfb31f215247d2fa08c8ed97a320191afc179
author: Oleksandr Byelkin
committer: Oleksandr Byelkin
timestamp: 2018-08-08 19:44:04 +0200
message:

MDEV-15475: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' failed on EXPLAIN EXTENDED with constant table and view

Print constant ISNULL fireld independent.
Fix of printing of view FRM and CREATE VIEW output

Comment by Igor Babaev [ 2018-08-11 ]

Ok to push

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