Bug #53409 Alter table can't rename a view with special characters
Submitted: 4 May 2010 12:58 Modified: 6 Jan 2011 9:53
Reporter: Jonas Oreland Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: Tatiana Azundris Nuernberg CPU Architecture:Any

[4 May 2010 12:58] Jonas Oreland
Description:
This is probably due to an incomplete fix for bug#14959
and was found while fixing cluster bug#52225

problem is that mysql_frm_type is called with table name, instead of
encoded filename, causing it to fail to open frm-file, if name contains
special characters such as "." or similar.

How to repeat:
havent tested, but taking testcase from bug#14959 but instead of calling view "v1", calling it say `../v1` should trigger bug

Suggested fix:
Use filename as argument to mysql_frm_type instead:
=== modified file 'sql/sql_table.cc'
--- sql/sql_table.cc    2010-04-26 09:16:28 +0000
+++ sql/sql_table.cc    2010-05-04 12:19:24 +0000
@@ -7004,7 +7004,7 @@ bool mysql_alter_table(THD *thd,char *ne
     into the main table list, like open_tables does).
     This code is wrong and will be removed, please do not copy.
   */
-  frm_type= mysql_frm_type(thd, new_name_buff, &table_type);
+  frm_type= mysql_frm_type(thd, reg_path, &table_type);
   /* Rename a view */
   /* Sic: there is a race here */
   if (frm_type == FRMTYPE_VIEW && !(alter_info->flags & ~ALTER_RENAME))
[4 May 2010 13:03] 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/107315

3190 Jonas Oreland	2010-05-04
      bug#53409 (part of bug#52225) - fix arguments to mysql_frm_type, pass filename instead of tablename, this as cluster uses table_type for further processing
[4 May 2010 13: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/107319

3191 Jonas Oreland	2010-05-04
      ndb - bug#52225
        in addition to fixing bug#53409, also handle tab/db-name vs. filename
        consistently wrt to replication (events)
        (for now settle on using tab/db-name instead of filename...which might
         actually be incorrect, but now it's atleast consistent)
[4 May 2010 13:27] Bugs System
Pushed into 5.1.44-ndb-7.0.15 (revid:jonas@mysql.com-20100504131650-so3jj5b5vqa8dfss) (version source revid:jonas@mysql.com-20100504131650-so3jj5b5vqa8dfss) (merge vers: 5.1.44-ndb-7.0.15) (pib:16)
[4 May 2010 13:28] Bugs System
Pushed into 5.1.44-ndb-6.3.34 (revid:jonas@mysql.com-20100504130906-vsp23m8380itegak) (version source revid:jonas@mysql.com-20100504130906-vsp23m8380itegak) (merge vers: 5.1.44-ndb-6.3.34) (pib:16)
[5 May 2010 6:37] Jon Stephens
Status update per comments in BUG#52225 and push messages above.
[5 May 2010 7:19] Jon Stephens
Documented fix in the NDB-6.3.34, 7.0.15, and 7.1.4 changelogs. See BUG#52225 for changelog entry.

Closed.
[5 May 2010 7:43] Jonas Oreland
not fixed/addressed in mainlin
[13 Oct 2010 9:48] Konstantin Osipov
I believe this is fixed in 5.5, please add a test case and close the bug.
[6 Jan 2011 8:46] 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/128052

3229 Tatiana Azundris Nurnberg	2011-01-06
      Bug#53409: Alter table can't rename a view with special characters
      Bug#14959
      Bug#52225
      
      Add missing test case for regular (non-NDB) server.
      We now try to handle database names with periods etc. correctly in ALTER.
     @ mysql-test/r/rename.result
        test
     @ mysql-test/t/rename.test
        test