[MDEV-16540] Fixing 10 years old MySQL bug 20356 lower table name on view Created: 2018-06-20  Updated: 2018-07-19

Status: Confirmed
Project: MariaDB Server
Component/s: Server
Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: VAROQUI Stephane Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: upstream
Environment:

OSX



 Description   

https://bugs.mysql.com/bug.php?id=20356


 
[9 Jun 2006 11:55] Peter Laursen
 
Description:
On Windows when creating a VIEW having UPPERCASE(s) it its name and based on tables also having UPPERCASE(s) in their names, *SHOW CREATE TABLE* returns only LOWERCASES for the VIEW itself and the TABLES used for its construction.
 
This makes it difficult to use a Windows machine with MySQL as a developer machine when using VIEWs (that can be very complex with several (hundreds) UNIONs and JOINs etc.) and then port it to a production machine on *nix where UPERCASES are used for TABLE and VIEW names.
 
IMHO it also is both an (un-necessary ?) over-simplification and a misunderstanding of how the 'case-insensivity' of Windows should be understood.
 
How to repeat:
CREATE TABLE `test`.`TableName1` (`id` bigint NOT NULL ,`t` varchar (20) NULL);
CREATE VIEW `test`.`ViewName1` AS ( SELECT * FROM TableName1);
SHOW CREATE TABLE TableName1;
/*
CREATE TABLE `TableName1` ( `id` bigint(20) NOT NULL,`t` varchar(20) default NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1
*/
SHOW CREATE TABLE ViewName1;
/*
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `viewname1` AS (select `tablename1`.`id` AS `id`,`tablename1`.`t` AS `t` from `tablename1`)
==> note that `ViewName1` becomes`viewname1` and `TableName1` becomes `tablename1`
*/
 
Suggested fix:
Let 'SHOW CREATE TABLE' return the LETTERCASE used when creating the VIEW.
 
If this in 'not a bug' according to the docs, then change the docs, so it will become a bug!  :-)  It is really annoying!



 Comments   
Comment by Elena Stepanova [ 2018-07-18 ]

There is a lot of hardly relevant rambling in that upstream report, but if I understand correctly, it eventually boils down to this:

With lower_case_table_names=2, always display table/view names in the case they were initially created.

Is it your request as well?

Comment by VAROQUI Stephane [ 2018-07-19 ]

Hi Elena,

This case pop up on my OSX when replication-manager is resharding of a real table !
Creating a VIEW based on the real table name aka City table.

The workaround was to rename the view just after it's creation to get back to some real table name that respect the casse.
cluster.ShardProxyRunQuery(c, "CREATE VIEW "schema"."table"_old AS SELECT * FROM "schema"."+table)
cluster.ShardProxyRunQuery(c, "RENAME TABLE "schema"."table"_old TO "schema"."table"_back, "schema"."table"_back TO "schema"."table"_old")

Have a nice day
/svar

Generated at Thu Feb 08 08:29:40 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.