[MYSQL] 함수생성시 오류발생! SQL 오류 (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)

2023. 11. 29. 15:34IT개발/Database

반응형

1. 결론

SET GLOBAL log_bin_trust_function_creators = ON;

/* 또는 아래와 같이 1을 주면 끝! */

SET GLOBAL log_bin_trust_function_creators = 1;

2. 현상

함수를 만들려고 하는데 생성이 안되네~!!

SQL 오류 (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)

이렇게 alert 창이 뜨는데.... 갑자기 잘되던게.... 이뭔 X소리야!

3. 분석

어디보자~ log_bin_trust_function_creators  MYSQL 스펙부터 보자

https://dev.mysql.com/doc/refman/8.0/en/replication-options-binary-log.html

 

MySQL :: MySQL 8.0 Reference Manual :: 17.1.6.4 Binary Logging Options and Variables

17.1.6.4 Binary Logging Options and Variables You can use the mysqld options and system variables that are described in this section to affect the operation of the binary log as well as to control which statements are written to the binary log. For additi

dev.mysql.com

  • log_bin_trust_function_creators
  • This variable applies when binary logging is enabled. It controls whether stored function creators can be trusted not to create stored functions that may cause unsafe events to be written to the binary log. If set to 0 (the default), users are not permitted to create or alter stored functions unless they have the SUPER privilege in addition to the CREATE ROUTINE or ALTER ROUTINE privilege. A setting of 0 also enforces the restriction that a function must be declared with the DETERMINISTIC characteristic, or with the READS SQL DATA or NO SQL characteristic. If the variable is set to 1, MySQL does not enforce these restrictions on stored function creation. This variable also applies to trigger creation. See Section 25.7, “Stored Program Binary Logging”.
  • Command-Line FormatDeprecatedSystem VariableScopeDynamicSET_VAR Hint AppliesTypeDefault Value
    --log-bin-trust-function-creators[={OFF|ON}]
    8.0.34
    log_bin_trust_function_creators
    Global
    Yes
    No
    Boolean
    OFF

직역해보이~  슈퍼권한 또는 함수 생성/수정 권한을 가진 사용자가 아닌 녀석이 함수를 생성하려거나 수정하려고 할때  발생하는 옵션이었다. 분명히 예전엔 해당계정으로 생성하고 수정했는데 뭐땜시 이게 맛탱이갔을꼬.... 흠...

암튼 권한이 있다가 없어졌거나 권한없어도 쓸수있게 열려있었다가 해당 옵션으로 닫힌건지는 모르겠지만! 
추후 모니터링해야겠다. 참고로 다른DB에 있는걸 현재DB로 한번 싹 dump 떠서 넣을때, 발생했다.

그즉슨... dump 밀어넣을때 뭔가! 뭔가! side-effect를 끼치지 않았을까 하는 의심!

내 로컬 DB에서 검증을 해봐야겠다 검증되면 또 포스팅 하겠...

반응형