<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="rewriter-query-rewrite-plugin">
      </a>
      7.6.4 The Rewriter Query Rewrite Plugin
     </h3>
    </div>
   </div>
  </div>
  <div class="toc">
   <dl class="toc">
    <dt>
     <span class="section">
      <a href="rewriter-query-rewrite-plugin-installation.html">
       7.6.4.1 Installing or Uninstalling the Rewriter Query Rewrite Plugin
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="rewriter-query-rewrite-plugin-usage.html">
       7.6.4.2 Using the Rewriter Query Rewrite Plugin
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="rewriter-query-rewrite-plugin-reference.html">
       7.6.4.3 Rewriter Query Rewrite Plugin Reference
      </a>
     </span>
    </dt>
   </dl>
  </div>
  <a class="indexterm" name="idm46045256648128">
  </a>
  <a class="indexterm" name="idm46045256647040">
  </a>
  <p>
   MySQL supports query rewrite plugins that can examine and possibly
      modify SQL statements received by the server before the server
      executes them. See
   <a class="ulink" href="/doc/extending-mysql/8.4/en/plugin-types.html#query-rewrite-plugin-type" target="_top">
    Query Rewrite Plugins
   </a>
   .
  </p>
  <p>
   MySQL distributions include a postparse query rewrite plugin named
   <code class="literal">
    Rewriter
   </code>
   and scripts for installing the plugin
      and its associated elements. These elements work together to
      provide statement-rewriting capability:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      A server-side plugin named
      <code class="literal">
       Rewriter
      </code>
      examines statements and may rewrite them, based on its
          in-memory cache of rewrite rules.
     </p>
    </li>
    <li class="listitem">
     <p>
      These statements are subject to rewriting:
      <a class="link" href="select.html" title="15.2.13 SELECT Statement">
       <code class="literal">
        SELECT
       </code>
      </a>
      ,
      <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
       <code class="literal">
        INSERT
       </code>
      </a>
      ,
      <a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
       <code class="literal">
        REPLACE
       </code>
      </a>
      ,
      <a class="link" href="update.html" title="15.2.17 UPDATE Statement">
       <code class="literal">
        UPDATE
       </code>
      </a>
      , and
      <a class="link" href="delete.html" title="15.2.2 DELETE Statement">
       <code class="literal">
        DELETE
       </code>
      </a>
      .
     </p>
     <p>
      Standalone statements and prepared statements are subject to
          rewriting. Statements occurring within view definitions or
          stored programs are not subject to rewriting.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="literal">
       Rewriter
      </code>
      plugin uses a database named
      <code class="literal">
       query_rewrite
      </code>
      containing a table named
      <code class="literal">
       rewrite_rules
      </code>
      . The table provides
          persistent storage for the rules that the plugin uses to
          decide whether to rewrite statements. Users communicate with
          the plugin by modifying the set of rules stored in this table.
          The plugin communicates with users by setting the
      <code class="literal">
       message
      </code>
      column of table rows.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="literal">
       query_rewrite
      </code>
      database contains a
          stored procedure named
      <code class="literal">
       flush_rewrite_rules()
      </code>
      that loads the
          contents of the rules table into the plugin.
     </p>
    </li>
    <li class="listitem">
     <p>
      A loadable function named
      <a class="link" href="rewriter-query-rewrite-plugin-reference.html#function_load-rewrite-rules">
       <code class="literal">
        load_rewrite_rules()
       </code>
      </a>
      is used by
          the
      <code class="literal">
       flush_rewrite_rules()
      </code>
      stored procedure.
     </p>
    </li>
    <li class="listitem">
     <p>
      The
      <code class="literal">
       Rewriter
      </code>
      plugin exposes system
          variables that enable plugin configuration and status
          variables that provide runtime operational information. This
          plugin also supports a privilege
          (
      <a class="link" href="privileges-provided.html#priv_skip-query-rewrite">
       <code class="literal">
        SKIP_QUERY_REWRITE
       </code>
      </a>
      ) that
          protects a given user's queries from being rewritten.
     </p>
    </li>
   </ul>
  </div>
  <p>
   The following sections describe how to install and use the
   <code class="literal">
    Rewriter
   </code>
   plugin, and provide reference
      information for its associated elements.
  </p>
 </div>
 <br/>
</div>
