-linkend="protocol-error-fields">), for example 'C'> for
-the SQLSTATE error code. NULL is returned if the
+
fieldcode> is an error field identifier; see the symbols
+listed below. NULL is returned if the
PGresult is not an error or warning result,
or does not include the specified field. Field values will normally
not include a trailing newline.
-Errors generated internally by libpq will have severity and primary message,
-but typically no other fields. Errors returned by a pre-3.0-protocol server
-will include severity and primary message, and sometimes a detail message,
-but no other fields.
+The following field codes are available:
+
+
+
+PG_DIAG_SEVERITY>
+
+The severity; the field contents are ERROR>,
+FATAL>, or PANIC> (in an error message), or
+WARNING>, NOTICE>, DEBUG>,
+INFO>, or LOG> (in a notice message), or a
+localized translation of one of these. Always present.
+
+
+
+
+
+PG_DIAG_SQLSTATE>
+
+
+The SQLSTATE code for the error (a 5-character string following SQL
+spec conventions). Not localizable. Always present.
+
+
+
+
+
+PG_DIAG_MESSAGE_PRIMARY>
+
+The primary human-readable error message (typically one line). Always
+present.
+
+
+
+
+
+PG_DIAG_MESSAGE_DETAIL>
+
+Detail: an optional secondary error message carrying more detail about
+the problem. May run to multiple lines.
+
+
+
+
+
+PG_DIAG_MESSAGE_HINT>
+
+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. May run to multiple lines.
+
+
+
+
+
+PG_DIAG_STATEMENT_POSITION>
+
+A string containing a decimal integer indicating an error cursor
+position as an index into the original statement string. The first
+character has index 1, and positions are measured in characters not
+bytes.
+
+
+
+
+
+PG_DIAG_CONTEXT>
+
+An indication of the context in which the error occurred. Presently
+this includes a call stack traceback of active PL functions. The
+trace is one entry per line, most recent first.
+
+
+
+
+
+PG_DIAG_SOURCE_FILE>
+
+The file name of the source-code location where the error was
+reported.
+
+
+
+
+
+PG_DIAG_SOURCE_LINE>
+
+The line number of the source-code location where the error was
+reported.
+
+
+
+
+
+PG_DIAG_SOURCE_FUNCTION>
+
+The name of the source-code function reporting the error.
+
+
+
+
+
+
+The client is responsible for formatting displayed information to meet
+its needs; in particular it should break long lines as needed.
+Newline characters appearing in the error message fields should be
+treated as paragraph breaks, not line breaks.
+
+
+Errors generated internally by
libpq will
+have severity and primary message, but typically no other fields.
+Errors returned by a pre-3.0-protocol server will include severity and
+primary message, and sometimes a detail message, but no other fields.