开发者

MySQL CREATE FUNCTION fails on a shared webserver

开发者 https://www.devze.com 2023-01-08 22:08 出处:网络
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_t

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_act开发者_C百科ion_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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号