<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h2 class="title">
      <a name="error-message-elements">
      </a>
      B.1 Error Message Sources and Elements
     </h2>
    </div>
   </div>
  </div>
  <p>
   This section discusses how error messages originate within MySQL
      and the elements they contain.
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      <a class="xref" href="error-message-elements.html#error-sources" title="Error Message Sources">
       Error Message Sources
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="error-message-elements.html#error-elements" title="Error Message Elements">
       Error Message Elements
      </a>
     </p>
    </li>
    <li class="listitem">
     <p>
      <a class="xref" href="error-message-elements.html#error-code-ranges" title="Error Code Ranges">
       Error Code Ranges
      </a>
     </p>
    </li>
   </ul>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h3 class="title">
       <a name="error-sources">
       </a>
       Error Message Sources
      </h3>
     </div>
    </div>
   </div>
   <p>
    Error messages can originate on the server side or the client
        side:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       On the server side, error messages may occur during the
            startup and shutdown processes, as a result of issues that
            occur during SQL statement execution, and so forth.
      </p>
      <div class="itemizedlist">
       <ul class="itemizedlist" style="list-style-type: circle; ">
        <li class="listitem">
         <p>
          The MySQL server writes some error messages to its error
                log. These indicate issues of interest to database
                administrators or that require DBA action.
         </p>
        </li>
        <li class="listitem">
         <p>
          The server sends other error messages to client
                programs. These indicate issues pertaining only to a
                particular client. The MySQL client library takes errors
                received from the server and makes them available to the
                host client program.
         </p>
        </li>
       </ul>
      </div>
     </li>
     <li class="listitem">
      <p>
       Client-side error messages are generated from within the
            MySQL client library, usually involving problems
            communicating with the server.
      </p>
     </li>
    </ul>
   </div>
   <p>
    Example server-side error messages written to the error log:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       This message produced during the startup process provides a
            status or progress indicator:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-none"><div class="docs-select-all right" id="sa83206953"><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-none">2018-10-28T13:01:32.735983Z 0 [Note] [MY-010303] [Server] Skipping
generation of SSL certificates as options related to SSL are specified.</code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       This message indicates an issue that requires DBA action:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-none"><div class="docs-select-all right" id="sa59934701"><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-none">2018-10-02T03:20:39.410387Z 768 [ERROR] [MY-010045] [Server] Event Scheduler:
[evtuser@localhost][myschema.e_daily] Unknown database 'mydb'</code></pre>
      </div>
     </li>
    </ul>
   </div>
   <p>
    Example server-side error message sent to client programs, as
        displayed by the
    <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
     <span class="command">
      <strong>
       mysql
      </strong>
     </span>
    </a>
    client:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa90297123"><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">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> no_such_table<span class="token punctuation">;</span>
<span class="token output">ERROR 1146 (42S02)<span class="token punctuation">:</span> Table 'test.no_such_table' doesn't exist</span></code></pre>
   </div>
   <p>
    Example client-side error message originating from within the
        client library, as displayed by the
    <a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
     <span class="command">
      <strong>
       mysql
      </strong>
     </span>
    </a>
    client:
   </p>
   <div class="copytoclipboard-wrapper">
    <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa2382189"><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-terminal"><span class="token prompt">$&gt; </span><span class="token command">mysql</span> <span class="token property">-h</span> no-such-host
