0

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.

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. 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. I think this is a different issue dealing with privileges.

user3525290
  • 1,557
  • 2
  • 20
  • 47
  • Works for me. See it here: http://sqlfiddle.com/#!9/6e43c/5 Maybe you need to change your delimiter to //? – Michael Jun 23 '17 at 16:34
  • What is the exact error you are getting? – Sloan Thrasher Jun 23 '17 at 16:52
  • 2
    Just as the error message is telling you: your function has to be `DETERMINISTIC` (or one of the other two) if binary logging is enabled. Since your function actually IS deterministic, all you need to do is to tell MySQL that by adding the word `DETERMINISTIC` infront of `RETURN` (not `returns`). – Solarflare Jun 24 '17 at 09:20
  • 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. I think this is a different issue dealing with privileges. – user3525290 Jun 26 '17 at 11:54

1 Answers1

0

It was a user permissions issue. I changed users and the code worked with the

Deterministic Return

added to the function.

user3525290
  • 1,557
  • 2
  • 20
  • 47