mysqldude
Error codes › 1418

MySQL & MariaDB error 1418: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA

Error messageThis 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)
Example from our test runs: 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_b (8.0.46)

With binary logging on, MySQL refuses to create a stored function that doesn't declare whether it is deterministic or modifies data, because it can't tell whether replicas would compute the same result.

MySQLMariaDB
SymbolER_BINLOG_UNSAFE_ROUTINEER_BINLOG_UNSAFE_ROUTINE
SQLSTATEHY000HY000
TypeServer errorServer error
Versionsevery release since 5.0 activeevery release since 5.5 active

What it means

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).

When statements are written to the binary log for replication or point-in-time recovery, a function that isn’t deterministic could give a different result on a replica. So CREATE FUNCTION must declare its characteristics, or the server must be told to trust function creators.

Why it happens

  • MySQL 8.0 turned binary logging on by default. Function definitions that worked on 5.7 (where log_bin was off unless configured) fail on 8.0+. Our tests show 1418 on MySQL 8.0, 8.4 and 9.x but not on 5.6/5.7 or the default MariaDB configuration, where binary logging is off.
  • Restoring a dump with functions into a server with binary logging on.

How to fix it

  • Declare what the function does: DETERMINISTIC (same input, same output) and/or NO SQL / READS SQL DATA. Only declare DETERMINISTIC if it is true.
  • Or, as an administrator, SET GLOBAL log_bin_trust_function_creators = 1; (and in my.cnf). That is needed when users without SUPER create functions; understand the replication trade-off first.

Reproduce it yourself

These steps are the exact test our harness runs. Use a scratch server, never production.

  1. Connect with mysql -u root -p and create a scratch database:

    CREATE DATABASE demo;
    USE demo;
  2. Run:

    CREATE FUNCTION add_tax(p DECIMAL(10,2)) RETURNS DECIMAL(10,2) RETURN p * 1.23;

You get: 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)(9.7.4)

Verified fixes

  1. Declare what the function does: DETERMINISTIC / NO SQL / READS SQL DATA

    CREATE FUNCTION add_tax(p DECIMAL(10,2)) RETURNS DECIMAL(10,2) DETERMINISTIC NO SQL RETURN p * 1.23;
    SELECT add_tax(100);

Tested on

StepMySQLMariaDB
5.65.78.08.4910.610.1111.411.8
Create a function without a characteristic while binary logging is on
repro
≠≠✓ 1418✓ 1418✓ 1418≠≠≠≠
Is binary logging on? (default ON from MySQL 8.0; OFF in the MariaDB images)
version check
≠≠✓✓✓≠≠≠≠
Declare what the function does: DETERMINISTIC / NO SQL / READS SQL DATA
fix
✓✓✓✓✓✓✓✓✓
Create a function without a characteristic while binary logging is on repro
MySQL 5.6≠5.7≠8.0✓ 14188.4✓ 14189✓ 1418
MariaDB 10.6≠10.11≠11.4≠11.8≠
Is binary logging on? (default ON from MySQL 8.0; OFF in the MariaDB images) version check
MySQL 5.6≠5.7≠8.0✓8.4✓9✓
MariaDB 10.6≠10.11≠11.4≠11.8≠
Declare what the function does: DETERMINISTIC / NO SQL / READS SQL DATA fix
MySQL 5.6✓5.7✓8.0✓8.4✓9✓
MariaDB 10.6✓10.11✓11.4✓11.8✓
✓works ✓ 1062fails with the error the step demonstrates ⚠works with a warning ≠runs, result differs ✗fails Tested 2026-11-25 on 5.6.51, 5.7.44, 8.0.46, 8.4.13, 9.7.4, 10.6.28, 10.11.19, 11.4.13, 11.8.9
What the warnings and failures say (2)
  • Create a function without a characteristic while binary logging is on (MySQL 5.6, MySQL 5.7, MariaDB 10.6, MariaDB 10.11, MariaDB 11.4, MariaDB 11.8): expected error 1418 did not occur
  • Is binary logging on? (default ON from MySQL 8.0; OFF in the MariaDB images) (MySQL 5.6, MySQL 5.7, MariaDB 10.6, MariaDB 10.11, MariaDB 11.4, MariaDB 11.8): rows differ

Related errors

  • 1419 ER_BINLOG_CREATE_ROUTINE_NEED_SUPER
  • 1227 ER_SPECIFIC_ACCESS_DENIED_ERRORexplained

Where this error shows up in our guides