<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="ddl-rewriter">
      </a>
      7.6.5 The ddl_rewriter Plugin
     </h3>
    </div>
   </div>
  </div>
  <div class="toc">
   <dl class="toc">
    <dt>
     <span class="section">
      <a href="ddl-rewriter-installation.html">
       7.6.5.1 Installing or Uninstalling ddl_rewriter
      </a>
     </span>
    </dt>
    <dt>
     <span class="section">
      <a href="ddl-rewriter-options.html">
       7.6.5.2 ddl_rewriter Plugin Options
      </a>
     </span>
    </dt>
   </dl>
  </div>
  <a class="indexterm" name="idm46045256232016">
  </a>
  <a class="indexterm" name="idm46045256230944">
  </a>
  <p>
   MySQL 8.4 includes a
   <code class="literal">
    ddl_rewriter
   </code>
   plugin that modifies
   <a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
    <code class="literal">
     CREATE TABLE
    </code>
   </a>
   statements received by the server before it parses and executes
      them. The plugin removes
   <code class="literal">
    ENCRYPTION
   </code>
   ,
   <code class="literal">
    DATA DIRECTORY
   </code>
   , and
   <code class="literal">
    INDEX
      DIRECTORY
   </code>
   clauses, which may be helpful when restoring
      tables from SQL dump files created from databases that are
      encrypted or that have their tables stored outside the data
      directory. For example, the plugin may enable restoring such dump
      files into an unencrypted instance or in an environment where the
      paths outside the data directory are not accessible.
  </p>
  <p>
   Before using the
   <code class="literal">
    ddl_rewriter
   </code>
   plugin, install
      it according to the instructions provided in
   <a class="xref" href="ddl-rewriter-installation.html" title="7.6.5.1 Installing or Uninstalling ddl_rewriter">
    Section 7.6.5.1, “Installing or Uninstalling ddl_rewriter”
   </a>
   .
  </p>
  <p>
   <code class="literal">
    ddl_rewriter
   </code>
   examines SQL statements received
      by the server prior to parsing, rewriting them according to these
      conditions:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <code class="literal">
       ddl_rewriter
      </code>
      considers only
      <a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
       <code class="literal">
        CREATE TABLE
       </code>
      </a>
      statements, and
          only if they are standalone statements that occur at the
          beginning of an input line or at the beginning of prepared
          statement text.
      <code class="literal">
       ddl_rewriter
      </code>
      does not
          consider
      <a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
       <code class="literal">
        CREATE TABLE
       </code>
      </a>
      statements within stored program definitions. Statements can
          extend over multiple lines.
     </p>
    </li>
    <li class="listitem">
     <p>
      Within statements considered for rewrite, instances of the
          following clauses are rewritten and each instance replaced by
          a single space:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         <code class="literal">
          ENCRYPTION
         </code>
        </p>
       </li>
       <li class="listitem">
        <p>
         <code class="literal">
          DATA DIRECTORY
         </code>
         (at the table and
              partition levels)
        </p>
       </li>
       <li class="listitem">
        <p>
         <code class="literal">
          INDEX DIRECTORY
         </code>
         (at the table and
              partition levels)
        </p>
       </li>
      </ul>
     </div>
    </li>
    <li class="listitem">
     <p>
      Rewriting does not depend on lettercase.
     </p>
    </li>
   </ul>
  </div>
  <p>
   If
   <code class="literal">
    ddl_rewriter
   </code>
   rewrites a statement, it
      generates a warning:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa78026208"><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 prompt">mysql&gt;</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t <span class="token punctuation">(</span>i <span class="token datatype">INT</span><span class="token punctuation">)</span> <span class="token keyword">DATA</span> <span class="token keyword">DIRECTORY</span> <span class="token string">'/var/mysql/data'</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected, 1 warning (0.03 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
  Level<span class="token punctuation">:</span> Note
   Code<span class="token punctuation">:</span> 1105
Message<span class="token punctuation">:</span> Query 'CREATE TABLE t (i INT) DATA DIRECTORY '/var/mysql/data''
         rewritten to 'CREATE TABLE t (i INT) ' by a query rewrite plugin
</span><span class="token output">1 row in set (0.00 sec)</span></code></pre>
  </div>
  <p>
   If the general query log or binary log is enabled, the server
      writes to it statements as they appear after any rewriting by
   <code class="literal">
    ddl_rewriter
   </code>
   .
  </p>
  <p>
   When installed,
   <code class="literal">
    ddl_rewriter
   </code>
   exposes the
      Performance Schema
   <code class="literal">
    memory/rewriter/ddl_rewriter
   </code>
   instrument for tracking plugin memory use. See
   <a class="xref" href="performance-schema-memory-summary-tables.html" title="29.12.20.10 Memory Summary Tables">
    Section 29.12.20.10, “Memory Summary Tables”
   </a>
  </p>
 </div>
 <br/>
</div>
