create function sumage(age int) returns char(16)
begin
if age>=70 and age<=80 then return '老人';
elseif age>=40 and age<70 then return '中年人';
elseif age>=20 and age<40 then return '年轻人';
elseif age>=1 and age<20 then return '小孩';
end if;
end
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)
经过百度,将 log_bin_trust_function_creators 打开就可以运行成功
但是我不明白为什么,在mysql创建function要打开 bin——log
它控制是否可以信任存储函数创建者,不会创建写入二进制日志引起不安全事件的存储函数。
说白了就是你这个函数是否安全,出事了mysql不管,你自己负责