MySQL 5.1.39 SQL语法错误
我已将 MySQL 服务器升级到 5.1.39,现在当我运行 SQL 脚本(之前可以运行)时,它会抛出错误。我多次检查语法,但找不到任何不兼容的代码部分。请针对此问题提出任何解决方案。
错误信息
Mysql::Error: 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 3 行的“CREATE FUNCTION clean_dymmy_table (dummy_name VARCHAR(255)) RETURNS V”附近使用的正确语法:
SQL 代码:
/*DELIMITER //*/
DROP FUNCTION IF EXISTS clean_dymmy_table;
CREATE FUNCTION clean_dymmy_table (dummy_name VARCHAR(255)) RETURNS VARCHAR(255)
DETERMINISTIC
BEGIN
DECLARE temp_val VARCHAR(255);
SET temp_val = dummy_name;
-- Test
SET temp_val = REPLACE(temp_val, 'Tmp ', '');
SET temp_val = REPLACE(temp_val, ' TmP', '');
SET temp_val = REPLACE(temp_val, 'TMP ', '');
SET temp_val = REPLACE(temp_val, ' TMP', '');
SET temp_val = REPLACE(temp_val, ' tmp', '');
RETURN dummy_name;
END/*//*/
I have made an upgrade for my MySQL Server to 5.1.39 and now when I run SQL scripts (which had worked previously) - it throws error. I have checked syntax many times and I couldn't find any incompatible code parts. Please suggest any solution for this problem.
Error message
Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE FUNCTION clean_dymmy_table (dummy_name VARCHAR(255)) RETURNS V' at line 3:
SQL code:
/*DELIMITER //*/
DROP FUNCTION IF EXISTS clean_dymmy_table;
CREATE FUNCTION clean_dymmy_table (dummy_name VARCHAR(255)) RETURNS VARCHAR(255)
DETERMINISTIC
BEGIN
DECLARE temp_val VARCHAR(255);
SET temp_val = dummy_name;
-- Test
SET temp_val = REPLACE(temp_val, 'Tmp ', '');
SET temp_val = REPLACE(temp_val, ' TmP', '');
SET temp_val = REPLACE(temp_val, 'TMP ', '');
SET temp_val = REPLACE(temp_val, ' TMP', '');
SET temp_val = REPLACE(temp_val, ' tmp', '');
RETURN dummy_name;
END/*//*/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不知道为什么你删除了 DELIMITER 部分,但是当我将其添加回来时,它运行良好:(
这是在 5.1.54 中......但我认为这并不重要)
Not sure why you removed the DELIMITER part, but when I add that back in, it runs fine:
(This was in 5.1.54... but I don't think that should matter)
预感:5.1.x 行中似乎有一个与
DELIMITER
有关的 MySQL Bug,可能会在这里困扰您:命令取决于你如何调用它,给定 cwallenpoole 的回复,考虑到您的 MySQL 版本,您的症状确实表明它很可能是该错误。您有可能升级吗?
A hunch: There seems to be a MySQL Bug in the 5.1.x line pertaining to
DELIMITER
that may be biting you here:Though that heavily depends on how you're calling it, given cwallenpoole's response, your symptom does suggest it may well be that bug, given your MySQL version. Is upgrading a possibility for you?