Stored Program Binary Logging •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: This function is deterministic (and does not modify data), so it is safe: This function uses  UUID() , which is not deterministic, so the function also is not deterministic and is not safe: This function modifies data, so it may not be safe: 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. •When you attempt to execute a stored function, if  binlog_format=STATEMENT  is set, the DETERMINISTIC  keyword must be specified in the function definition. If this is not the case, an error is generated and the function does not run, unless  log_bin_trust_function_creators=1  is specified to override this check (see below). For recursive function calls, the  DETERMINISTIC  keyword is required on the outermost call only. If row-based or mixed binary logging is in use, the statement is accepted and replicated even if the function was defined without the  DETERMINISTIC  keyword. •Because MySQL does not check if a function really is deterministic at creation time, the invocation of a stored function with the  DETERMINISTIC  keyword might carry out an action that is unsafe for statement-based logging, or invoke a function or procedure containing unsafe statements. If this occurs when  binlog_format=STATEMENT  is set, a warning message is issued. If row-based or mixed binary logging is in use, no warning is issued, and the statement is replicated in row-based format. •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; CREATE FUNCTION f3(p_id INT) RETURNS INT BEGIN UPDATE t SET modtime = NOW() WHERE id = p_id; RETURN ROW_COUNT(); END; CREATE FUNCTION f2() RETURNS CHAR(36) CHARACTER SET utf8 BEGIN RETURN UUID(); END; CREATE FUNCTION f1(i INT) RETURNS INT DETERMINISTIC READS SQL DATA BEGIN RETURN i; END; 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) 4756