zoukankan      html  css  js  c++  java
  • mysql 报错之创建自定义函数

    I experienced this error while trying to alter one of my stored procedures remotely on a master server. After some research, I ended up getting information from “Binary Logging of Stored Programs“.

    From MySQL Reference in verbatim:
    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 DETERMINISTIC, NO 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)

    Further reading helped me arrive to the conclusion to the cause of this error:

    Cause:
    The error arises if the binary logging option, which is required for the replication, is turned on for the MySQL server.

    We can choose solutions listed below depending to our system requirements, for me, I opted on using the later.

    1. When creating or altering 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.
    2. 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_creators system 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.

     

    POSTED ON SUNDAY, NOVEMBER 11TH, 2012 AT 11:54 PM PRINT THIS ARTICLE EMAIL THIS ARTICLE

     
     
     

    ob·liv·i·on

    noun ə-ˈbli-vēən
    Reference : Merriam-Webster
    1. the fact or condition of forgetting or having forgotten; especially : the condition of being oblivious
    2. the condition or state of being forgotten or unknown
     

    tH3 oBlivIOus

    Aldwin Llacuna GalaponAldwin Llacuna Galapon
    IT Consultant / Software and Web Developer

     

    Do not take life too seriously. You might not get out of it alive!

     
    • FACEBOOK
    • TWITTER
     
     
     
  • 相关阅读:
    排序前后console.log输出无变化
    Cause: java.sql.SQLException: ORA-00904: "ID": 标识符无效
    无法解析Model中的实体类
    generatorConfig.xml
    cannot load oci dll [87/193]:
    jsp页面在 移动端 自适应,chrome浏览器没问题,可是safari浏览器有问题的解决方法
    【DP专题】——洛谷P1220关路灯
    学习笔记:查最大内存
    c++ try throw catch
    Dijkstra算法
  • 原文地址:https://www.cnblogs.com/best-jobs/p/3806292.html
Copyright © 2011-2022 走看看