MySQL 5.1.39 SQL语法错误

发布于 2024-11-17 06:59:25 字数 864 浏览 2 评论 0原文

我已将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

过期情话 2024-11-24 06:59:25

不知道为什么你删除了 DELIMITER 部分,但是当我将其添加回来时,它运行良好:(

DELIMITER // -- you have to change what MySQL expects between commands
DROP FUNCTION IF EXISTS clean_dymmy_table // -- tell it a new command's coming
CREATE FUNCTION clean_dymmy_table (dummy_name VARCHAR(255)) 
                                   RETURNS VARCHAR(255)
DETERMINISTIC
BEGIN
    -- now this can be parsed as part of the current command.
    DECLARE temp_val VARCHAR(255); 
    SET temp_val = dummy_name;

    -- Test
    RETURN dummy_name;
END
// -- Now you're done with that command.
-- go back to semi-colons, because otherwise life is too zany for me.
DELIMITER ; 

这是在 5.1.54 中......但我认为这并不重要)

Not sure why you removed the DELIMITER part, but when I add that back in, it runs fine:

DELIMITER // -- you have to change what MySQL expects between commands
DROP FUNCTION IF EXISTS clean_dymmy_table // -- tell it a new command's coming
CREATE FUNCTION clean_dymmy_table (dummy_name VARCHAR(255)) 
                                   RETURNS VARCHAR(255)
DETERMINISTIC
BEGIN
    -- now this can be parsed as part of the current command.
    DECLARE temp_val VARCHAR(255); 
    SET temp_val = dummy_name;

    -- Test
    RETURN dummy_name;
END
// -- Now you're done with that command.
-- go back to semi-colons, because otherwise life is too zany for me.
DELIMITER ; 

(This was in 5.1.54... but I don't think that should matter)

迎风吟唱 2024-11-24 06:59:25

预感:5.1.x 行中似乎有一个与 DELIMITER 有关的 MySQL Bug,可能会在这里困扰您:

  • #46429 在 MySql.Data.MySqlClient.MySqlScript 中使用 DELIMITER

命令取决于你如何调用它,给定 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:

  • #46429 use DELIMITER command in MySql.Data.MySqlClient.MySqlScript

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文