Temporary tables and replication
TEMPORARY TABLE + statement vs row binlog — avoid replica surprises.
TEMPORARY TABLE is session-scoped. Replication makes that slippery.
Statement-based
CREATE TEMPORARY can replicate; later statements assume the temp exists on the replica session. Connection mismatch or parallel apply → breakages.
Row-based
Temps used only inside a session often need not exist on the replica if only permanent-table row events matter. Mixed mode still bites.
Rules
- Prefer
binlog_format=ROW - Avoid temps in replicated stored programs when possible
- Stage in ordinary tables with session-specific names if work must span replicated statements
- Test failover with the app’s real session patterns
Fine on a single server. Smell in heavily replicated OLTP paths.