日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

Mysql ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA

發布時間:2025/3/15 数据库 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Mysql ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
ERROR 1418 (HY000): 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)錯誤的原因:Mysql配置了復制,復制功能也就意味著Master數據的變化,會同步到Slave。對于函數,Mysql要求函數不能修改數據。解決辦法:1、創建函數的時候,明確說明我不會修改數據。創建函數的時候有5個選項:a、DETERMINISTIC 確定性的b、NO SQL 沒有包含SQl語句,當然也不會修改數據c、READS SQL DATA 只是讀取數據,當然也不會修改數據d、MODIFIES SQL DATA 要修改數據e、CONTAINS SQL 包含了SQL語句怎么理解DETERMINISTIC確定性的?可以認為輸入相同,方法執行過程,輸出也是相同的。也就是方法的可重入性。不可重入的方法:方法內使用了靜態的數據,使用了malloc和free,使用了標準I/O函數。創建函數必須明確指出a、b、c三個選項中的一個,才能執行成功。如下:mysql> show variables like 'log_bin%';+---------------------------------+-------+| Variable_name ? ? ? ? ? ? ? ? ? | Value |+---------------------------------+-------+| log_bin ? ? ? ? ? ? ? ? ? ? ? ? | ON ? ?|| log_bin_trust_function_creators | OFF ? || log_bin_trust_routine_creators ?| OFF ? |+---------------------------------+-------+3 rows in setmysql> create function fun1 (num int(9)) returns int(9)beginreturn 1;end;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)mysql> create function fun1 (num int(9)) returns int(9) reads sql databeginreturn 1;end;Query OK, 0 rows affectedmysql> drop function fun1;Query OK, 0 rows affectedmysql> create function fun1 (num int(9)) returns int(9) deterministicbeginreturn 1;end;Query OK, 0 rows affected2、告訴Mysql,信任我,方法不會修改數據,Mysql不再檢查,即使修改了數據。這個時候要靠你信守承諾,否則后果自負。mysql> drop function fun1;Query OK, 0 rows affectedmysql> set global log_bin_trust_function_creators=on;Query OK, 0 rows affectedmysql> show variables like 'log_bin%';+---------------------------------+-------+| Variable_name ? ? ? ? ? ? ? ? ? | Value |+---------------------------------+-------+| log_bin ? ? ? ? ? ? ? ? ? ? ? ? | ON ? ?|| log_bin_trust_function_creators | ON ? ?|| log_bin_trust_routine_creators ?| ON ? ?|+---------------------------------+-------+3 rows in setmysql> create function fun1 (num int(9)) returns int(9) modifies sql databeginreturn 1;end;Query OK, 0 rows affected

轉載于:https://www.cnblogs.com/nzbbody/p/4391783.html

總結

以上是生活随笔為你收集整理的Mysql ERROR 1418 (HY000): This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。