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
3,878 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 57

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 57

Expert Comment

by:Julian Hansen
ID: 39878831
Weird - works here - what version of MySQL are you on?
0
Upcoming Webinar: Securing your MySQL/MariaDB data

Join Percona’s Chief Evangelist, Colin Charles as he presents Securing your MySQL®/MariaDB® data on Tuesday, July 11, 2017 at 7:00 am PDT / 10:00 am EDT (UTC-7).

 

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 57

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 57

Accepted Solution

by:
Julian Hansen earned 500 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

705 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