<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="function-loading">
      </a>
      7.7.1 Installing and Uninstalling Loadable Functions
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045254213360">
  </a>
  <a class="indexterm" name="idm46045254212304">
  </a>
  <a class="indexterm" name="idm46045254210816">
  </a>
  <a class="indexterm" name="idm46045254209728">
  </a>
  <p>
   Loadable functions, as the name implies, must be loaded into the
      server before they can be used. MySQL supports automatic function
      loading during server startup and manual loading thereafter.
  </p>
  <p>
   While a loadable function is loaded, information about it is
      available as described in
   <a class="xref" href="obtaining-loadable-function-information.html" title="7.7.2 Obtaining Information About Loadable Functions">
    Section 7.7.2, “Obtaining Information About Loadable Functions”
   </a>
   .
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="function-loading.html#loadable-function-installing" title="Installing Loadable Functions">
       Installing Loadable Functions
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="function-loading.html#loadable-function-uninstalling" title="Uninstalling Loadable Functions">
       Uninstalling Loadable Functions
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="function-loading.html#loadable-function-upgrading" title="Reinstalling or Upgrading Loadable Functions">
       Reinstalling or Upgrading Loadable Functions
      </a>
     </p>
    </li>
   </ul>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="loadable-function-installing">
       </a>
       Installing Loadable Functions
      </h4>
     </div>
    </div>
   </div>
   <p>
    To load a loadable function manually, use the
    <a class="link" href="create-function-loadable.html" title="15.7.4.1 CREATE FUNCTION Statement for Loadable Functions">
     <code class="literal">
      CREATE
        FUNCTION
     </code>
    </a>
    statement. For example:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa28970028"><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">FUNCTION</span> metaphon
  <span class="token keyword">RETURNS</span> <span class="token keyword">STRING</span>
  <span class="token keyword">SONAME</span> <span class="token string">'udf_example.so'</span><span class="token punctuation">;</span></code></pre>
   </div>
   <p>
    The file base name depends on your platform. Common suffixes are
    <code class="filename">
     .so
    </code>
    for Unix and Unix-like systems,
    <code class="filename">
     .dll
    </code>
    for Windows.
   </p>
   <p>
    <a class="link" href="create-function-loadable.html" title="15.7.4.1 CREATE FUNCTION Statement for Loadable Functions">
     <code class="literal">
      CREATE
        FUNCTION
     </code>
    </a>
    has these effects:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       It loads the function into the server to make it available
            immediately.
      </p>
     </li>
     <li class="listitem">
      <p>
       It registers the function in the
       <code class="literal">
        mysql.func
       </code>
       system table to make it
            persistent across server restarts. For this reason,
       <a class="link" href="create-function-loadable.html" title="15.7.4.1 CREATE FUNCTION Statement for Loadable Functions">
        <code class="literal">
         CREATE
            FUNCTION
        </code>
       </a>
       requires the
       <a class="link" href="privileges-provided.html#priv_insert">
        <code class="literal">
         INSERT
        </code>
       </a>
       privilege for the
       <code class="literal">
        mysql
       </code>
       system database.
      </p>
     </li>
     <li class="listitem">
      <p>
       It adds the function to the Performance Schema
       <a class="link" href="performance-schema-user-defined-functions-table.html" title="29.12.22.10 The user_defined_functions Table">
        <code class="literal">
         user_defined_functions
        </code>
       </a>
       table
            that provides runtime information about installed loadable
            functions. See
       <a class="xref" href="obtaining-loadable-function-information.html" title="7.7.2 Obtaining Information About Loadable Functions">
        Section 7.7.2, “Obtaining Information About Loadable Functions”
       </a>
       .
      </p>
     </li>
    </ul>
   </div>
   <p>
    Automatic loading of loadable functions occurs during the normal
        server startup sequence:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       Functions registered in the
       <code class="literal">
        mysql.func
       </code>
       table are installed.
      </p>
     </li>
     <li class="listitem">
      <p>
       Components or plugins that are installed at startup may
            automatically install related functions.
      </p>
     </li>
     <li class="listitem">
      <p>
       Automatic function installation adds the functions to the
            Performance Schema
       <a class="link" href="performance-schema-user-defined-functions-table.html" title="29.12.22.10 The user_defined_functions Table">
        <code class="literal">
         user_defined_functions
        </code>
       </a>
       table
            that provides runtime information about installed functions.
      </p>
     </li>
    </ul>
   </div>
   <p>
    If the server is started with the
    <a class="link" href="server-options.html#option_mysqld_skip-grant-tables">
     <code class="option">
      --skip-grant-tables
     </code>
    </a>
    option,
        functions registered in the
    <code class="literal">
     mysql.func
    </code>
    table
        are not loaded and are unavailable. This does not apply to
        functions installed automatically by a component or plugin.
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="loadable-function-uninstalling">
       </a>
       Uninstalling Loadable Functions
      </h4>
     </div>
    </div>
   </div>
   <p>
    To remove a loadable function, use the
    <a class="link" href="drop-function-loadable.html" title="15.7.4.2 DROP FUNCTION Statement for Loadable Functions">
     <code class="literal">
      DROP
        FUNCTION
     </code>
    </a>
    statement. For example:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa67537964"><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">DROP</span> <span class="token keyword">FUNCTION</span> metaphon<span class="token punctuation">;</span></code></pre>
   </div>
   <p>
    <a class="link" href="drop-function-loadable.html" title="15.7.4.2 DROP FUNCTION Statement for Loadable Functions">
     <code class="literal">
      DROP
        FUNCTION
     </code>
    </a>
    has these effects:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       It unloads the function to make it unavailable.
      </p>
     </li>
     <li class="listitem">
      <p>
       It removes the function from the
       <code class="literal">
        mysql.func
       </code>
       system table. For this reason,
       <a class="link" href="drop-function-loadable.html" title="15.7.4.2 DROP FUNCTION Statement for Loadable Functions">
        <code class="literal">
         DROP
            FUNCTION
        </code>
       </a>
       requires the
       <a class="link" href="privileges-provided.html#priv_delete">
        <code class="literal">
         DELETE
        </code>
       </a>
       privilege for the
       <code class="literal">
        mysql
       </code>
       system database. With the function
            no longer registered in the
       <code class="literal">
        mysql.func
       </code>
       table, the server does not load the function during
            subsequent restarts.
      </p>
     </li>
     <li class="listitem">
      <p>
       It removes the function from the Performance Schema
       <a class="link" href="performance-schema-user-defined-functions-table.html" title="29.12.22.10 The user_defined_functions Table">
        <code class="literal">
         user_defined_functions
        </code>
       </a>
       table
            that provides runtime information about installed loadable
            functions.
      </p>
     </li>
    </ul>
   </div>
   <p>
    <a class="link" href="drop-function-loadable.html" title="15.7.4.2 DROP FUNCTION Statement for Loadable Functions">
     <code class="literal">
      DROP
        FUNCTION
     </code>
    </a>
    cannot be used to drop a loadable function
        that is installed automatically by components or plugins rather
        than by using
    <a class="link" href="create-function-loadable.html" title="15.7.4.1 CREATE FUNCTION Statement for Loadable Functions">
     <code class="literal">
      CREATE
        FUNCTION
     </code>
    </a>
    . Such a function is also dropped
        automatically, when the component or plugin that installed it is
        uninstalled.
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h4 class="title">
       <a name="loadable-function-upgrading">
       </a>
       Reinstalling or Upgrading Loadable Functions
      </h4>
     </div>
    </div>
   </div>
   <p>
    To reinstall or upgrade the shared library associated with a
        loadable function, issue a
    <a class="link" href="drop-function-loadable.html" title="15.7.4.2 DROP FUNCTION Statement for Loadable Functions">
     <code class="literal">
      DROP
        FUNCTION
     </code>
    </a>
    statement, upgrade the shared library, and
        then issue a
    <a class="link" href="create-function-loadable.html" title="15.7.4.1 CREATE FUNCTION Statement for Loadable Functions">
     <code class="literal">
      CREATE
        FUNCTION
     </code>
    </a>
    statement. If you upgrade the shared library
        first and then use
    <a class="link" href="drop-function-loadable.html" title="15.7.4.2 DROP FUNCTION Statement for Loadable Functions">
     <code class="literal">
      DROP
        FUNCTION
     </code>
    </a>
    , the server may unexpectedly shut down.
   </p>
  </div>
 </div>
 <br/>
</div>
