您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

【MySQL案例】ERROR 1418

2024/4/15 14:01:21发布91次查看
1.1.1.error 1418 【环境描述】 mysql5.0.67 【问题描述】 创建存储过程的时候遇到error 1418报错。 # 创建函数的sql语句 create function `xxx`( num01 int ) returnsint(11) begin declare mm int default 0; if (xx) then set mm = num01*num01*10; elsei
1.1.1. error 1418
【环境描述】
mysql5.0.67
【问题描述】
创建存储过程的时候遇到error 1418报错。
# 创建函数的sql语句
create function `xxx`( num01 int ) returnsint(11)
begin
       declare mm  int default 0;
       if  (xx) then
                set mm = num01*num01*10;
       elseif  xxx then
                set mm = 10;  
       else
                case num01
                        when  30 then set mm = 111;
                        when  31 then set mm = 222;
                end case;      
       end if;
       return mm;
end
# 报错信息
# error 1418 (hy000) at line xxxxx: thisfunction has none of deterministic, no sql, or reads sql data in itsdeclaration and binary logging is enabled (you *might* want to use the lesssafe log_bin_trust_function_creators variable)
【解决方法】
关闭关闭binary log或者修改参数。
此处采用修改参数的方法:
set globallog_bin_trust_function_creators=1;
【报错原因】
by default, for a create functionstatement to be accepted, at least one of deterministic, nosql, or reads sql datamust be specified explicitly. otherwise an error occurs:
error1418 (hy000): this function has none of deterministic, no sql,
or readssql data in its declaration and binary logging is enabled
(you*might* want to use the less safe log_bin_trust_function_creators
variable)
if you set log_bin_trust_function_creatorsto 1, the requirement that functions be
deterministic or not modify data is dropped.
【参考资料】
command-lineformat --log-bin-trust-function-creators
option-fileformat log-bin-trust-function-creators
systemvariable name log_bin_trust_function_creators
variablescope global
dynamicvariable yes
permittedvalues
type boolean
default false
this variable applieswhen binary logging is enabled. it controls whether stored function creators canbe trusted not to create stored functions that will cause unsafe events to bewritten to the binary log. if set to 0 (the default), users are not permittedto create or alter stored functions unless they have thesuper privilege in addition to thecreate routine oralter routine privilege. a setting of0 also enforces the restriction that a function must be declared with thedeterministic characteristic, or with thereads sql data orno sql characteristic. if the variable is set to 1, mysqldoes not enforce these restrictions on stored function creation. this variablealso applies to trigger creation. seediv19.7, “binary logging of stored programs”.
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product