CREATE FUNCTION error "This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA" CREATE FUNCTION error "This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA" mysql mysql

CREATE FUNCTION error "This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA"


I've googled and here I am.I've found a way :

SET GLOBAL log_bin_trust_function_creators = 1;

But be careful, it may be unsafe for data recovery or replication...


As per my understating it cause problem when data recovery or replication

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

MySQL 5.0.6: Statements that create stored routines and CALL statements are logged. Stored function invocations are logged when they occur in statements that update data (because those statements are logged).

However, function invocations are not logged when they occur in statements such as SELECT that do not change data, even if a data change occurs within a function itself; this can cause problems.

Under some circumstances, functions and procedures can have different effects if executed at different times or on different (master and slave) machines, and thus can be unsafe for data recovery or replication.

E.g.

CREATE FUNCTION myfunc () RETURNS INT DETERMINISTICBEGIN  INSERT INTO t (i) VALUES(1);  RETURN 0;END;SELECT myfunc();

If a stored function is invoked within a statement such as SELECT that does not modify data, execution of the function is not written to the binary log, even if the function itself modifies data. This logging behavior has the potential to cause problems. Suppose that a function myfunc() is defined as above.


There are two ways to fix this:

Execute the following in the MySQL console:

SET GLOBAL log_bin_trust_function_creators = 1;

Add the following to the mysql.ini configuration file:

log_bin_trust_function_creators = 1

The setting relaxes the checking for non-deterministic functions. Non-deterministic functions are functions that modify data (i.e. have update, insert or delete statement(s)). For more info, see here.

Please note, if binary logging is NOT enabled, this setting does not apply.