summaryrefslogtreecommitdiff
path: root/src/interfaces/libpq
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2005-10-15 02:49:52 +0000
committerBruce Momjian <bruce@momjian.us>2005-10-15 02:49:52 +0000
commit1dc34982511d91ef8a2b71bdcb870f067c1b3da9 (patch)
tree1046adab1d4b964e0c38afeec0ee6546f61d9a8a /src/interfaces/libpq
parent790c01d28099587bbe2c623d4389b62ee49b1dee (diff)
downloadpostgresql-1dc34982511d91ef8a2b71bdcb870f067c1b3da9.tar.gz
Standard pgindent run for 8.1.
Diffstat (limited to 'src/interfaces/libpq')
-rw-r--r--src/interfaces/libpq/fe-auth.c36
-rw-r--r--src/interfaces/libpq/fe-auth.h4
-rw-r--r--src/interfaces/libpq/fe-connect.c381
-rw-r--r--src/interfaces/libpq/fe-exec.c200
-rw-r--r--src/interfaces/libpq/fe-lobj.c49
-rw-r--r--src/interfaces/libpq/fe-misc.c146
-rw-r--r--src/interfaces/libpq/fe-print.c37
-rw-r--r--src/interfaces/libpq/fe-protocol2.c189
-rw-r--r--src/interfaces/libpq/fe-protocol3.c198
-rw-r--r--src/interfaces/libpq/fe-secure.c160
-rw-r--r--src/interfaces/libpq/libpq-fe.h46
-rw-r--r--src/interfaces/libpq/libpq-int.h99
-rw-r--r--src/interfaces/libpq/pqexpbuffer.c33
-rw-r--r--src/interfaces/libpq/pthread-win32.h14
-rw-r--r--src/interfaces/libpq/win32.c4
15 files changed, 773 insertions, 823 deletions
diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c
index 4075aad614..4b15ff643d 100644
--- a/src/interfaces/libpq/fe-auth.c
+++ b/src/interfaces/libpq/fe-auth.c
@@ -10,7 +10,7 @@
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.104 2005/10/08 19:32:58 tgl Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.c,v 1.105 2005/10/15 02:49:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -64,7 +64,8 @@
*/
#define STARTUP_MSG 7 /* Initialise a connection */
-#define STARTUP_KRB4_MSG 10 /* krb4 session follows. Not supported any more. */
+#define STARTUP_KRB4_MSG 10 /* krb4 session follows. Not supported any
+ * more. */
#define STARTUP_KRB5_MSG 11 /* krb5 session follows */
#define STARTUP_PASSWORD_MSG 14 /* Password follows */
@@ -139,7 +140,7 @@ pg_an_to_ln(char *aname)
if ((p = strchr(aname, '/')) || (p = strchr(aname, '@')))
*p = '\0';
#ifdef WIN32
- for (p = aname; *p ; p++)
+ for (p = aname; *p; p++)
*p = pg_tolower(*p);
#endif
@@ -265,9 +266,9 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, const char *hostname, const char *s
}
/*
- * libpq uses a non-blocking socket. But kerberos needs a blocking
- * socket, and we have to block somehow to do mutual authentication
- * anyway. So we temporarily make it blocking.
+ * libpq uses a non-blocking socket. But kerberos needs a blocking socket,
+ * and we have to block somehow to do mutual authentication anyway. So we
+ * temporarily make it blocking.
*/
if (!pg_set_block(sock))
{
@@ -291,11 +292,11 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, const char *hostname, const char *s
{
#if defined(HAVE_KRB5_ERROR_TEXT_DATA)
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- libpq_gettext("Kerberos 5 authentication rejected: %*s\n"),
+ libpq_gettext("Kerberos 5 authentication rejected: %*s\n"),
(int) err_ret->text.length, err_ret->text.data);
#elif defined(HAVE_KRB5_ERROR_E_DATA)
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- libpq_gettext("Kerberos 5 authentication rejected: %*s\n"),
+ libpq_gettext("Kerberos 5 authentication rejected: %*s\n"),
(int) err_ret->e_data->length,
(const char *) err_ret->e_data->data);
#else
@@ -321,7 +322,7 @@ pg_krb5_sendauth(char *PQerrormsg, int sock, const char *hostname, const char *s
char sebuf[256];
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- libpq_gettext("could not restore non-blocking mode on socket: %s\n"),
+ libpq_gettext("could not restore non-blocking mode on socket: %s\n"),
pqStrerror(errno, sebuf, sizeof(sebuf)));
ret = STATUS_ERROR;
}
@@ -355,8 +356,8 @@ pg_local_sendauth(char *PQerrormsg, PGconn *conn)
#endif
/*
- * The backend doesn't care what we send here, but it wants exactly
- * one character to force recvmsg() to block and wait for us.
+ * The backend doesn't care what we send here, but it wants exactly one
+ * character to force recvmsg() to block and wait for us.
*/
buf = '\0';
iov.iov_base = &buf;
@@ -388,7 +389,7 @@ pg_local_sendauth(char *PQerrormsg, PGconn *conn)
return STATUS_OK;
#else
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- libpq_gettext("SCM_CRED authentication method not supported\n"));
+ libpq_gettext("SCM_CRED authentication method not supported\n"));
return STATUS_ERROR;
#endif
}
@@ -473,7 +474,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
case AUTH_REQ_KRB4:
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- libpq_gettext("Kerberos 4 authentication not supported\n"));
+ libpq_gettext("Kerberos 4 authentication not supported\n"));
return STATUS_ERROR;
case AUTH_REQ_KRB5:
@@ -490,7 +491,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
break;
#else
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- libpq_gettext("Kerberos 5 authentication not supported\n"));
+ libpq_gettext("Kerberos 5 authentication not supported\n"));
return STATUS_ERROR;
#endif
@@ -506,7 +507,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
if (pg_password_sendauth(conn, password, areq) != STATUS_OK)
{
(void) snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- "fe_sendauth: error sending password authentication\n");
+ "fe_sendauth: error sending password authentication\n");
return STATUS_ERROR;
}
break;
@@ -518,7 +519,7 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
default:
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- libpq_gettext("authentication method %u not supported\n"), areq);
+ libpq_gettext("authentication method %u not supported\n"), areq);
return STATUS_ERROR;
}
@@ -587,6 +588,7 @@ fe_getauthname(char *PQerrormsg)
const char *name = NULL;
char *authn;
MsgType authsvc;
+
#ifdef WIN32
char username[128];
DWORD namesize = sizeof(username) - 1;
@@ -623,7 +625,7 @@ fe_getauthname(char *PQerrormsg)
if (authsvc != STARTUP_MSG && authsvc != STARTUP_KRB5_MSG)
snprintf(PQerrormsg, PQERRORMSG_LENGTH,
- libpq_gettext("fe_getauthname: invalid authentication system: %d\n"),
+ libpq_gettext("fe_getauthname: invalid authentication system: %d\n"),
authsvc);
authn = name ? strdup(name) : NULL;
diff --git a/src/interfaces/libpq/fe-auth.h b/src/interfaces/libpq/fe-auth.h
index 024107564b..0e015711ec 100644
--- a/src/interfaces/libpq/fe-auth.h
+++ b/src/interfaces/libpq/fe-auth.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.h,v 1.21 2005/06/27 02:04:26 neilc Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-auth.h,v 1.22 2005/10/15 02:49:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -39,6 +39,6 @@ extern MsgType fe_getauthsvc(char *PQerrormsg);
extern void fe_setauthsvc(const char *name, char *PQerrormsg);
extern char *fe_getauthname(char *PQerrormsg);
-#define PG_KRB5_VERSION "PGVER5.1" /* at most KRB_SENDAUTH_VLEN chars */
+#define PG_KRB5_VERSION "PGVER5.1" /* at most KRB_SENDAUTH_VLEN chars */
#endif /* FE_AUTH_H */
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 012631a135..f9f3246f50 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.321 2005/09/26 17:49:09 petere Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.322 2005/10/15 02:49:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -116,9 +116,9 @@
*/
static const PQconninfoOption PQconninfoOptions[] = {
/*
- * "authtype" is no longer used, so mark it "don't show". We keep it
- * in the array so as not to reject conninfo strings from old apps
- * that might still try to set it.
+ * "authtype" is no longer used, so mark it "don't show". We keep it in
+ * the array so as not to reject conninfo strings from old apps that might
+ * still try to set it.
*/
{"authtype", "PGAUTHTYPE", DefaultAuthtype, NULL,
"Database-Authtype", "D", 20},
@@ -168,8 +168,8 @@ static const PQconninfoOption PQconninfoOptions[] = {
#endif
/*
- * "sslmode" option is allowed even without client SSL support because
- * the client can still handle SSL modes "disable" and "allow".
+ * "sslmode" option is allowed even without client SSL support because the
+ * client can still handle SSL modes "disable" and "allow".
*/
{"sslmode", "PGSSLMODE", DefaultSSLMode, NULL,
"SSL-Mode", "", 8}, /* sizeof("disable") == 8 */
@@ -177,7 +177,7 @@ static const PQconninfoOption PQconninfoOptions[] = {
#ifdef KRB5
/* Kerberos authentication supports specifying the service name */
{"krbsrvname", "PGKRBSRVNAME", PG_KRB_SRVNAM, NULL,
- "Kerberos-service-name", "", 20},
+ "Kerberos-service-name", "", 20},
#endif
/* Terminating entry --- MUST BE LAST */
@@ -370,8 +370,8 @@ connectOptions1(PGconn *conn, const char *conninfo)
/*
* Move option values into conn structure
*
- * Don't put anything cute here --- intelligence should be in
- * connectOptions2 ...
+ * Don't put anything cute here --- intelligence should be in connectOptions2
+ * ...
*
* XXX: probably worth checking strdup() return value here...
*/
@@ -476,7 +476,7 @@ connectOptions2(PGconn *conn)
{
conn->status = CONNECTION_BAD;
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("invalid sslmode value: \"%s\"\n"),
+ libpq_gettext("invalid sslmode value: \"%s\"\n"),
conn->sslmode);
return false;
}
@@ -488,8 +488,8 @@ connectOptions2(PGconn *conn)
case 'p': /* "prefer" */
/*
- * warn user that an SSL connection will never be
- * negotiated since SSL was not compiled in?
+ * warn user that an SSL connection will never be negotiated
+ * since SSL was not compiled in?
*/
break;
@@ -655,8 +655,8 @@ connectNoDelay(PGconn *conn)
char sebuf[256];
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not set socket to TCP no delay mode: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ libpq_gettext("could not set socket to TCP no delay mode: %s\n"),
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
return 0;
}
#endif
@@ -686,9 +686,9 @@ connectFailureMessage(PGconn *conn, int errorno)
NI_NUMERICSERV);
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "could not connect to server: %s\n"
- "\tIs the server running locally and accepting\n"
- "\tconnections on Unix domain socket \"%s\"?\n"
+ "could not connect to server: %s\n"
+ "\tIs the server running locally and accepting\n"
+ "\tconnections on Unix domain socket \"%s\"?\n"
),
SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)),
service);
@@ -698,9 +698,9 @@ connectFailureMessage(PGconn *conn, int errorno)
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "could not connect to server: %s\n"
- "\tIs the server running on host \"%s\" and accepting\n"
- "\tTCP/IP connections on port %s?\n"
+ "could not connect to server: %s\n"
+ "\tIs the server running on host \"%s\" and accepting\n"
+ "\tTCP/IP connections on port %s?\n"
),
SOCK_STRERROR(errorno, sebuf, sizeof(sebuf)),
conn->pghostaddr
@@ -815,12 +815,11 @@ connectDBStart(PGconn *conn)
conn->status = CONNECTION_NEEDED;
/*
- * The code for processing CONNECTION_NEEDED state is in
- * PQconnectPoll(), so that it can easily be re-executed if needed
- * again during the asynchronous startup process. However, we must
- * run it once here, because callers expect a success return from this
- * routine to mean that we are in PGRES_POLLING_WRITING connection
- * state.
+ * The code for processing CONNECTION_NEEDED state is in PQconnectPoll(),
+ * so that it can easily be re-executed if needed again during the
+ * asynchronous startup process. However, we must run it once here,
+ * because callers expect a success return from this routine to mean that
+ * we are in PGRES_POLLING_WRITING connection state.
*/
if (PQconnectPoll(conn) == PGRES_POLLING_WRITING)
return 1;
@@ -863,8 +862,7 @@ connectDBComplete(PGconn *conn)
if (timeout > 0)
{
/*
- * Rounding could cause connection to fail; need at least 2
- * secs
+ * Rounding could cause connection to fail; need at least 2 secs
*/
if (timeout < 2)
timeout = 2;
@@ -877,8 +875,7 @@ connectDBComplete(PGconn *conn)
{
/*
* Wait, if necessary. Note that the initial state (just after
- * PQconnectStart) is to wait for the socket to select for
- * writing.
+ * PQconnectStart) is to wait for the socket to select for writing.
*/
switch (flag)
{
@@ -954,8 +951,8 @@ PQconnectPoll(PGconn *conn)
switch (conn->status)
{
/*
- * We really shouldn't have been polled in these two cases,
- * but we can handle it.
+ * We really shouldn't have been polled in these two cases, but we
+ * can handle it.
*/
case CONNECTION_BAD:
return PGRES_POLLING_FAILED;
@@ -995,24 +992,24 @@ PQconnectPoll(PGconn *conn)
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
"invalid connection state, "
- "probably indicative of memory corruption\n"
+ "probably indicative of memory corruption\n"
));
goto error_return;
}
-keep_going: /* We will come back to here until there
- * is nothing left to do. */
+keep_going: /* We will come back to here until there is
+ * nothing left to do. */
switch (conn->status)
{
case CONNECTION_NEEDED:
{
/*
* Try to initiate a connection to one of the addresses
- * returned by getaddrinfo_all(). conn->addr_cur is the
- * next one to try. We fail when we run out of addresses
- * (reporting the error returned for the *last*
- * alternative, which may not be what users expect :-().
+ * returned by getaddrinfo_all(). conn->addr_cur is the next
+ * one to try. We fail when we run out of addresses
+ * (reporting the error returned for the *last* alternative,
+ * which may not be what users expect :-().
*/
while (conn->addr_cur != NULL)
{
@@ -1028,8 +1025,8 @@ keep_going: /* We will come back to here until there
if (conn->sock < 0)
{
/*
- * ignore socket() failure if we have more
- * addresses to try
+ * ignore socket() failure if we have more addresses
+ * to try
*/
if (addr_cur->ai_next != NULL)
{
@@ -1037,15 +1034,15 @@ keep_going: /* We will come back to here until there
continue;
}
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not create socket: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ libpq_gettext("could not create socket: %s\n"),
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
break;
}
/*
- * Select socket options: no delay of outgoing data
- * for TCP sockets, nonblock mode, close-on-exec.
- * Fail if any of this fails.
+ * Select socket options: no delay of outgoing data for
+ * TCP sockets, nonblock mode, close-on-exec. Fail if any
+ * of this fails.
*/
if (!IS_AF_UNIX(addr_cur->ai_family))
{
@@ -1061,7 +1058,7 @@ keep_going: /* We will come back to here until there
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not set socket to non-blocking mode: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
closesocket(conn->sock);
conn->sock = -1;
conn->addr_cur = addr_cur->ai_next;
@@ -1073,18 +1070,17 @@ keep_going: /* We will come back to here until there
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not set socket to close-on-exec mode: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
closesocket(conn->sock);
conn->sock = -1;
conn->addr_cur = addr_cur->ai_next;
continue;
}
-#endif /* F_SETFD */
+#endif /* F_SETFD */
/*
- * Start/make connection. This should not block,
- * since we are in nonblock mode. If it does, well,
- * too bad.
+ * Start/make connection. This should not block, since we
+ * are in nonblock mode. If it does, well, too bad.
*/
if (connect(conn->sock, addr_cur->ai_addr,
addr_cur->ai_addrlen) < 0)
@@ -1095,9 +1091,9 @@ keep_going: /* We will come back to here until there
SOCK_ERRNO == 0)
{
/*
- * This is fine - we're in non-blocking mode,
- * and the connection is in progress. Tell
- * caller to wait for write-ready on socket.
+ * This is fine - we're in non-blocking mode, and
+ * the connection is in progress. Tell caller to
+ * wait for write-ready on socket.
*/
conn->status = CONNECTION_STARTED;
return PGRES_POLLING_WRITING;
@@ -1107,20 +1103,19 @@ keep_going: /* We will come back to here until there
else
{
/*
- * Hm, we're connected already --- seems the
- * "nonblock connection" wasn't. Advance the
- * state machine and go do the next stuff.
+ * Hm, we're connected already --- seems the "nonblock
+ * connection" wasn't. Advance the state machine and
+ * go do the next stuff.
*/
conn->status = CONNECTION_STARTED;
goto keep_going;
}
/*
- * This connection failed --- set up error report,
- * then close socket (do it this way in case close()
- * affects the value of errno...). We will ignore the
- * connect() failure and keep going if there are more
- * addresses.
+ * This connection failed --- set up error report, then
+ * close socket (do it this way in case close() affects
+ * the value of errno...). We will ignore the connect()
+ * failure and keep going if there are more addresses.
*/
connectFailureMessage(conn, SOCK_ERRNO);
if (conn->sock >= 0)
@@ -1136,8 +1131,8 @@ keep_going: /* We will come back to here until there
} /* loop over addresses */
/*
- * Ooops, no more addresses. An appropriate error message
- * is already set up, so just set the right status.
+ * Ooops, no more addresses. An appropriate error message is
+ * already set up, so just set the right status.
*/
goto error_return;
}
@@ -1148,8 +1143,8 @@ keep_going: /* We will come back to here until there
ACCEPT_TYPE_ARG3 optlen = sizeof(optval);
/*
- * Write ready, since we've made it here, so the
- * connection has been made ... or has failed.
+ * Write ready, since we've made it here, so the connection
+ * has been made ... or has failed.
*/
/*
@@ -1161,23 +1156,22 @@ keep_going: /* We will come back to here until there
(char *) &optval, &optlen) == -1)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not get socket error status: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ libpq_gettext("could not get socket error status: %s\n"),
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
goto error_return;
}
else if (optval != 0)
{
/*
- * When using a nonblocking connect, we will typically
- * see connect failures at this point, so provide a
- * friendly error message.
+ * When using a nonblocking connect, we will typically see
+ * connect failures at this point, so provide a friendly
+ * error message.
*/
connectFailureMessage(conn, optval);
/*
- * If more addresses remain, keep trying, just as in
- * the case where connect() returned failure
- * immediately.
+ * If more addresses remain, keep trying, just as in the
+ * case where connect() returned failure immediately.
*/
if (conn->addr_cur->ai_next != NULL)
{
@@ -1201,7 +1195,7 @@ keep_going: /* We will come back to here until there
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not get client address from socket: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
goto error_return;
}
@@ -1220,9 +1214,8 @@ keep_going: /* We will come back to here until there
#ifdef USE_SSL
/*
- * If SSL is enabled and we haven't already got it
- * running, request it instead of sending the startup
- * message.
+ * If SSL is enabled and we haven't already got it running,
+ * request it instead of sending the startup message.
*/
if (IS_AF_UNIX(conn->raddr.addr.ss_family))
{
@@ -1237,16 +1230,15 @@ keep_going: /* We will come back to here until there
/*
* Send the SSL request packet.
*
- * Theoretically, this could block, but it really
- * shouldn't since we only got here if the socket is
- * write-ready.
+ * Theoretically, this could block, but it really shouldn't
+ * since we only got here if the socket is write-ready.
*/
pv = htonl(NEGOTIATE_SSL_CODE);
if (pqPacketSend(conn, 0, &pv, sizeof(pv)) != STATUS_OK)
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("could not send SSL negotiation packet: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
goto error_return;
}
/* Ok, wait for response */
@@ -1260,10 +1252,10 @@ keep_going: /* We will come back to here until there
*/
if (PG_PROTOCOL_MAJOR(conn->pversion) >= 3)
startpacket = pqBuildStartupPacket3(conn, &packetlen,
- EnvironmentOptions);
+ EnvironmentOptions);
else
startpacket = pqBuildStartupPacket2(conn, &packetlen,
- EnvironmentOptions);
+ EnvironmentOptions);
if (!startpacket)
{
printfPQExpBuffer(&conn->errorMessage,
@@ -1274,14 +1266,14 @@ keep_going: /* We will come back to here until there
/*
* Send the startup packet.
*
- * Theoretically, this could block, but it really shouldn't
- * since we only got here if the socket is write-ready.
+ * Theoretically, this could block, but it really shouldn't since
+ * we only got here if the socket is write-ready.
*/
if (pqPacketSend(conn, 0, startpacket, packetlen) != STATUS_OK)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not send startup packet: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ libpq_gettext("could not send startup packet: %s\n"),
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
free(startpacket);
goto error_return;
}
@@ -1302,15 +1294,15 @@ keep_going: /* We will come back to here until there
PostgresPollingStatusType pollres;
/*
- * On first time through, get the postmaster's response to
- * our SSL negotiation packet.
+ * On first time through, get the postmaster's response to our
+ * SSL negotiation packet.
*/
if (conn->ssl == NULL)
{
/*
* We use pqReadData here since it has the logic to
- * distinguish no-data-yet from connection closure.
- * Since conn->ssl isn't set, a plain recv() will occur.
+ * distinguish no-data-yet from connection closure. Since
+ * conn->ssl isn't set, a plain recv() will occur.
*/
char SSLok;
int rdresult;
@@ -1402,8 +1394,8 @@ keep_going: /* We will come back to here until there
}
/*
- * Handle authentication exchange: wait for postmaster
- * messages and respond as necessary.
+ * Handle authentication exchange: wait for postmaster messages
+ * and respond as necessary.
*/
case CONNECTION_AWAITING_RESPONSE:
{
@@ -1413,9 +1405,9 @@ keep_going: /* We will come back to here until there
AuthRequest areq;
/*
- * Scan the message from current point (note that if we
- * find the message is incomplete, we will return without
- * advancing inStart, and resume here next time).
+ * Scan the message from current point (note that if we find
+ * the message is incomplete, we will return without advancing
+ * inStart, and resume here next time).
*/
conn->inCursor = conn->inStart;
@@ -1435,8 +1427,8 @@ keep_going: /* We will come back to here until there
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "expected authentication request from "
- "server, but received %c\n"),
+ "expected authentication request from "
+ "server, but received %c\n"),
beresp);
goto error_return;
}
@@ -1458,17 +1450,17 @@ keep_going: /* We will come back to here until there
/*
* Try to validate message length before using it.
- * Authentication requests can't be very large. Errors
- * can be a little larger, but not huge. If we see a
- * large apparent length in an error, it means we're
- * really talking to a pre-3.0-protocol server; cope.
+ * Authentication requests can't be very large. Errors can be
+ * a little larger, but not huge. If we see a large apparent
+ * length in an error, it means we're really talking to a
+ * pre-3.0-protocol server; cope.
*/
if (beresp == 'R' && (msgLength < 8 || msgLength > 100))
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "expected authentication request from "
- "server, but received %c\n"),
+ "expected authentication request from "
+ "server, but received %c\n"),
beresp);
goto error_return;
}
@@ -1486,9 +1478,8 @@ keep_going: /* We will come back to here until there
conn->inStart = conn->inCursor;
/*
- * The postmaster typically won't end its message with
- * a newline, so add one to conform to libpq
- * conventions.
+ * The postmaster typically won't end its message with a
+ * newline, so add one to conform to libpq conventions.
*/
appendPQExpBufferChar(&conn->errorMessage, '\n');
@@ -1513,16 +1504,16 @@ keep_going: /* We will come back to here until there
/*
* Can't process if message body isn't all here yet.
*
- * (In protocol 2.0 case, we are assuming messages carry at
- * least 4 bytes of data.)
+ * (In protocol 2.0 case, we are assuming messages carry at least
+ * 4 bytes of data.)
*/
msgLength -= 4;
avail = conn->inEnd - conn->inCursor;
if (avail < msgLength)
{
/*
- * Before returning, try to enlarge the input buffer
- * if needed to hold the whole message; see notes in
+ * Before returning, try to enlarge the input buffer if
+ * needed to hold the whole message; see notes in
* pqParseInput3.
*/
if (pqCheckInBufferSpace(conn->inCursor + msgLength, conn))
@@ -1557,8 +1548,7 @@ keep_going: /* We will come back to here until there
/*
* if sslmode is "allow" and we haven't tried an SSL
- * connection already, then retry with an SSL
- * connection
+ * connection already, then retry with an SSL connection
*/
if (conn->sslmode[0] == 'a' /* "allow" */
&& conn->ssl == NULL
@@ -1575,8 +1565,8 @@ keep_going: /* We will come back to here until there
}
/*
- * if sslmode is "prefer" and we're in an SSL
- * connection, then do a non-SSL retry
+ * if sslmode is "prefer" and we're in an SSL connection,
+ * then do a non-SSL retry
*/
if (conn->sslmode[0] == 'p' /* "prefer" */
&& conn->ssl
@@ -1626,21 +1616,20 @@ keep_going: /* We will come back to here until there
}
/*
- * OK, we successfully read the message; mark data
- * consumed
+ * OK, we successfully read the message; mark data consumed
*/
conn->inStart = conn->inCursor;
/* Respond to the request if necessary. */
/*
- * Note that conn->pghost must be non-NULL if we are going
- * to avoid the Kerberos code doing a hostname look-up.
+ * Note that conn->pghost must be non-NULL if we are going to
+ * avoid the Kerberos code doing a hostname look-up.
*/
/*
- * XXX fe-auth.c has not been fixed to support
- * PQExpBuffers, so:
+ * XXX fe-auth.c has not been fixed to support PQExpBuffers,
+ * so:
*/
if (fe_sendauth(areq, conn, conn->pghost, conn->pgpass,
conn->errorMessage.data) != STATUS_OK)
@@ -1651,10 +1640,9 @@ keep_going: /* We will come back to here until there
conn->errorMessage.len = strlen(conn->errorMessage.data);
/*
- * Just make sure that any data sent by fe_sendauth is
- * flushed out. Although this theoretically could block,
- * it really shouldn't since we don't send large auth
- * responses.
+ * Just make sure that any data sent by fe_sendauth is flushed
+ * out. Although this theoretically could block, it really
+ * shouldn't since we don't send large auth responses.
*/
if (pqFlush(conn))
goto error_return;
@@ -1680,14 +1668,14 @@ keep_going: /* We will come back to here until there
{
/*
* Now we expect to hear from the backend. A ReadyForQuery
- * message indicates that startup is successful, but we
- * might also get an Error message indicating failure.
- * (Notice messages indicating nonfatal warnings are also
- * allowed by the protocol, as are ParameterStatus and
- * BackendKeyData messages.) Easiest way to handle this is
- * to let PQgetResult() read the messages. We just have to
- * fake it out about the state of the connection, by
- * setting asyncStatus = PGASYNC_BUSY (done above).
+ * message indicates that startup is successful, but we might
+ * also get an Error message indicating failure. (Notice
+ * messages indicating nonfatal warnings are also allowed by
+ * the protocol, as are ParameterStatus and BackendKeyData
+ * messages.) Easiest way to handle this is to let
+ * PQgetResult() read the messages. We just have to fake it
+ * out about the state of the connection, by setting
+ * asyncStatus = PGASYNC_BUSY (done above).
*/
if (PQisBusy(conn))
@@ -1706,11 +1694,10 @@ keep_going: /* We will come back to here until there
libpq_gettext("unexpected message from server during startup\n"));
/*
- * if the resultStatus is FATAL, then
- * conn->errorMessage already has a copy of the error;
- * needn't copy it back. But add a newline if it's not
- * there already, since postmaster error messages may
- * not have one.
+ * if the resultStatus is FATAL, then conn->errorMessage
+ * already has a copy of the error; needn't copy it back.
+ * But add a newline if it's not there already, since
+ * postmaster error messages may not have one.
*/
if (conn->errorMessage.len <= 0 ||
conn->errorMessage.data[conn->errorMessage.len - 1] != '\n')
@@ -1741,8 +1728,7 @@ keep_going: /* We will come back to here until there
case CONNECTION_SETENV:
/*
- * Do post-connection housekeeping (only needed in protocol
- * 2.0).
+ * Do post-connection housekeeping (only needed in protocol 2.0).
*
* We pretend that the connection is OK for the duration of these
* queries.
@@ -1773,8 +1759,8 @@ keep_going: /* We will come back to here until there
default:
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "invalid connection state %c, "
- "probably indicative of memory corruption\n"
+ "invalid connection state %c, "
+ "probably indicative of memory corruption\n"
),
conn->status);
goto error_return;
@@ -1785,11 +1771,11 @@ keep_going: /* We will come back to here until there
error_return:
/*
- * We used to close the socket at this point, but that makes it
- * awkward for those above us if they wish to remove this socket from
- * their own records (an fd_set for example). We'll just have this
- * socket closed when PQfinish is called (which is compulsory even
- * after an error, since the connection structure must be freed).
+ * We used to close the socket at this point, but that makes it awkward
+ * for those above us if they wish to remove this socket from their own
+ * records (an fd_set for example). We'll just have this socket closed
+ * when PQfinish is called (which is compulsory even after an error, since
+ * the connection structure must be freed).
*/
conn->status = CONNECTION_BAD;
return PGRES_POLLING_FAILED;
@@ -1806,11 +1792,11 @@ makeEmptyPGconn(void)
PGconn *conn;
#ifdef WIN32
+
/*
- * Make sure socket support is up and running.
- * Even though this is done in libpqdll.c, that is only for MSVC and
- * BCC builds and doesn't work for static builds at all, so we have
- * to do it in the main code too.
+ * Make sure socket support is up and running. Even though this is done in
+ * libpqdll.c, that is only for MSVC and BCC builds and doesn't work for
+ * static builds at all, so we have to do it in the main code too.
*/
WSADATA wsaData;
@@ -1841,15 +1827,15 @@ makeEmptyPGconn(void)
#endif
/*
- * We try to send at least 8K at a time, which is the usual size of
- * pipe buffers on Unix systems. That way, when we are sending a
- * large amount of data, we avoid incurring extra kernel context swaps
- * for partial bufferloads. The output buffer is initially made 16K
- * in size, and we try to dump it after accumulating 8K.
+ * We try to send at least 8K at a time, which is the usual size of pipe
+ * buffers on Unix systems. That way, when we are sending a large amount
+ * of data, we avoid incurring extra kernel context swaps for partial
+ * bufferloads. The output buffer is initially made 16K in size, and we
+ * try to dump it after accumulating 8K.
*
- * With the same goal of minimizing context swaps, the input buffer will
- * be enlarged anytime it has less than 8K free, so we initially
- * allocate twice that.
+ * With the same goal of minimizing context swaps, the input buffer will be
+ * enlarged anytime it has less than 8K free, so we initially allocate
+ * twice that.
*/
conn->inBufSize = 16 * 1024;
conn->inBuffer = (char *) malloc(conn->inBufSize);
@@ -1928,7 +1914,7 @@ freePGconn(PGconn *conn)
notify = conn->notifyHead;
while (notify != NULL)
{
- PGnotify *prev = notify;
+ PGnotify *prev = notify;
notify = notify->next;
free(prev);
@@ -1980,9 +1966,9 @@ closePGconn(PGconn *conn)
}
/*
- * must reset the blocking status so a possible reconnect will work
- * don't call PQsetnonblocking() because it will fail if it's unable
- * to flush the connection.
+ * must reset the blocking status so a possible reconnect will work don't
+ * call PQsetnonblocking() because it will fail if it's unable to flush
+ * the connection.
*/
conn->nonblocking = FALSE;
@@ -2005,7 +1991,7 @@ closePGconn(PGconn *conn)
notify = conn->notifyHead;
while (notify != NULL)
{
- PGnotify *prev = notify;
+ PGnotify *prev = notify;
notify = notify->next;
free(prev);
@@ -2104,7 +2090,7 @@ PQresetPoll(PGconn *conn)
PGcancel *
PQgetCancel(PGconn *conn)
{
- PGcancel *cancel;
+ PGcancel *cancel;
if (!conn)
return NULL;
@@ -2159,7 +2145,7 @@ internal_cancel(SockAddr *raddr, int be_pid, int be_key,
int save_errno = SOCK_ERRNO;
int tmpsock = -1;
char sebuf[256];
- int maxlen;
+ int maxlen;
struct
{
uint32 packetlen;
@@ -2167,8 +2153,8 @@ internal_cancel(SockAddr *raddr, int be_pid, int be_key,
} crp;
/*
- * We need to open a temporary connection to the postmaster. Do
- * this with only kernel calls.
+ * We need to open a temporary connection to the postmaster. Do this with
+ * only kernel calls.
*/
if ((tmpsock = socket(raddr->addr.ss_family, SOCK_STREAM, 0)) < 0)
{
@@ -2208,12 +2194,11 @@ retry4:
}
/*
- * Wait for the postmaster to close the connection, which indicates
- * that it's processed the request. Without this delay, we might
- * issue another command only to find that our cancel zaps that
- * command instead of the one we thought we were canceling. Note we
- * don't actually expect this read to obtain any data, we are just
- * waiting for EOF to be signaled.
+ * Wait for the postmaster to close the connection, which indicates that
+ * it's processed the request. Without this delay, we might issue another
+ * command only to find that our cancel zaps that command instead of the
+ * one we thought we were canceling. Note we don't actually expect this
+ * read to obtain any data, we are just waiting for EOF to be signaled.
*/
retry5:
if (recv(tmpsock, (char *) &crp, 1, 0) < 0)
@@ -2230,9 +2215,10 @@ retry5:
return TRUE;
cancel_errReturn:
+
/*
- * Make sure we don't overflow the error buffer. Leave space for
- * the \n at the end, and for the terminating zero.
+ * Make sure we don't overflow the error buffer. Leave space for the \n at
+ * the end, and for the terminating zero.
*/
maxlen = errbufsize - strlen(errbuf) - 2;
if (maxlen >= 0)
@@ -2253,7 +2239,7 @@ cancel_errReturn:
* Returns TRUE if able to send the cancel request, FALSE if not.
*
* On failure, an error message is stored in *errbuf, which must be of size
- * errbufsize (recommended size is 256 bytes). *errbuf is not changed on
+ * errbufsize (recommended size is 256 bytes). *errbuf is not changed on
* success return.
*/
int
@@ -2284,7 +2270,7 @@ PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
int
PQrequestCancel(PGconn *conn)
{
- int r;
+ int r;
/* Check we have an open connection */
if (!conn)
@@ -2362,9 +2348,9 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
i;
/*
- * We have to special-case the environment variable PGSERVICE here,
- * since this is and should be called before inserting environment
- * defaults for other connection options.
+ * We have to special-case the environment variable PGSERVICE here, since
+ * this is and should be called before inserting environment defaults for
+ * other connection options.
*/
if (service == NULL)
service = getenv("PGSERVICE");
@@ -2398,7 +2384,7 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
{
fclose(f);
printfPQExpBuffer(errorMessage,
- libpq_gettext("ERROR: line %d too long in service file \"%s\"\n"),
+ libpq_gettext("ERROR: line %d too long in service file \"%s\"\n"),
linenr,
serviceFile);
return 2;
@@ -2437,8 +2423,8 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
if (group_found)
{
/*
- * Finally, we are in the right group and can parse
- * the line
+ * Finally, we are in the right group and can parse the
+ * line
*/
char *key,
*val;
@@ -2458,8 +2444,8 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
*val++ = '\0';
/*
- * Set the parameter --- but don't override any
- * previous explicit setting.
+ * Set the parameter --- but don't override any previous
+ * explicit setting.
*/
found_keyword = false;
for (i = 0; options[i].keyword; i++)
@@ -2638,8 +2624,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
}
/*
- * Now we have the name and the value. Search for the param
- * record.
+ * Now we have the name and the value. Search for the param record.
*/
for (option = options; option->keyword != NULL; option++)
{
@@ -2649,7 +2634,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
if (option->keyword == NULL)
{
printfPQExpBuffer(errorMessage,
- libpq_gettext("invalid connection option \"%s\"\n"),
+ libpq_gettext("invalid connection option \"%s\"\n"),
pname);
PQconninfoFree(options);
free(buf);
@@ -2676,8 +2661,8 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
free(buf);
/*
- * If there's a service spec, use it to obtain any
- * not-explicitly-given parameters.
+ * If there's a service spec, use it to obtain any not-explicitly-given
+ * parameters.
*/
if (parseServiceInfo(options, errorMessage))
{
@@ -2686,8 +2671,8 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
}
/*
- * Get the fallback resources for parameters not specified in the
- * conninfo string nor the service.
+ * Get the fallback resources for parameters not specified in the conninfo
+ * string nor the service.
*/
for (option = options; option->keyword != NULL; option++)
{
@@ -3100,7 +3085,7 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
FILE *fp;
char pgpassfile[MAXPGPATH];
struct stat stat_buf;
- char *passfile_env;
+ char *passfile_env;
#define LINELEN NAMEDATALEN*5
char buf[LINELEN];
@@ -3138,7 +3123,7 @@ PasswordFromFile(char *hostname, char *port, char *dbname, char *username)
if (!S_ISREG(stat_buf.st_mode))
{
fprintf(stderr,
- libpq_gettext("WARNING: password file \"%s\" is not a plain file\n"),
+ libpq_gettext("WARNING: password file \"%s\" is not a plain file\n"),
pgpassfile);
free(pgpassfile);
return NULL;
@@ -3212,7 +3197,6 @@ pqGetHomeDirectory(char *buf, int bufsize)
return false;
StrNCpy(buf, pwd->pw_dir, bufsize);
return true;
-
#else
char tmppath[MAX_PATH];
@@ -3235,7 +3219,6 @@ default_threadlock(int acquire)
#ifdef ENABLE_THREAD_SAFETY
#ifndef WIN32
static pthread_mutex_t singlethread_lock = PTHREAD_MUTEX_INITIALIZER;
-
#else
static pthread_mutex_t singlethread_lock = NULL;
static long mutex_initlock = 0;
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index 0835b263bd..84637072bc 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.175 2005/09/24 17:53:28 tgl Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.176 2005/10/15 02:49:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -30,7 +30,7 @@
#endif
/* keep this in same order as ExecStatusType in libpq-fe.h */
-char *const pgresStatus[] = {
+char *const pgresStatus[] = {
"PGRES_EMPTY_QUERY",
"PGRES_COMMAND_OK",
"PGRES_TUPLES_OK",
@@ -209,8 +209,8 @@ pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary)
return res->null_field;
/*
- * If alignment is needed, round up the current position to an
- * alignment boundary.
+ * If alignment is needed, round up the current position to an alignment
+ * boundary.
*/
if (isBinary)
{
@@ -234,10 +234,9 @@ pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary)
/*
* If the requested object is very large, give it its own block; this
- * avoids wasting what might be most of the current block to start a
- * new block. (We'd have to special-case requests bigger than the
- * block size anyway.) The object is always given binary alignment in
- * this case.
+ * avoids wasting what might be most of the current block to start a new
+ * block. (We'd have to special-case requests bigger than the block size
+ * anyway.) The object is always given binary alignment in this case.
*/
if (nBytes >= PGRESULT_SEP_ALLOC_THRESHOLD)
{
@@ -393,8 +392,8 @@ void
pqSaveErrorResult(PGconn *conn)
{
/*
- * If no old async result, just let PQmakeEmptyPGresult make one.
- * Likewise if old result is not an error message.
+ * If no old async result, just let PQmakeEmptyPGresult make one. Likewise
+ * if old result is not an error message.
*/
if (conn->result == NULL ||
conn->result->resultStatus != PGRES_FATAL_ERROR ||
@@ -423,9 +422,9 @@ pqPrepareAsyncResult(PGconn *conn)
PGresult *res;
/*
- * conn->result is the PGresult to return. If it is NULL (which
- * probably shouldn't happen) we assume there is an appropriate error
- * message in conn->errorMessage.
+ * conn->result is the PGresult to return. If it is NULL (which probably
+ * shouldn't happen) we assume there is an appropriate error message in
+ * conn->errorMessage.
*/
res = conn->result;
conn->result = NULL; /* handing over ownership to caller */
@@ -435,8 +434,8 @@ pqPrepareAsyncResult(PGconn *conn)
else
{
/*
- * Make sure PQerrorMessage agrees with result; it could be
- * different if we have concatenated messages.
+ * Make sure PQerrorMessage agrees with result; it could be different
+ * if we have concatenated messages.
*/
resetPQExpBuffer(&conn->errorMessage);
appendPQExpBufferStr(&conn->errorMessage,
@@ -455,7 +454,7 @@ pqPrepareAsyncResult(PGconn *conn)
* a trailing newline, and should not be more than one line).
*/
void
-pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt, ...)
+pqInternalNotice(const PGNoticeHooks * hooks, const char *fmt,...)
{
char msgBuf[1024];
va_list args;
@@ -484,8 +483,8 @@ pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt, ...)
/* XXX should provide a SQLSTATE too? */
/*
- * Result text is always just the primary message + newline. If we
- * can't allocate it, don't bother invoking the receiver.
+ * Result text is always just the primary message + newline. If we can't
+ * allocate it, don't bother invoking the receiver.
*/
res->errMsg = (char *) pqResultAlloc(res, strlen(msgBuf) + 2, FALSE);
if (res->errMsg)
@@ -506,20 +505,20 @@ pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt, ...)
* Returns TRUE if OK, FALSE if not enough memory to add the row
*/
int
-pqAddTuple(PGresult *res, PGresAttValue *tup)
+pqAddTuple(PGresult *res, PGresAttValue * tup)
{
if (res->ntups >= res->tupArrSize)
{
/*
* Try to grow the array.
*
- * We can use realloc because shallow copying of the structure is
- * okay. Note that the first time through, res->tuples is NULL.
- * While ANSI says that realloc() should act like malloc() in that
- * case, some old C libraries (like SunOS 4.1.x) coredump instead.
- * On failure realloc is supposed to return NULL without damaging
- * the existing allocation. Note that the positions beyond
- * res->ntups are garbage, not necessarily NULL.
+ * We can use realloc because shallow copying of the structure is okay.
+ * Note that the first time through, res->tuples is NULL. While ANSI
+ * says that realloc() should act like malloc() in that case, some old
+ * C libraries (like SunOS 4.1.x) coredump instead. On failure realloc
+ * is supposed to return NULL without damaging the existing
+ * allocation. Note that the positions beyond res->ntups are garbage,
+ * not necessarily NULL.
*/
int newSize = (res->tupArrSize > 0) ? res->tupArrSize * 2 : 128;
PGresAttValue **newTuples;
@@ -595,7 +594,7 @@ pqSaveParameterStatus(PGconn *conn, const char *name, const char *value)
* Store new info as a single malloc block
*/
pstatus = (pgParameterStatus *) malloc(sizeof(pgParameterStatus) +
- strlen(name) +strlen(value) + 2);
+ strlen(name) + strlen(value) + 2);
if (pstatus)
{
char *ptr;
@@ -611,8 +610,8 @@ pqSaveParameterStatus(PGconn *conn, const char *name, const char *value)
}
/*
- * Special hacks: remember client_encoding as a numeric value, and
- * convert server version to a numeric form as well.
+ * Special hacks: remember client_encoding as a numeric value, and convert
+ * server version to a numeric form as well.
*/
if (strcmp(name, "client_encoding") == 0)
conn->client_encoding = pg_char_to_encoding(value);
@@ -653,7 +652,7 @@ PQsendQuery(PGconn *conn, const char *query)
if (!query)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("command string is a null pointer\n"));
+ libpq_gettext("command string is a null pointer\n"));
return 0;
}
@@ -670,9 +669,8 @@ PQsendQuery(PGconn *conn, const char *query)
conn->queryclass = PGQUERY_SIMPLE;
/*
- * Give the data a push. In nonblock mode, don't complain if we're
- * unable to send it all; PQgetResult() will do any additional
- * flushing needed.
+ * Give the data a push. In nonblock mode, don't complain if we're unable
+ * to send it all; PQgetResult() will do any additional flushing needed.
*/
if (pqFlush(conn) < 0)
{
@@ -705,7 +703,7 @@ PQsendQueryParams(PGconn *conn,
if (!command)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("command string is a null pointer\n"));
+ libpq_gettext("command string is a null pointer\n"));
return 0;
}
@@ -722,10 +720,10 @@ PQsendQueryParams(PGconn *conn,
/*
* PQsendPrepare
- * Submit a Parse message, but don't wait for it to finish
+ * Submit a Parse message, but don't wait for it to finish
*
* Returns: 1 if successfully submitted
- * 0 if error (conn->errorMessage is set)
+ * 0 if error (conn->errorMessage is set)
*/
int
PQsendPrepare(PGconn *conn,
@@ -738,14 +736,14 @@ PQsendPrepare(PGconn *conn,
if (!stmtName)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("statement name is a null pointer\n"));
+ libpq_gettext("statement name is a null pointer\n"));
return 0;
}
if (!query)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("command string is a null pointer\n"));
+ libpq_gettext("command string is a null pointer\n"));
return 0;
}
@@ -753,7 +751,7 @@ PQsendPrepare(PGconn *conn,
if (PG_PROTOCOL_MAJOR(conn->pversion) < 3)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("function requires at least protocol version 3.0\n"));
+ libpq_gettext("function requires at least protocol version 3.0\n"));
return 0;
}
@@ -765,7 +763,7 @@ PQsendPrepare(PGconn *conn,
if (nParams > 0 && paramTypes)
{
- int i;
+ int i;
if (pqPutInt(nParams, 2, conn) < 0)
goto sendFailed;
@@ -792,9 +790,8 @@ PQsendPrepare(PGconn *conn,
conn->queryclass = PGQUERY_PREPARE;
/*
- * Give the data a push. In nonblock mode, don't complain if we're
- * unable to send it all; PQgetResult() will do any additional
- * flushing needed.
+ * Give the data a push. In nonblock mode, don't complain if we're unable
+ * to send it all; PQgetResult() will do any additional flushing needed.
*/
if (pqFlush(conn) < 0)
goto sendFailed;
@@ -828,7 +825,7 @@ PQsendQueryPrepared(PGconn *conn,
if (!stmtName)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("statement name is a null pointer\n"));
+ libpq_gettext("statement name is a null pointer\n"));
return 0;
}
@@ -866,7 +863,7 @@ PQsendQueryStart(PGconn *conn)
if (conn->asyncStatus != PGASYNC_IDLE)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("another command is already in progress\n"));
+ libpq_gettext("another command is already in progress\n"));
return false;
}
@@ -902,13 +899,13 @@ PQsendQueryGuts(PGconn *conn,
if (PG_PROTOCOL_MAJOR(conn->pversion) < 3)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("function requires at least protocol version 3.0\n"));
+ libpq_gettext("function requires at least protocol version 3.0\n"));
return 0;
}
/*
- * We will send Parse (if needed), Bind, Describe Portal, Execute,
- * Sync, using specified statement name and the unnamed portal.
+ * We will send Parse (if needed), Bind, Describe Portal, Execute, Sync,
+ * using specified statement name and the unnamed portal.
*/
if (command)
@@ -1022,9 +1019,8 @@ PQsendQueryGuts(PGconn *conn,
conn->queryclass = PGQUERY_EXTENDED;
/*
- * Give the data a push. In nonblock mode, don't complain if we're
- * unable to send it all; PQgetResult() will do any additional
- * flushing needed.
+ * Give the data a push. In nonblock mode, don't complain if we're unable
+ * to send it all; PQgetResult() will do any additional flushing needed.
*/
if (pqFlush(conn) < 0)
goto sendFailed;
@@ -1051,8 +1047,8 @@ pqHandleSendFailure(PGconn *conn)
{
/*
* Accept any available input data, ignoring errors. Note that if
- * pqReadData decides the backend has closed the channel, it will
- * close our side of the socket --- that's just what we want here.
+ * pqReadData decides the backend has closed the channel, it will close
+ * our side of the socket --- that's just what we want here.
*/
while (pqReadData(conn) > 0)
/* loop until no more data readable */ ;
@@ -1076,9 +1072,9 @@ PQconsumeInput(PGconn *conn)
return 0;
/*
- * for non-blocking connections try to flush the send-queue, otherwise
- * we may never get a response for something that may not have already
- * been sent because it's in our write buffer!
+ * for non-blocking connections try to flush the send-queue, otherwise we
+ * may never get a response for something that may not have already been
+ * sent because it's in our write buffer!
*/
if (pqIsnonblocking(conn))
{
@@ -1087,10 +1083,10 @@ PQconsumeInput(PGconn *conn)
}
/*
- * Load more data, if available. We do this no matter what state we
- * are in, since we are probably getting called because the
- * application wants to get rid of a read-select condition. Note that
- * we will NOT block waiting for more input.
+ * Load more data, if available. We do this no matter what state we are
+ * in, since we are probably getting called because the application wants
+ * to get rid of a read-select condition. Note that we will NOT block
+ * waiting for more input.
*/
if (pqReadData(conn) < 0)
return 0;
@@ -1157,8 +1153,8 @@ PQgetResult(PGconn *conn)
int flushResult;
/*
- * If data remains unsent, send it. Else we might be waiting for
- * the result of a command the backend hasn't even got yet.
+ * If data remains unsent, send it. Else we might be waiting for the
+ * result of a command the backend hasn't even got yet.
*/
while ((flushResult = pqFlush(conn)) > 0)
{
@@ -1212,7 +1208,7 @@ PQgetResult(PGconn *conn)
break;
default:
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("unexpected asyncStatus: %d\n"),
+ libpq_gettext("unexpected asyncStatus: %d\n"),
(int) conn->asyncStatus);
res = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR);
break;
@@ -1268,7 +1264,7 @@ PQexecParams(PGconn *conn,
/*
* PQprepare
- * Creates a prepared statement by issuing a v3.0 parse message.
+ * Creates a prepared statement by issuing a v3.0 parse message.
*
* If the query was not even sent, return NULL; conn->errorMessage is set to
* a relevant message.
@@ -1324,9 +1320,8 @@ PQexecStart(PGconn *conn)
return false;
/*
- * Silently discard any prior query result that application didn't
- * eat. This is probably poor design, but it's here for backward
- * compatibility.
+ * Silently discard any prior query result that application didn't eat.
+ * This is probably poor design, but it's here for backward compatibility.
*/
while ((result = PQgetResult(conn)) != NULL)
{
@@ -1339,7 +1334,7 @@ PQexecStart(PGconn *conn)
{
/* In protocol 3, we can get out of a COPY IN state */
if (PQputCopyEnd(conn,
- libpq_gettext("COPY terminated by new PQexec")) < 0)
+ libpq_gettext("COPY terminated by new PQexec")) < 0)
return false;
/* keep waiting to swallow the copy's failure message */
}
@@ -1347,7 +1342,7 @@ PQexecStart(PGconn *conn)
{
/* In older protocols we have to punt */
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("COPY IN state must be terminated first\n"));
+ libpq_gettext("COPY IN state must be terminated first\n"));
return false;
}
}
@@ -1356,9 +1351,9 @@ PQexecStart(PGconn *conn)
if (PG_PROTOCOL_MAJOR(conn->pversion) >= 3)
{
/*
- * In protocol 3, we can get out of a COPY OUT state: we
- * just switch back to BUSY and allow the remaining COPY
- * data to be dropped on the floor.
+ * In protocol 3, we can get out of a COPY OUT state: we just
+ * switch back to BUSY and allow the remaining COPY data to be
+ * dropped on the floor.
*/
conn->asyncStatus = PGASYNC_BUSY;
/* keep waiting to swallow the copy's completion message */
@@ -1367,7 +1362,7 @@ PQexecStart(PGconn *conn)
{
/* In older protocols we have to punt */
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("COPY OUT state must be terminated first\n"));
+ libpq_gettext("COPY OUT state must be terminated first\n"));
return false;
}
}
@@ -1390,9 +1385,9 @@ PQexecFinish(PGconn *conn)
PGresult *lastResult;
/*
- * For backwards compatibility, return the last result if there are
- * more than one --- but merge error messages if we get more than one
- * error result.
+ * For backwards compatibility, return the last result if there are more
+ * than one --- but merge error messages if we get more than one error
+ * result.
*
* We have to stop if we see copy in/out, however. We will resume parsing
* after application performs the data transfer.
@@ -1412,8 +1407,7 @@ PQexecFinish(PGconn *conn)
result = lastResult;
/*
- * Make sure PQerrorMessage agrees with concatenated
- * result
+ * Make sure PQerrorMessage agrees with concatenated result
*/
resetPQExpBuffer(&conn->errorMessage);
appendPQExpBufferStr(&conn->errorMessage, result->errMsg);
@@ -1494,11 +1488,11 @@ PQputCopyData(PGconn *conn, const char *buffer, int nbytes)
if (nbytes > 0)
{
/*
- * Try to flush any previously sent data in preference to growing
- * the output buffer. If we can't enlarge the buffer enough to
- * hold the data, return 0 in the nonblock case, else hard error.
- * (For simplicity, always assume 5 bytes of overhead even in
- * protocol 2.0 case.)
+ * Try to flush any previously sent data in preference to growing the
+ * output buffer. If we can't enlarge the buffer enough to hold the
+ * data, return 0 in the nonblock case, else hard error. (For
+ * simplicity, always assume 5 bytes of overhead even in protocol 2.0
+ * case.)
*/
if ((conn->outBufSize - conn->outCount - 5) < nbytes)
{
@@ -1569,8 +1563,8 @@ PQputCopyEnd(PGconn *conn, const char *errormsg)
}
/*
- * If we sent the COPY command in extended-query mode, we must
- * issue a Sync as well.
+ * If we sent the COPY command in extended-query mode, we must issue a
+ * Sync as well.
*/
if (conn->queryclass != PGQUERY_SIMPLE)
{
@@ -1982,8 +1976,8 @@ PQfnumber(const PGresult *res, const char *field_name)
return -1;
/*
- * Note: it is correct to reject a zero-length input string; the
- * proper input to match a zero-length field name would be "".
+ * Note: it is correct to reject a zero-length input string; the proper
+ * input to match a zero-length field name would be "".
*/
if (field_name == NULL ||
field_name[0] == '\0' ||
@@ -1992,8 +1986,8 @@ PQfnumber(const PGresult *res, const char *field_name)
/*
* Note: this code will not reject partially quoted strings, eg
- * foo"BAR"foo will become fooBARfoo when it probably ought to be an
- * error condition.
+ * foo"BAR"foo will become fooBARfoo when it probably ought to be an error
+ * condition.
*/
field_case = strdup(field_name);
if (field_case == NULL)
@@ -2156,11 +2150,11 @@ PQoidValue(const PGresult *res)
char *endptr = NULL;
unsigned long result;
- if (!res ||
- !res->cmdStatus ||
- strncmp(res->cmdStatus, "INSERT ", 7) != 0 ||
- res->cmdStatus[7] < '0' ||
- res->cmdStatus[7] > '9')
+ if (!res ||
+ !res->cmdStatus ||
+ strncmp(res->cmdStatus, "INSERT ", 7) != 0 ||
+ res->cmdStatus[7] < '0' ||
+ res->cmdStatus[7] > '9')
return InvalidOid;
result = strtoul(res->cmdStatus + 7, &endptr, 10);
@@ -2280,11 +2274,10 @@ PQsetnonblocking(PGconn *conn, int arg)
return (0);
/*
- * to guarantee constancy for flushing/query/result-polling behavior
- * we need to flush the send queue at this point in order to guarantee
- * proper behavior. this is ok because either they are making a
- * transition _from_ or _to_ blocking mode, either way we can block
- * them.
+ * to guarantee constancy for flushing/query/result-polling behavior we
+ * need to flush the send queue at this point in order to guarantee proper
+ * behavior. this is ok because either they are making a transition _from_
+ * or _to_ blocking mode, either way we can block them.
*/
/* if we are going from blocking to non-blocking flush here */
if (pqFlush(conn))
@@ -2519,9 +2512,9 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
/*
* Note: if we see '\' followed by something that isn't a
* recognized escape sequence, we loop around having done
- * nothing except advance i. Therefore the something will
- * be emitted as ordinary data on the next cycle. Corner
- * case: '\' at end of string will just be discarded.
+ * nothing except advance i. Therefore the something will be
+ * emitted as ordinary data on the next cycle. Corner case:
+ * '\' at end of string will just be discarded.
*/
break;
@@ -2530,8 +2523,7 @@ PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
break;
}
}
- buflen = j; /* buflen is the length of the dequoted
- * data */
+ buflen = j; /* buflen is the length of the dequoted data */
/* Shrink the buffer to be no larger than necessary */
/* +1 avoids unportable behavior when buflen==0 */
diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c
index 665efe90bc..6745849c51 100644
--- a/src/interfaces/libpq/fe-lobj.c
+++ b/src/interfaces/libpq/fe-lobj.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.53 2005/06/13 02:26:53 tgl Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.54 2005/10/15 02:49:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -328,7 +328,7 @@ lo_create(PGconn *conn, Oid lobjId)
if (conn->lobjfuncs->fn_lo_create == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function lo_create\n"));
+ libpq_gettext("cannot determine OID of function lo_create\n"));
return InvalidOid;
}
@@ -453,8 +453,8 @@ lo_import(PGconn *conn, const char *filename)
char sebuf[256];
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not open file \"%s\": %s\n"),
- filename, pqStrerror(errno, sebuf, sizeof(sebuf)));
+ libpq_gettext("could not open file \"%s\": %s\n"),
+ filename, pqStrerror(errno, sebuf, sizeof(sebuf)));
return InvalidOid;
}
@@ -465,7 +465,7 @@ lo_import(PGconn *conn, const char *filename)
if (lobjOid == InvalidOid)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not create large object for file \"%s\"\n"),
+ libpq_gettext("could not create large object for file \"%s\"\n"),
filename);
(void) close(fd);
return InvalidOid;
@@ -475,7 +475,7 @@ lo_import(PGconn *conn, const char *filename)
if (lobj == -1)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not open large object %u\n"),
+ libpq_gettext("could not open large object %u\n"),
lobjOid);
(void) close(fd);
return InvalidOid;
@@ -490,7 +490,7 @@ lo_import(PGconn *conn, const char *filename)
if (tmp < nbytes)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("error while reading file \"%s\"\n"),
+ libpq_gettext("error while reading file \"%s\"\n"),
filename);
(void) close(fd);
(void) lo_close(conn, lobj);
@@ -525,7 +525,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename)
if (lobj == -1)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not open large object %u\n"), lobjId);
+ libpq_gettext("could not open large object %u\n"), lobjId);
return -1;
}
@@ -538,8 +538,8 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename)
char sebuf[256];
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not open file \"%s\": %s\n"),
- filename, pqStrerror(errno, sebuf, sizeof(sebuf)));
+ libpq_gettext("could not open file \"%s\": %s\n"),
+ filename, pqStrerror(errno, sebuf, sizeof(sebuf)));
(void) lo_close(conn, lobj);
return -1;
}
@@ -553,7 +553,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename)
if (tmp < nbytes)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("error while writing to file \"%s\"\n"),
+ libpq_gettext("error while writing to file \"%s\"\n"),
filename);
(void) lo_close(conn, lobj);
(void) close(fd);
@@ -566,7 +566,7 @@ lo_export(PGconn *conn, Oid lobjId, const char *filename)
if (close(fd))
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("error while writing to file \"%s\"\n"),
+ libpq_gettext("error while writing to file \"%s\"\n"),
filename);
return -1;
}
@@ -605,9 +605,8 @@ lo_initialize(PGconn *conn)
MemSet((char *) lobjfuncs, 0, sizeof(PGlobjfuncs));
/*
- * Execute the query to get all the functions at once. In 7.3 and
- * later we need to be schema-safe. lo_create only exists in 8.1
- * and up.
+ * Execute the query to get all the functions at once. In 7.3 and later
+ * we need to be schema-safe. lo_create only exists in 8.1 and up.
*/
if (conn->sversion >= 70300)
query = "select proname, oid from pg_catalog.pg_proc "
@@ -680,62 +679,62 @@ lo_initialize(PGconn *conn)
PQclear(res);
/*
- * Finally check that we really got all large object interface
- * functions --- except lo_create, which may not exist.
+ * Finally check that we really got all large object interface functions
+ * --- except lo_create, which may not exist.
*/
if (lobjfuncs->fn_lo_open == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function lo_open\n"));
+ libpq_gettext("cannot determine OID of function lo_open\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_close == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function lo_close\n"));
+ libpq_gettext("cannot determine OID of function lo_close\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_creat == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function lo_creat\n"));
+ libpq_gettext("cannot determine OID of function lo_creat\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_unlink == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function lo_unlink\n"));
+ libpq_gettext("cannot determine OID of function lo_unlink\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_lseek == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function lo_lseek\n"));
+ libpq_gettext("cannot determine OID of function lo_lseek\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_tell == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function lo_tell\n"));
+ libpq_gettext("cannot determine OID of function lo_tell\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_read == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function loread\n"));
+ libpq_gettext("cannot determine OID of function loread\n"));
free(lobjfuncs);
return -1;
}
if (lobjfuncs->fn_lo_write == 0)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("cannot determine OID of function lowrite\n"));
+ libpq_gettext("cannot determine OID of function lowrite\n"));
free(lobjfuncs);
return -1;
}
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c
index 2eff7e4fe2..c78d8b3c66 100644
--- a/src/interfaces/libpq/fe-misc.c
+++ b/src/interfaces/libpq/fe-misc.c
@@ -23,7 +23,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.121 2005/09/26 17:49:09 petere Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-misc.c,v 1.122 2005/10/15 02:49:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -226,7 +226,7 @@ pqGetInt(int *result, size_t bytes, PGconn *conn)
break;
default:
pqInternalNotice(&conn->noticeHooks,
- "integer of size %lu not supported by pqGetInt",
+ "integer of size %lu not supported by pqGetInt",
(unsigned long) bytes);
return EOF;
}
@@ -262,7 +262,7 @@ pqPutInt(int value, size_t bytes, PGconn *conn)
break;
default:
pqInternalNotice(&conn->noticeHooks,
- "integer of size %lu not supported by pqPutInt",
+ "integer of size %lu not supported by pqPutInt",
(unsigned long) bytes);
return EOF;
}
@@ -289,9 +289,9 @@ pqCheckOutBufferSpace(int bytes_needed, PGconn *conn)
return 0;
/*
- * If we need to enlarge the buffer, we first try to double it in
- * size; if that doesn't work, enlarge in multiples of 8K. This
- * avoids thrashing the malloc pool by repeated small enlargements.
+ * If we need to enlarge the buffer, we first try to double it in size; if
+ * that doesn't work, enlarge in multiples of 8K. This avoids thrashing
+ * the malloc pool by repeated small enlargements.
*
* Note: tests for newsize > 0 are to catch integer overflow.
*/
@@ -352,9 +352,9 @@ pqCheckInBufferSpace(int bytes_needed, PGconn *conn)
return 0;
/*
- * If we need to enlarge the buffer, we first try to double it in
- * size; if that doesn't work, enlarge in multiples of 8K. This
- * avoids thrashing the malloc pool by repeated small enlargements.
+ * If we need to enlarge the buffer, we first try to double it in size; if
+ * that doesn't work, enlarge in multiples of 8K. This avoids thrashing
+ * the malloc pool by repeated small enlargements.
*
* Note: tests for newsize > 0 are to catch integer overflow.
*/
@@ -565,20 +565,19 @@ pqReadData(PGconn *conn)
}
/*
- * If the buffer is fairly full, enlarge it. We need to be able to
- * enlarge the buffer in case a single message exceeds the initial
- * buffer size. We enlarge before filling the buffer entirely so as
- * to avoid asking the kernel for a partial packet. The magic constant
- * here should be large enough for a TCP packet or Unix pipe
- * bufferload. 8K is the usual pipe buffer size, so...
+ * If the buffer is fairly full, enlarge it. We need to be able to enlarge
+ * the buffer in case a single message exceeds the initial buffer size.
+ * We enlarge before filling the buffer entirely so as to avoid asking the
+ * kernel for a partial packet. The magic constant here should be large
+ * enough for a TCP packet or Unix pipe bufferload. 8K is the usual pipe
+ * buffer size, so...
*/
if (conn->inBufSize - conn->inEnd < 8192)
{
if (pqCheckInBufferSpace(conn->inEnd + 8192, conn))
{
/*
- * We don't insist that the enlarge worked, but we need some
- * room
+ * We don't insist that the enlarge worked, but we need some room
*/
if (conn->inBufSize - conn->inEnd < 100)
return -1; /* errorMessage already set */
@@ -608,8 +607,8 @@ retry3:
goto definitelyFailed;
#endif
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not receive data from server: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ libpq_gettext("could not receive data from server: %s\n"),
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
return -1;
}
if (nread > 0)
@@ -617,17 +616,16 @@ retry3:
conn->inEnd += nread;
/*
- * Hack to deal with the fact that some kernels will only give us
- * back 1 packet per recv() call, even if we asked for more and
- * there is more available. If it looks like we are reading a
- * long message, loop back to recv() again immediately, until we
- * run out of data or buffer space. Without this, the
- * block-and-restart behavior of libpq's higher levels leads to
- * O(N^2) performance on long messages.
+ * Hack to deal with the fact that some kernels will only give us back
+ * 1 packet per recv() call, even if we asked for more and there is
+ * more available. If it looks like we are reading a long message,
+ * loop back to recv() again immediately, until we run out of data or
+ * buffer space. Without this, the block-and-restart behavior of
+ * libpq's higher levels leads to O(N^2) performance on long messages.
*
- * Since we left-justified the data above, conn->inEnd gives the
- * amount of data already read in the current message. We
- * consider the message "long" once we have acquired 32k ...
+ * Since we left-justified the data above, conn->inEnd gives the amount
+ * of data already read in the current message. We consider the
+ * message "long" once we have acquired 32k ...
*/
if (conn->inEnd > 32768 &&
(conn->inBufSize - conn->inEnd) >= 8192)
@@ -642,18 +640,18 @@ retry3:
return 1; /* got a zero read after successful tries */
/*
- * A return value of 0 could mean just that no data is now available,
- * or it could mean EOF --- that is, the server has closed the
- * connection. Since we have the socket in nonblock mode, the only way
- * to tell the difference is to see if select() is saying that the
- * file is ready. Grumble. Fortunately, we don't expect this path to
- * be taken much, since in normal practice we should not be trying to
- * read data unless the file selected for reading already.
+ * A return value of 0 could mean just that no data is now available, or
+ * it could mean EOF --- that is, the server has closed the connection.
+ * Since we have the socket in nonblock mode, the only way to tell the
+ * difference is to see if select() is saying that the file is ready.
+ * Grumble. Fortunately, we don't expect this path to be taken much,
+ * since in normal practice we should not be trying to read data unless
+ * the file selected for reading already.
*
- * In SSL mode it's even worse: SSL_read() could say WANT_READ and then
- * data could arrive before we make the pqReadReady() test. So we
- * must play dumb and assume there is more data, relying on the SSL
- * layer to detect true EOF.
+ * In SSL mode it's even worse: SSL_read() could say WANT_READ and then data
+ * could arrive before we make the pqReadReady() test. So we must play
+ * dumb and assume there is more data, relying on the SSL layer to detect
+ * true EOF.
*/
#ifdef USE_SSL
@@ -699,8 +697,8 @@ retry4:
goto definitelyFailed;
#endif
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not receive data from server: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ libpq_gettext("could not receive data from server: %s\n"),
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
return -1;
}
if (nread > 0)
@@ -710,15 +708,15 @@ retry4:
}
/*
- * OK, we are getting a zero read even though select() says ready.
- * This means the connection has been closed. Cope.
+ * OK, we are getting a zero read even though select() says ready. This
+ * means the connection has been closed. Cope.
*/
definitelyFailed:
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "server closed the connection unexpectedly\n"
- "\tThis probably means the server terminated abnormally\n"
- "\tbefore or while processing the request.\n"));
+ "server closed the connection unexpectedly\n"
+ "\tThis probably means the server terminated abnormally\n"
+ "\tbefore or while processing the request.\n"));
conn->status = CONNECTION_BAD; /* No more connection to backend */
pqsecure_close(conn);
closesocket(conn->sock);
@@ -761,9 +759,9 @@ pqSendSome(PGconn *conn, int len)
if (sent < 0)
{
/*
- * Anything except EAGAIN/EWOULDBLOCK/EINTR is trouble. If
- * it's EPIPE or ECONNRESET, assume we've lost the backend
- * connection permanently.
+ * Anything except EAGAIN/EWOULDBLOCK/EINTR is trouble. If it's
+ * EPIPE or ECONNRESET, assume we've lost the backend connection
+ * permanently.
*/
switch (SOCK_ERRNO)
{
@@ -784,25 +782,25 @@ pqSendSome(PGconn *conn, int len)
#endif
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "server closed the connection unexpectedly\n"
- "\tThis probably means the server terminated abnormally\n"
- "\tbefore or while processing the request.\n"));
+ "server closed the connection unexpectedly\n"
+ "\tThis probably means the server terminated abnormally\n"
+ "\tbefore or while processing the request.\n"));
/*
- * We used to close the socket here, but that's a bad
- * idea since there might be unread data waiting
- * (typically, a NOTICE message from the backend
- * telling us it's committing hara-kiri...). Leave
- * the socket open until pqReadData finds no more data
- * can be read. But abandon attempt to send data.
+ * We used to close the socket here, but that's a bad idea
+ * since there might be unread data waiting (typically, a
+ * NOTICE message from the backend telling us it's
+ * committing hara-kiri...). Leave the socket open until
+ * pqReadData finds no more data can be read. But abandon
+ * attempt to send data.
*/
conn->outCount = 0;
return -1;
default:
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not send data to server: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ libpq_gettext("could not send data to server: %s\n"),
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
/* We don't assume it's a fatal error... */
conn->outCount = 0;
return -1;
@@ -831,16 +829,15 @@ pqSendSome(PGconn *conn, int len)
/*
* There are scenarios in which we can't send data because the
- * communications channel is full, but we cannot expect the
- * server to clear the channel eventually because it's blocked
- * trying to send data to us. (This can happen when we are
- * sending a large amount of COPY data, and the server has
- * generated lots of NOTICE responses.) To avoid a deadlock
- * situation, we must be prepared to accept and buffer
- * incoming data before we try again. Furthermore, it is
- * possible that such incoming data might not arrive until
- * after we've gone to sleep. Therefore, we wait for either
- * read ready or write ready.
+ * communications channel is full, but we cannot expect the server
+ * to clear the channel eventually because it's blocked trying to
+ * send data to us. (This can happen when we are sending a large
+ * amount of COPY data, and the server has generated lots of
+ * NOTICE responses.) To avoid a deadlock situation, we must be
+ * prepared to accept and buffer incoming data before we try
+ * again. Furthermore, it is possible that such incoming data
+ * might not arrive until after we've gone to sleep. Therefore,
+ * we wait for either read ready or write ready.
*/
if (pqReadData(conn) < 0)
{
@@ -990,7 +987,7 @@ pqSocketCheck(PGconn *conn, int forRead, int forWrite, time_t end_time)
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("select() failed: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
}
return result;
@@ -1040,7 +1037,6 @@ pqSocketPoll(int sock, int forRead, int forWrite, time_t end_time)
}
return poll(&input_fd, 1, timeout_ms);
-
#else /* !HAVE_POLL */
fd_set input_mask;
@@ -1134,9 +1130,9 @@ libpq_gettext(const char *msgid)
{
/* dgettext() preserves errno, but bindtextdomain() doesn't */
#ifdef WIN32
- int save_errno = GetLastError();
+ int save_errno = GetLastError();
#else
- int save_errno = errno;
+ int save_errno = errno;
#endif
const char *ldir;
diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c
index a83004328c..f49859020b 100644
--- a/src/interfaces/libpq/fe-print.c
+++ b/src/interfaces/libpq/fe-print.c
@@ -10,7 +10,7 @@
* didn't really belong there.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.63 2005/08/23 21:02:03 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-print.c,v 1.64 2005/10/15 02:49:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,7 +45,7 @@ static void do_field(const PQprintOpt *po, const PGresult *res,
unsigned char *fieldNotNum, int *fieldMax,
const int fieldMaxLen, FILE *fout);
static char *do_header(FILE *fout, const PQprintOpt *po, const int nFields,
- int *fieldMax, const char **fieldNames, unsigned char *fieldNotNum,
+ int *fieldMax, const char **fieldNames, unsigned char *fieldNotNum,
const int fs_len, const PGresult *res);
static void output_row(FILE *fout, const PQprintOpt *po, const int nFields, char **fields,
unsigned char *fieldNotNum, int *fieldMax, char *border,
@@ -88,6 +88,7 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
int total_line_length = 0;
int usePipe = 0;
char *pagerenv;
+
#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
sigset_t osigset;
bool sigpipe_masked = false;
@@ -99,7 +100,6 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
#ifdef TIOCGWINSZ
struct winsize screen_size;
-
#else
struct winsize
{
@@ -156,8 +156,8 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
)
{
/*
- * If we think there'll be more than one screen of output, try
- * to pipe to the pager program.
+ * If we think there'll be more than one screen of output, try to
+ * pipe to the pager program.
*/
#ifdef TIOCGWINSZ
if (ioctl(fileno(stdout), TIOCGWINSZ, &screen_size) == -1 ||
@@ -195,8 +195,8 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
sigpipe_masked = true;
#else
oldsigpipehandler = pqsignal(SIGPIPE, SIG_IGN);
-#endif /* ENABLE_THREAD_SAFETY */
-#endif /* WIN32 */
+#endif /* ENABLE_THREAD_SAFETY */
+#endif /* WIN32 */
}
else
fout = stdout;
@@ -256,7 +256,7 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
{
if (po->html3)
fprintf(fout,
- "<table %s><caption align=high>%d</caption>\n",
+ "<table %s><caption align=high>%d</caption>\n",
po->tableOpt ? po->tableOpt : "", i);
else
fprintf(fout, libpq_gettext("-- RECORD %d --\n"), i);
@@ -276,7 +276,7 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
{
if (po->caption)
fprintf(fout,
- "<table %s><caption align=high>%s</caption>\n",
+ "<table %s><caption align=high>%s</caption>\n",
po->tableOpt ? po->tableOpt : "",
po->caption);
else
@@ -284,7 +284,7 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
"<table %s><caption align=high>"
"Retrieved %d rows * %d fields"
"</caption>\n",
- po->tableOpt ? po->tableOpt : "", nTups, nFields);
+ po->tableOpt ? po->tableOpt : "", nTups, nFields);
}
else
fprintf(fout, "<table %s>", po->tableOpt ? po->tableOpt : "");
@@ -311,15 +311,15 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
_pclose(fout);
#else
pclose(fout);
-
+
#ifdef ENABLE_THREAD_SAFETY
/* we can't easily verify if EPIPE occurred, so say it did */
if (sigpipe_masked)
pq_reset_sigpipe(&osigset, sigpipe_pending, true);
#else
pqsignal(SIGPIPE, oldsigpipehandler);
-#endif /* ENABLE_THREAD_SAFETY */
-#endif /* WIN32 */
+#endif /* ENABLE_THREAD_SAFETY */
+#endif /* WIN32 */
}
if (po->html3 && !po->expanded)
fputs("</table>\n", fout);
@@ -380,9 +380,9 @@ do_field(const PQprintOpt *po, const PGresult *res,
}
/*
- * Above loop will believe E in first column is numeric; also,
- * we insist on a digit in the last column for a numeric. This
- * test is still not bulletproof but it handles most cases.
+ * Above loop will believe E in first column is numeric; also, we
+ * insist on a digit in the last column for a numeric. This test
+ * is still not bulletproof but it handles most cases.
*/
if (*pval == 'E' || *pval == 'e' ||
!(ch >= '0' && ch <= '9'))
@@ -547,7 +547,7 @@ output_row(FILE *fout, const PQprintOpt *po, const int nFields, char **fields,
if (po->html3)
fprintf(fout, "<td align=%s>%s</td>",
- fieldNotNum[field_index] ? "left" : "right", p ? p : "");
+ fieldNotNum[field_index] ? "left" : "right", p ? p : "");
else
{
fprintf(fout,
@@ -678,8 +678,7 @@ PQprintTuples(const PGresult *res,
FILE *fout, /* output stream */
int PrintAttNames, /* print attribute names or not */
int TerseOutput, /* delimiter bars or not? */
- int colWidth /* width of column, if 0, use variable
- * width */
+ int colWidth /* width of column, if 0, use variable width */
)
{
int nFields;
diff --git a/src/interfaces/libpq/fe-protocol2.c b/src/interfaces/libpq/fe-protocol2.c
index b5753dba44..8e3614ac07 100644
--- a/src/interfaces/libpq/fe-protocol2.c
+++ b/src/interfaces/libpq/fe-protocol2.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.18 2005/06/12 00:00:21 neilc Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.19 2005/10/15 02:49:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -89,7 +89,7 @@ pqSetenvPoll(PGconn *conn)
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
"invalid setenv state %c, "
- "probably indicative of memory corruption\n"
+ "probably indicative of memory corruption\n"
),
conn->setenv_state);
goto error_return;
@@ -104,8 +104,8 @@ pqSetenvPoll(PGconn *conn)
{
/*
* Send SET commands for stuff directed by Environment
- * Options. Note: we assume that SET commands won't
- * start transaction blocks, even in a 7.3 server with
+ * Options. Note: we assume that SET commands won't start
+ * transaction blocks, even in a 7.3 server with
* autocommit off.
*/
char setQuery[100]; /* note length limit in
@@ -125,7 +125,7 @@ pqSetenvPoll(PGconn *conn)
conn->next_eo->pgName, val);
#ifdef CONNECTDEBUG
fprintf(stderr,
- "Use environment variable %s to send %s\n",
+ "Use environment variable %s to send %s\n",
conn->next_eo->envName, setQuery);
#endif
if (!PQsendQuery(conn, setQuery))
@@ -173,9 +173,9 @@ pqSetenvPoll(PGconn *conn)
case SETENV_STATE_QUERY1_SEND:
{
/*
- * Issue query to get information we need. Here we
- * must use begin/commit in case autocommit is off by
- * default in a 7.3 server.
+ * Issue query to get information we need. Here we must
+ * use begin/commit in case autocommit is off by default
+ * in a 7.3 server.
*
* Note: version() exists in all protocol-2.0-supporting
* backends. In 7.3 it would be safer to write
@@ -227,8 +227,8 @@ pqSetenvPoll(PGconn *conn)
val += 11;
/*
- * strip off platform part (scribbles on
- * result, naughty naughty)
+ * strip off platform part (scribbles on result,
+ * naughty naughty)
*/
ptr = strchr(val, ' ');
if (ptr)
@@ -254,11 +254,11 @@ pqSetenvPoll(PGconn *conn)
const char *query;
/*
- * pg_client_encoding does not exist in pre-7.2
- * servers. So we need to be prepared for an error
- * here. Do *not* start a transaction block, except
- * in 7.3 servers where we need to prevent
- * autocommit-off from starting a transaction anyway.
+ * pg_client_encoding does not exist in pre-7.2 servers.
+ * So we need to be prepared for an error here. Do *not*
+ * start a transaction block, except in 7.3 servers where
+ * we need to prevent autocommit-off from starting a
+ * transaction anyway.
*/
if (conn->sversion >= 70300 &&
conn->sversion < 70400)
@@ -295,16 +295,15 @@ pqSetenvPoll(PGconn *conn)
{
/* Extract client encoding and save it */
val = PQgetvalue(res, 0, 0);
- if (val && *val) /* null should not happen,
- * but */
+ if (val && *val) /* null should not happen, but */
pqSaveParameterStatus(conn, "client_encoding",
val);
}
else
{
/*
- * Error: presumably function not available,
- * so use PGCLIENTENCODING or SQL_ASCII as the
+ * Error: presumably function not available, so
+ * use PGCLIENTENCODING or SQL_ASCII as the
* fallback.
*/
val = getenv("PGCLIENTENCODING");
@@ -331,7 +330,7 @@ pqSetenvPoll(PGconn *conn)
default:
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("invalid state %c, "
- "probably indicative of memory corruption\n"),
+ "probably indicative of memory corruption\n"),
conn->setenv_state);
goto error_return;
}
@@ -361,11 +360,10 @@ pqParseInput2(PGconn *conn)
for (;;)
{
/*
- * Quit if in COPY_OUT state: we expect raw data from the server
- * until PQendcopy is called. Don't try to parse it according to
- * the normal protocol. (This is bogus. The data lines ought to
- * be part of the protocol and have identifying leading
- * characters.)
+ * Quit if in COPY_OUT state: we expect raw data from the server until
+ * PQendcopy is called. Don't try to parse it according to the normal
+ * protocol. (This is bogus. The data lines ought to be part of the
+ * protocol and have identifying leading characters.)
*/
if (conn->asyncStatus == PGASYNC_COPY_OUT)
return;
@@ -381,9 +379,9 @@ pqParseInput2(PGconn *conn)
* NOTIFY and NOTICE messages can happen in any state besides COPY
* OUT; always process them right away.
*
- * Most other messages should only be processed while in BUSY state.
- * (In particular, in READY state we hold off further parsing
- * until the application collects the current PGresult.)
+ * Most other messages should only be processed while in BUSY state. (In
+ * particular, in READY state we hold off further parsing until the
+ * application collects the current PGresult.)
*
* However, if the state is IDLE then we got trouble; we need to deal
* with the unexpected message somehow.
@@ -407,10 +405,10 @@ pqParseInput2(PGconn *conn)
/*
* Unexpected message in IDLE state; need to recover somehow.
* ERROR messages are displayed using the notice processor;
- * anything else is just dropped on the floor after displaying
- * a suitable warning notice. (An ERROR is very possibly the
- * backend telling us why it is about to close the connection,
- * so we don't want to just discard it...)
+ * anything else is just dropped on the floor after displaying a
+ * suitable warning notice. (An ERROR is very possibly the
+ * backend telling us why it is about to close the connection, so
+ * we don't want to just discard it...)
*/
if (id == 'E')
{
@@ -420,7 +418,7 @@ pqParseInput2(PGconn *conn)
else
{
pqInternalNotice(&conn->noticeHooks,
- "message type 0x%02x arrived from server while idle",
+ "message type 0x%02x arrived from server while idle",
id);
/* Discard the unexpected message; good idea?? */
conn->inStart = conn->inEnd;
@@ -440,7 +438,7 @@ pqParseInput2(PGconn *conn)
if (conn->result == NULL)
{
conn->result = PQmakeEmptyPGresult(conn,
- PGRES_COMMAND_OK);
+ PGRES_COMMAND_OK);
if (!conn->result)
return;
}
@@ -467,15 +465,15 @@ pqParseInput2(PGconn *conn)
id);
if (conn->result == NULL)
conn->result = PQmakeEmptyPGresult(conn,
- PGRES_EMPTY_QUERY);
+ PGRES_EMPTY_QUERY);
conn->asyncStatus = PGASYNC_READY;
break;
case 'K': /* secret key data from the backend */
/*
- * This is expected only during backend startup, but
- * it's just as easy to handle it as part of the main
- * loop. Save the data and continue processing.
+ * This is expected only during backend startup, but it's
+ * just as easy to handle it as part of the main loop.
+ * Save the data and continue processing.
*/
if (pqGetInt(&(conn->be_pid), 4, conn))
return;
@@ -487,8 +485,7 @@ pqParseInput2(PGconn *conn)
return;
/* We pretty much ignore this message type... */
break;
- case 'T': /* row descriptions (start of query
- * results) */
+ case 'T': /* row descriptions (start of query results) */
if (conn->result == NULL)
{
/* First 'T' in a query sequence */
@@ -499,10 +496,10 @@ pqParseInput2(PGconn *conn)
{
/*
* A new 'T' message is treated as the start of
- * another PGresult. (It is not clear that this
- * is really possible with the current backend.)
- * We stop parsing until the application accepts
- * the current result.
+ * another PGresult. (It is not clear that this is
+ * really possible with the current backend.) We stop
+ * parsing until the application accepts the current
+ * result.
*/
conn->asyncStatus = PGASYNC_READY;
return;
@@ -679,8 +676,8 @@ getAnotherTuple(PGconn *conn, bool binary)
MemSet(conn->curTuple, 0, nfields * sizeof(PGresAttValue));
/*
- * If it's binary, fix the column format indicators. We assume
- * the backend will consistently send either B or D, not a mix.
+ * If it's binary, fix the column format indicators. We assume the
+ * backend will consistently send either B or D, not a mix.
*/
if (binary)
{
@@ -765,16 +762,16 @@ outOfMemory:
/* Replace partially constructed result with an error result */
/*
- * we do NOT use pqSaveErrorResult() here, because of the likelihood
- * that there's not enough memory to concatenate messages...
+ * we do NOT use pqSaveErrorResult() here, because of the likelihood that
+ * there's not enough memory to concatenate messages...
*/
pqClearAsyncResult(conn);
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("out of memory for query result\n"));
/*
- * XXX: if PQmakeEmptyPGresult() fails, there's probably not much
- * we can do to recover...
+ * XXX: if PQmakeEmptyPGresult() fails, there's probably not much we can
+ * do to recover...
*/
conn->result = PQmakeEmptyPGresult(conn, PGRES_FATAL_ERROR);
conn->asyncStatus = PGASYNC_READY;
@@ -805,8 +802,8 @@ pqGetErrorNotice2(PGconn *conn, bool isError)
/*
* Since the message might be pretty long, we create a temporary
- * PQExpBuffer rather than using conn->workBuffer. workBuffer is
- * intended for stuff that is expected to be short.
+ * PQExpBuffer rather than using conn->workBuffer. workBuffer is intended
+ * for stuff that is expected to be short.
*/
initPQExpBuffer(&workBuf);
if (pqGets(&workBuf, conn))
@@ -826,12 +823,12 @@ pqGetErrorNotice2(PGconn *conn, bool isError)
goto failure;
/*
- * Break the message into fields. We can't do very much here, but we
- * can split the severity code off, and remove trailing newlines.
- * Also, we use the heuristic that the primary message extends only to
- * the first newline --- anything after that is detail message. (In
- * some cases it'd be better classed as hint, but we can hardly be
- * expected to guess that here.)
+ * Break the message into fields. We can't do very much here, but we can
+ * split the severity code off, and remove trailing newlines. Also, we use
+ * the heuristic that the primary message extends only to the first
+ * newline --- anything after that is detail message. (In some cases it'd
+ * be better classed as hint, but we can hardly be expected to guess that
+ * here.)
*/
while (workBuf.len > 0 && workBuf.data[workBuf.len - 1] == '\n')
workBuf.data[--workBuf.len] = '\0';
@@ -867,8 +864,8 @@ pqGetErrorNotice2(PGconn *conn, bool isError)
/*
* Either save error as current async result, or just emit the notice.
- * Also, if it's an error and we were in a transaction block, assume
- * the server has now gone to error-in-transaction state.
+ * Also, if it's an error and we were in a transaction block, assume the
+ * server has now gone to error-in-transaction state.
*/
if (isError)
{
@@ -922,8 +919,8 @@ checkXactStatus(PGconn *conn, const char *cmdTag)
/*
* Normally we get into INERROR state by detecting an Error message.
- * However, if we see one of these tags then we know for sure the
- * server is in abort state ...
+ * However, if we see one of these tags then we know for sure the server
+ * is in abort state ...
*/
else if (strcmp(cmdTag, "*ABORT STATE*") == 0) /* pre-7.3 only */
conn->xactStatus = PQTRANS_INERROR;
@@ -949,9 +946,9 @@ getNotify(PGconn *conn)
return EOF;
/*
- * Store the relation name right after the PQnotify structure so it
- * can all be freed at once. We don't use NAMEDATALEN because we
- * don't want to tie this interface to a specific server name length.
+ * Store the relation name right after the PQnotify structure so it can
+ * all be freed at once. We don't use NAMEDATALEN because we don't want
+ * to tie this interface to a specific server name length.
*/
nmlen = strlen(conn->workBuffer.data);
newNotify = (PGnotify *) malloc(sizeof(PGnotify) + nmlen + 1);
@@ -1011,8 +1008,8 @@ pqGetCopyData2(PGconn *conn, char **buffer, int async)
msgLength = conn->inCursor - conn->inStart;
/*
- * If it's the end-of-data marker, consume it, exit COPY_OUT mode,
- * and let caller read status with PQgetResult().
+ * If it's the end-of-data marker, consume it, exit COPY_OUT mode, and
+ * let caller read status with PQgetResult().
*/
if (msgLength == 3 &&
strncmp(&conn->inBuffer[conn->inStart], "\\.\n", 3) == 0)
@@ -1069,8 +1066,8 @@ pqGetline2(PGconn *conn, char *s, int maxlen)
}
/*
- * Since this is a purely synchronous routine, we don't bother to
- * maintain conn->inCursor; there is no need to back up.
+ * Since this is a purely synchronous routine, we don't bother to maintain
+ * conn->inCursor; there is no need to back up.
*/
while (maxlen > 1)
{
@@ -1116,11 +1113,11 @@ pqGetlineAsync2(PGconn *conn, char *buffer, int bufsize)
return -1; /* we are not doing a copy... */
/*
- * Move data from libpq's buffer to the caller's. We want to accept
- * data only in units of whole lines, not partial lines. This ensures
- * that we can recognize the terminator line "\\.\n". (Otherwise, if
- * it happened to cross a packet/buffer boundary, we might hand the
- * first one or two characters off to the caller, which we shouldn't.)
+ * Move data from libpq's buffer to the caller's. We want to accept data
+ * only in units of whole lines, not partial lines. This ensures that we
+ * can recognize the terminator line "\\.\n". (Otherwise, if it happened
+ * to cross a packet/buffer boundary, we might hand the first one or two
+ * characters off to the caller, which we shouldn't.)
*/
conn->inCursor = conn->inStart;
@@ -1146,12 +1143,11 @@ pqGetlineAsync2(PGconn *conn, char *buffer, int bufsize)
/*
* We don't have a complete line. We'd prefer to leave it in libpq's
- * buffer until the rest arrives, but there is a special case: what if
- * the line is longer than the buffer the caller is offering us? In
- * that case we'd better hand over a partial line, else we'd get into
- * an infinite loop. Do this in a way that ensures we can't
- * misrecognize a terminator line later: leave last 3 characters in
- * libpq buffer.
+ * buffer until the rest arrives, but there is a special case: what if the
+ * line is longer than the buffer the caller is offering us? In that case
+ * we'd better hand over a partial line, else we'd get into an infinite
+ * loop. Do this in a way that ensures we can't misrecognize a terminator
+ * line later: leave last 3 characters in libpq buffer.
*/
if (avail == 0 && bufsize > 3)
{
@@ -1180,8 +1176,8 @@ pqEndcopy2(PGconn *conn)
}
/*
- * make sure no data is waiting to be sent, abort if we are
- * non-blocking and the flush fails
+ * make sure no data is waiting to be sent, abort if we are non-blocking
+ * and the flush fails
*/
if (pqFlush(conn) && pqIsnonblocking(conn))
return (1);
@@ -1208,8 +1204,8 @@ pqEndcopy2(PGconn *conn)
* Trouble. For backwards-compatibility reasons, we issue the error
* message as if it were a notice (would be nice to get rid of this
* silliness, but too many apps probably don't handle errors from
- * PQendcopy reasonably). Note that the app can still obtain the
- * error status from the PGconn object.
+ * PQendcopy reasonably). Note that the app can still obtain the error
+ * status from the PGconn object.
*/
if (conn->errorMessage.len > 0)
{
@@ -1225,17 +1221,17 @@ pqEndcopy2(PGconn *conn)
PQclear(result);
/*
- * The worst case is that we've lost sync with the backend entirely
- * due to application screwup of the copy in/out protocol. To recover,
- * reset the connection (talk about using a sledgehammer...)
+ * The worst case is that we've lost sync with the backend entirely due to
+ * application screwup of the copy in/out protocol. To recover, reset the
+ * connection (talk about using a sledgehammer...)
*/
pqInternalNotice(&conn->noticeHooks,
- "lost synchronization with server, resetting connection");
+ "lost synchronization with server, resetting connection");
/*
* Users doing non-blocking connections need to handle the reset
- * themselves, they'll need to check the connection status if we
- * return an error.
+ * themselves, they'll need to check the connection status if we return an
+ * error.
*/
if (pqIsnonblocking(conn))
PQresetStart(conn);
@@ -1317,8 +1313,7 @@ pqFunctionCall2(PGconn *conn, Oid fnid,
}
/*
- * Scan the message. If we run out of data, loop around to try
- * again.
+ * Scan the message. If we run out of data, loop around to try again.
*/
conn->inCursor = conn->inStart;
needInput = true;
@@ -1328,8 +1323,8 @@ pqFunctionCall2(PGconn *conn, Oid fnid,
/*
* We should see V or E response to the command, but might get N
- * and/or A notices first. We also need to swallow the final Z
- * before returning.
+ * and/or A notices first. We also need to swallow the final Z before
+ * returning.
*/
switch (id)
{
@@ -1365,7 +1360,7 @@ pqFunctionCall2(PGconn *conn, Oid fnid,
{
/* The backend violates the protocol. */
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("protocol error: id=0x%x\n"),
+ libpq_gettext("protocol error: id=0x%x\n"),
id);
pqSaveErrorResult(conn);
conn->inStart = conn->inCursor;
@@ -1397,7 +1392,7 @@ pqFunctionCall2(PGconn *conn, Oid fnid,
default:
/* The backend violates the protocol. */
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("protocol error: id=0x%x\n"),
+ libpq_gettext("protocol error: id=0x%x\n"),
id);
pqSaveErrorResult(conn);
conn->inStart = conn->inCursor;
@@ -1425,7 +1420,7 @@ pqFunctionCall2(PGconn *conn, Oid fnid,
*/
char *
pqBuildStartupPacket2(PGconn *conn, int *packetlen,
- const PQEnvironmentOption *options)
+ const PQEnvironmentOption * options)
{
StartupPacket *startpacket;
diff --git a/src/interfaces/libpq/fe-protocol3.c b/src/interfaces/libpq/fe-protocol3.c
index 273159f430..d3af5ad447 100644
--- a/src/interfaces/libpq/fe-protocol3.c
+++ b/src/interfaces/libpq/fe-protocol3.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.21 2005/06/12 00:00:21 neilc Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.22 2005/10/15 02:49:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -51,8 +51,8 @@ static int getParameterStatus(PGconn *conn);
static int getNotify(PGconn *conn);
static int getCopyStart(PGconn *conn, ExecStatusType copytype);
static int getReadyForQuery(PGconn *conn);
-static int build_startup_packet(const PGconn *conn, char *packet,
- const PQEnvironmentOption *options);
+static int build_startup_packet(const PGconn *conn, char *packet,
+ const PQEnvironmentOption * options);
/*
@@ -73,8 +73,8 @@ pqParseInput3(PGconn *conn)
for (;;)
{
/*
- * Try to read a message. First get the type code and length.
- * Return if not enough data.
+ * Try to read a message. First get the type code and length. Return
+ * if not enough data.
*/
conn->inCursor = conn->inStart;
if (pqGetc(&id, conn))
@@ -83,9 +83,9 @@ pqParseInput3(PGconn *conn)
return;
/*
- * Try to validate message type/length here. A length less than 4
- * is definitely broken. Large lengths should only be believed
- * for a few message types.
+ * Try to validate message type/length here. A length less than 4 is
+ * definitely broken. Large lengths should only be believed for a few
+ * message types.
*/
if (msgLength < 4)
{
@@ -106,20 +106,20 @@ pqParseInput3(PGconn *conn)
if (avail < msgLength)
{
/*
- * Before returning, enlarge the input buffer if needed to
- * hold the whole message. This is better than leaving it to
- * pqReadData because we can avoid multiple cycles of
- * realloc() when the message is large; also, we can implement
- * a reasonable recovery strategy if we are unable to make the
- * buffer big enough.
+ * Before returning, enlarge the input buffer if needed to hold
+ * the whole message. This is better than leaving it to
+ * pqReadData because we can avoid multiple cycles of realloc()
+ * when the message is large; also, we can implement a reasonable
+ * recovery strategy if we are unable to make the buffer big
+ * enough.
*/
if (pqCheckInBufferSpace(conn->inCursor + msgLength, conn))
{
/*
- * XXX add some better recovery code... plan is to skip
- * over the message using its length, then report an
- * error. For the moment, just treat this like loss of
- * sync (which indeed it might be!)
+ * XXX add some better recovery code... plan is to skip over
+ * the message using its length, then report an error. For the
+ * moment, just treat this like loss of sync (which indeed it
+ * might be!)
*/
handleSyncLoss(conn, id, msgLength);
}
@@ -127,20 +127,20 @@ pqParseInput3(PGconn *conn)
}
/*
- * NOTIFY and NOTICE messages can happen in any state; always
- * process them right away.
+ * NOTIFY and NOTICE messages can happen in any state; always process
+ * them right away.
*
- * Most other messages should only be processed while in BUSY state.
- * (In particular, in READY state we hold off further parsing
- * until the application collects the current PGresult.)
+ * Most other messages should only be processed while in BUSY state. (In
+ * particular, in READY state we hold off further parsing until the
+ * application collects the current PGresult.)
*
* However, if the state is IDLE then we got trouble; we need to deal
* with the unexpected message somehow.
*
- * ParameterStatus ('S') messages are a special case: in IDLE state
- * we must process 'em (this case could happen if a new value was
- * adopted from config file due to SIGHUP), but otherwise we hold
- * off until BUSY state.
+ * ParameterStatus ('S') messages are a special case: in IDLE state we
+ * must process 'em (this case could happen if a new value was adopted
+ * from config file due to SIGHUP), but otherwise we hold off until
+ * BUSY state.
*/
if (id == 'A')
{
@@ -163,9 +163,9 @@ pqParseInput3(PGconn *conn)
* ERROR messages are displayed using the notice processor;
* ParameterStatus is handled normally; anything else is just
* dropped on the floor after displaying a suitable warning
- * notice. (An ERROR is very possibly the backend telling us
- * why it is about to close the connection, so we don't want
- * to just discard it...)
+ * notice. (An ERROR is very possibly the backend telling us why
+ * it is about to close the connection, so we don't want to just
+ * discard it...)
*/
if (id == 'E')
{
@@ -180,7 +180,7 @@ pqParseInput3(PGconn *conn)
else
{
pqInternalNotice(&conn->noticeHooks,
- "message type 0x%02x arrived from server while idle",
+ "message type 0x%02x arrived from server while idle",
id);
/* Discard the unexpected message */
conn->inCursor += msgLength;
@@ -199,7 +199,7 @@ pqParseInput3(PGconn *conn)
if (conn->result == NULL)
{
conn->result = PQmakeEmptyPGresult(conn,
- PGRES_COMMAND_OK);
+ PGRES_COMMAND_OK);
if (!conn->result)
return;
}
@@ -221,7 +221,7 @@ pqParseInput3(PGconn *conn)
if (conn->result == NULL)
{
conn->result = PQmakeEmptyPGresult(conn,
- PGRES_EMPTY_QUERY);
+ PGRES_EMPTY_QUERY);
if (!conn->result)
return;
}
@@ -234,7 +234,7 @@ pqParseInput3(PGconn *conn)
if (conn->result == NULL)
{
conn->result = PQmakeEmptyPGresult(conn,
- PGRES_COMMAND_OK);
+ PGRES_COMMAND_OK);
if (!conn->result)
return;
}
@@ -252,9 +252,9 @@ pqParseInput3(PGconn *conn)
case 'K': /* secret key data from the backend */
/*
- * This is expected only during backend startup, but
- * it's just as easy to handle it as part of the main
- * loop. Save the data and continue processing.
+ * This is expected only during backend startup, but it's
+ * just as easy to handle it as part of the main loop.
+ * Save the data and continue processing.
*/
if (pqGetInt(&(conn->be_pid), 4, conn))
return;
@@ -272,10 +272,10 @@ pqParseInput3(PGconn *conn)
{
/*
* A new 'T' message is treated as the start of
- * another PGresult. (It is not clear that this
- * is really possible with the current backend.)
- * We stop parsing until the application accepts
- * the current result.
+ * another PGresult. (It is not clear that this is
+ * really possible with the current backend.) We stop
+ * parsing until the application accepts the current
+ * result.
*/
conn->asyncStatus = PGASYNC_READY;
return;
@@ -285,13 +285,13 @@ pqParseInput3(PGconn *conn)
/*
* NoData indicates that we will not be seeing a
- * RowDescription message because the statement or
- * portal inquired about doesn't return rows. Set up a
- * COMMAND_OK result, instead of TUPLES_OK.
+ * RowDescription message because the statement or portal
+ * inquired about doesn't return rows. Set up a COMMAND_OK
+ * result, instead of TUPLES_OK.
*/
if (conn->result == NULL)
conn->result = PQmakeEmptyPGresult(conn,
- PGRES_COMMAND_OK);
+ PGRES_COMMAND_OK);
break;
case 'D': /* Data Row */
if (conn->result != NULL &&
@@ -302,12 +302,11 @@ pqParseInput3(PGconn *conn)
return;
}
else if (conn->result != NULL &&
- conn->result->resultStatus == PGRES_FATAL_ERROR)
+ conn->result->resultStatus == PGRES_FATAL_ERROR)
{
/*
- * We've already choked for some reason. Just
- * discard tuples till we get to the end of the
- * query.
+ * We've already choked for some reason. Just discard
+ * tuples till we get to the end of the query.
*/
conn->inCursor += msgLength;
}
@@ -335,19 +334,19 @@ pqParseInput3(PGconn *conn)
case 'd': /* Copy Data */
/*
- * If we see Copy Data, just silently drop it. This
- * would only occur if application exits COPY OUT mode
- * too early.
+ * If we see Copy Data, just silently drop it. This would
+ * only occur if application exits COPY OUT mode too
+ * early.
*/
conn->inCursor += msgLength;
break;
case 'c': /* Copy Done */
/*
- * If we see Copy Done, just silently drop it. This
- * is the normal case during PQendcopy. We will keep
- * swallowing data, expecting to see command-complete
- * for the COPY command.
+ * If we see Copy Done, just silently drop it. This is
+ * the normal case during PQendcopy. We will keep
+ * swallowing data, expecting to see command-complete for
+ * the COPY command.
*/
break;
default:
@@ -395,7 +394,7 @@ handleSyncLoss(PGconn *conn, char id, int msgLength)
{
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "lost synchronization with server: got message type \"%c\", length %d\n"),
+ "lost synchronization with server: got message type \"%c\", length %d\n"),
id, msgLength);
/* build an error result holding the error message */
pqSaveErrorResult(conn);
@@ -618,16 +617,16 @@ pqGetErrorNotice3(PGconn *conn, bool isError)
/*
* Since the fields might be pretty long, we create a temporary
- * PQExpBuffer rather than using conn->workBuffer. workBuffer is
- * intended for stuff that is expected to be short. We shouldn't use
+ * PQExpBuffer rather than using conn->workBuffer. workBuffer is intended
+ * for stuff that is expected to be short. We shouldn't use
* conn->errorMessage either, since this might be only a notice.
*/
initPQExpBuffer(&workBuf);
/*
* Make a PGresult to hold the accumulated fields. We temporarily lie
- * about the result status, so that PQmakeEmptyPGresult doesn't
- * uselessly copy conn->errorMessage.
+ * about the result status, so that PQmakeEmptyPGresult doesn't uselessly
+ * copy conn->errorMessage.
*/
res = PQmakeEmptyPGresult(conn, PGRES_EMPTY_QUERY);
if (!res)
@@ -808,9 +807,9 @@ getNotify(PGconn *conn)
}
/*
- * Store the strings right after the PQnotify structure so it can all
- * be freed at once. We don't use NAMEDATALEN because we don't want
- * to tie this interface to a specific server name length.
+ * Store the strings right after the PQnotify structure so it can all be
+ * freed at once. We don't use NAMEDATALEN because we don't want to tie
+ * this interface to a specific server name length.
*/
nmlen = strlen(svname);
extralen = strlen(conn->workBuffer.data);
@@ -940,9 +939,9 @@ pqGetCopyData3(PGconn *conn, char **buffer, int async)
for (;;)
{
/*
- * Do we have the next input message? To make life simpler for
- * async callers, we keep returning 0 until the next message is
- * fully available, even if it is not Copy Data.
+ * Do we have the next input message? To make life simpler for async
+ * callers, we keep returning 0 until the next message is fully
+ * available, even if it is not Copy Data.
*/
conn->inCursor = conn->inStart;
if (pqGetc(&id, conn))
@@ -1017,7 +1016,7 @@ pqGetline3(PGconn *conn, char *s, int maxlen)
conn->copy_is_binary)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("PQgetline: not doing text COPY OUT\n"));
+ libpq_gettext("PQgetline: not doing text COPY OUT\n"));
*s = '\0';
return EOF;
}
@@ -1070,9 +1069,8 @@ pqGetlineAsync3(PGconn *conn, char *buffer, int bufsize)
/*
* Recognize the next input message. To make life simpler for async
- * callers, we keep returning 0 until the next message is fully
- * available even if it is not Copy Data. This should keep PQendcopy
- * from blocking.
+ * callers, we keep returning 0 until the next message is fully available
+ * even if it is not Copy Data. This should keep PQendcopy from blocking.
*/
conn->inCursor = conn->inStart;
if (pqGetc(&id, conn))
@@ -1084,8 +1082,8 @@ pqGetlineAsync3(PGconn *conn, char *buffer, int bufsize)
return 0;
/*
- * Cannot proceed unless it's a Copy Data message. Anything else
- * means end of copy mode.
+ * Cannot proceed unless it's a Copy Data message. Anything else means
+ * end of copy mode.
*/
if (id != 'd')
return -1;
@@ -1144,8 +1142,8 @@ pqEndcopy3(PGconn *conn)
return 1;
/*
- * If we sent the COPY command in extended-query mode, we must
- * issue a Sync as well.
+ * If we sent the COPY command in extended-query mode, we must issue a
+ * Sync as well.
*/
if (conn->queryclass != PGQUERY_SIMPLE)
{
@@ -1156,8 +1154,8 @@ pqEndcopy3(PGconn *conn)
}
/*
- * make sure no data is waiting to be sent, abort if we are
- * non-blocking and the flush fails
+ * make sure no data is waiting to be sent, abort if we are non-blocking
+ * and the flush fails
*/
if (pqFlush(conn) && pqIsnonblocking(conn))
return (1);
@@ -1167,12 +1165,11 @@ pqEndcopy3(PGconn *conn)
resetPQExpBuffer(&conn->errorMessage);
/*
- * Non blocking connections may have to abort at this point. If
- * everyone played the game there should be no problem, but in error
- * scenarios the expected messages may not have arrived yet. (We are
- * assuming that the backend's packetizing will ensure that
- * CommandComplete arrives along with the CopyDone; are there corner
- * cases where that doesn't happen?)
+ * Non blocking connections may have to abort at this point. If everyone
+ * played the game there should be no problem, but in error scenarios the
+ * expected messages may not have arrived yet. (We are assuming that the
+ * backend's packetizing will ensure that CommandComplete arrives along
+ * with the CopyDone; are there corner cases where that doesn't happen?)
*/
if (pqIsnonblocking(conn) && PQisBusy(conn))
return (1);
@@ -1191,8 +1188,8 @@ pqEndcopy3(PGconn *conn)
* Trouble. For backwards-compatibility reasons, we issue the error
* message as if it were a notice (would be nice to get rid of this
* silliness, but too many apps probably don't handle errors from
- * PQendcopy reasonably). Note that the app can still obtain the
- * error status from the PGconn object.
+ * PQendcopy reasonably). Note that the app can still obtain the error
+ * status from the PGconn object.
*/
if (conn->errorMessage.len > 0)
{
@@ -1293,8 +1290,7 @@ pqFunctionCall3(PGconn *conn, Oid fnid,
}
/*
- * Scan the message. If we run out of data, loop around to try
- * again.
+ * Scan the message. If we run out of data, loop around to try again.
*/
needInput = true;
@@ -1305,9 +1301,9 @@ pqFunctionCall3(PGconn *conn, Oid fnid,
continue;
/*
- * Try to validate message type/length here. A length less than 4
- * is definitely broken. Large lengths should only be believed
- * for a few message types.
+ * Try to validate message type/length here. A length less than 4 is
+ * definitely broken. Large lengths should only be believed for a few
+ * message types.
*/
if (msgLength < 4)
{
@@ -1328,16 +1324,16 @@ pqFunctionCall3(PGconn *conn, Oid fnid,
if (avail < msgLength)
{
/*
- * Before looping, enlarge the input buffer if needed to hold
- * the whole message. See notes in parseInput.
+ * Before looping, enlarge the input buffer if needed to hold the
+ * whole message. See notes in parseInput.
*/
if (pqCheckInBufferSpace(conn->inCursor + msgLength, conn))
{
/*
- * XXX add some better recovery code... plan is to skip
- * over the message using its length, then report an
- * error. For the moment, just treat this like loss of
- * sync (which indeed it might be!)
+ * XXX add some better recovery code... plan is to skip over
+ * the message using its length, then report an error. For the
+ * moment, just treat this like loss of sync (which indeed it
+ * might be!)
*/
handleSyncLoss(conn, id, msgLength);
break;
@@ -1347,8 +1343,8 @@ pqFunctionCall3(PGconn *conn, Oid fnid,
/*
* We should see V or E response to the command, but might get N
- * and/or A notices first. We also need to swallow the final Z
- * before returning.
+ * and/or A notices first. We also need to swallow the final Z before
+ * returning.
*/
switch (id)
{
@@ -1404,7 +1400,7 @@ pqFunctionCall3(PGconn *conn, Oid fnid,
default:
/* The backend violates the protocol. */
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("protocol error: id=0x%x\n"),
+ libpq_gettext("protocol error: id=0x%x\n"),
id);
pqSaveErrorResult(conn);
/* trust the specified message length as what to skip */
@@ -1434,7 +1430,7 @@ pqFunctionCall3(PGconn *conn, Oid fnid,
*/
char *
pqBuildStartupPacket3(PGconn *conn, int *packetlen,
- const PQEnvironmentOption *options)
+ const PQEnvironmentOption * options)
{
char *startpacket;
@@ -1457,7 +1453,7 @@ pqBuildStartupPacket3(PGconn *conn, int *packetlen,
*/
static int
build_startup_packet(const PGconn *conn, char *packet,
- const PQEnvironmentOption *options)
+ const PQEnvironmentOption * options)
{
int packet_len = 0;
const PQEnvironmentOption *next_eo;
diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c
index 4ef11616ae..316ea4ac26 100644
--- a/src/interfaces/libpq/fe-secure.c
+++ b/src/interfaces/libpq/fe-secure.c
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.71 2005/08/28 16:37:48 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.72 2005/10/15 02:49:48 momjian Exp $
*
* NOTES
* [ Most of these notes are wrong/obsolete, but perhaps not all ]
@@ -274,15 +274,16 @@ pqsecure_open_client(PGconn *conn)
char *err = SSLerrmessage();
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not establish SSL connection: %s\n"),
+ libpq_gettext("could not establish SSL connection: %s\n"),
err);
SSLerrfree(err);
close_SSL(conn);
return PGRES_POLLING_FAILED;
}
+
/*
- * Initialize errorMessage to empty. This allows open_client_SSL()
- * to detect whether client_cert_cb() has stored a message.
+ * Initialize errorMessage to empty. This allows open_client_SSL() to
+ * detect whether client_cert_cb() has stored a message.
*/
resetPQExpBuffer(&conn->errorMessage);
}
@@ -332,11 +333,10 @@ rloop:
case SSL_ERROR_WANT_WRITE:
/*
- * Returning 0 here would cause caller to wait for
- * read-ready, which is not correct since what SSL wants
- * is wait for write-ready. The former could get us stuck
- * in an infinite wait, so don't risk it; busy-loop
- * instead.
+ * Returning 0 here would cause caller to wait for read-ready,
+ * which is not correct since what SSL wants is wait for
+ * write-ready. The former could get us stuck in an infinite
+ * wait, so don't risk it; busy-loop instead.
*/
goto rloop;
case SSL_ERROR_SYSCALL:
@@ -345,12 +345,12 @@ rloop:
if (n == -1)
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL SYSCALL error: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ libpq_gettext("SSL SYSCALL error: %s\n"),
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
else
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL SYSCALL error: EOF detected\n"));
+ libpq_gettext("SSL SYSCALL error: EOF detected\n"));
SOCK_ERRNO_SET(ECONNRESET);
n = -1;
@@ -362,7 +362,7 @@ rloop:
char *err = SSLerrmessage();
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL error: %s\n"), err);
+ libpq_gettext("SSL error: %s\n"), err);
SSLerrfree(err);
}
/* fall through */
@@ -372,7 +372,7 @@ rloop:
break;
default:
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("unrecognized SSL error code: %d\n"),
+ libpq_gettext("unrecognized SSL error code: %d\n"),
err);
n = -1;
break;
@@ -392,21 +392,21 @@ ssize_t
pqsecure_write(PGconn *conn, const void *ptr, size_t len)
{
ssize_t n;
-
-#ifndef WIN32
+
+#ifndef WIN32
#ifdef ENABLE_THREAD_SAFETY
sigset_t osigmask;
bool sigpipe_pending;
bool got_epipe = false;
-
+
if (pq_block_sigpipe(&osigmask, &sigpipe_pending) < 0)
return -1;
#else
pqsigfunc oldsighandler = pqsignal(SIGPIPE, SIG_IGN);
-#endif /* ENABLE_THREAD_SAFETY */
-#endif /* WIN32 */
-
+#endif /* ENABLE_THREAD_SAFETY */
+#endif /* WIN32 */
+
#ifdef USE_SSL
if (conn->ssl)
{
@@ -422,8 +422,8 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
/*
* Returning 0 here causes caller to wait for write-ready,
- * which is not really the right thing, but it's the best
- * we can do.
+ * which is not really the right thing, but it's the best we
+ * can do.
*/
n = 0;
break;
@@ -441,13 +441,13 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
got_epipe = true;
#endif
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL SYSCALL error: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ libpq_gettext("SSL SYSCALL error: %s\n"),
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
}
else
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL SYSCALL error: EOF detected\n"));
+ libpq_gettext("SSL SYSCALL error: EOF detected\n"));
SOCK_ERRNO_SET(ECONNRESET);
n = -1;
}
@@ -458,7 +458,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
char *err = SSLerrmessage();
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL error: %s\n"), err);
+ libpq_gettext("SSL error: %s\n"), err);
SSLerrfree(err);
}
/* fall through */
@@ -468,7 +468,7 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
break;
default:
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("unrecognized SSL error code: %d\n"),
+ libpq_gettext("unrecognized SSL error code: %d\n"),
err);
n = -1;
break;
@@ -483,14 +483,14 @@ pqsecure_write(PGconn *conn, const void *ptr, size_t len)
got_epipe = true;
#endif
}
-
+
#ifndef WIN32
#ifdef ENABLE_THREAD_SAFETY
pq_reset_sigpipe(&osigmask, sigpipe_pending, got_epipe);
#else
pqsignal(SIGPIPE, oldsighandler);
-#endif /* ENABLE_THREAD_SAFETY */
-#endif /* WIN32 */
+#endif /* ENABLE_THREAD_SAFETY */
+#endif /* WIN32 */
return n;
}
@@ -539,7 +539,7 @@ verify_peer(PGconn *conn)
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext("error querying socket: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
return -1;
}
@@ -553,10 +553,9 @@ verify_peer(PGconn *conn)
int herrno = 0;
/*
- * Currently, pqGethostbyname() is used only on platforms that
- * don't have getaddrinfo(). If you enable this function, you
- * should convert the pqGethostbyname() function call to use
- * getaddrinfo().
+ * Currently, pqGethostbyname() is used only on platforms that don't
+ * have getaddrinfo(). If you enable this function, you should
+ * convert the pqGethostbyname() function call to use getaddrinfo().
*/
pqGethostbyname(conn->peer_cn, &hpstr, buf, sizeof(buf),
&h, &herrno);
@@ -566,7 +565,7 @@ verify_peer(PGconn *conn)
if (h == NULL)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not get information about host \"%s\": %s\n"),
+ libpq_gettext("could not get information about host \"%s\": %s\n"),
conn->peer_cn, hstrerror(h_errno));
return -1;
}
@@ -608,19 +607,19 @@ verify_peer(PGconn *conn)
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
"server common name \"%s\" does not resolve to %ld.%ld.%ld.%ld\n"),
- conn->peer_cn, (l >> 24) % 0x100, (l >> 16) % 0x100,
+ conn->peer_cn, (l >> 24) % 0x100, (l >> 16) % 0x100,
(l >> 8) % 0x100, l % 0x100);
break;
default:
printfPQExpBuffer(&conn->errorMessage,
libpq_gettext(
- "server common name \"%s\" does not resolve to peer address\n"),
+ "server common name \"%s\" does not resolve to peer address\n"),
conn->peer_cn);
}
return -1;
}
-#endif /* NOT_USED */
+#endif /* NOT_USED */
/*
* Load precomputed DH parameters.
@@ -774,6 +773,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
{
char homedir[MAXPGPATH];
struct stat buf;
+
#ifndef WIN32
struct stat buf2;
#endif
@@ -786,7 +786,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
if (!pqGetHomeDirectory(homedir, sizeof(homedir)))
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not get user information\n"));
+ libpq_gettext("could not get user information\n"));
return 0;
}
@@ -795,7 +795,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
if ((fp = fopen(fnbuf, "r")) == NULL)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not open certificate file \"%s\": %s\n"),
+ libpq_gettext("could not open certificate file \"%s\": %s\n"),
fnbuf, pqStrerror(errno, sebuf, sizeof(sebuf)));
return 0;
}
@@ -804,7 +804,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
char *err = SSLerrmessage();
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not read certificate file \"%s\": %s\n"),
+ libpq_gettext("could not read certificate file \"%s\": %s\n"),
fnbuf, err);
SSLerrfree(err);
fclose(fp);
@@ -817,7 +817,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
if (stat(fnbuf, &buf) == -1)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("certificate present, but not private key file \"%s\"\n"),
+ libpq_gettext("certificate present, but not private key file \"%s\"\n"),
fnbuf);
return 0;
}
@@ -826,7 +826,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
buf.st_uid != geteuid())
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("private key file \"%s\" has wrong permissions\n"),
+ libpq_gettext("private key file \"%s\" has wrong permissions\n"),
fnbuf);
return 0;
}
@@ -834,7 +834,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
if ((fp = fopen(fnbuf, "r")) == NULL)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not open private key file \"%s\": %s\n"),
+ libpq_gettext("could not open private key file \"%s\": %s\n"),
fnbuf, pqStrerror(errno, sebuf, sizeof(sebuf)));
return 0;
}
@@ -852,7 +852,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
char *err = SSLerrmessage();
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not read private key file \"%s\": %s\n"),
+ libpq_gettext("could not read private key file \"%s\": %s\n"),
fnbuf, err);
SSLerrfree(err);
fclose(fp);
@@ -866,7 +866,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
char *err = SSLerrmessage();
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("certificate does not match private key file \"%s\": %s\n"),
+ libpq_gettext("certificate does not match private key file \"%s\": %s\n"),
fnbuf, err);
SSLerrfree(err);
return 0;
@@ -881,9 +881,9 @@ static unsigned long
pq_threadidcallback(void)
{
/*
- * This is not starndard-compliant. pthread_self() returns
- * pthread_t, and shouldn't be cast to unsigned long, but
- * CRYPTO_set_id_callback requires it, so we have to do it.
+ * This is not starndard-compliant. pthread_self() returns pthread_t, and
+ * shouldn't be cast to unsigned long, but CRYPTO_set_id_callback requires
+ * it, so we have to do it.
*/
return (unsigned long) pthread_self();
}
@@ -898,7 +898,6 @@ pq_lockingcallback(int mode, int n, const char *file, int line)
else
pthread_mutex_unlock(&pq_lockarray[n]);
}
-
#endif /* ENABLE_THREAD_SAFETY */
static int
@@ -907,7 +906,6 @@ init_ssl_system(PGconn *conn)
#ifdef ENABLE_THREAD_SAFETY
#ifndef WIN32
static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER;
-
#else
static pthread_mutex_t init_mutex = NULL;
static long mutex_initlock = 0;
@@ -954,7 +952,7 @@ init_ssl_system(PGconn *conn)
char *err = SSLerrmessage();
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("could not create SSL context: %s\n"),
+ libpq_gettext("could not create SSL context: %s\n"),
err);
SSLerrfree(err);
#ifdef ENABLE_THREAD_SAFETY
@@ -1037,7 +1035,7 @@ open_client_SSL(PGconn *conn)
r = SSL_connect(conn->ssl);
if (r <= 0)
{
- int err = SSL_get_error(conn->ssl, r);
+ int err = SSL_get_error(conn->ssl, r);
switch (err)
{
@@ -1053,11 +1051,11 @@ open_client_SSL(PGconn *conn)
if (r == -1)
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL SYSCALL error: %s\n"),
- SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
+ libpq_gettext("SSL SYSCALL error: %s\n"),
+ SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
else
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("SSL SYSCALL error: EOF detected\n"));
+ libpq_gettext("SSL SYSCALL error: EOF detected\n"));
close_SSL(conn);
return PGRES_POLLING_FAILED;
}
@@ -1068,7 +1066,7 @@ open_client_SSL(PGconn *conn)
* these will be detected by client_cert_cb() which is
* called from SSL_connect(). We want to return that
* error message and not the rather unhelpful error that
- * OpenSSL itself returns. So check to see if an error
+ * OpenSSL itself returns. So check to see if an error
* message was already stored.
*/
if (conn->errorMessage.len == 0)
@@ -1086,7 +1084,7 @@ open_client_SSL(PGconn *conn)
default:
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("unrecognized SSL error code: %d\n"),
+ libpq_gettext("unrecognized SSL error code: %d\n"),
err);
close_SSL(conn);
return PGRES_POLLING_FAILED;
@@ -1106,7 +1104,7 @@ open_client_SSL(PGconn *conn)
if (r != X509_V_OK)
{
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("certificate could not be validated: %s\n"),
+ libpq_gettext("certificate could not be validated: %s\n"),
X509_verify_cert_error_string(r));
close_SSL(conn);
return PGRES_POLLING_FAILED;
@@ -1120,7 +1118,7 @@ open_client_SSL(PGconn *conn)
char *err = SSLerrmessage();
printfPQExpBuffer(&conn->errorMessage,
- libpq_gettext("certificate could not be obtained: %s\n"),
+ libpq_gettext("certificate could not be obtained: %s\n"),
err);
SSLerrfree(err);
close_SSL(conn);
@@ -1142,8 +1140,8 @@ open_client_SSL(PGconn *conn)
/*
* this is necessary to eliminate man-in-the-middle attacks and
- * impersonations where the attacker somehow learned the server's
- * private key
+ * impersonations where the attacker somehow learned the server's private
+ * key
*/
if (verify_peer(conn) == -1)
{
@@ -1231,29 +1229,27 @@ PQgetssl(PGconn *conn)
return NULL;
return conn->ssl;
}
-
-#else /* !USE_SSL */
+#else /* !USE_SSL */
void *
PQgetssl(PGconn *conn)
{
return NULL;
}
-
#endif /* USE_SSL */
#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
/*
- * Block SIGPIPE for this thread. This prevents send()/write() from exiting
+ * Block SIGPIPE for this thread. This prevents send()/write() from exiting
* the application.
*/
int
pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending)
{
- sigset_t sigpipe_sigset;
- sigset_t sigset;
-
+ sigset_t sigpipe_sigset;
+ sigset_t sigset;
+
sigemptyset(&sigpipe_sigset);
sigaddset(&sigpipe_sigset, SIGPIPE);
@@ -1268,7 +1264,7 @@ pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending)
/* Is there a pending SIGPIPE? */
if (sigpending(&sigset) != 0)
return -1;
-
+
if (sigismember(&sigset, SIGPIPE))
*sigpipe_pending = true;
else
@@ -1276,15 +1272,15 @@ pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending)
}
else
*sigpipe_pending = false;
-
+
return 0;
}
-
+
/*
* Discard any pending SIGPIPE and reset the signal mask.
*
* Note: we are effectively assuming here that the C library doesn't queue
- * up multiple SIGPIPE events. If it did, then we'd accidentally leave
+ * up multiple SIGPIPE events. If it did, then we'd accidentally leave
* ours in the queue when an event was already pending and we got another.
* As long as it doesn't queue multiple events, we're OK because the caller
* can't tell the difference.
@@ -1295,15 +1291,15 @@ pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending)
* gotten one, pass got_epipe = TRUE.
*
* We do not want this to change errno, since if it did that could lose
- * the error code from a preceding send(). We essentially assume that if
+ * the error code from a preceding send(). We essentially assume that if
* we were able to do pq_block_sigpipe(), this can't fail.
*/
void
pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending, bool got_epipe)
{
- int save_errno = SOCK_ERRNO;
- int signo;
- sigset_t sigset;
+ int save_errno = SOCK_ERRNO;
+ int signo;
+ sigset_t sigset;
/* Clear SIGPIPE only if none was pending */
if (got_epipe && !sigpipe_pending)
@@ -1311,19 +1307,19 @@ pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending, bool got_epipe)
if (sigpending(&sigset) == 0 &&
sigismember(&sigset, SIGPIPE))
{
- sigset_t sigpipe_sigset;
-
+ sigset_t sigpipe_sigset;
+
sigemptyset(&sigpipe_sigset);
sigaddset(&sigpipe_sigset, SIGPIPE);
sigwait(&sigpipe_sigset, &signo);
}
}
-
+
/* Restore saved block mask */
pthread_sigmask(SIG_SETMASK, osigset, NULL);
SOCK_ERRNO_SET(save_errno);
}
-#endif /* ENABLE_THREAD_SAFETY */
+#endif /* ENABLE_THREAD_SAFETY */
diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h
index f68bc0d658..a26721e9f6 100644
--- a/src/interfaces/libpq/libpq-fe.h
+++ b/src/interfaces/libpq/libpq-fe.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.119 2005/09/24 17:53:28 tgl Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.120 2005/10/15 02:49:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -39,16 +39,16 @@ typedef enum
{
/*
* Although it is okay to add to this list, values which become unused
- * should never be removed, nor should constants be redefined - that
- * would break compatibility with existing code.
+ * should never be removed, nor should constants be redefined - that would
+ * break compatibility with existing code.
*/
CONNECTION_OK,
CONNECTION_BAD,
/* Non-blocking mode only below here */
/*
- * The existence of these should never be relied upon - they should
- * only be used for user feedback or similar purposes.
+ * The existence of these should never be relied upon - they should only
+ * be used for user feedback or similar purposes.
*/
CONNECTION_STARTED, /* Waiting for connection to be made. */
CONNECTION_MADE, /* Connection OK; waiting to send. */
@@ -78,12 +78,12 @@ typedef enum
* anything was executed properly by the
* backend */
PGRES_TUPLES_OK, /* a query command that returns tuples was
- * executed properly by the backend,
- * PGresult contains the result tuples */
+ * executed properly by the backend, PGresult
+ * contains the result tuples */
PGRES_COPY_OUT, /* Copy Out data transfer in progress */
PGRES_COPY_IN, /* Copy In data transfer in progress */
- PGRES_BAD_RESPONSE, /* an unexpected response was recv'd from
- * the backend */
+ PGRES_BAD_RESPONSE, /* an unexpected response was recv'd from the
+ * backend */
PGRES_NONFATAL_ERROR, /* notice or warning message */
PGRES_FATAL_ERROR /* query failed */
} ExecStatusType;
@@ -146,8 +146,7 @@ typedef char pqbool;
typedef struct _PQprintOpt
{
- pqbool header; /* print output field headings and row
- * count */
+ pqbool header; /* print output field headings and row count */
pqbool align; /* fill align the fields */
pqbool standard; /* old brain dead format */
pqbool html3; /* output html tables */
@@ -156,8 +155,8 @@ typedef struct _PQprintOpt
char *fieldSep; /* field separator */
char *tableOpt; /* insert to HTML <table ...> */
char *caption; /* HTML <caption> */
- char **fieldName; /* null terminated array of replacement
- * field names */
+ char **fieldName; /* null terminated array of replacement field
+ * names */
} PQprintOpt;
/* ----------------
@@ -175,11 +174,11 @@ typedef struct _PQconninfoOption
char *compiled; /* Fallback compiled in default value */
char *val; /* Option's current value, or NULL */
char *label; /* Label for field in connect dialog */
- char *dispchar; /* Character to display for this field in
- * a connect dialog. Values are: ""
- * Display entered value as is "*"
- * Password field - hide value "D" Debug
- * option - don't show by default */
+ char *dispchar; /* Character to display for this field in a
+ * connect dialog. Values are: "" Display
+ * entered value as is "*" Password field -
+ * hide value "D" Debug option - don't show
+ * by default */
int dispsize; /* Field size in characters for dialog */
} PQconninfoOption;
@@ -321,8 +320,8 @@ extern PGresult *PQexecParams(PGconn *conn,
const int *paramFormats,
int resultFormat);
extern PGresult *PQprepare(PGconn *conn, const char *stmtName,
- const char *query, int nParams,
- const Oid *paramTypes);
+ const char *query, int nParams,
+ const Oid *paramTypes);
extern PGresult *PQexecPrepared(PGconn *conn,
const char *stmtName,
int nParams,
@@ -342,8 +341,8 @@ extern int PQsendQueryParams(PGconn *conn,
const int *paramFormats,
int resultFormat);
extern int PQsendPrepare(PGconn *conn, const char *stmtName,
- const char *query, int nParams,
- const Oid *paramTypes);
+ const char *query, int nParams,
+ const Oid *paramTypes);
extern int PQsendQueryPrepared(PGconn *conn,
const char *stmtName,
int nParams,
@@ -467,8 +466,7 @@ PQprintTuples(const PGresult *res,
FILE *fout, /* output stream */
int printAttName, /* print attribute names */
int terseOutput, /* delimiter bars */
- int width); /* width of column, if 0, use variable
- * width */
+ int width); /* width of column, if 0, use variable width */
/* === in fe-lobj.c === */
diff --git a/src/interfaces/libpq/libpq-int.h b/src/interfaces/libpq/libpq-int.h
index 3eb66dea2d..d2ee44753b 100644
--- a/src/interfaces/libpq/libpq-int.h
+++ b/src/interfaces/libpq/libpq-int.h
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.107 2005/08/23 21:02:03 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.108 2005/10/15 02:49:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -39,8 +39,8 @@
#endif
#ifdef WIN32_CLIENT_ONLY
-typedef int ssize_t; /* ssize_t doesn't exist in VC (at least
- * not VC6) */
+typedef int ssize_t; /* ssize_t doesn't exist in VC (at least not
+ * VC6) */
#endif
/* include stuff common to fe and be */
@@ -92,7 +92,7 @@ typedef struct pgresAttDesc
Oid typid; /* type id */
int typlen; /* type size */
int atttypmod; /* type-specific modifier info */
-} PGresAttDesc;
+} PGresAttDesc;
/*
* Data for a single attribute of a single tuple
@@ -117,9 +117,8 @@ typedef struct pgresAttDesc
typedef struct pgresAttValue
{
int len; /* length in bytes of the value */
- char *value; /* actual value, plus terminating zero
- * byte */
-} PGresAttValue;
+ char *value; /* actual value, plus terminating zero byte */
+} PGresAttValue;
/* Typedef for message-field list entries */
typedef struct pgMessageField
@@ -127,7 +126,7 @@ typedef struct pgMessageField
struct pgMessageField *next; /* list link */
char code; /* field code */
char contents[1]; /* field value (VARIABLE LENGTH) */
-} PGMessageField;
+} PGMessageField;
/* Fields needed for notice handling */
typedef struct
@@ -136,7 +135,7 @@ typedef struct
void *noticeRecArg;
PQnoticeProcessor noticeProc; /* notice message processor */
void *noticeProcArg;
-} PGNoticeHooks;
+} PGNoticeHooks;
struct pg_result
{
@@ -147,22 +146,21 @@ struct pg_result
* PGresAttValue's */
int tupArrSize; /* allocated size of tuples array */
ExecStatusType resultStatus;
- char cmdStatus[CMDSTATUS_LEN]; /* cmd status from the
- * query */
+ char cmdStatus[CMDSTATUS_LEN]; /* cmd status from the query */
int binary; /* binary tuple values if binary == 1,
* otherwise text */
/*
- * These fields are copied from the originating PGconn, so that
- * operations on the PGresult don't have to reference the PGconn.
+ * These fields are copied from the originating PGconn, so that operations
+ * on the PGresult don't have to reference the PGconn.
*/
PGNoticeHooks noticeHooks;
int client_encoding; /* encoding id */
/*
* Error information (all NULL if not an error result). errMsg is the
- * "overall" error message returned by PQresultErrorMessage. If we
- * have per-field info then it is stored in a linked list.
+ * "overall" error message returned by PQresultErrorMessage. If we have
+ * per-field info then it is stored in a linked list.
*/
char *errMsg; /* error message, or NULL if no error */
PGMessageField *errFields; /* message broken into fields */
@@ -171,8 +169,8 @@ struct pg_result
char null_field[1];
/*
- * Space management information. Note that attDescs and error stuff,
- * if not null, point into allocated blocks. But tuples points to a
+ * Space management information. Note that attDescs and error stuff, if
+ * not null, point into allocated blocks. But tuples points to a
* separately malloc'd block, so that we can realloc it.
*/
PGresult_data *curBlock; /* most recently allocated block */
@@ -188,7 +186,7 @@ typedef enum
PGASYNC_READY, /* result ready for PQgetResult */
PGASYNC_COPY_IN, /* Copy In data transfer in progress */
PGASYNC_COPY_OUT /* Copy Out data transfer in progress */
-} PGAsyncStatusType;
+} PGAsyncStatusType;
/* PGQueryClass tracks which query protocol we are now executing */
typedef enum
@@ -196,7 +194,7 @@ typedef enum
PGQUERY_SIMPLE, /* simple Query protocol (PQexec) */
PGQUERY_EXTENDED, /* full Extended protocol (PQexecParams) */
PGQUERY_PREPARE /* Parse only (PQprepare) */
-} PGQueryClass;
+} PGQueryClass;
/* PGSetenvStatusType defines the state of the PQSetenv state machine */
/* (this is used only for 2.0-protocol connections) */
@@ -209,14 +207,14 @@ typedef enum
SETENV_STATE_QUERY2_SEND, /* About to send a status query */
SETENV_STATE_QUERY2_WAIT, /* Waiting for query to complete */
SETENV_STATE_IDLE
-} PGSetenvStatusType;
+} PGSetenvStatusType;
/* Typedef for the EnvironmentOptions[] array */
typedef struct PQEnvironmentOption
{
const char *envName, /* name of an environment variable */
*pgName; /* name of corresponding SET variable */
-} PQEnvironmentOption;
+} PQEnvironmentOption;
/* Typedef for parameter-status list entries */
typedef struct pgParameterStatus
@@ -225,7 +223,7 @@ typedef struct pgParameterStatus
char *name; /* parameter name */
char *value; /* parameter value */
/* Note: name and value are stored in same malloc block as struct is */
-} pgParameterStatus;
+} pgParameterStatus;
/* large-object-access data ... allocated only if large-object code is used. */
typedef struct pgLobjfuncs
@@ -239,7 +237,7 @@ typedef struct pgLobjfuncs
Oid fn_lo_tell; /* OID of backend function lo_tell */
Oid fn_lo_read; /* OID of backend function LOread */
Oid fn_lo_write; /* OID of backend function LOwrite */
-} PGlobjfuncs;
+} PGlobjfuncs;
/*
* PGconn stores all the state data associated with a single connection
@@ -248,16 +246,15 @@ typedef struct pgLobjfuncs
struct pg_conn
{
/* Saved values of connection options */
- char *pghost; /* the machine on which the server is
- * running */
- char *pghostaddr; /* the IPv4 address of the machine on
- * which the server is running, in IPv4
- * numbers-and-dots notation. Takes
- * precedence over above. */
+ char *pghost; /* the machine on which the server is running */
+ char *pghostaddr; /* the IPv4 address of the machine on which
+ * the server is running, in IPv4
+ * numbers-and-dots notation. Takes precedence
+ * over above. */
char *pgport; /* the server's communication port */
- char *pgunixsocket; /* the Unix-domain socket that the server
- * is listening on; if NULL, uses a
- * default constructed from pgport */
+ char *pgunixsocket; /* the Unix-domain socket that the server is
+ * listening on; if NULL, uses a default
+ * constructed from pgport */
char *pgtty; /* tty on which the backend messages is
* displayed (OBSOLETE, NOT USED) */
char *connect_timeout; /* connection timeout (numeric string) */
@@ -267,7 +264,7 @@ struct pg_conn
char *pgpass;
char *sslmode; /* SSL mode (require,prefer,allow,disable) */
#ifdef KRB5
- char *krbsrvname; /* Kerberos service name */
+ char *krbsrvname; /* Kerberos service name */
#endif
/* Optional file to write trace info to */
@@ -282,11 +279,11 @@ struct pg_conn
PGTransactionStatusType xactStatus;
/* note: xactStatus never changes to ACTIVE */
PGQueryClass queryclass;
- bool nonblocking; /* whether this connection is using
- * nonblock sending semantics */
+ bool nonblocking; /* whether this connection is using nonblock
+ * sending semantics */
char copy_is_binary; /* 1 = copy binary, 0 = copy text */
- int copy_already_done; /* # bytes already returned in
- * COPY OUT */
+ int copy_already_done; /* # bytes already returned in COPY
+ * OUT */
PGnotify *notifyHead; /* oldest unreported Notify msg */
PGnotify *notifyTail; /* newest unreported Notify msg */
@@ -312,17 +309,14 @@ struct pg_conn
pgParameterStatus *pstatus; /* ParameterStatus data */
int client_encoding; /* encoding id */
PGVerbosity verbosity; /* error/notice message verbosity */
- PGlobjfuncs *lobjfuncs; /* private state for large-object access
- * fns */
+ PGlobjfuncs *lobjfuncs; /* private state for large-object access fns */
/* Buffer for data received from backend and not yet processed */
char *inBuffer; /* currently allocated buffer */
int inBufSize; /* allocated size of buffer */
- int inStart; /* offset to first unconsumed data in
- * buffer */
+ int inStart; /* offset to first unconsumed data in buffer */
int inCursor; /* next byte to tentatively consume */
- int inEnd; /* offset to first position after avail
- * data */
+ int inEnd; /* offset to first position after avail data */
/* Buffer for data not yet sent to backend */
char *outBuffer; /* currently allocated buffer */
@@ -330,8 +324,8 @@ struct pg_conn
int outCount; /* number of chars waiting in buffer */
/* State for constructing messages in outBuffer */
- int outMsgStart; /* offset to msg start (length word); if
- * -1, msg has no length word */
+ int outMsgStart; /* offset to msg start (length word); if -1,
+ * msg has no length word */
int outMsgEnd; /* offset to msg end (so far) */
/* Status for asynchronous result construction */
@@ -408,10 +402,10 @@ extern void pqClearAsyncResult(PGconn *conn);
extern void pqSaveErrorResult(PGconn *conn);
extern PGresult *pqPrepareAsyncResult(PGconn *conn);
extern void
-pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt, ...)
+pqInternalNotice(const PGNoticeHooks * hooks, const char *fmt,...)
/* This lets gcc check the format string for consistency. */
__attribute__((format(printf, 2, 3)));
-extern int pqAddTuple(PGresult *res, PGresAttValue *tup);
+extern int pqAddTuple(PGresult *res, PGresAttValue * tup);
extern void pqSaveMessageField(PGresult *res, char code,
const char *value);
extern void pqSaveParameterStatus(PGconn *conn, const char *name,
@@ -423,7 +417,7 @@ extern void pqHandleSendFailure(PGconn *conn);
extern PostgresPollingStatusType pqSetenvPoll(PGconn *conn);
extern char *pqBuildStartupPacket2(PGconn *conn, int *packetlen,
- const PQEnvironmentOption *options);
+ const PQEnvironmentOption * options);
extern void pqParseInput2(PGconn *conn);
extern int pqGetCopyData2(PGconn *conn, char **buffer, int async);
extern int pqGetline2(PGconn *conn, char *s, int maxlen);
@@ -437,7 +431,7 @@ extern PGresult *pqFunctionCall2(PGconn *conn, Oid fnid,
/* === in fe-protocol3.c === */
extern char *pqBuildStartupPacket3(PGconn *conn, int *packetlen,
- const PQEnvironmentOption *options);
+ const PQEnvironmentOption * options);
extern void pqParseInput3(PGconn *conn);
extern int pqGetErrorNotice3(PGconn *conn, bool isError);
extern int pqGetCopyData3(PGconn *conn, char **buffer, int async);
@@ -452,8 +446,8 @@ extern PGresult *pqFunctionCall3(PGconn *conn, Oid fnid,
/* === in fe-misc.c === */
/*
- * "Get" and "Put" routines return 0 if successful, EOF if not. Note that
- * for Get, EOF merely means the buffer is exhausted, not that there is
+ * "Get" and "Put" routines return 0 if successful, EOF if not. Note that for
+ * Get, EOF merely means the buffer is exhausted, not that there is
* necessarily any error.
*/
extern int pqCheckOutBufferSpace(int bytes_needed, PGconn *conn);
@@ -488,7 +482,7 @@ extern ssize_t pqsecure_write(PGconn *, const void *ptr, size_t len);
#if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
extern int pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending);
extern void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending,
- bool got_epipe);
+ bool got_epipe);
#endif
/*
@@ -501,7 +495,6 @@ extern void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending,
extern char *
libpq_gettext(const char *msgid)
__attribute__((format_arg(1)));
-
#else
#define libpq_gettext(x) (x)
#endif
diff --git a/src/interfaces/libpq/pqexpbuffer.c b/src/interfaces/libpq/pqexpbuffer.c
index 279faeba23..b28adc434b 100644
--- a/src/interfaces/libpq/pqexpbuffer.c
+++ b/src/interfaces/libpq/pqexpbuffer.c
@@ -17,7 +17,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.20 2004/12/31 22:03:50 pgsql Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/pqexpbuffer.c,v 1.21 2005/10/15 02:49:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -135,9 +135,9 @@ enlargePQExpBuffer(PQExpBuffer str, size_t needed)
char *newdata;
/*
- * Guard against ridiculous "needed" values, which can occur if we're
- * fed bogus data. Without this, we can get an overflow or infinite
- * loop in the following.
+ * Guard against ridiculous "needed" values, which can occur if we're fed
+ * bogus data. Without this, we can get an overflow or infinite loop in
+ * the following.
*/
if (needed >= ((size_t) INT_MAX - str->len))
return 0;
@@ -150,19 +150,18 @@ enlargePQExpBuffer(PQExpBuffer str, size_t needed)
return 1; /* got enough space already */
/*
- * We don't want to allocate just a little more space with each
- * append; for efficiency, double the buffer size each time it
- * overflows. Actually, we might need to more than double it if
- * 'needed' is big...
+ * We don't want to allocate just a little more space with each append;
+ * for efficiency, double the buffer size each time it overflows.
+ * Actually, we might need to more than double it if 'needed' is big...
*/
newlen = (str->maxlen > 0) ? (2 * str->maxlen) : 64;
while (needed > newlen)
newlen = 2 * newlen;
/*
- * Clamp to INT_MAX in case we went past it. Note we are assuming
- * here that INT_MAX <= UINT_MAX/2, else the above loop could
- * overflow. We will still have newlen >= needed.
+ * Clamp to INT_MAX in case we went past it. Note we are assuming here
+ * that INT_MAX <= UINT_MAX/2, else the above loop could overflow. We
+ * will still have newlen >= needed.
*/
if (newlen > (size_t) INT_MAX)
newlen = (size_t) INT_MAX;
@@ -197,8 +196,8 @@ printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
{
/*
* Try to format the given string into the available space; but if
- * there's hardly any space, don't bother trying, just fall
- * through to enlarge the buffer first.
+ * there's hardly any space, don't bother trying, just fall through to
+ * enlarge the buffer first.
*/
if (str->maxlen > str->len + 16)
{
@@ -245,8 +244,8 @@ appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
{
/*
* Try to format the given string into the available space; but if
- * there's hardly any space, don't bother trying, just fall
- * through to enlarge the buffer first.
+ * there's hardly any space, don't bother trying, just fall through to
+ * enlarge the buffer first.
*/
if (str->maxlen > str->len + 16)
{
@@ -321,8 +320,8 @@ appendBinaryPQExpBuffer(PQExpBuffer str, const char *data, size_t datalen)
str->len += datalen;
/*
- * Keep a trailing null in place, even though it's probably useless
- * for binary data...
+ * Keep a trailing null in place, even though it's probably useless for
+ * binary data...
*/
str->data[str->len] = '\0';
}
diff --git a/src/interfaces/libpq/pthread-win32.h b/src/interfaces/libpq/pthread-win32.h
index 4109c89871..c30eaeb291 100644
--- a/src/interfaces/libpq/pthread-win32.h
+++ b/src/interfaces/libpq/pthread-win32.h
@@ -5,13 +5,15 @@ typedef ULONG pthread_key_t;
typedef HANDLE pthread_mutex_t;
typedef int pthread_once_t;
-DWORD pthread_self();
+DWORD pthread_self();
-void pthread_setspecific(pthread_key_t, void*);
-void* pthread_getspecific(pthread_key_t);
+void pthread_setspecific(pthread_key_t, void *);
+void *pthread_getspecific(pthread_key_t);
-void pthread_mutex_init(pthread_mutex_t *, void *attr);
-void pthread_mutex_lock(pthread_mutex_t*); // blocking
-void pthread_mutex_unlock(pthread_mutex_t*);
+void pthread_mutex_init(pthread_mutex_t *, void *attr);
+void pthread_mutex_lock(pthread_mutex_t *);
+
+//blocking
+void pthread_mutex_unlock(pthread_mutex_t *);
#endif
diff --git a/src/interfaces/libpq/win32.c b/src/interfaces/libpq/win32.c
index bd48b2d2cd..dbca603e0d 100644
--- a/src/interfaces/libpq/win32.c
+++ b/src/interfaces/libpq/win32.c
@@ -290,7 +290,7 @@ winsock_strerror(int err, char *strerrbuf, size_t buflen)
dlls[i].handle = (void *) LoadLibraryEx(
dlls[i].dll_name,
0,
- LOAD_LIBRARY_AS_DATAFILE);
+ LOAD_LIBRARY_AS_DATAFILE);
}
if (dlls[i].dll_name && !dlls[i].handle)
@@ -303,7 +303,7 @@ winsock_strerror(int err, char *strerrbuf, size_t buflen)
success = 0 != FormatMessage(
flags,
dlls[i].handle, err,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
strerrbuf, buflen - 64,
0
);