#At file:///home/ram/mysql/b44860-5.1-bugteam/ based on revid:jimw@stripped
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.
modified:
mysql-test/r/view.result
mysql-test/t/view.test
sql/sql_rename.cc
sql/sql_table.cc
=== modified file 'mysql-test/r/view.result'
--- a/mysql-test/r/view.result 2009-03-06 14:56:17 +0000
+++ b/mysql-test/r/view.result 2009-05-18 05:11:11 +0000
@@ -3817,6 +3817,14 @@ call p();
call p();
drop view a;
drop procedure p;
+#
+# Bug #44860: ALTER TABLE on view crashes server
+#
+CREATE TABLE t1 (a INT);
+CREATE VIEW v1 AS SELECT a FROM t1;
+ALTER TABLE v1;
+DROP VIEW v1;
+DROP TABLE t1;
# -----------------------------------------------------------------
# -- End of 5.1 tests.
# -----------------------------------------------------------------
=== modified file 'mysql-test/t/view.test'
--- a/mysql-test/t/view.test 2009-03-06 14:56:17 +0000
+++ b/mysql-test/t/view.test 2009-05-18 05:11:11 +0000
@@ -3836,6 +3836,17 @@ drop procedure p;
###########################################################################
+
+--echo #
+--echo # Bug #44860: ALTER TABLE on view crashes server
+--echo #
+CREATE TABLE t1 (a INT);
+CREATE VIEW v1 AS SELECT a FROM t1;
+ALTER TABLE v1;
+DROP VIEW v1;
+DROP TABLE t1;
+
+
--echo # -----------------------------------------------------------------
--echo # -- End of 5.1 tests.
--echo # -----------------------------------------------------------------
=== modified file 'sql/sql_rename.cc'
--- a/sql/sql_rename.cc 2009-04-13 13:09:10 +0000
+++ b/sql/sql_rename.cc 2009-05-18 05:11:11 +0000
@@ -261,6 +261,8 @@ do_rename(THD *thd, TABLE_LIST *ren_tabl
old_alias= ren_table->table_name;
new_alias= new_table_name;
}
+ DBUG_ASSERT(new_alias);
+
build_table_filename(name, sizeof(name),
new_db, new_alias, reg_ext, 0);
if (!access(name,F_OK))
=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc 2009-05-15 13:03:22 +0000
+++ b/sql/sql_table.cc 2009-05-18 05:11:11 +0000
@@ -6139,6 +6139,13 @@ bool mysql_alter_table(THD *thd,char *ne
/* Sic: there is a race here */
if (frm_type == FRMTYPE_VIEW && !(alter_info->flags & ~ALTER_RENAME))
{
+ /* If no new view name specified do nothing. */
+ if (!new_name)
+ {
+ my_ok(thd);
+ DBUG_RETURN(FALSE);
+ }
+
/*
Avoid problems with a rename on a table that we have locked or
if the user is trying to to do this in a transcation context
Attachment: [text/bzr-bundle] bzr/ramil@mysql.com-20090518051111-l4xqcuc11r714os6.bundle