Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
MySQL VIEW definition's UTF-8 problem #61
UTF-8 chars are broken in MySQL / MariaDB View definitions when open in HeidiSQL View Editor:
UTF-8 chars should be correct on view editor, db export to a file and to another database.
UTF-8 chars are broken.
Failure information (for bugs)
Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.
Steps to reproduce
Create a view:
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_test` AS select 'ĞÜŞİÖÇ' AS `col1`,'ğüşıöç' AS `col12`
Click on that view in HeidiSQL and see that Turkish characters are broken, shown as
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_test` AS SELECT 'Ä�ÃœÅ�Ä°Ã–Ã‡' AS col1, 'ÄŸÃ¼ÅŸÄ±Ã¶Ã§' AS col12 ;
This can be fixed by using below SQL:
SELECT CAST(LOAD_FILE( CONCAT( IFNULL(@@GLOBAL.datadir, CONCAT(@@GLOBAL.basedir, 'data/')), 'test/v_test.frm' ) ) AS CHAR CHARACTER SET utf8);
related forum post: https://www.heidisql.com/forum.php?t=24623
Should be working in the next HeidiSQL build.
One thing I also want to fix along with this issue is that the .frm file on the server's hard disk has some encoding for international characters like ü, ö etc. HeidiSQL tries to load
There seems to be no handy SQL function for encoding an identifier just like MySQL or MariaDB do it when storing .frm files with international characters.
I found a helpful blog article from Kolbe Kegel at MariaDB, about demystifying identifier mappings. But to repeat his steps HeidiSQL would need some internal mapping table for characters and probably even a own procedure. Even better would be a native Delphi procedure which does the same encoding. But that is too much effort only for getting the original formatted VIEW code in cases where the view name has international characters.
I'm not sure if this helps but, in MySQL Reference Manual, it says
Please see https://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_load-file and especially https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_character_set_filesystem which says:
which could help.