<span class="token output">ERROR 2005 (HY000)<span class="token punctuation">:</span> Unknown MySQL server host 'no-such-host' (-2)</span></code></pre>
   </div>
   <p>
    Whether an error originates from within the client library or is
        received from the server, a MySQL client program may respond in
        varying ways. As just illustrated, the client may display the
        error message so the user can take corrective measures. The
        client may instead internally attempt to resolve or retry a
        failed operation, or take other action.
   </p>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h3 class="title">
       <a name="error-elements">
       </a>
       Error Message Elements
      </h3>
     </div>
    </div>
   </div>
   <p>
    When an error occurs, error information includes several
        elements: an error code, SQLSTATE value, and message string.
        These elements have the following characteristics:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       Error code: This value is numeric. It is MySQL-specific and
            is not portable to other database systems.
      </p>
      <p>
       Each error number has a corresponding symbolic value.
            Examples:
      </p>
      <div class="itemizedlist">
       <ul class="itemizedlist" style="list-style-type: circle; ">
        <li class="listitem">
         <p>
          The symbol for server error number
          <code class="literal">
           1146
          </code>
          is
          <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_no_such_table" target="_top">
           <code class="literal">
            ER_NO_SUCH_TABLE
           </code>
          </a>
          .
         </p>
        </li>
        <li class="listitem">
         <p>
          The symbol for client error number
          <code class="literal">
           2005
          </code>
          is
          <a class="ulink" href="/doc/mysql-errors/8.4/en/client-error-reference.html#error_cr_unknown_host" target="_top">
           <code class="literal">
            CR_UNKNOWN_HOST
           </code>
          </a>
          .
         </p>
        </li>
       </ul>
      </div>
      <p>
       The set of error codes used in error messages is partitioned
            into distinct ranges; see
       <a class="xref" href="error-message-elements.html#error-code-ranges" title="Error Code Ranges">
        Error Code Ranges
       </a>
       .
      </p>
      <p>
       Error codes are stable across General Availability (GA)
            releases of a given MySQL series. Before a series reaches GA
            status, new codes may still be under development and are
            subject to change.
      </p>
     </li>
     <li class="listitem">
      <p>
       SQLSTATE value: This value is a five-character string (for
            example,
       <code class="literal">
        '42S02'
       </code>
       ). SQLSTATE values are
            taken from ANSI SQL and ODBC and are more standardized than
            the numeric error codes. The first two characters of an
            SQLSTATE value indicate the error class:
      </p>
      <div class="itemizedlist">
       <ul class="itemizedlist" style="list-style-type: circle; ">
        <li class="listitem">
         <p>
          Class =
          <code class="literal">
           '00'
          </code>
          indicates success.
         </p>
        </li>
        <li class="listitem">
         <p>
          Class =
          <code class="literal">
           '01'
          </code>
          indicates a warning.
         </p>
        </li>
        <li class="listitem">
         <p>
          Class =
          <code class="literal">
           '02'
          </code>
          indicates
          <span class="quote">
           “
           <span class="quote">
            not
                found.
           </span>
           ”
          </span>
          This is relevant within the context of
                cursors and is used to control what happens when a
                cursor reaches the end of a data set. This condition
                also occurs for
          <code class="literal">
           SELECT ... INTO
           <em class="replaceable">
            <code>
             var_list
            </code>
           </em>
          </code>
          statements
                that retrieve no rows.
         </p>
        </li>
        <li class="listitem">
         <p>
          Class &gt;
          <code class="literal">
           '02'
          </code>
          indicates an
                exception.
         </p>
        </li>
       </ul>
      </div>
      <p>
       For server-side errors, not all MySQL error numbers have
            corresponding SQLSTATE values. In these cases,
       <code class="literal">
        'HY000'
       </code>
       (general error) is used.
      </p>
      <p>
       For client-side errors, the SQLSTATE value is always
       <code class="literal">
        'HY000'
       </code>
       (general error), so it is not
            meaningful for distinguishing one client error from another.
      </p>
     </li>
     <li class="listitem">
      <p>
       Message string: This string provides a textual description
            of the error.
      </p>
     </li>
    </ul>
   </div>
  </div>
  <div class="simplesect">
   <div class="titlepage">
    <div>
     <div class="simple">
      <h3 class="title">
       <a name="error-code-ranges">
       </a>
       Error Code Ranges
      </h3>
     </div>
    </div>
   </div>
   <p>
    The set of error codes used in error messages is partitioned
        into distinct ranges, each with its own purpose:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       1 to 999: Global error codes. This error code range is
            called
       <span class="quote">
        “
        <span class="quote">
         global
        </span>
        ”
       </span>
       because it is a shared range
            that is used by the server as well as by clients.
      </p>
      <p>
       When an error in this range originates on the server side,
            the server writes it to the error log, padding the error
            code with leading zeros to six digits and adding a prefix of
       <code class="literal">
        MY-
       </code>
       .
      </p>
      <p>
       When an error in this range originates on the client side,
            the client library makes it available to the client program
            with no zero-padding or prefix.
      </p>
     </li>
     <li class="listitem">
      <p>
       1,000 to 1,999: Server error codes reserved for messages
            sent to clients.
      </p>
     </li>
     <li class="listitem">
      <p>
       2,000 to 2,999: Client error codes reserved for use by the
            client library.
      </p>
     </li>
     <li class="listitem">
      <p>
       3,000 to 4,999: Server error codes reserved for messages
            sent to clients.
      </p>
     </li>
     <li class="listitem">
      <p>
       5,000 to 5,999: Error codes reserved for use by X Plugin
            for messages sent to clients.
      </p>
     </li>
     <li class="listitem">
      <p>
       10,000 to 49,999: Server error codes reserved for messages
            to be written to the error log (not sent to clients).
      </p>
      <p>
       When an error in this range occurs, the server writes it to
            the error log, padding the error code with leading zeros to
            six digits and adding a prefix of
       <code class="literal">
        MY-
       </code>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       50,000 to 51,999: Error codes reserved for use by third
            parties.
      </p>
     </li>
    </ul>
   </div>
   <p>
    The server handles error messages written to the error log
        differently from error messages sent to clients:
   </p>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       When the server writes a message to the error log, it pads
            the error code with leading zeros to six digits and adds a
            prefix of
       <code class="literal">
        MY-
       </code>
       (examples:
       <a class="ulink" href="/doc/mysql-errors/8.4/en/global-error-reference.html#error_ee_unknown_charset" target="_top">
        <code class="literal">
         MY-000022
        </code>
       </a>
       ,
       <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_scheduler_stopped" target="_top">
        <code class="literal">
         MY-010048
        </code>
       </a>
       ).
      </p>
     </li>
     <li class="listitem">
      <p>
       When the server sends a message to a client program, it adds
            no zero-padding or prefix to the error code (examples:
       <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_open_as_readonly" target="_top">
        <code class="literal">
         1036
        </code>
       </a>
       ,
       <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_invalid_field_size" target="_top">
        <code class="literal">
         3013
        </code>
       </a>
       ).
      </p>
     </li>
    </ul>
   </div>
  </div>
 </div>
 <br/>
</div>
