<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h2 class="title">
      <a name="stored-program-restrictions">
      </a>
      27.8 Restrictions on Stored Programs
     </h2>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045081274016">
  </a>
  <a class="indexterm" name="idm46045081272528">
  </a>
  <a class="indexterm" name="idm46045081271040">
  </a>
  <a class="indexterm" name="idm46045081269552">
  </a>
  <a class="indexterm" name="idm46045081268064">
  </a>
  <a class="indexterm" name="idm46045081266576">
  </a>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="stored-program-restrictions.html#stored-routine-sql-restrictions" title="SQL Statements Not Permitted in Stored Routines">
       SQL Statements Not Permitted in Stored Routines
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="stored-program-restrictions.html#stored-routines-function-restrictions" title="Restrictions for Stored Functions">
       Restrictions for Stored Functions
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="stored-program-restrictions.html#stored-routines-trigger-restrictions" title="Restrictions for Triggers">
       Restrictions for Triggers
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="stored-program-restrictions.html#stored-routine-name-conflicts" title="Name Conflicts within Stored Routines">
       Name Conflicts within Stored Routines
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="stored-program-restrictions.html#stored-routines-replication-restrictions" title="Replication Considerations">
       Replication Considerations
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="stored-program-restrictions.html#stored-routines-debugging-restrictions" title="Debugging Considerations">
       Debugging Considerations
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="stored-program-restrictions.html#stored-routines-standard-restrictions" title="Unsupported Syntax from the SQL:2003 Standard">
       Unsupported Syntax from the SQL:2003 Standard
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="stored-program-restrictions.html#stored-routines-concurrency-restrictions" title="Stored Routine Concurrency Considerations">
       Stored Routine Concurrency Considerations
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="stored-program-restrictions.html#stored-routines-event-restrictions" title="Event Scheduler Restrictions">
       Event Scheduler Restrictions
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="stored-program-restrictions.html#stored-routines-ndbcluster" title="Stored routines and triggers in NDB Cluster">
       Stored routines and triggers in NDB Cluster
      </a>
     </p>
    </li>
   </ul>
  </div>
  <p>
   These restrictions apply to the features described in
   <a class="xref" href="stored-objects.html" title="Chapter 27 Stored Objects">
    Chapter 27,
    <i>
     Stored Objects
    </i>
   </a>
   .
  </p>
  <p>
   Some of the restrictions noted here apply to all stored routines;
      that is, both to stored procedures and stored functions. There are
      also some
   <a class="link" href="stored-program-restrictions.html#stored-routines-function-restrictions" title="Restrictions for Stored Functions">
    restrictions
      specific to stored functions
   </a>
   but not to stored procedures.
  </p>
  <p>
   The restrictions for stored functions also apply to triggers.
      There are also some
   <a class="link" href="stored-program-restrictions.html#stored-routines-trigger-restrictions" title="Restrictions for Triggers">
    restrictions
      specific to triggers
   </a>
   .
  </p>
  <p>
   The restrictions for stored procedures also apply to the
   <a class="link" href="do.html" title="15.2.3 DO Statement">
    <code class="literal">
     DO
    </code>
   </a>
   clause of Event Scheduler event
      definitions. There are also some
   <a class="link" href="stored-program-restrictions.html#stored-routines-event-restrictions" title="Event Scheduler Restrictions">
    restrictions
      specific to events
   </a>
   .
  </p>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h3 class="title">
       <a name="stored-routine-sql-restrictions">
       </a>
       SQL Statements Not Permitted in Stored Routines
      </h3>
     </div>
    </div>
   </div>
   <p>
    Stored routines cannot contain arbitrary SQL statements. The
        following statements are not permitted:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       The locking statements
       <a class="link" href="lock-tables.html" title="15.3.6 LOCK TABLES and UNLOCK TABLES Statements">
        <code class="literal">
         LOCK
            TABLES
        </code>
       </a>
       and
       <a class="link" href="lock-tables.html" title="15.3.6 LOCK TABLES and UNLOCK TABLES Statements">
        <code class="literal">
         UNLOCK
            TABLES
        </code>
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <a class="link" href="alter-view.html" title="15.1.11 ALTER VIEW Statement">
        <code class="literal">
         ALTER VIEW
        </code>
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
        <code class="literal">
         LOAD DATA
        </code>
       </a>
       and
       <a class="link" href="load-xml.html" title="15.2.10 LOAD XML Statement">
        <code class="literal">
         LOAD XML
        </code>
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       SQL prepared statements
            (
       <a class="link" href="prepare.html" title="15.5.1 PREPARE Statement">
        <code class="literal">
         PREPARE
        </code>
       </a>
       ,
       <a class="link" href="execute.html" title="15.5.2 EXECUTE Statement">
        <code class="literal">
         EXECUTE
        </code>
       </a>
       ,
       <a class="link" href="deallocate-prepare.html" title="15.5.3 DEALLOCATE PREPARE Statement">
        <code class="literal">
         DEALLOCATE PREPARE
        </code>
       </a>
       ) can be
            used in stored procedures, but not stored functions or
            triggers. Thus, stored functions and triggers cannot use
            dynamic SQL (where you construct statements as strings and
            then execute them).
      </p>
     </li>
     <li class="listitem">
      <p>
       Generally, statements not permitted in SQL prepared
            statements are also not permitted in stored programs. For a
            list of statements supported as prepared statements, see
       <a class="xref" href="sql-prepared-statements.html" title="15.5 Prepared Statements">
        Section 15.5, “Prepared Statements”
       </a>
       . Exceptions are
       <a class="link" href="signal.html" title="15.6.7.5 SIGNAL Statement">
        <code class="literal">
         SIGNAL
        </code>
       </a>
       ,
       <a class="link" href="resignal.html" title="15.6.7.4 RESIGNAL Statement">
        <code class="literal">
         RESIGNAL
        </code>
       </a>
       , and
       <a class="link" href="get-diagnostics.html" title="15.6.7.3 GET DIAGNOSTICS Statement">
        <code class="literal">
         GET DIAGNOSTICS
        </code>
       </a>
       , which are
            not permissible as prepared statements but are permitted in
            stored programs.
      </p>
     </li>
     <li class="listitem">
      <p>
       Because local variables are in scope only during stored
            program execution, references to them are not permitted in
            prepared statements created within a stored program.
            Prepared statement scope is the current session, not the
            stored program, so the statement could be executed after the
            program ends, at which point the variables would no longer
            be in scope. For example,
       <code class="literal">
        SELECT ... INTO
        <em class="replaceable">
         <code>
          local_var
         </code>
        </em>
       </code>
       cannot be
            used as a prepared statement. This restriction also applies
            to stored procedure and function parameters. See
       <a class="xref" href="prepare.html" title="15.5.1 PREPARE Statement">
        Section 15.5.1, “PREPARE Statement”
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       Within all stored programs (stored procedures and functions,
            triggers, and events), the parser treats
       <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
        <code class="literal">
         BEGIN
            [WORK]
        </code>
       </a>
       as the beginning of a
       <a class="link" href="begin-end.html" title="15.6.1 BEGIN ... END Compound Statement">
        <code class="literal">
         BEGIN ...
            END
        </code>
       </a>
       block. To begin a transaction in this context,
            use
       <a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
        <code class="literal">
         START
            TRANSACTION
        </code>
       </a>
       instead.
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h3 class="title">
       <a name="stored-routines-function-restrictions">
       </a>
       Restrictions for Stored Functions
      </h3>
     </div>
    </div>
   </div>
   <p>
    The following additional statements or operations are not
        permitted within stored functions. They are permitted within
        stored procedures, except stored procedures that are invoked
        from within a stored function or trigger. For example, if you
        use
    <a class="link" href="flush.html" title="15.7.8.3 FLUSH Statement">
     <code class="literal">
      FLUSH
     </code>
    </a>
    in a stored procedure,
        that stored procedure cannot be called from a stored function or
        trigger.
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       Statements that perform explicit or implicit commit or
            rollback. Support for these statements is not required by
            the SQL standard, which states that each DBMS vendor may
            decide whether to permit them.
      </p>
     </li>
     <li class="listitem">
      <p>
       Statements that return a result set. This includes
       <a class="link" href="select.html" title="15.2.13 SELECT Statement">
        <code class="literal">
         SELECT
        </code>
       </a>
       statements that do not
            have an
       <code class="literal">
        INTO
        <em class="replaceable">
         <code>
          var_list
         </code>
        </em>
       </code>
       clause and
            other statements such as
       <a class="link" href="show.html" title="15.7.7 SHOW Statements">
        <code class="literal">
         SHOW
        </code>
       </a>
       ,
       <a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
        <code class="literal">
         EXPLAIN
        </code>
       </a>
       , and
       <a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
        <code class="literal">
         CHECK TABLE
        </code>
       </a>
       . A function can
            process a result set either with
       <a class="link" href="select-into.html" title="15.2.13.1 SELECT ... INTO Statement">
        <code class="literal">
         SELECT ... INTO
         <em class="replaceable">
          <code>
           var_list
          </code>
         </em>
        </code>
       </a>
       or by using a
            cursor and
       <a class="link" href="fetch.html" title="15.6.6.3 Cursor FETCH Statement">
        <code class="literal">
         FETCH
        </code>
       </a>
       statements.
            See
       <a class="xref" href="select-into.html" title="15.2.13.1 SELECT ... INTO Statement">
        Section 15.2.13.1, “SELECT ... INTO Statement”
       </a>
       , and
       <a class="xref" href="cursors.html" title="15.6.6 Cursors">
        Section 15.6.6, “Cursors”
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       <a class="link" href="flush.html" title="15.7.8.3 FLUSH Statement">
        <code class="literal">
         FLUSH
        </code>
       </a>
       statements.
      </p>
     </li>
     <li class="listitem">
      <p>
       Stored functions cannot be used recursively.
      </p>
     </li>
     <li class="listitem">
      <p>
       A stored function or trigger cannot modify a table that is
            already being used (for reading or writing) by the statement
            that invoked the function or trigger.
      </p>
     </li>
     <li class="listitem">
      <p>
       If you refer to a temporary table multiple times in a stored
            function under different aliases, a
       <code class="literal">
        Can't reopen
            table:
            '
        <em class="replaceable">
         <code>
          tbl_name
         </code>
        </em>
        <code class="literal">
        </code>
        '
       </code>
       error occurs, even if the references occur in different
            statements within the function.
      </p>
     </li>
     <li class="listitem">
      <p>
       <a class="link" href="handler.html" title="15.2.5 HANDLER Statement">
        <code class="literal">
         HANDLER ...
            READ
        </code>
       </a>
       statements that invoke stored functions can
            cause replication errors and are disallowed.
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h3 class="title">
       <a name="stored-routines-trigger-restrictions">
       </a>
       Restrictions for Triggers
      </h3>
     </div>
    </div>
   </div>
   <p>
    For triggers, the following additional restrictions apply:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       Triggers are not activated by foreign key actions.
      </p>
     </li>
     <li class="listitem">
      <p>
       When using row-based replication, triggers on the replica
            are not activated by statements originating on the source.
            The triggers on the replica are activated when using
            statement-based replication. For more information, see
       <a class="xref" href="replication-features-triggers.html" title="19.5.1.36 Replication and Triggers">
        Section 19.5.1.36, “Replication and Triggers”
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       The
       <a class="link" href="return.html" title="15.6.5.7 RETURN Statement">
        <code class="literal">
         RETURN
        </code>
       </a>
       statement is not
            permitted in triggers, which cannot return a value. To exit
            a trigger immediately, use the
       <a class="link" href="leave.html" title="15.6.5.4 LEAVE Statement">
        <code class="literal">
         LEAVE
        </code>
       </a>
       statement.
      </p>
     </li>
     <li class="listitem">
      <p>
       Triggers are not permitted on tables in the
       <code class="literal">
        mysql
       </code>
       database. Nor are they permitted on
       <code class="literal">
        INFORMATION_SCHEMA
       </code>
       or
       <code class="literal">
        performance_schema
       </code>
       tables. Those tables
            are actually views and triggers are not permitted on views.
      </p>
     </li>
     <li class="listitem">
      <p>
       The trigger cache does not detect when metadata of the
            underlying objects has changed. If a trigger uses a table
            and the table has changed since the trigger was loaded into
            the cache, the trigger operates using the outdated metadata.
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h3 class="title">
       <a name="stored-routine-name-conflicts">
       </a>
       Name Conflicts within Stored Routines
      </h3>
     </div>
    </div>
   </div>
   <p>
    The same identifier might be used for a routine parameter, a
        local variable, and a table column. Also, the same local
        variable name can be used in nested blocks. For example:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa54420625"><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">CREATE</span> <span class="token keyword">PROCEDURE</span> p <span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span>
<span class="token keyword">BEGIN</span>
  <span class="token keyword">DECLARE</span> i <span class="token datatype">INT</span> <span class="token keyword">DEFAULT</span> <span class="token number">0</span><span class="token punctuation">;</span>
  <span class="token keyword">SELECT</span> i <span class="token keyword">FROM</span> t<span class="token punctuation">;</span>
  <span class="token keyword">BEGIN</span>
    <span class="token keyword">DECLARE</span> i <span class="token datatype">INT</span> <span class="token keyword">DEFAULT</span> <span class="token number">1</span><span class="token punctuation">;</span>
    <span class="token keyword">SELECT</span> i <span class="token keyword">FROM</span> t<span class="token punctuation">;</span>
  <span class="token keyword">END</span><span class="token punctuation">;</span>
<span class="token keyword">END</span><span class="token punctuation">;</span></code></pre>
   </div>
   <p>
    In such cases, the identifier is ambiguous and the following
        precedence rules apply:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       A local variable takes precedence over a routine parameter
            or table column.
      </p>
     </li>
     <li class="listitem">
      <p>
       A routine parameter takes precedence over a table column.
      </p>
     </li>
     <li class="listitem">
      <p>
       A local variable in an inner block takes precedence over a
            local variable in an outer block.
      </p>
     </li>
    </ul>
   </div>
   <p>
    The behavior that variables take precedence over table columns
        is nonstandard.
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h3 class="title">
       <a name="stored-routines-replication-restrictions">
       </a>
       Replication Considerations
      </h3>
     </div>
    </div>
   </div>
   <p>
    Use of stored routines can cause replication problems. This
        issue is discussed further in
    <a class="xref" href="stored-programs-logging.html" title="27.7 Stored Program Binary Logging">
     Section 27.7, “Stored Program Binary Logging”
    </a>
    .
   </p>
   <p>
    The
    <a class="link" href="replication-options-replica.html#option_mysqld_replicate-wild-do-table">
     <code class="option">
      --replicate-wild-do-table=
      <em class="replaceable">
       <code>
        db_name.tbl_name
       </code>
      </em>
     </code>
    </a>
    option applies to tables, views, and triggers. It does not apply
        to stored procedures and functions, or events. To filter
        statements operating on the latter objects, use one or more of
        the
    <code class="option">
     --replicate-*-db
    </code>
    options.
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h3 class="title">
       <a name="stored-routines-debugging-restrictions">
       </a>
       Debugging Considerations
      </h3>
     </div>
    </div>
   </div>
   <p>
    There are no stored routine debugging facilities.
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h3 class="title">
       <a name="stored-routines-standard-restrictions">
       </a>
       Unsupported Syntax from the SQL:2003 Standard
      </h3>
     </div>
    </div>
   </div>
   <p>
    The MySQL stored routine syntax is based on the SQL:2003
        standard. The following items from that standard are not
        currently supported:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       <code class="literal">
        UNDO
       </code>
       handlers
      </p>
     </li>
     <li class="listitem">
      <p>
       <code class="literal">
        FOR
       </code>
       loops
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h3 class="title">
       <a name="stored-routines-concurrency-restrictions">
       </a>
       Stored Routine Concurrency Considerations
      </h3>
     </div>
    </div>
   </div>
   <p>
    To prevent problems of interaction between sessions, when a
        client issues a statement, the server uses a snapshot of
        routines and triggers available for execution of the statement.
        That is, the server calculates a list of procedures, functions,
        and triggers that may be used during execution of the statement,
        loads them, and then proceeds to execute the statement. While
        the statement executes, it does not see changes to routines
        performed by other sessions.
   </p>
   <p>
    For maximum concurrency, stored functions should minimize their
        side-effects; in particular, updating a table within a stored
        function can reduce concurrent operations on that table. A
        stored function acquires table locks before executing, to avoid
        inconsistency in the binary log due to mismatch of the order in
        which statements execute and when they appear in the log. When
        statement-based binary logging is used, statements that invoke a
        function are recorded rather than the statements executed within
        the function. Consequently, stored functions that update the
        same underlying tables do not execute in parallel. In contrast,
        stored procedures do not acquire table-level locks. All
        statements executed within stored procedures are written to the
        binary log, even for statement-based binary logging. See
    <a class="xref" href="stored-programs-logging.html" title="27.7 Stored Program Binary Logging">
     Section 27.7, “Stored Program Binary Logging”
    </a>
    .
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h3 class="title">
       <a name="stored-routines-event-restrictions">
       </a>
       Event Scheduler Restrictions
      </h3>
     </div>
    </div>
   </div>
   <p>
    The following limitations are specific to the Event Scheduler:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       Event names are handled in case-insensitive fashion. For
            example, you cannot have two events in the same database
            with the names
       <code class="literal">
        anEvent
       </code>
       and
       <code class="literal">
        AnEvent
       </code>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       An event may not be created from within a stored program. An
            event may not be altered, or dropped from within a stored
            program, if the event name is specified by means of a
            variable. An event also may not create, alter, or drop
            stored routines or triggers.
      </p>
     </li>
     <li class="listitem">
      <p>
       DDL statements on events are prohibited while a
       <a class="link" href="lock-tables.html" title="15.3.6 LOCK TABLES and UNLOCK TABLES Statements">
        <code class="literal">
         LOCK TABLES
        </code>
       </a>
       statement is in
            effect.
      </p>
     </li>
     <li class="listitem">
      <p>
       Event timings using the intervals
       <code class="literal">
        YEAR
       </code>
       ,
       <code class="literal">
        QUARTER
       </code>
       ,
       <code class="literal">
        MONTH
       </code>
       , and
       <code class="literal">
        YEAR_MONTH
       </code>
       are resolved in months; those
            using any other interval are resolved in seconds. There is
            no way to cause events scheduled to occur at the same second
            to execute in a given order. In addition—due to
            rounding, the nature of threaded applications, and the fact
            that a nonzero length of time is required to create events
            and to signal their execution—events may be delayed by
            as much as 1 or 2 seconds. However, the time shown in 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's
       <code class="literal">
        LAST_EXECUTED
       </code>
       column is
            always accurate to within one second of the actual event
            execution time. (See also Bug #16522.)
      </p>
     </li>
     <li class="listitem">
      <p>
       Each execution of the statements contained in the body of an
            event takes place in a new connection; thus, these
            statements have no effect in a given user session on the
            server's statement counts such as
       <code class="literal">
        Com_select
       </code>
       and
       <code class="literal">
        Com_insert
       </code>
       that are displayed by
       <a class="link" href="show-status.html" title="15.7.7.37 SHOW STATUS Statement">
        <code class="literal">
         SHOW STATUS
        </code>
       </a>
       . However, such
            counts
       <span class="emphasis">
        <em>
         are
        </em>
       </span>
       updated in the global scope.
            (Bug #16422)
      </p>
     </li>
     <li class="listitem">
      <p>
       Events do not support times later than the end of the Unix
            Epoch; this is approximately the beginning of the year 2038.
            Such dates are specifically not permitted by the Event
            Scheduler. (Bug #16396)
      </p>
     </li>
     <li class="listitem">
      <p>
       References to stored functions, loadable functions, and
            tables in the
       <code class="literal">
        ON SCHEDULE
       </code>
       clauses 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>
       statements are
            not supported. These sorts of references are not permitted.
            (See Bug #22830 for more information.)
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h3 class="title">
       <a name="stored-routines-ndbcluster">
       </a>
       Stored routines and triggers in NDB Cluster
      </h3>
     </div>
    </div>
   </div>
   <p>
    While stored procedures, stored functions, triggers, and
        scheduled events are all supported by tables using the
    <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
     <code class="literal">
      NDB
     </code>
    </a>
    storage engine, you must keep
        in mind that these do
    <span class="emphasis">
     <em>
      not
     </em>
    </span>
    propagate
        automatically between MySQL Servers acting as Cluster SQL nodes.
        This is because stored routine and trigger definitions are
        stored in tables in the
    <code class="literal">
     mysql
    </code>
    system database
        using
    <code class="literal">
     InnoDB
    </code>
    tables, which are not copied
        between Cluster nodes.
   </p>
   <p>
    Any stored routine or trigger that interacts with MySQL Cluster
        tables must be re-created by running the appropriate
    <a class="link" href="create-procedure.html" title="15.1.17 CREATE PROCEDURE and CREATE FUNCTION Statements">
     <code class="literal">
      CREATE PROCEDURE
     </code>
    </a>
    ,
    <a class="link" href="create-function.html" title="15.1.14 CREATE FUNCTION Statement">
     <code class="literal">
      CREATE FUNCTION
     </code>
    </a>
    , or
    <a class="link" href="create-trigger.html" title="15.1.22 CREATE TRIGGER Statement">
     <code class="literal">
      CREATE TRIGGER
     </code>
    </a>
    statements on each
        MySQL Server that participates in the cluster where you wish to
        use the stored routine or trigger. Similarly, any changes to
        existing stored routines or triggers must be carried out
        explicitly on all Cluster SQL nodes, using the appropriate
    <code class="literal">
     ALTER
    </code>
    or
    <code class="literal">
     DROP
    </code>
    statements
        on each MySQL Server accessing the cluster.
   </p>
   <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
    <div class="admon-title">
     Warning
    </div>
    <p>
     Do
     <span class="emphasis">
      <em>
       not
      </em>
     </span>
     attempt to work around the issue
          just described by converting any
     <code class="literal">
      mysql
     </code>
     database tables to use the
     <a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
      <code class="literal">
       NDB
      </code>
     </a>
     storage engine.
     <span class="emphasis">
      <em>
       Altering the system tables in the
       <code class="literal">
        mysql
       </code>
       database is not supported
      </em>
     </span>
     and is very likely to produce undesirable results.
    </p>
   </div>
  </div>
 </div>
 <br/>
</div>
