0

Whenever I run this code:

SET GLOBAL log_bin_trust_function_creators=TRUE; 

DROP FUNCTION IF EXISTS GreaterCircleNm;
DELIMITER go
CREATE FUNCTION GreaterCircleNm( lat1 FLOAT, lon1 FLOAT, lat2 FLOAT, lon2 FLOAT ) RETURNS float
BEGIN
  DECLARE pi, q1, dist FLOAT;
  SET pi = PI();
  SET lat1 = lat1 * pi / 180;
  SET lon1 = lon1 * pi / 180;
  SET lat2 = lat2 * pi / 180;
  SET lon2 = lon2 * pi / 180;
SET q1 = ACOS(sin(lat1)*sin(lat2)+COS(lat1)*COS(lat2)*COS(lon1-lon2));
SET dist = q1*180*60/pi;
RETURN dist;
END;
go
DELIMITER ;

I get an error telling me I don't have super privileges. My hosting provider already told me that it is not possible for me to (1) get those privileges or (2) have them run the code. That leaves me with option (3) which is to remove SET GLOBAL log_bin_trust_function_creators=TRUE; while still creating the function. I'm not sure if this is possible, but I'd appreciate any help.

4

1 回答 1

1

SET GLOBAL没有超级特权,你什么都做不了。
参照。http://dev.mysql.com/doc/refman/5.6/en/set-statement.html

设置全局变量需要 SUPER 权限。

你不能SET SESSION为这个变量:

mysql> SET SESSION log_bin_trust_function_creators=0;
ERROR 1229 (HY000): Variable 'log_bin_trust_function_creators' 
is a GLOBAL variable and should be set with SET GLOBAL

文档确认了这一点,该文档仅将变量列为 GLOBAL,而不是基于 SESSION。

所以不,你不能解决这个问题。如果他们不想给你超级特权,你必须要求你的提供者为你创建函数。

或者从另一个允许您超级特权的提供商那里获得不同的托管计划。

否则不要在 SQL 存储函数中进行此计算。

于 2013-08-08T07:38:00.550 回答