Bug #4599 Views: Server crashes on INSERT if underlying table dropped
Submitted: 18 Jul 2004 21:25 Modified: 21 Jul 2004 21:46
Reporter: Trudy Pelzer Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.1-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Oleksandr Byelkin CPU Architecture:Any

[18 Jul 2004 21:25] Trudy Pelzer
Description:
If one creates a view (e.g. vt1) based upon a single underlying table (e.g. t1), then drops the table, then recreates the table with the same format except for the columns names, then tries to insert into the view, MySQL crashes with this error:
ERROR 2013 (HY000): Lost connection to MySQL server during query

How to repeat:
create table t1 (col1 char(5),col2 char(5));
create view vt1 as select * from t1;
drop table t1;
create table t1 (col1 char(5),newcol2 char(5));
insert into vt1 values('a','aa');
[18 Jul 2004 22:40] MySQL Verification Team
Verified on Debian:

/home/miguel/dbs/5.0/libexec/mysqld: ready for connections.
Version: '5.0.1-alpha-debug-log'  socket: '/home/miguel/dbs/5.0/mysql50.sock'  port: 3306
[New Thread 163851 (LWP 10718)]
mysqld: sql_view.cc:827: bool check_key_in_view(THD*, TABLE_LIST*): Assertion `view->table != 0 && view->field_translation != 0' failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread 163851 (LWP 10718)]
0x4025b721 in kill () from /lib/libc.so.6
(gdb) backtrace full
#0  0x4025b721 in kill () from /lib/libc.so.6
No symbol table info available.
#1  0x40173771 in pthread_kill () from /lib/libpthread.so.0
No symbol table info available.
#2  0x40173a7b in raise () from /lib/libpthread.so.0
No symbol table info available.
#3  0x4025b4d4 in raise () from /lib/libc.so.6
No symbol table info available.
#4  0x4025c9e8 in abort () from /lib/libc.so.6
No symbol table info available.
#5  0x40254b3f in __assert_fail () from /lib/libc.so.6
No symbol table info available.
#6  0x0829cb29 in check_key_in_view (thd=0x8767468, view=0x8776380)
    at sql_view.cc:827
        _db_func_ = 0x82937c0 "\213\033\205ÛuÃ\200¿h\005"
        _db_file_ = 0x8776380 ""
        _db_level_ = 142044768
        _db_framep_ = (char **) 0x1
        table = (TABLE *) 0x8769a68
        trans = (class Item **) 0x4017b1f0
        key_info = (KEY *) 0x8761958
        primary_key = 64
        num = 2
#7  0x081f2964 in mysql_prepare_insert (thd=0x8767468, table_list=0x8776380,
    table=0x8769a68, fields=@0x8767838, values=0x8776480, update_fields=@0x0,
---Type <return> to continue, or q <return> to quit---
    update_values=@0x0, duplic=DUP_ERROR) at sql_insert.cc:539
        insert_into_view = true
        _db_func_ = 0x1 <Address 0x1 out of bounds>
        _db_file_ = 0x0
        _db_level_ = 0
        _db_framep_ = (char **) 0xbe5ff0a4
        unused_conds = (class Item *) 0x0
#8  0x081f1e0f in mysql_insert (thd=0x8767468, table_list=0x8776380,
    fields=@0x8767838, values_list=@0x8767850, update_fields=@0x8767694,
    update_values=@0x8767844, duplic=DUP_ERROR) at sql_insert.cc:213
        error = 0
        res = 0
        log_on = true
        transactional_table = false
        log_delayed = false
        value_count = 1
        counter = 1
        id = 6
        info = {records = 141980776, deleted = 141980776, updated = 3193958988,
  copied = 135986051, error_count = 5966, handle_duplicates = 3193958964,
  escape_char = -1101008328, last_errno = -1101008324, update_fields = 0xbe5ff238,
  update_values = 0xbe5ff23c}
        table = (TABLE *) 0x8769a68
        its = {<base_list_iterator> = {list = 0x8767850, el = 0x8776530,
    prev = 0x0, current = 0x0}, <No data fields>}
---Type <return> to continue, or q <return> to quit---
        values = (List_item *) 0x8776480
        query = 0x8776318 "insert into vt1 values('a','aa')"
        lock_type = TL_WRITE_CONCURRENT_INSERT
        _db_func_ = 0x8776337 ")"
        _db_file_ = 0x1 <Address 0x1 out of bounds>
        _db_level_ = 6
        _db_framep_ = (char **) 0x0
#9  0x081a8293 in mysql_execute_command (thd=0x8767468) at sql_parse.cc:2728
        update = 0 '\0'
        res = 0
        lex = (LEX *) 0x876749c
        first_table = (TABLE_LIST *) 0x8776380
        all_tables = (TABLE_LIST *) 0x8776380
        select_lex = (SELECT_LEX *) 0x8767628
        unit = (SELECT_LEX_UNIT *) 0x87674a8
        _db_func_ = 0x0
        _db_file_ = 0x864dec0 ""
        _db_level_ = 3193959260
        _db_framep_ = (char **) 0x84881f3
#10 0x081ac744 in mysql_parse (thd=0x8767468,
    inBuf=0x8776318 "insert into vt1 values('a','aa')", length=141980828)
    at sql_parse.cc:4422
        lex = (LEX *) 0x876749c
        _db_func_ = 0x84885c6 "\211ì]ÃU\211å\203ì\030\215Eü\211D$\b\215Eø\211D$\004\213E\b\211\004$èß\023Èÿºÿÿÿÿ\205Àu:\203=tÂd\b"
---Type <return> to continue, or q <return> to quit---
        _db_file_ = 0x2800b <Address 0x2800b out of bounds>
        _db_level_ = 0
        _db_framep_ = (char **) 0xbe5ff7a8
#11 0x081a4b8f in dispatch_command (command=COM_QUERY, thd=0x8767468,
    packet=0x87722b9 "insert into vt1 values('a','aa')", packet_length=33)
    at sql_parse.cc:1481
        net = (NET *) 0x8767ad4
        error = false
        _db_func_ = 0xbe5ff918 "\b@\027@,ù_¾!"
        _db_file_ = 0xbe5ff91c ",ù_¾!"
        _db_level_ = 4294967295
        _db_framep_ = (char **) 0xbe5ff964
        start_of_query = 141980776
#12 0x081a44a8 in do_command (thd=0x8767468) at sql_parse.cc:1296
        packet = 0x87722b8 "\003insert into vt1 values('a','aa')"
        old_timeout = 30
        packet_length = 33
        net = (NET *) 0x8767ad4
        command = COM_QUERY
        _db_func_ = 0x817e263 "\213]ü\211ì]ÃU\211å\203ì8\211]ü\213]\b\211\034$è\212"
        _db_file_ = 0x87687d4 "8\212v\b"
        _db_level_ = 8192
        _db_framep_ = (char **) 0x1000
#13 0x081a3919 in handle_one_connection (arg=0x0) at sql_parse.cc:1032
        error = 6
---Type <return> to continue, or q <return> to quit---
        net = (NET *) 0x8767ad4
        thd = (class THD *) 0x8767468
        launch_time = 0
        set = {__val = {0 <repeats 32 times>}}
#14 0x40170e51 in pthread_start_thread () from /lib/libpthread.so.0
No symbol table info available.
#15 0x40170ecf in pthread_start_thread_event () from /lib/libpthread.so.0
No symbol table info available.
#16 0x4030969a in clone () from /lib/libc.so.6
No symbol table info available.
(gdb)
[21 Jul 2004 3:27] Oleksandr Byelkin
ChangeSet 
  1.1717 04/07/21 04:26:20 bell@sanja.is.com.ua +30 -0 
  error message interception (Bug#4598) 
  error handling of view initialization fixed (Bug#4599)
[21 Jul 2004 21:46] Oleksandr Byelkin
Thank you for bugreport. Bugfix is pushed in our source repository.