WL#3339: Issue warnings when statement-based replication may fail

Affects: Server-5.1   —   Status: Complete

Suggestion from Mats.

IDEA
----

Now that we have a mixed binlogging mode, whose intent is that it should
toggle into row-based mode for all statements where statement-based
binlogging may be unsafe (e.g. ``UUID()``, UDFs, stored functions inserting
into more than one table with auto_increment), it makes sense to warn the
user (via a warning sent to the client) and the DBA (via a warning printed to
the error log) when he's using such statement in statement-based mode.

For example, if the master is using statement-based binary logging, you would see::

  INSERT INTO t SELECT UUID();

warning: statement-based binary logging is not safe with this statement,
please consider using mixed or row-based binary logging

A similar warning would be printed to the error log (together with the
statement involved).

PROBLEMS
--------

- We should not fill the error log: write to the error log only once per
  run of mysqld
- Should we issue one warning to the client per session or one per statement?
- We should not give false alarms: SELECT UUID() is safe, i.e. we should warn
  only if the statement did write something to the binlog

EXTENSIONS
----------

To make it even more useful, we should extend the mixed mode to use row-based
in other statement-based-unsafe situations to be listed: multiple calls to
RAND(), use of SYSDATE(), etc, anything listed in the "replication features and
known problems" of the manual

REFERENCES
----------

See also WL#3303.