Bug #47789 Assertion `!_entered' failed in check_key_in_view when DELETE + recreate table
Submitted: 2 Oct 2009 11:12 Modified: 7 Feb 2013 13:35
Reporter: Philip Stoev Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: General Severity:S3 (Non-critical)
Version:5.1-debug, 6.0-debug OS:Any
Assigned to: CPU Architecture:Any

[2 Oct 2009 11:12] Philip Stoev
Description:
After a re-creating a table that participates in a view, deleting from that view causes mysqld to crash as follows:

#6  0x000000315a42bec9 in __assert_fail () from /lib64/libc.so.6
#7  0x0000000000557e9e in ~Dbug_violation_helper (this=0x7f3e82ae4cff) at ../../include/my_dbug.h:29
#8  0x00000000008102b8 in check_key_in_view (thd=0x1157d68, view=0x11bfeb8) at sql_view.cc:1840
#9  0x00000000007110e7 in mysql_prepare_delete (thd=0x1157d68, table_list=0x11bfeb8, conds=0x7f3e82ae4f08) at sql_delete.cc:485
#10 0x0000000000711471 in mysql_delete (thd=0x1157d68, table_list=0x11bfeb8, conds=0x11c0360, order=0x1159d90, limit=1, options=0,
    reset_auto_increment=false) at sql_delete.cc:70
#11 0x000000000065b7a4 in mysql_execute_command (thd=0x1157d68) at sql_parse.cc:3279
#12 0x000000000066152b in mysql_parse (thd=0x1157d68, inBuf=0x11bfd78 "DELETE FROM testdb_A . t1_view_2_A WHERE `pk` > 2 LIMIT 1", length=57,
    found_semicolon=0x7f3e82ae6ed0) at sql_parse.cc:5942
#13 0x0000000000662373 in dispatch_command (command=COM_QUERY, thd=0x1157d68, packet=0x11ac339 "DELETE FROM testdb_A . t1_view_2_A WHERE `pk` > 2 LIMIT 1",
    packet_length=57) at sql_parse.cc:1224
#14 0x0000000000663765 in do_command (thd=0x1157d68) at sql_parse.cc:865
#15 0x000000000064f996 in handle_one_connection (arg=0x1157d68) at sql_connect.cc:1127
#16 0x000000315b0073da in start_thread () from /lib64/libpthread.so.0
#17 0x000000315a4e627d in clone () from /lib64/libc.so.6

mysqld: ../include/my_dbug.h:29: Dbug_violation_helper::~Dbug_violation_helper(): Assertion `!_entered' failed.

How to repeat:
CREATE DATABASE IF NOT EXISTS testdb_A  COLLATE = utf8_bin;

CREATE TABLE testdb_A . table1_int_autoinc ( `int` int, pk integer auto_increment, `int_key` int,       primary key (pk), key (`int_key` ));

CREATE TABLE testdb_A . t1  LIKE testdb_A . table1_int_autoinc;
ALTER TABLE testdb_A . t1  CHANGE COLUMN `int_key` my_column INT;

CREATE OR REPLACE VIEW testdb_A . t1_view_2_A  AS SELECT * FROM testdb_A . t1;

DROP TABLE IF EXISTS testdb_A . t1;
CREATE TABLE IF NOT EXISTS testdb_A . t1 LIKE testdb_A . table1_int_autoinc;

DELETE FROM testdb_A . t1_view_2_A WHERE `pk` > 2 LIMIT 1;
[2 Oct 2009 18:55] Peter Laursen
-- If the test case is complete like 

CREATE DATABASE IF NOT EXISTS testdb_A  COLLATE = utf8_bin;

CREATE TABLE testdb_A . table1_int_autoinc ( `int` INT, pk INTEGER AUTO_INCREMENT,
`int_key` INT,       PRIMARY KEY (pk), KEY (`int_key` ));

CREATE TABLE testdb_A . t1  LIKE testdb_A . table1_int_autoinc;
ALTER TABLE testdb_A . t1  CHANGE COLUMN `int_key` my_column INT;

CREATE OR REPLACE VIEW testdb_A . t1_view_2_A  AS SELECT * FROM testdb_A . t1;

DROP TABLE IF EXISTS testdb_A . t1;
CREATE TABLE IF NOT EXISTS testdb_A . t1 LIKE testdb_A . table1_int_autoinc;

DELETE FROM testdb_A . t1_view_2_A WHERE `pk` > 2 LIMIT 1;

-- I do not get a crash with 5.1.39 64 bit server for Windows but just
/*
Error Code : 1356
View 'testdb_a.t1_view_2_a' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
*/
[16 Oct 2009 17:57] MySQL Verification Team
I am able to crash just the debug version on Windows:

c:\dbs>c:\dbs\5.1\bin\mysql -uroot --port=3510 --prompt="mysql 5.1 >"
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.41-Win X64-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql 5.1 >DELETE FROM testdb_A . t1_view_2_A WHERE `pk` > 2 LIMIT 1;
ERROR 2013 (HY000): Lost connection to MySQL server during query
mysql 5.1 >

The opt version has the below error message:

mysql 5.1 >DELETE FROM testdb_A . t1_view_2_A WHERE `pk` > 2 LIMIT 1;
ERROR 1356 (HY000): View 'testdb_a.t1_view_2_a' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them

mysql 5.1 >exit
[26 Oct 2009 8:27] Valeriy Kravchuk
Only debug binaries are affected. Verified with recent 5.1.41 from bzr on Mac OS X.
[7 Feb 2013 13:35] Erlend Dahl
Fixed in 5.1.43 as a duplicate of Bug#48995