Mysql ERROR 1418 (HY000): This function has none of deterministic, NO SQL, or READS SQL DATA

Source: Internet
Author: User

ERROR 1418 (HY000): This function has none of the deterministic, NO SQL, or READS SQL DATA in its declaration and binary Loggi The reason for the error of the *might* want to use the less safe log_bin_trust_function_creators variable): The MySQL configuration is replicated, and the copy function means that the MA Ster data changes will be synchronized to the slave. For functions, MySQL requires that the function cannot modify the data. WORKAROUND: 1. When creating a function, make it clear that I will not modify the data. There are 5 options when creating a function: A, deterministic deterministic B, no SQL does not contain SQL statements, and of course it does not modify data C, READS SQL data only reads data, and of course does not modify data d, modifies SQL data To modify the data e, CONTAINS SQL contains the SQL statement how to understand deterministic deterministic? You can think of the same input, the method execution process, the output is the same. That is, the reentrant nature of the method. Non-reentrant method: Static data is used within the method, malloc and free are used, and standard I/O functions are used. The CREATE function must explicitly indicate one of the three options for a, B, and C in order to perform successfully. The following:mysql> show variables like ' log_bin% '; +---------------------------------+-------+| Variable_name                   | Value |+---------------------------------+-------+| Log_bin                         | On    | | log_bin_trust_function_creators | OFF   | | Log_bin_trust_routine_creators | OFF   |+---------------------------------+-------+3 rows in setmysql> create function fun1 (num int (9)) returns in T (9) Beginreturn 1;end;1418-this function has none of the deterministic, NO SQL, or READS SQL DATA in its declaration and bin ARY logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable) mysql> Create Fu Nction fun1 (num int (9)) returns INT (9) reads SQL Databeginreturn 1;end; Query OK, 0 rows affectedmysql> drop function fun1; Query OK, 0 rows affectedmysql> create function fun1 (num int (9)) returns INT (9) Deterministicbeginreturn 1;end; Query OK, 0 rows Affected2, tell MySQL, trust me, the method will not modify the data, MySQL no longer check, even if the data is modified. This time depends on you to keep your promise, otherwise the consequences are at your own risk. mysql> drop function fun1; Query OK, 0 rows affectedmysql> set global log_bin_trust_function_creators=on; Query OK, 0 rows affectedmysql> show variables like ' log_bin% '; +---------------------------------+-------+| Variable_name                   |Value |+---------------------------------+-------+| Log_bin                         | On    | | log_bin_trust_function_creators | On    | | Log_bin_trust_routine_creators  | On    |+---------------------------------+-------+3 rows in setmysql> create function fun1 (num int (9)) Retu RNs Int (9) modifies SQL Databeginreturn 1;end; Query OK, 0 rows affected

Mysql ERROR 1418 (HY000): This function has none of deterministic, NO SQL, or READS SQL DATA

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.