Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
c3664c0c
Commit
c3664c0c
authored
Aug 24, 2003
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add macros for error result fields to libpq.
parent
b4ab39ff
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
16 deletions
+146
-16
doc/src/sgml/libpq.sgml
doc/src/sgml/libpq.sgml
+127
-9
src/interfaces/ecpg/ecpglib/connect.c
src/interfaces/ecpg/ecpglib/connect.c
+3
-3
src/interfaces/ecpg/ecpglib/error.c
src/interfaces/ecpg/ecpglib/error.c
+3
-3
src/interfaces/libpq/libpq-fe.h
src/interfaces/libpq/libpq-fe.h
+13
-1
No files found.
doc/src/sgml/libpq.sgml
View file @
c3664c0c
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.13
1 2003/08/13 16:29:03 tgl
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.13
2 2003/08/24 18:36:38 petere
Exp $
-->
<chapter id="libpq">
...
...
@@ -1283,20 +1283,138 @@ Returns an individual field of an error report.
<synopsis>
char *PQresultErrorField(const PGresult *res, int fieldcode);
</synopsis>
<parameter>fieldcode</> is an error field identifier defined by the
<productname>PostgreSQL</> protocol (see <xref
linkend="protocol-error-fields">), for example <literal>'C'</> for
the SQLSTATE error code. NULL is returned if the
<parameter>fieldcode</> is an error field identifier; see the symbols
listed below. <symbol>NULL</symbol> is returned if the
<structname>PGresult</structname> is not an error or warning result,
or does not include the specified field. Field values will normally
not include a trailing newline.
</para>
<para>
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:
<variablelist>
<varlistentry>
<term><symbol>PG_DIAG_SEVERITY</></term>
<listitem>
<para>
The severity; the field contents are <literal>ERROR</>,
<literal>FATAL</>, or <literal>PANIC</> (in an error message), or
<literal>WARNING</>, <literal>NOTICE</>, <literal>DEBUG</>,
<literal>INFO</>, or <literal>LOG</> (in a notice message), or a
localized translation of one of these. Always present.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><symbol>PG_DIAG_SQLSTATE</>
</term>
<listitem>
<para>
The SQLSTATE code for the error (a 5-character string following SQL
spec conventions). Not localizable. Always present.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><symbol>PG_DIAG_MESSAGE_PRIMARY</></term>
<listitem>
<para>
The primary human-readable error message (typically one line). Always
present.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><symbol>PG_DIAG_MESSAGE_DETAIL</></term>
<listitem>
<para>
Detail: an optional secondary error message carrying more detail about
the problem. May run to multiple lines.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><symbol>PG_DIAG_MESSAGE_HINT</></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. May run to multiple lines.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><symbol>PG_DIAG_STATEMENT_POSITION</></term>
<listitem>
<para>
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.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><symbol>PG_DIAG_CONTEXT</></term>
<listitem>
<para>
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.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><symbol>PG_DIAG_SOURCE_FILE</></term>
<listitem>
<para>
The file name of the source-code location where the error was
reported.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><symbol>PG_DIAG_SOURCE_LINE</></term>
<listitem>
<para>
The line number of the source-code location where the error was
reported.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><symbol>PG_DIAG_SOURCE_FUNCTION</></term>
<listitem>
<para>
The name of the source-code function reporting the error.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
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.
</para>
<para>
Errors generated internally by <application>libpq</application> 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.
</para>
<para>
...
...
src/interfaces/ecpg/ecpglib/connect.c
View file @
c3664c0c
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.1
6 2003/08/08 13:16:20
petere Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.1
7 2003/08/24 18:36:38
petere Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
...
...
@@ -158,8 +158,8 @@ ECPGsetconn(int lineno, const char *connection_name)
static
void
ECPGnoticeReceiver
(
void
*
arg
,
const
PGresult
*
result
)
{
char
*
sqlstate
=
PQresultErrorField
(
result
,
'C'
);
char
*
message
=
PQresultErrorField
(
result
,
'M'
);
char
*
sqlstate
=
PQresultErrorField
(
result
,
PG_DIAG_SQLSTATE
);
char
*
message
=
PQresultErrorField
(
result
,
PG_DIAG_MESSAGE_PRIMARY
);
struct
sqlca_t
*
sqlca
=
ECPGget_sqlca
();
int
sqlcode
;
...
...
src/interfaces/ecpg/ecpglib/error.c
View file @
c3664c0c
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.
7 2003/08/08 13:16:20
petere Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/error.c,v 1.
8 2003/08/24 18:36:38
petere Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
...
...
@@ -164,10 +164,10 @@ ECPGraise_backend(int line, PGresult *result, PGconn *conn, int compat)
if
(
result
)
{
sqlstate
=
PQresultErrorField
(
result
,
'C'
);
sqlstate
=
PQresultErrorField
(
result
,
PG_DIAG_SQLSTATE
);
if
(
sqlstate
==
NULL
)
sqlstate
=
ECPG_SQLSTATE_ECPG_INTERNAL_ERROR
;
message
=
PQresultErrorField
(
result
,
'M'
);
message
=
PQresultErrorField
(
result
,
PG_DIAG_MESSAGE_PRIMARY
);
}
else
{
...
...
src/interfaces/libpq/libpq-fe.h
View file @
c3664c0c
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq-fe.h,v 1.9
8 2003/08/13 16:29:03 tgl
Exp $
* $Id: libpq-fe.h,v 1.9
9 2003/08/24 18:36:38 petere
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -104,6 +104,18 @@ typedef enum
PQERRORS_VERBOSE
/* all the facts, ma'am */
}
PGVerbosity
;
/* for PQresultErrorField() */
#define PG_DIAG_SEVERITY 'S'
#define PG_DIAG_SQLSTATE 'C'
#define PG_DIAG_MESSAGE_PRIMARY 'M'
#define PG_DIAG_MESSAGE_DETAIL 'D'
#define PG_DIAG_MESSAGE_HINT 'H'
#define PG_DIAG_STATEMENT_POSITION 'P'
#define PG_DIAG_CONTEXT 'W'
#define PG_DIAG_SOURCE_FILE 'F'
#define PG_DIAG_SOURCE_LINE 'L'
#define PG_DIAG_SOURCE_FUNCTION 'R'
/* PGconn encapsulates a connection to the backend.
* The contents of this struct are not supposed to be known to applications.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment