mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Add PQresStatus() function to avoid direct access to pgresStatus[] array,
making life easier for Windoids...
This commit is contained in:
		@@ -7,7 +7,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * IDENTIFICATION
 | 
					 * 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)
 | 
						if (strcmp(opt, "-status") == 0)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		Tcl_AppendResult(interp, pgresStatus[PQresultStatus(result)], 0);
 | 
							Tcl_AppendResult(interp, PQresStatus(PQresultStatus(result)), 0);
 | 
				
			||||||
		return TCL_OK;
 | 
							return TCL_OK;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else if (strcmp(opt, "-error") == 0)
 | 
						else if (strcmp(opt, "-error") == 0)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * IDENTIFICATION
 | 
					 * 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;
 | 
						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 *
 | 
					const char *
 | 
				
			||||||
PQresultErrorMessage(PGresult *res)
 | 
					PQresultErrorMessage(PGresult *res)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,7 +6,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * Copyright (c) 1994, Regents of the University of California
 | 
					 * 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
 | 
							PGRES_FATAL_ERROR
 | 
				
			||||||
	} ExecStatusType;
 | 
						} 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[];
 | 
						extern const char * const pgresStatus[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* PGconn encapsulates a connection to the backend.
 | 
					/* PGconn encapsulates a connection to the backend.
 | 
				
			||||||
@@ -79,7 +81,6 @@ extern		"C"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* PQnoticeProcessor is the function type for the notice-message callback.
 | 
					/* PQnoticeProcessor is the function type for the notice-message callback.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					 | 
				
			||||||
	typedef void (*PQnoticeProcessor) (void * arg, const char * message);
 | 
						typedef void (*PQnoticeProcessor) (void * arg, const char * message);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Print options for PQprint() */
 | 
					/* Print options for PQprint() */
 | 
				
			||||||
@@ -230,6 +231,7 @@ extern		"C"
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	/* Accessor functions for PGresult objects */
 | 
						/* Accessor functions for PGresult objects */
 | 
				
			||||||
	extern ExecStatusType PQresultStatus(PGresult *res);
 | 
						extern ExecStatusType PQresultStatus(PGresult *res);
 | 
				
			||||||
 | 
						extern const char *PQresStatus(ExecStatusType status);
 | 
				
			||||||
	extern const char *PQresultErrorMessage(PGresult *res);
 | 
						extern const char *PQresultErrorMessage(PGresult *res);
 | 
				
			||||||
	extern int	PQntuples(PGresult *res);
 | 
						extern int	PQntuples(PGresult *res);
 | 
				
			||||||
	extern int	PQnfields(PGresult *res);
 | 
						extern int	PQnfields(PGresult *res);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -66,3 +66,4 @@ EXPORTS
 | 
				
			|||||||
	pgresStatus		@ 63
 | 
						pgresStatus		@ 63
 | 
				
			||||||
	PQmblen			@ 64
 | 
						PQmblen			@ 64
 | 
				
			||||||
	PQresultErrorMessage	@ 65
 | 
						PQresultErrorMessage	@ 65
 | 
				
			||||||
 | 
						PQresStatus		@ 66
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -90,7 +90,7 @@ main()
 | 
				
			|||||||
		/* async notification only come back as a result of a query */
 | 
							/* async notification only come back as a result of a query */
 | 
				
			||||||
		/* we can send empty queries */
 | 
							/* we can send empty queries */
 | 
				
			||||||
		res = PQexec(conn, " ");
 | 
							res = PQexec(conn, " ");
 | 
				
			||||||
/*		printf("res->status = %s\n", pgresStatus[PQresultStatus(res)]); */
 | 
					/*		printf("res->status = %s\n", PQresStatus(PQresultStatus(res))); */
 | 
				
			||||||
		/* check for asynchronous returns */
 | 
							/* check for asynchronous returns */
 | 
				
			||||||
		notify = PQnotifies(conn);
 | 
							notify = PQnotifies(conn);
 | 
				
			||||||
		if (notify)
 | 
							if (notify)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user