1635
MariaDBERRORNotableReplicationHIGH confidence

Cannot change binlog_direct_non_transactional_updates inside a stored function or trigger

Production Risk

Low — the SET is rejected; routine logic is unaffected.

What this means

Attempting to change binlog_direct_non_transactional_updates from within a stored function or trigger is not permitted.

Why it happens
  1. 1A stored function or trigger contains a SET SESSION binlog_direct_non_transactional_updates statement.
How to reproduce
trigger — this will error
trigger — this will error
CREATE FUNCTION f() RETURNS INT
BEGIN
  SET SESSION binlog_direct_non_transactional_updates = ON;
  RETURN 1;
END;

expected output

ERROR 1635 (HY000): Cannot change the binlog direct flag inside a stored function or trigger.

Fix

Set the variable outside the stored routine

Set the variable outside the stored routine
SET SESSION binlog_direct_non_transactional_updates = ON;
SELECT f();

Why this works

Variables that affect replication behaviour must be set at the session level outside routines.

Sources
Official documentation ↗

MySQL 8.0 — 1635 ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_DIRECT

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors