MySQL CREATE FUNCTION 在共享 Web 服务器上失败

发布于 2024-09-11 07:25:34 字数 1103 浏览 11 评论 0原文

我有以下功能。当我尝试在网络服务器上创建它时,它失败了

您没有 SUPER 权限并且已启用二进制日志记录(您可能希望使用不太安全的 log_bin_trust_function_creators 变量)

我从未在任何其他虚拟主机(以及完全相同的功能)中遇到过相同的问题,如何我可以解决这个问题吗? (我无法更改 MySQL 设置)。

CREATE FUNCTION `has_action_access`(in_role VARCHAR(255), in_request VARCHAR(255), in_action VARCHAR(255)) RETURNS tinyint(1)
    READS SQL DATA
    DETERMINISTIC
BEGIN

    DECLARE current_role VARCHAR(255);  
    DECLARE found, cont TINYINT(1) DEFAULT 0;
    SET current_role = in_role;

    findattempt: REPEAT
        SELECT COUNT(*) FROM cyp_action_access WHERE request = in_request AND action = in_action AND role = current_role INTO found;

        IF found = 0 THEN
            SELECT COUNT(*) FROM cyp_roles WHERE name = current_role INTO cont;
            IF cont = 1 THEN
                SELECT inherits FROM cyp_roles WHERE name = current_role INTO current_role;
                END IF;
            END IF;
    UNTIL (cont = 0 OR found > 0) END REPEAT;
    RETURN found;
END;
  • MySQL服务器的版本是5.0.90-log

I have the following function. When I try to create it on a webserver, it fails with

You do not have the SUPER privilege and binary logging is enabled (you might want to use the less safe log_bin_trust_function_creators variable)

I never had the same problem with any other webhosting (and the exact same function), how can I fix this? (I can't change MySQL settings).

CREATE FUNCTION `has_action_access`(in_role VARCHAR(255), in_request VARCHAR(255), in_action VARCHAR(255)) RETURNS tinyint(1)
    READS SQL DATA
    DETERMINISTIC
BEGIN

    DECLARE current_role VARCHAR(255);  
    DECLARE found, cont TINYINT(1) DEFAULT 0;
    SET current_role = in_role;

    findattempt: REPEAT
        SELECT COUNT(*) FROM cyp_action_access WHERE request = in_request AND action = in_action AND role = current_role INTO found;

        IF found = 0 THEN
            SELECT COUNT(*) FROM cyp_roles WHERE name = current_role INTO cont;
            IF cont = 1 THEN
                SELECT inherits FROM cyp_roles WHERE name = current_role INTO current_role;
                END IF;
            END IF;
    UNTIL (cont = 0 OR found > 0) END REPEAT;
    RETURN found;
END;
  • MySQL server's version is 5.0.90-log.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

何以笙箫默 2024-09-18 07:25:34

您的用户没有超级权限。您需要联系您的网络托管提供商并让他们更新此信息。如果他们不授予您该选项,请要求他们为您执行该脚本。

Your user does not have super privilege. You will need to contact your webhosting provider and have them update this. If they will not grant you that option ask them to execute the script for you.

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