*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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)
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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)
{
*
* 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 $
*
*-------------------------------------------------------------------------
*/
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.
/* PQnoticeProcessor is the function type for the notice-message callback.
*/
-
typedef void (*PQnoticeProcessor) (void * arg, const char * message);
/* Print options for PQprint() */
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)
/* Override default notice processor */
extern void PQsetNoticeProcessor(PGconn *conn,
- PQnoticeProcessor proc,
- void *arg);
+ PQnoticeProcessor proc,
+ void *arg);
/* === in fe-exec.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);