aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1999-02-07 22:08:54 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1999-02-07 22:08:54 +0000
commitfa0f24165c026c522c052ac2f4ea35b97e6bbb5f (patch)
treefe059780389a2847f0bc190b4426d4a16ec526d5 /src/interfaces/libpq
parentf2802669856dafe9e26b21cc8779acf6dcbef921 (diff)
downloadpostgresql-fa0f24165c026c522c052ac2f4ea35b97e6bbb5f.tar.gz
postgresql-fa0f24165c026c522c052ac2f4ea35b97e6bbb5f.zip
Add PQresStatus() function to avoid direct access to pgresStatus[] array,
making life easier for Windoids...
Diffstat (limited to 'src/interfaces/libpq')
-rw-r--r--src/interfaces/libpq/fe-exec.c11
-rw-r--r--src/interfaces/libpq/libpq-fe.h16
-rw-r--r--src/interfaces/libpq/libpqdll.def1
3 files changed, 20 insertions, 8 deletions
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index e1d71bac488..f2f22a04e65 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.72 1999/02/03 20:19:10 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.73 1999/02/07 22:08:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1519,6 +1519,15 @@ PQresultStatus(PGresult *res)
}
const char *
+PQresStatus(ExecStatusType status)
+{
+ if (((int) status) < 0 ||
+ ((int) status) >= (sizeof(pgresStatus) / sizeof(pgresStatus[0])))
+ return "Invalid ExecStatusType code";
+ return pgresStatus[status];
+}
+
+const char *
PQresultErrorMessage(PGresult *res)
{
if (!res || !res->errMsg)
diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h
index cedecd95c27..b45907ab69e 100644
--- a/src/interfaces/libpq/libpq-fe.h
+++ b/src/interfaces/libpq/libpq-fe.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq-fe.h,v 1.47 1999/02/05 04:25:55 momjian Exp $
+ * $Id: libpq-fe.h,v 1.48 1999/02/07 22:08:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -49,7 +49,9 @@ extern "C"
PGRES_FATAL_ERROR
} ExecStatusType;
-/* String descriptions of the ExecStatusTypes */
+/* String descriptions of the ExecStatusTypes.
+ * NB: direct use of this array is now deprecated; call PQresStatus() instead.
+ */
extern const char * const pgresStatus[];
/* PGconn encapsulates a connection to the backend.
@@ -79,7 +81,6 @@ extern "C"
/* PQnoticeProcessor is the function type for the notice-message callback.
*/
-
typedef void (*PQnoticeProcessor) (void * arg, const char * message);
/* Print options for PQprint() */
@@ -153,8 +154,8 @@ extern "C"
extern PGconn *PQconnectdb(const char *conninfo);
extern PGconn *PQsetdbLogin(const char *pghost, const char *pgport,
const char *pgoptions, const char *pgtty,
- const char *dbName,
- const char *login, const char *pwd);
+ const char *dbName,
+ const char *login, const char *pwd);
#define PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME) \
PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, NULL, NULL)
@@ -192,8 +193,8 @@ extern "C"
/* Override default notice processor */
extern void PQsetNoticeProcessor(PGconn *conn,
- PQnoticeProcessor proc,
- void *arg);
+ PQnoticeProcessor proc,
+ void *arg);
/* === in fe-exec.c === */
@@ -230,6 +231,7 @@ extern "C"
/* Accessor functions for PGresult objects */
extern ExecStatusType PQresultStatus(PGresult *res);
+ extern const char *PQresStatus(ExecStatusType status);
extern const char *PQresultErrorMessage(PGresult *res);
extern int PQntuples(PGresult *res);
extern int PQnfields(PGresult *res);
diff --git a/src/interfaces/libpq/libpqdll.def b/src/interfaces/libpq/libpqdll.def
index e42b25d43b0..d83bdfafd48 100644
--- a/src/interfaces/libpq/libpqdll.def
+++ b/src/interfaces/libpq/libpqdll.def
@@ -66,3 +66,4 @@ EXPORTS
pgresStatus @ 63
PQmblen @ 64
PQresultErrorMessage @ 65
+ PQresStatus @ 66