<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="replication-features-invoked">
      </a>
      19.5.1.16 Replication of Invoked Features
     </h4>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045135499520">
  </a>
  <a class="indexterm" name="idm46045135498032">
  </a>
  <a class="indexterm" name="idm46045135496544">
  </a>
  <a class="indexterm" name="idm46045135495056">
  </a>
  <a class="indexterm" name="idm46045135493568">
  </a>
  <a class="indexterm" name="idm46045135492080">
  </a>
  <a class="indexterm" name="idm46045135490592">
  </a>
  <p>
   Replication of invoked features such as loadable functions and
        stored programs (stored procedures and functions, triggers, and
        events) provides the following characteristics:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      The effects of the feature are always replicated.
     </p>
    </li>
    <li class="listitem">
     <p>
      The following statements are replicated using
            statement-based replication:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         <a class="link" href="create-event.html" title="15.1.13 CREATE EVENT Statement">
          <code class="literal">
           CREATE EVENT
          </code>
         </a>
        </p>
       </li>
       <li class="listitem">
        <p>
         <a class="link" href="alter-event.html" title="15.1.3 ALTER EVENT Statement">
          <code class="literal">
           ALTER EVENT
          </code>
         </a>
        </p>
       </li>
       <li class="listitem">
        <p>
         <a class="link" href="drop-event.html" title="15.1.25 DROP EVENT Statement">
          <code class="literal">
           DROP EVENT
          </code>
         </a>
        </p>
       </li>
       <li class="listitem">
        <p>
         <a class="link" href="create-procedure.html" title="15.1.17 CREATE PROCEDURE and CREATE FUNCTION Statements">
          <code class="literal">
           CREATE PROCEDURE
          </code>
         </a>
        </p>
       </li>
       <li class="listitem">
        <p>
         <a class="link" href="drop-procedure.html" title="15.1.29 DROP PROCEDURE and DROP FUNCTION Statements">
          <code class="literal">
           DROP PROCEDURE
          </code>
         </a>
        </p>
       </li>
       <li class="listitem">
        <p>
         <a class="link" href="create-function.html" title="15.1.14 CREATE FUNCTION Statement">
          <code class="literal">
           CREATE FUNCTION
          </code>
         </a>
        </p>
       </li>
       <li class="listitem">
        <p>
         <a class="link" href="drop-function.html" title="15.1.26 DROP FUNCTION Statement">
          <code class="literal">
           DROP FUNCTION
          </code>
         </a>
        </p>
       </li>
       <li class="listitem">
        <p>
         <a class="link" href="create-trigger.html" title="15.1.22 CREATE TRIGGER Statement">
          <code class="literal">
           CREATE TRIGGER
          </code>
         </a>
        </p>
       </li>
       <li class="listitem">
        <p>
         <a class="link" href="drop-trigger.html" title="15.1.34 DROP TRIGGER Statement">
          <code class="literal">
           DROP TRIGGER
          </code>
         </a>
        </p>
       </li>
      </ul>
     </div>
     <p>
      However, the
      <span class="emphasis">
       <em>
        effects
       </em>
      </span>
      of features
            created, modified, or dropped using these statements are
            replicated using row-based replication.
     </p>
     <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
      <div class="admon-title">
       Note
      </div>
      <p>
       Attempting to replicate invoked features using
              statement-based replication produces the warning
       <span class="errortext">
        Statement is not safe to log in statement
              format
       </span>
       . For example, trying to replicate a
              loadable function with statement-based replication
              generates this warning because it currently cannot be
              determined by the MySQL server whether the function is
              deterministic. If you are absolutely certain that the
              invoked feature's effects are deterministic, you can
              safely disregard such warnings.
      </p>
     </div>
    </li>
    <li class="listitem">
     <p>
      <a class="indexterm" name="idm46045135465024">
      </a>
      <a class="indexterm" name="idm46045135463536">
      </a>
      <a class="indexterm" name="idm46045135462048">
      </a>
      <a class="indexterm" name="idm46045135460560">
      </a>
      In the case of
      <a class="link" href="create-event.html" title="15.1.13 CREATE EVENT Statement">
       <code class="literal">
        CREATE EVENT
       </code>
      </a>
      and
      <a class="link" href="alter-event.html" title="15.1.3 ALTER EVENT Statement">
       <code class="literal">
        ALTER EVENT
       </code>
      </a>
      :
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         The status of the event is set to
         <code class="literal">
          REPLICA_SIDE_DISABLED
         </code>
         on the replica
                regardless of the state specified (this does not apply
                to
         <a class="link" href="drop-event.html" title="15.1.25 DROP EVENT Statement">
          <code class="literal">
           DROP EVENT
          </code>
         </a>
         ).
        </p>
       </li>
       <li class="listitem">
        <p>
         The source on which the event was created is identified
                on the replica by its server ID. The
         <code class="literal">
          ORIGINATOR
         </code>
         column in
         <a class="link" href="information-schema-events-table.html" title="28.3.14 The INFORMATION_SCHEMA EVENTS Table">
          <code class="literal">
           INFORMATION_SCHEMA.EVENTS
          </code>
         </a>
         stores this information. See
         <a class="xref" href="show-events.html" title="15.7.7.19 SHOW EVENTS Statement">
          Section 15.7.7.19, “SHOW EVENTS Statement”
         </a>
         , for more information.
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      The feature implementation resides on the replica in a
            renewable state so that if the source fails, the replica can
            be used as the source without loss of event processing.
     </p>
    </li>
   </ul>
  </div>
  <p>
   To determine whether there are any scheduled events on a MySQL
        server that were created on a different server (that was acting
        as a source), query the Information Schema
   <a class="link" href="information-schema-events-table.html" title="28.3.14 The INFORMATION_SCHEMA EVENTS Table">
    <code class="literal">
     EVENTS
    </code>
   </a>
   table in a manner similar to
        what is shown here:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa59699655"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> EVENT_SCHEMA<span class="token punctuation">,</span> EVENT_NAME
    <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">EVENTS</span>
    <span class="token keyword">WHERE</span> <span class="token keyword">STATUS</span> <span class="token operator">=</span> <span class="token string">'REPLICA_SIDE_DISABLED'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   Alternatively, you can use the
   <a class="link" href="show-events.html" title="15.7.7.19 SHOW EVENTS Statement">
    <code class="literal">
     SHOW
        EVENTS
    </code>
   </a>
   statement, like this:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa59166252"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SHOW</span> <span class="token keyword">EVENTS</span>
    <span class="token keyword">WHERE</span> <span class="token keyword">STATUS</span> <span class="token operator">=</span> <span class="token string">'REPLICA_SIDE_DISABLED'</span><span class="token punctuation">;</span></code></pre>
  </div>
  <p>
   When promoting a replica having such events to a source, you
        must enable each event using
   <a class="link" href="alter-event.html" title="15.1.3 ALTER EVENT Statement">
    <code class="literal">
     ALTER EVENT
     <em class="replaceable">
      <code>
       event_name
      </code>
     </em>
     ENABLE
    </code>
   </a>
   , where
   <em class="replaceable">
    <code>
     event_name
    </code>
   </em>
   is the name of the event.
  </p>
  <p>
   If more than one source was involved in creating events on this
        replica, and you wish to identify events that were created only
        on a given source having the server ID
   <em class="replaceable">
    <code>
     source_id
    </code>
   </em>
   , modify the previous query
        on the
   <a class="link" href="information-schema-events-table.html" title="28.3.14 The INFORMATION_SCHEMA EVENTS Table">
    <code class="literal">
     EVENTS
    </code>
   </a>
   table to include the
   <code class="literal">
    ORIGINATOR
   </code>
   column, as shown here:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa6923916"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> EVENT_SCHEMA<span class="token punctuation">,</span> EVENT_NAME<span class="token punctuation">,</span> ORIGINATOR
    <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">EVENTS</span>
    <span class="token keyword">WHERE</span> <span class="token keyword">STATUS</span> <span class="token operator">=</span> <span class="token string">'REPLICA_SIDE_DISABLED'</span>
    <span class="token operator">AND</span>   ORIGINATOR <span class="token operator">=</span> <span class="token string">'<em class="replaceable">source_id</em>'</span></code></pre>
  </div>
  <p>
   You can employ
   <code class="literal">
    ORIGINATOR
   </code>
   with the
   <a class="link" href="show-events.html" title="15.7.7.19 SHOW EVENTS Statement">
    <code class="literal">
     SHOW EVENTS
    </code>
   </a>
   statement in a
        similar fashion:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa93082231"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SHOW</span> <span class="token keyword">EVENTS</span>
    <span class="token keyword">WHERE</span> <span class="token keyword">STATUS</span> <span class="token operator">=</span> <span class="token string">'REPLICA_SIDE_DISABLED'</span>
    <span class="token operator">AND</span>   ORIGINATOR <span class="token operator">=</span> <span class="token string">'<em class="replaceable">source_id</em>'</span></code></pre>
  </div>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    <code class="literal">
     REPLICA_SIDE_DISABLED
    </code>
    replaces
    <code class="literal">
     SLAVESIDE_DISABLED
    </code>
    , which is deprecated.
   </p>
  </div>
  <p>
   Before enabling events that were replicated from the source, you
        should disable the MySQL Event Scheduler on the replica (using a
        statement such as
   <code class="literal">
    SET GLOBAL event_scheduler =
        OFF;
   </code>
   ), run any necessary
   <a class="link" href="alter-event.html" title="15.1.3 ALTER EVENT Statement">
    <code class="literal">
     ALTER
        EVENT
    </code>
   </a>
   statements, restart the server, then re-enable
        the Event Scheduler on the replica afterward (using a statement
        such as
   <code class="literal">
    SET GLOBAL event_scheduler = ON;
   </code>
   )-
  </p>
  <p>
   If you later demote the new source back to being a replica, you
        must disable manually all events enabled by the
   <a class="link" href="alter-event.html" title="15.1.3 ALTER EVENT Statement">
    <code class="literal">
     ALTER EVENT
    </code>
   </a>
   statements. You can
        do this by storing in a separate table the event names from the
   <a class="link" href="select.html" title="15.2.13 SELECT Statement">
    <code class="literal">
     SELECT
    </code>
   </a>
   statement shown
        previously, or using
   <a class="link" href="alter-event.html" title="15.1.3 ALTER EVENT Statement">
    <code class="literal">
     ALTER EVENT
    </code>
   </a>
   statements to rename the events with a common prefix such as
   <code class="literal">
    replicated_
   </code>
   to identify them.
  </p>
  <p>
   If you rename the events, then when demoting this server back to
        being a replica, you can identify the events by querying the
   <a class="link" href="information-schema-events-table.html" title="28.3.14 The INFORMATION_SCHEMA EVENTS Table">
    <code class="literal">
     EVENTS
    </code>
   </a>
   table, as shown here:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa31078478"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token function">CONCAT</span><span class="token punctuation">(</span>EVENT_SCHEMA<span class="token punctuation">,</span> <span class="token string">'.'</span><span class="token punctuation">,</span> EVENT_NAME<span class="token punctuation">)</span> <span class="token keyword">AS</span> <span class="token string">'Db.Event'</span>
      <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">EVENTS</span>
      <span class="token keyword">WHERE</span> <span class="token function">INSTR</span><span class="token punctuation">(</span>EVENT_NAME<span class="token punctuation">,</span> <span class="token string">'replicated_'</span><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span></code></pre>
  </div>
 </div>
 <br/>
</div>
