查看日志信息:show variables like 'log_%';显示'log_bin'、'log_bin_trust_function_creators'等状态

解决方法:

  1. 关闭binary logging
  2. 在创建函数 begin 之前加上 DETERMINISTIC READS SQL DATA
  3. SET GLOBAL log_bin_trust_function_creators = 1;

参考  http://dev.mysql.com/doc/refman/5.0/en/stored-programs-logging.html

  • When you create a stored function, you must declare either that it is deterministic or that it does not modify data. Otherwise, it may be unsafe for data recovery or replication.

    By default, for a CREATE FUNCTION statement to be accepted, at least one of DETERMINISTICNO SQL, or READS SQL DATA must be specified explicitly. Otherwise an error occurs:

    ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL,
    or READS SQL DATA in its declaration and binary logging is enabled
    (you *might* want to use the less safe log_bin_trust_function_creators
    variable)

    This function is deterministic (and does not modify data), so it is safe:

    CREATE FUNCTION f1(i INT)
    RETURNS INT
    DETERMINISTIC
    READS SQL DATA
    BEGIN
    RETURN i;
    END;

    This function uses UUID(), which is not deterministic, so the function also is not deterministic and is not safe:

    CREATE FUNCTION f2()
    RETURNS CHAR(36) CHARACTER SET utf8
    BEGIN
    RETURN UUID();
    END;

    This function modifies data, so it may not be safe:

    CREATE FUNCTION f3(p_id INT)
    RETURNS INT
    BEGIN
    UPDATE t SET modtime = NOW() WHERE id = p_id;
    RETURN ROW_COUNT();
    END;

    Assessment of the nature of a function is based on the “honesty” of the creator: MySQL does not check that a function declared DETERMINISTIC is free of statements that produce nondeterministic results.

  • To relax the preceding conditions on function creation (that you must have the SUPER privilege and that a function must be declared deterministic or to not modify data), set the global log_bin_trust_function_creatorssystem variable to 1. By default, this variable has a value of 0, but you can change it like this:

    mysql> SET GLOBAL log_bin_trust_function_creators = 1;
    

    You can also set this variable by using the --log-bin-trust-function-creators=1 option when starting the server.

    If binary logging is not enabled, log_bin_trust_function_creators does not apply. SUPER is not required for function creation unless, as described previously, the DEFINER value in the function definition requires it.

  • For information about built-in functions that may be unsafe for replication (and thus cause stored functions that use them to be unsafe as well), see Section 16.4.1, “Replication Features and Issues”.

最新文章

  1. php用redis保存session
  2. C实现通用数据结构--单链表
  3. [转].NET下读取PDF文本
  4. win32_11gR2_database安装教程
  5. python_day7【模块configparser、XML、requests、shutil、系统命令-面向对象】之篇
  6. jQuery-单击文字或图片内容放大显示效果插件
  7. Chapter 17_2 备忘录函数
  8. 第一行代码_activity生命周期
  9. vue实现星级评价效果
  10. ASP.NET中直接用C# 动态修改CSS样式
  11. PAT甲级1103 Integer Factorization【dfs】【剪枝】
  12. python进程池
  13. c++文件的读写
  14. RPC原理
  15. HDU 1233 还是畅通工程 (最小生成树 )
  16. 学JS的心路历程Day28 - PixiJS -基础(二)
  17. JavaScript--DOM进阶(20)
  18. python爬虫:抓取下载电影文件,合并ts文件为完整视频
  19. 多媒体文件格式之TS
  20. flume学习笔记

热门文章

  1. AWK Demo
  2. linux shell 入门
  3. 动手动脑:String.equals()的使用方法
  4. Hibernate多对多关联
  5. Android L 64位兼容32 应用程序的认识
  6. python中完善decorator
  7. Java zip 压缩 文件夹删除,移动,重命名,复制
  8. Redis 高级实用特性
  9. Vue.js学习笔记 第二篇 样式绑定
  10. springcloud-声明式调用服务Feign