or does not include the specified field. Field values will normally
not include a trailing newline. The caller should not free the
result directly. It will be freed when the
associated <structname>PGresult</structname> handle is passed to
<xref linkend="libpq-PQclear"/>.
</para>
<para>
The following field codes are available:
<variablelist>
<varlistentry id="libpq-pg-diag-severity">
<term><symbol>PG_DIAG_SEVERITY</symbol></term>
<listitem>
<para>
The severity; the field contents are <literal>ERROR</literal>,
<literal>FATAL</literal>, or <literal>PANIC</literal> (in an error message),
or <literal>WARNING</literal>, <literal>NOTICE</literal>, <literal>DEBUG</literal>,
<literal>INFO</literal>, or <literal>LOG</literal> (in a notice message), or
a localized translation of one of these. Always present.
</para>
</listitem>
</varlistentry>
<varlistentry id="libpq-PG-diag-severity-nonlocalized">
<term><symbol>PG_DIAG_SEVERITY_NONLOCALIZED</symbol></term>
<listitem>
<para>
The severity; the field contents are <literal>ERROR</literal>,
<literal>FATAL</literal>, or <literal>PANIC</literal> (in an error message),
or <literal>WARNING</literal>, <literal>NOTICE</literal>, <literal>DEBUG</literal>,
<literal>INFO</literal>, or <literal>LOG</literal> (in a notice message).
This is identical to the <symbol>PG_DIAG_SEVERITY</symbol> field except
that the contents are never localized. This is present only in
reports generated by <productname>PostgreSQL</productname> versions 9.6
and later.
</para>
</listitem>
</varlistentry>
<varlistentry id="libpq-pg-diag-sqlstate">
<term><symbol>PG_DIAG_SQLSTATE</symbol><indexterm
><primary>error codes</primary><secondary>libpq</secondary></indexterm></term>
<listitem>
<para>
The SQLSTATE code for the error. The SQLSTATE code identifies
the type of error that has occurred; it can be used by
front-end applications to perform specific operations (such
as error handling) in response to a particular database error.
For a list of the possible SQLSTATE codes, see <xref
linkend="errcodes-appendix"/>. This field is not localizable,
and is always present.
</para>
</listitem>
</varlistentry>
<varlistentry id="libpq-pg-diag-message-primary">
<term><symbol>PG_DIAG_MESSAGE_PRIMARY</symbol></term>
<listitem>
<para>
The primary human-readable error message (typically one line).
Always present.
</para>
</listitem>
</varlistentry>
<varlistentry id="libpq-pg-diag-message-detail">
<term><symbol>PG_DIAG_MESSAGE_DETAIL</symbol></term>
<listitem>
<para>
Detail: an optional secondary error message carrying more
detail about the problem. Might run to multiple lines.
</para>
</listitem>
</varlistentry>
<varlistentry id="libpq-pg-diag-message-hint">
<term><symbol>PG_DIAG_MESSAGE_HINT</symbol></term>
<listitem>
<para>
Hint: an optional suggestion what to do about the problem.
This is intended to differ from detail in that it offers advice
(potentially inappropriate) rather than hard facts. Might
run to multiple lines.
</para>
</listitem>
</varlistentry>
<varlistentry id="libpq-pg-diag-statement-position">
<term><symbol>PG_DIAG_STATEMENT_POSITION</symbol></term>
<listitem>