Bug #44860 ALTER TABLE on view crashes server
Submitted: 14 May 2009 7:23 Modified: 26 Jun 2009 2:32
Reporter: Oli Sennhauser Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Views Severity:S2 (Serious)
Version:5.1.34 OS:Any
Assigned to: Ramil Kalimullin CPU Architecture:Any
Tags: alter table view server crash
Triage: Triaged: D1 (Critical)

[14 May 2009 7:23] Oli Sennhauser
Description:
ALTER TABLE on a view crashes server.

How to repeat:
CREATE TABLE a (id int);
CREATE VIEW v AS SELECT id FROM a;
ALTER TABLE v;
-> lost connection (crash)

my.cnf = all default settings.

stack_bottom = 0xb49c93c8 thread_stack 0x30000
/home/mysql/product/mysql-5.1.34/bin/mysqld(my_print_stacktrace+0x21)[0x84d6981]
/home/mysql/product/mysql-5.1.34/bin/mysqld(handle_segfault+0x381)[0x8200291]
[0xb7f19420]
/home/mysql/product/mysql-5.1.34/bin/mysqld(_Z20build_table_filenamePcjPKcS1_S1_j+0xea)[0x8300daa]
/home/mysql/product/mysql-5.1.34/bin/mysqld(_Z9do_renameP3THDP10TABLE_LISTPcS3_S3_b+0x63)[0x830dc03]
/home/mysql/product/mysql-5.1.34/bin/mysqld(_Z17mysql_alter_tableP3THDPcS1_P24st_ha_create_informationP10TABLE_LISTP10Alter_infojP8st_orderb+0x1055)[0x83081e5]
/home/mysql/product/mysql-5.1.34/bin/mysqld(_Z21mysql_execute_commandP3THD+0x30fb)[0x8212d4b]
/home/mysql/product/mysql-5.1.34/bin/mysqld(_Z11mysql_parseP3THDPKcjPS2_+0x340)[0x8217430]
/home/mysql/product/mysql-5.1.34/bin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x11e0)[0x8218620]
/home/mysql/product/mysql-5.1.34/bin/mysqld(_Z10do_commandP3THD+0xe0)[0x8218ea0]
/home/mysql/product/mysql-5.1.34/bin/mysqld(handle_one_connection+0x233)[0x82099a3]
/lib/tls/i686/cmov/libpthread.so.0[0xb7ee94fb]
/lib/tls/i686/cmov/libc.so.6(clone+0x5e)[0xb7df8e5e]
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x8b8acc0 = ALTER TABLE v
thd->thread_id=3
thd->killed=NOT_KILLED

Suggested fix:
no clue.
[14 May 2009 7:48] Simon Mudd
The fix is to provide a suitable error message, along the lines of:

ALTER TABLE failed: No such table XXXXX.

That is check the object type correctly before trying to operate on it.

Hence I think the category is wrong. This is a problem with a TABLE not a VIEW.
[18 May 2009 5:11] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/74327

2880 Ramil Kalimullin	2009-05-18
      Fix for bug#44860: ALTER TABLE on view crashes server
      
      Problem: executing queries like "ALTER TABLE view1;" we don't
      check new view's name (which is not specified),
      that leads to server crash.
      
      Fix: do nothing (to be consistent with the behaviour for tables) 
      in such cases.
     @ mysql-test/r/view.result
        Fix for bug#44860: ALTER TABLE on view crashes server
          - test result.
     @ mysql-test/t/view.test
        Fix for bug#44860: ALTER TABLE on view crashes server
          - test case.
     @ sql/sql_rename.cc
        Fix for bug#44860: ALTER TABLE on view crashes server
          - do_rename(): new view/table name must be specified, ASSERT() added.
     @ sql/sql_table.cc
        Fix for bug#44860: ALTER TABLE on view crashes server
          - mysql_alter_table(): renaming a view, check if new
        view name is specified.
[19 May 2009 4:26] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/74441

2888 Ramil Kalimullin	2009-05-19
      Fix for bug#44860: ALTER TABLE on view crashes server
      
      Problem: executing queries like "ALTER TABLE view1;" we don't
      check new view's name (which is not specified),
      that leads to server crash.
      
      Fix: do nothing (to be consistent with the behaviour for tables) 
      in such cases.
     @ mysql-test/r/view.result
        Fix for bug#44860: ALTER TABLE on view crashes server
          - test result.
     @ mysql-test/t/view.test
        Fix for bug#44860: ALTER TABLE on view crashes server
          - test case.
     @ sql/sql_rename.cc
        Fix for bug#44860: ALTER TABLE on view crashes server
          - do_rename(): new view/table name must be specified, ASSERT() added.
     @ sql/sql_table.cc
        Fix for bug#44860: ALTER TABLE on view crashes server
          - mysql_alter_table(): renaming a view, check if new
        view name is specified.
[19 May 2009 6:48] Ramil Kalimullin
Pushed to {5.1, 6.0}-bugteam.
[28 May 2009 8:16] Bugs System
Pushed into 5.1.36 (revid:joro@sun.com-20090528073639-yohsb4q1jzg7ycws) (version source revid:ramil@mysql.com-20090519042536-l4brd8nluz002t3m) (merge vers: 5.1.36) (pib:6)
[1 Jun 2009 19:22] Paul Dubois
Noted in 5.1.36 changelog.

ALTER TABLE on a view crashed the server.

Setting report to NDI pending push into 6.0.x.
[17 Jun 2009 19:24] Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090616183122-chjzbaa30qopdra9) (version source revid:ramil@mysql.com-20090519044724-6u4oel2muqkqf1yx) (merge vers: 6.0.12-alpha) (pib:11)
[26 Jun 2009 2:32] Paul Dubois
Noted in 5.4.4 changelog.
[12 Aug 2009 22:25] Paul Dubois
Noted in 5.4.2 changelog because next 5.4 version will be 5.4.2 and not 5.4.4.
[15 Aug 2009 1:42] Paul Dubois
Ignore previous comment about 5.4.2.
[26 Aug 2009 13:46] Bugs System
Pushed into 5.1.37-ndb-7.0.8 (revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[26 Aug 2009 13:46] Bugs System
Pushed into 5.1.37-ndb-6.3.27 (revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (version source revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (merge vers: 5.1.37-ndb-6.3.27) (pib:11)
[26 Aug 2009 13:48] Bugs System
Pushed into 5.1.37-ndb-6.2.19 (revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (version source revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (merge vers: 5.1.37-ndb-6.2.19) (pib:11)
[27 Aug 2009 16:32] Bugs System
Pushed into 5.1.35-ndb-7.1.0 (revid:magnus.blaudd@sun.com-20090827163030-6o3kk6r2oua159hr) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[7 Oct 2009 19:13] Paul Dubois
The 5.4 fix has been pushed to 5.4.2.