1931
MySQLERRORNotableReplicationHIGH confidence

Stored function or trigger prevents switch out of row-based logging

Production Risk

Medium — may cause replication inconsistency if the format is mismatched.

What this means

MySQL cannot switch binlog_format away from ROW while executing inside a stored function or trigger, because the binlog format must remain consistent throughout the routine's execution.

Why it happens
  1. 1Attempt to SET binlog_format inside a stored function or trigger.
How to reproduce
trigger — this will error
trigger — this will error
-- Inside a stored function:
SET SESSION binlog_format = 'STATEMENT'; -- error inside SF/trigger

expected output

ERROR 1931 (HY000): Cannot change the binlog format inside a stored function or trigger.

Fix

Set binlog_format before calling the stored function

Set binlog_format before calling the stored function
SET SESSION binlog_format = 'STATEMENT';
CALL my_proc();

Why this works

Change the binlog format at the session level before entering stored routines.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 1931 ER_STORED_FUNCTION_PREVENTS_SWITCH_OUT_OF_RBR2

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

← All MySQL errors