Oracle 5.0 Reference Manual page 1729

Table of Contents

Advertisement

->
BEGIN
->
IF @@server_id=2 THEN DROP DATABASE accounting; END IF;
->
END;
->
//
mysql>
delimiter ;
mysql>
CALL unsafe_sp();
The
CREATE PROCEDURE
execute them. Because the slave SQL thread has full privileges, it will execute the
statement that drops the
the master and slave and is not replication-safe.
The preceding example uses a stored procedure, but similar problems can occur for stored functions
that are invoked within statements that are written to the binary log: Function invocation has different
effects on the master and slave.
To guard against this danger for servers that have binary logging enabled, MySQL 5.0.6 introduces
the requirement that stored procedure and function creators must have the
in addition to the usual
or
PROCEDURE
ALTER
[576]
privilege. Without the
ROUTINE
ERROR 1419 (HY000): You do not have the SUPER privilege and
binary logging is enabled (you *might* want to use the less safe
log_bin_trust_routine_creators variable)
If you do not want to require routine creators to have the
all users with the
CREATE ROUTINE
developers), set the global
can also set this variable by using the
when starting the server. If binary logging is not enabled,
does not apply.
SUPER
value in the routine definition requires it.
DEFINER
• If a routine that performs updates is nondeterministic, it is not repeatable. This can have two
undesirable effects:
• It will make a slave different from the master.
• Restored data will be different from the original data.
To deal with these problems, MySQL enforces the following requirement: On a master server,
creation and alteration of a routine is refused unless you declare the routine to be deterministic or to
not modify data. Two sets of routine characteristics apply here:
• The
DETERMINISTIC
always produces the same result for given inputs. The default is
neither characteristic is given. To declare that a routine is deterministic, you must specify
explicitly.
DETERMINISTIC
• The
CONTAINS
SQL,
provide information about whether the routine reads or writes data. Either
indicates that a routine does not change data, but you must specify one of these explicitly
DATA
because the default is
By default, for a
CREATE PROCEDURE
of DETERMINISTIC,
occurs:
ERROR 1418 (HY000): This routine has none of DETERMINISTIC, NO SQL,
or READS SQL DATA in its declaration and binary logging is enabled
(you *might* want to use the less safe log_bin_trust_routine_creators
variable)
Binary Logging of Stored Programs
and
statements are written to the binary log, so the slave will
CALL
database. Thus, the
accounting
[576]
CREATE ROUTINE
FUNCTION, you must have the
SUPER
[576]
privilege on your system are experienced application
log_bin_trust_routine_creators
--log-bin-trust-routine-creators=1
[578]
is not required for routine creation unless, as described previously, the
and
NOT DETERMINISTIC
NO
SQL,
READS SQL
if no characteristic is given.
CONTAINS SQL
or
CREATE FUNCTION
SQL, or
NO
READS SQL DATA
1709
statement has different effects on
CALL
privilege that is required. Similarly, to use
[578]
SUPER
[578]
privilege, an error will occur:
[578]
SUPER
log_bin_trust_routine_creators
characteristics indicate whether a routine
NOT DETERMINISTIC
DATA, and
MODIFIES SQL DATA
statement to be accepted, at least one
must be specified explicitly. Otherwise an error
DROP DATABASE
[578]
privilege,
SUPER
ALTER
privilege in addition to the
privilege (for example, if
system variable to 1. You
[1468]
if
characteristics
or
NO SQL
READS SQL
ALTER
option

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents