Description:
In the function mysql_rename_view() some tablename_to_filename encodings are missing. Same in some functions called by it. The below test result shows the misbehaviour:
! DROP TABLE IF EXISTS t1, `t-blüten`;
! CREATE TABLE t1 (c1 INT);
! CREATE VIEW v1 AS SELECT c1 FROM t1;
! SHOW TABLES;
! Tables_in_test
! t1
! v1
! RENAME TABLE t1 TO t2;
! RENAME TABLE v1 TO v2;
! SHOW TABLES;
! Tables_in_test
! t2
! v2
! DROP TABLE t2;
! DROP VIEW v2;
! CREATE TABLE `t-blüten` (c1 INT);
! CREATE VIEW `v-blüten` AS SELECT c1 FROM `t-blüten`;
! SHOW TABLES;
! Tables_in_test
! t-blüten
! v-blüten
! RENAME TABLE `t-blüten` TO `t-nägel`;
! RENAME TABLE `v-blüten` TO `v-nägel`;
! ERROR HY000: Can't get stat of './test/v-blüten.frm' (Errcode: 2)
! SHOW TABLES;
! Tables_in_test
! t-nägel
! v-blüten
! DROP TABLE `t-nägel`;
! DROP VIEW `v-nägel`;
! ERROR 42S02: Unknown table 'test.v-nägel'
! DROP VIEW `v-blüten`;
! CREATE TABLE `#sql-t1` (c1 INT);
! CREATE VIEW `#sql-v1` AS SELECT c1 FROM `#sql-t1`;
! SHOW TABLES;
! Tables_in_test
! #sql-t1
! #sql-v1
! RENAME TABLE `#sql-t1` TO `#sql-t2`;
! RENAME TABLE `#sql-v1` TO `#sql-v2`;
! ERROR HY000: Can't get stat of './test/#sql-v1.frm' (Errcode: 2)
! SHOW TABLES;
! Tables_in_test
! #sql-t2
! #sql-v1
! DROP TABLE `#sql-t2`;
! DROP VIEW `#sql-v2`;
! ERROR 42S02: Unknown table 'test.#sql-v2'
! DROP VIEW `#sql-v1`;
How to repeat:
# For demo purposes
--disable_abort_on_error
#
# Bug#????? - View renaming lacks tablename_to_filename encoding
#
--disable_warnings
DROP TABLE IF EXISTS t1, `t-blüten`, `#sql-t1`;
DROP TABLE IF EXISTS t2, `t-nägel`, `#sql-t2`;
DROP VIEW IF EXISTS v1, `v-blüten`, `#sql-v1`;
DROP VIEW IF EXISTS v2, `v-nägel`, `#sql-v2`;
--enable_warnings
#
# How everything should go
CREATE TABLE t1 (c1 INT);
CREATE VIEW v1 AS SELECT c1 FROM t1;
SHOW TABLES;
RENAME TABLE t1 TO t2;
RENAME TABLE v1 TO v2;
SHOW TABLES;
DROP TABLE t2;
DROP VIEW v2;
#
# Now the same with names that should be encoded
CREATE TABLE `t-blüten` (c1 INT);
CREATE VIEW `v-blüten` AS SELECT c1 FROM `t-blüten`;
SHOW TABLES;
RENAME TABLE `t-blüten` TO `t-nägel`;
# Wrong: --error 13
RENAME TABLE `v-blüten` TO `v-nägel`;
SHOW TABLES;
DROP TABLE `t-nägel`;
# Wrong: --error ER_BAD_TABLE_ERROR
DROP VIEW `v-nägel`;
#
#This should not be necessary and even fail
# Right: --error ER_BAD_TABLE_ERROR
DROP VIEW `v-blüten`;
#
# Now the same with special names that should be encoded too
CREATE TABLE `#sql-t1` (c1 INT);
CREATE VIEW `#sql-v1` AS SELECT c1 FROM `#sql-t1`;
SHOW TABLES;
RENAME TABLE `#sql-t1` TO `#sql-t2`;
# Wrong: --error 13
RENAME TABLE `#sql-v1` TO `#sql-v2`;
SHOW TABLES;
DROP TABLE `#sql-t2`;
# Wrong: --error ER_BAD_TABLE_ERROR
DROP VIEW `#sql-v2`;
#
#This should not be necessary and even fail
# Right: --error ER_BAD_TABLE_ERROR
DROP VIEW `#sql-v1`;