Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfa0f241

Browse files
committed
Add PQresStatus() function to avoid direct access to pgresStatus[] array,
making life easier for Windoids...
1 parentf280266 commitfa0f241

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed

‎src/interfaces/libpgtcl/pgtclCmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.39 1999/01/17 21:12:55 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.40 1999/02/07 22:08:51 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -545,7 +545,7 @@ Pg_result(ClientData cData, Tcl_Interp * interp, int argc, char *argv[])
545545

546546
if (strcmp(opt,"-status")==0)
547547
{
548-
Tcl_AppendResult(interp,pgresStatus[PQresultStatus(result)],0);
548+
Tcl_AppendResult(interp,PQresStatus(PQresultStatus(result)),0);
549549
returnTCL_OK;
550550
}
551551
elseif (strcmp(opt,"-error")==0)

‎src/interfaces/libpq/fe-exec.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.72 1999/02/03 20:19:10 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.73 1999/02/07 22:08:52 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1518,6 +1518,15 @@ PQresultStatus(PGresult *res)
15181518
returnres->resultStatus;
15191519
}
15201520

1521+
constchar*
1522+
PQresStatus(ExecStatusTypestatus)
1523+
{
1524+
if (((int)status)<0||
1525+
((int)status) >= (sizeof(pgresStatus) /sizeof(pgresStatus[0])))
1526+
return"Invalid ExecStatusType code";
1527+
returnpgresStatus[status];
1528+
}
1529+
15211530
constchar*
15221531
PQresultErrorMessage(PGresult*res)
15231532
{

‎src/interfaces/libpq/libpq-fe.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: libpq-fe.h,v 1.47 1999/02/05 04:25:55 momjian Exp $
9+
* $Id: libpq-fe.h,v 1.48 1999/02/07 22:08:53 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -49,7 +49,9 @@ extern"C"
4949
PGRES_FATAL_ERROR
5050
}ExecStatusType;
5151

52-
/* String descriptions of the ExecStatusTypes */
52+
/* String descriptions of the ExecStatusTypes.
53+
* NB: direct use of this array is now deprecated; call PQresStatus() instead.
54+
*/
5355
externconstchar*constpgresStatus[];
5456

5557
/* PGconn encapsulates a connection to the backend.
@@ -79,7 +81,6 @@ extern"C"
7981

8082
/* PQnoticeProcessor is the function type for the notice-message callback.
8183
*/
82-
8384
typedefvoid (*PQnoticeProcessor) (void*arg,constchar*message);
8485

8586
/* Print options for PQprint() */
@@ -153,8 +154,8 @@ extern"C"
153154
externPGconn*PQconnectdb(constchar*conninfo);
154155
externPGconn*PQsetdbLogin(constchar*pghost,constchar*pgport,
155156
constchar*pgoptions,constchar*pgtty,
156-
constchar*dbName,
157-
constchar*login,constchar*pwd);
157+
constchar*dbName,
158+
constchar*login,constchar*pwd);
158159
#definePQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME) \
159160
PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, NULL, NULL)
160161

@@ -192,8 +193,8 @@ extern"C"
192193

193194
/* Override default notice processor */
194195
externvoidPQsetNoticeProcessor(PGconn*conn,
195-
PQnoticeProcessorproc,
196-
void*arg);
196+
PQnoticeProcessorproc,
197+
void*arg);
197198

198199
/* === in fe-exec.c === */
199200

@@ -230,6 +231,7 @@ extern"C"
230231

231232
/* Accessor functions for PGresult objects */
232233
externExecStatusTypePQresultStatus(PGresult*res);
234+
externconstchar*PQresStatus(ExecStatusTypestatus);
233235
externconstchar*PQresultErrorMessage(PGresult*res);
234236
externintPQntuples(PGresult*res);
235237
externintPQnfields(PGresult*res);

‎src/interfaces/libpq/libpqdll.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,4 @@ EXPORTS
6666
pgresStatus@ 63
6767
PQmblen@ 64
6868
PQresultErrorMessage@ 65
69+
PQresStatus@ 66

‎src/test/examples/testlibpq2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ main()
9090
/* async notification only come back as a result of a query */
9191
/* we can send empty queries */
9292
res=PQexec(conn," ");
93-
/*printf("res->status = %s\n",pgresStatus[PQresultStatus(res)]); */
93+
/*printf("res->status = %s\n",PQresStatus(PQresultStatus(res))); */
9494
/* check for asynchronous returns */
9595
notify=PQnotifies(conn);
9696
if (notify)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp