<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="replication-rules-table-options">
      </a>
      19.2.5.2 Evaluation of Table-Level Replication Options
     </h4>
    </div>
   </div>
  </div>
  <p>
   The replica checks for and evaluates table options only if
        either of the following two conditions is true:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      No matching database options were found.
     </p>
    </li>
    <li class="listitem">
     <p>
      One or more database options were found, and were evaluated
            to arrive at an
      <span class="quote">
       “
       <span class="quote">
        execute
       </span>
       ”
      </span>
      condition according
            to the rules described in the previous section (see
      <a class="xref" href="replication-rules-db-options.html" title="19.2.5.1 Evaluation of Database-Level Replication and Binary Logging Options">
       Section 19.2.5.1, “Evaluation of Database-Level Replication and Binary Logging Options”
      </a>
      ).
     </p>
    </li>
   </ul>
  </div>
  <p>
   First, as a preliminary condition, the replica checks whether
        statement-based replication is enabled. If so, and the statement
        occurs within a stored function, the replica executes the
        statement and exits. If row-based replication is enabled, the
        replica does not know whether a statement occurred within a
        stored function on the source, so this condition does not apply.
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    For statement-based replication, replication events represent
          statements (all changes making up a given event are associated
          with a single SQL statement); for row-based replication, each
          event represents a change in a single table row (thus a single
          statement such as
    <code class="literal">
     UPDATE mytable SET mycol =
          1
    </code>
    may yield many row-based events). When viewed in
          terms of events, the process of checking table options is the
          same for both row-based and statement-based replication.
   </p>
  </div>
  <p>
   Having reached this point, if there are no table options, the
        replica simply executes all events. If there are any
   <a class="link" href="replication-options-replica.html#option_mysqld_replicate-do-table">
    <code class="option">
     --replicate-do-table
    </code>
   </a>
   or
   <a class="link" href="replication-options-replica.html#option_mysqld_replicate-wild-do-table">
    <code class="option">
     --replicate-wild-do-table
    </code>
   </a>
   options, the event must match one of these if it is to be
        executed; otherwise, it is ignored. If there are any
   <a class="link" href="replication-options-replica.html#option_mysqld_replicate-ignore-table">
    <code class="option">
     --replicate-ignore-table
    </code>
   </a>
   or
   <a class="link" href="replication-options-replica.html#option_mysqld_replicate-wild-ignore-table">
    <code class="option">
     --replicate-wild-ignore-table
    </code>
   </a>
   options, all events are executed except those that match any of
        these options.
  </p>
  <div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Important
   </div>
   <p>
    Table-level replication filters are only applied to tables
          that are explicitly mentioned and operated on in the query.
          They do not apply to tables that are implicitly updated by the
          query. For example, a
    <a class="link" href="grant.html" title="15.7.1.6 GRANT Statement">
     <code class="literal">
      GRANT
     </code>
    </a>
    statement, which updates the
    <code class="literal">
     mysql.user
    </code>
    system table but does not mention that table, is not affected
          by a filter that specifies
    <code class="literal">
     mysql.%
    </code>
    as the
          wildcard pattern.
   </p>
  </div>
  <p>
   The following steps describe this evaluation in more detail. The
        starting point is the end of the evaluation of the
        database-level options, as described in
   <a class="xref" href="replication-rules-db-options.html" title="19.2.5.1 Evaluation of Database-Level Replication and Binary Logging Options">
    Section 19.2.5.1, “Evaluation of Database-Level Replication and Binary Logging Options”
   </a>
   .
  </p>
  <div class="orderedlist">
   <ol class="orderedlist" type="1">
    <li class="listitem">
     <p>
      Are there any table replication options?
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: disc; ">
       <li class="listitem">
        <p>
         <b>
          Yes.
         </b>
         Continue to step 2.
        </p>
       </li>
       <li class="listitem">
        <p>
         <b>
          No.
         </b>
         Execute the update and exit.
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      Which logging format is used?
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: disc; ">
       <li class="listitem">
        <p>
         <b>
          STATEMENT.
         </b>
         Carry out the remaining steps for each statement that
                  performs an update.
        </p>
       </li>
       <li class="listitem">
        <p>
         <b>
          ROW.
         </b>
         Carry out the remaining steps for each update of a
                  table row.
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      Are there any
      <a class="link" href="replication-options-replica.html#option_mysqld_replicate-do-table">
       <code class="option">
        --replicate-do-table
       </code>
      </a>
      options?
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: disc; ">
       <li class="listitem">
        <p>
         <b>
          Yes.
         </b>
         Does the table match any of them?
        </p>
        <div class="itemizedlist">
         <ul class="itemizedlist" style="list-style-type: circle; ">
          <li class="listitem">
           <p>
            <b>
             Yes.
            </b>
            Execute the update and exit.
           </p>
          </li>
          <li class="listitem">
           <p>
            <b>
             No.
            </b>
            Continue to step 4.
           </p>
          </li>
         </ul>
        </div>
       </li>
       <li class="listitem">
        <p>
         <b>
          No.
         </b>
         Continue to step 4.
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      Are there any
      <a class="link" href="replication-options-replica.html#option_mysqld_replicate-ignore-table">
       <code class="option">
        --replicate-ignore-table
       </code>
      </a>
      options?
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: disc; ">
       <li class="listitem">
        <p>
         <b>
          Yes.
         </b>
         Does the table match any of them?
        </p>
        <div class="itemizedlist">
         <ul class="itemizedlist" style="list-style-type: circle; ">
          <li class="listitem">
           <p>
            <b>
             Yes.
            </b>
            Ignore the update and exit.
           </p>
          </li>
          <li class="listitem">
           <p>
            <b>
             No.
            </b>
            Continue to step 5.
           </p>
          </li>
         </ul>
        </div>
       </li>
       <li class="listitem">
        <p>
         <b>
          No.
         </b>
         Continue to step 5.
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      Are there any
      <a class="link" href="replication-options-replica.html#option_mysqld_replicate-wild-do-table">
       <code class="option">
        --replicate-wild-do-table
       </code>
      </a>
      options?
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: disc; ">
       <li class="listitem">
        <p>
         <b>
          Yes.
         </b>
         Does the table match any of them?
        </p>
        <div class="itemizedlist">
         <ul class="itemizedlist" style="list-style-type: circle; ">
          <li class="listitem">
           <p>
            <b>
             Yes.
            </b>
            Execute the update and exit.
           </p>
          </li>
          <li class="listitem">
           <p>
            <b>
             No.
            </b>
            Continue to step 6.
           </p>
          </li>
         </ul>
        </div>
       </li>
       <li class="listitem">
        <p>
         <b>
          No.
         </b>
         Continue to step 6.
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      Are there any
      <a class="link" href="replication-options-replica.html#option_mysqld_replicate-wild-ignore-table">
       <code class="option">
        --replicate-wild-ignore-table
       </code>
      </a>
      options?
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: disc; ">
       <li class="listitem">
        <p>
         <b>
          Yes.
         </b>
         Does the table match any of them?
        </p>
        <div class="itemizedlist">
         <ul class="itemizedlist" style="list-style-type: circle; ">
          <li class="listitem">
           <p>
            <b>
             Yes.
            </b>
            Ignore the update and exit.
           </p>
          </li>
          <li class="listitem">
           <p>
            <b>
             No.
            </b>
            Continue to step 7.
           </p>
          </li>
         </ul>
        </div>
       </li>
       <li class="listitem">
        <p>
         <b>
          No.
         </b>
         Continue to step 7.
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      Is there another table to be tested?
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: disc; ">
       <li class="listitem">
        <p>
         <b>
          Yes.
         </b>
         Go back to step 3.
        </p>
       </li>
       <li class="listitem">
        <p>
         <b>
          No.
         </b>
         Continue to step 8.
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      Are there any
      <a class="link" href="replication-options-replica.html#option_mysqld_replicate-do-table">
       <code class="option">
        --replicate-do-table
       </code>
      </a>
      or
      <a class="link" href="replication-options-replica.html#option_mysqld_replicate-wild-do-table">
       <code class="option">
        --replicate-wild-do-table
       </code>
      </a>
      options?
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: disc; ">
       <li class="listitem">
        <p>
         <b>
          Yes.
         </b>
         Ignore the update and exit.
        </p>
       </li>
       <li class="listitem">
        <p>
         <b>
          No.
         </b>
         Execute the update and exit.
        </p>
       </li>
      </ul>
     </div>
    </li>
   </ol>
  </div>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    Statement-based replication stops if a single SQL statement
          operates on both a table that is included by a
    <a class="link" href="replication-options-replica.html#option_mysqld_replicate-do-table">
     <code class="option">
      --replicate-do-table
     </code>
    </a>
    or
    <a class="link" href="replication-options-replica.html#option_mysqld_replicate-wild-do-table">
     <code class="option">
      --replicate-wild-do-table
     </code>
    </a>
    option, and another table that is ignored by a
    <a class="link" href="replication-options-replica.html#option_mysqld_replicate-ignore-table">
     <code class="option">
      --replicate-ignore-table
     </code>
    </a>
    or
    <a class="link" href="replication-options-replica.html#option_mysqld_replicate-wild-ignore-table">
     <code class="option">
      --replicate-wild-ignore-table
     </code>
    </a>
    option. The replica must either execute or ignore the complete
          statement (which forms a replication event), and it cannot
          logically do this. This also applies to row-based replication
          for DDL statements, because DDL statements are always logged
          as statements, without regard to the logging format in effect.
          The only type of statement that can update both an included
          and an ignored table and still be replicated successfully is a
          DML statement that has been logged with
    <a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
     <code class="literal">
      binlog_format=ROW
     </code>
    </a>
    .
   </p>
  </div>
 </div>
 <br/>
</div>
