Common SQL Errors

MySQL Error 1674 ER_BINLOG_UNSAFE_SYSTEM_FUNCTION - Causes, Fixes, and Prevention

Galaxy Team
August 7, 2025

<p>The statement uses a nondeterministic system function, making it unsafe for statement-based replication and causing Error 1674.</p>

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error code 1674?

<p>MySQL Error 1674: ER_BINLOG_UNSAFE_SYSTEM_FUNCTION appears when a query calls a nondeterministic system function like NOW() or UUID() while binary logging is set to STATEMENT or MIXED. Switch to ROW logging or rewrite the query without the unsafe function to resolve the issue.</p>

Error Highlights

Typical Error Message

Statement is unsafe because it uses a system function

Error Type

Replication Error

Language

MySQL

Symbol

ER_BINLOG_UNSAFE_SYSTEM_FUNCTION

Error Code

1674

SQL State

HY000

Explanation

Table of Contents

What is MySQL Error 1674 ER_BINLOG_UNSAFE_SYSTEM_FUNCTION?

Error 1674 triggers when you execute a statement that invokes a nondeterministic system function while the server is using STATEMENT or MIXED binary logging format. MySQL marks the statement as unsafe because the function could return different values on replicas, breaking data consistency.

Why does this error matter in replication?

Statement-based replication replays SQL text on replicas. If the function gives a different result on the replica, tables diverge silently. Stopping the statement and warning the user protects data integrity across the primary and replicas.

When does the error typically occur?

The error surfaces during writes that call functions such as NOW(), SYSDATE(), UUID(), RAND(), or LOAD_FILE(). It also appears in triggers, stored procedures, and CREATE TABLE ... SELECT constructs that reference the same nondeterministic functions.

How do I quickly fix ER_BINLOG_UNSAFE_SYSTEM_FUNCTION?

Use one of three approaches: switch the global binlog_format to ROW, capture the function value into a variable and reuse it, or replace the function with a deterministic alternative. These changes allow the statement to be logged safely.

Is it safe to ignore the warning?

No. Ignoring the error risks replica drift, making future analytics and failover impossible to trust. Always correct the statement or adjust the logging mode before re-executing the query.

Common Causes

Calling NOW() or SYSDATE()

Timestamp functions return different values on each server, so MySQL blocks statement logging.

Using UUID() or RAND()

Unique identifiers and random numbers differ per host, producing non-identical rows on replicas.

Reference in Triggers or Procedures

Nondeterministic calls hidden inside stored code are still unsafe under STATEMENT or MIXED formats.

LOAD_FILE or DATA DIRECTORY paths

File system reads may succeed on the primary but fail on replicas due to different paths or permissions.

Related Errors

Error 1592 - ER_BINLOG_UNSAFE_STATEMENT

General warning for other nondeterministic constructs, not limited to system functions.

Error 1665 - ER_BINLOG_UNSAFE_AUTOINC_COLUMNS

Occurs when inserting into tables with AUTO_INCREMENT and SELECT in STATEMENT mode.

Error 1659 - ER_BINLOG_UNSAFE_UPDATE

Shows up when UPDATE uses LIMIT without ORDER BY, leading to unpredictable row order.

FAQs

Does switching to ROW format impact performance?

Row logging slightly increases log volume, but modern storage and compression minimize the difference. The consistency gain usually outweighs the cost.

Can I toggle binlog_format per session?

Yes. Use SET SESSION binlog_format after connecting to override the global setting temporarily.

Why does MIXED format still fail?

In MIXED mode, MySQL tries STATEMENT first and falls back to ROW only when it detects safety. Some unsafe functions are blocked before fallback.

How does Galaxy help avoid replication drift?

Galaxy highlights unsafe functions, offers AI rewrite suggestions, and lets teams enforce lint rules that ban nondeterministic calls in shared queries.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo