简体   繁体   English

Mysql函数确定性错误

[英]Mysql Function Deterministic Error

I am using the below function to split a string. 我正在使用以下函数来拆分字符串。 I am getting the following error when I try to create the function on my live database: 尝试在实时数据库上创建函数时出现以下错误:

This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled. 此函数的声明中没有DETERMINISTIC,NO SQL或READS SQL DATA,并且启用了二进制日志记录。

The function doesn't actually hit the database at all. 该函数实际上根本不会访问数据库。 All it does is breakup a string. 它所做的就是分解一个字符串。 So if I send in '1,2,3,4' it splits them up. 因此,如果我发送“ 1、2、3、4”,则将其拆分。 How do I get past this error? 我如何克服这个错误? I am not actually modifying any tables. 我实际上并没有修改任何表。

DELIMITER ;;
CREATE FUNCTION `stringSplit`(
x VARCHAR(255),
delim VARCHAR(12),
pos INT) RETURNS varchar(255) CHARSET latin1
RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, ',', pos),
LENGTH(SUBSTRING_INDEX(x, delim, pos -1)) + 1), delim, '') ;;
DELIMITER ;

****** Update ****** ******更新******

I am getting the following error code. 我收到以下错误代码。

ERROR 1419 (HY000): You do not have the SUPER privilege and binary logging is enabled

I think it is correct by adding 'DETERMINISTIC' before the return statement. 我认为在return语句前添加'DETERMINISTIC'是正确的。 I think this is a different issue dealing with privileges. 我认为这是处理特权的另一个问题。

It was a user permissions issue. 这是一个用户权限问题。 I changed users and the code worked with the 我更改了用户,并且代码与

Deterministic Return

added to the function. 添加到功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM