[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Error Code: 1418. 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_crea

Posted on 2014-02-19
9
Medium Priority
?
4,458 Views
Last Modified: 2014-02-26
from oop php tutorial
I do not yet understand the .sql file so I copy paste the query and the message

CREATE FUNCTION return_distance (lat_a DOUBLE, long_a DOUBLE, lat_b DOUBLE, long_b DOUBLE) RETURNS DOUBLE  BEGIN  DECLARE distance DOUBLE;  SET distance = SIN(RADIANS(lat_a)) * SIN(RADIANS(lat_b))  + COS(RADIANS(lat_a))  * COS(RADIANS(lat_b))  * COS(RADIANS(long_a - long_b));  RETURN((DEGREES(ACOS(distance))) * 69.09);  END

Open in new window



Error Code: 1418. 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)

Open in new window

0
Comment
Question by:rgb192
  • 5
  • 4
9 Comments
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 39872569
Try Adding DELIMITER around your code i.e

DELIMITER $$
CREATE FUNCTION return_distance (lat_a DOUBLE, long_a DOUBLE, lat_b DOUBLE, long_b DOUBLE) RETURNS DOUBLE  BEGIN  DECLARE distance DOUBLE;  SET distance = SIN(RADIANS(lat_a)) * SIN(RADIANS(lat_b))  + COS(RADIANS(lat_a))  * COS(RADIANS(lat_b))  * COS(RADIANS(long_a - long_b));  RETURN((DEGREES(ACOS(distance))) * 69.09);  END$$
DELIMITER;

Open in new window

0
 

Author Comment

by:rgb192
ID: 39878681
the tutorial had $delimiter around it , but I get same error.


DELIMITER $$
CREATE FUNCTION return_distance (lat_a DOUBLE, long_a DOUBLE, lat_b DOUBLE, long_b DOUBLE) RETURNS DOUBLE  BEGIN  DECLARE distance DOUBLE;  SET distance = SIN(RADIANS(lat_a)) * SIN(RADIANS(lat_b))  + COS(RADIANS(lat_a))  * COS(RADIANS(lat_b))  * COS(RADIANS(long_a - long_b));  RETURN((DEGREES(ACOS(distance))) * 69.09);  END$$
DELIMITER;



Error Code: 1418. 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)
0
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 39878831
Weird - works here - what version of MySQL are you on?
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

Author Comment

by:rgb192
ID: 39881130
MySQL Version :
5.5.24
0
 

Author Comment

by:rgb192
ID: 39884661
could this be a setting in mysql workbench since I am using
MySQL Version :
5.5.24

I have access to change mysql settings because I am using wamp on my windows7 desktop
0
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 39885030
I am on 5.0.27
I have also tested on a couple of other servers
5.5.33-29.3 - Success
5.1.58 - Success

Can't really give you any indication as to why it is failing - nothing wrong with the definition.

If you are on WAMP have you tried executing it through PHPMyAdmin ?
0
 

Author Comment

by:rgb192
ID: 39889306
in phpmyadmin

Error
SQL query:

DELIMITER $$ CREATE FUNCTION return_distance(

lat_a DOUBLE,
long_a DOUBLE,
lat_b DOUBLE,
long_b DOUBLE
) RETURNS DOUBLE BEGIN DECLARE distance DOUBLE;

SET distance = SIN( RADIANS( lat_a ) ) * SIN( RADIANS( lat_b ) ) + COS( RADIANS( lat_a ) ) * COS( RADIANS( lat_b ) ) * COS( RADIANS( long_a - long_b ) ) ;

RETURN (
(
DEGREES( ACOS( distance ) )
) * 69.09
);

END$$
MySQL said: Documentation

#1418 - 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)


I have access to change mysql settings because I am using wamp on my windows7 desktop so do you know what mysql settings I should change?
0
 
LVL 60

Accepted Solution

by:
Julian Hansen earned 2000 total points
ID: 39890102
So then it has nothing to do with your SQL Workbench and is instead some setting on the server.

Maybe this article is of use http://www.jamediasolutions.com/blog/deterministic-no-sql-or-reads-sql-data-in-its-declaration.html

Failing that have you tried

DELIMITER $$ CREATE FUNCTION return_distance(

lat_a DOUBLE,
long_a DOUBLE,
lat_b DOUBLE,
long_b DOUBLE
) 
RETURNS DOUBLE 
DETERMINISTIC
BEGIN DECLARE distance DOUBLE;
...

Open in new window

0
 

Author Closing Comment

by:rgb192
ID: 39890934
SET GLOBAL log_bin_trust_function_creators = 1;

thanks.  I did not get to try your command because
SET GLOBAL log_bin_trust_function_creators = 1;
worked.
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month17 days, 21 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question