diff --git a/src/interfaces/libpgtcl/pgtclCmds.c b/src/interfaces/libpgtcl/pgtclCmds.c index 57f0ab0dd0723447f914c6376b6a9c9ac8cfaeac..248f16559cc598e9e09be55fb47c3853866679ab 100644 --- a/src/interfaces/libpgtcl/pgtclCmds.c +++ b/src/interfaces/libpgtcl/pgtclCmds.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.39 1999/01/17 21:12:55 tgl Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.40 1999/02/07 22:08:51 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -545,7 +545,7 @@ Pg_result(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) if (strcmp(opt, "-status") == 0) { - Tcl_AppendResult(interp, pgresStatus[PQresultStatus(result)], 0); + Tcl_AppendResult(interp, PQresStatus(PQresultStatus(result)), 0); return TCL_OK; } else if (strcmp(opt, "-error") == 0) diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index e1d71bac4881a39fd207137d6162ca37fd0f1c5d..f2f22a04e6571fe4a6919741a1834f4820e437eb 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 $ * *------------------------------------------------------------------------- */ @@ -1518,6 +1518,15 @@ PQresultStatus(PGresult *res) return res->resultStatus; } +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) { diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index cedecd95c27b845f11715cf0b0997bc739bac646..b45907ab69ebcc0ab2b10b46962c7d6082d47479 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 e42b25d43b0182582dcf02c01dcdcc1505a4a12b..d83bdfafd4809b42bf179fa875092f6b48db710e 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 diff --git a/src/test/examples/testlibpq2.c b/src/test/examples/testlibpq2.c index 540ed91cbfe8e72958ca1eb5e594b87485570e52..059e39102e2ec7b2ffc9d0a1069f686a8850f081 100644 --- a/src/test/examples/testlibpq2.c +++ b/src/test/examples/testlibpq2.c @@ -90,7 +90,7 @@ main() /* async notification only come back as a result of a query */ /* we can send empty queries */ res = PQexec(conn, " "); -/* printf("res->status = %s\n", pgresStatus[PQresultStatus(res)]); */ +/* printf("res->status = %s\n", PQresStatus(PQresultStatus(res))); */ /* check for asynchronous returns */ notify = PQnotifies(conn); if (notify)