index 69db8d830cb7d3b9658e219eac08cf100e2a0468..db7549f2bcf627e7df246056804a28a67af5fcee 100644 (file)
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.325 2006年01月11日 08:43:13 neilc Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.326 2006年02月13日 22:33:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
else
conn->sslmode = strdup(DefaultSSLMode);
+ /*
+ * Only if we get this far is it appropriate to try to connect.
+ * (We need a state flag, rather than just the boolean result of
+ * this function, in case someone tries to PQreset() the PGconn.)
+ */
+ conn->options_valid = true;
+
return true;
}
if (!conn)
return 0;
+ if (!conn->options_valid)
+ goto connect_errReturn;
+
/* Ensure our buffers are empty */
conn->inStart = conn->inCursor = conn->inEnd = 0;
conn->outCount = 0;
conn->status = CONNECTION_BAD;
conn->asyncStatus = PGASYNC_IDLE;
conn->xactStatus = PQTRANS_IDLE;
+ conn->options_valid = false;
+ conn->nonblocking = false;
conn->setenv_state = SETENV_STATE_IDLE;
conn->client_encoding = PG_SQL_ASCII;
conn->verbosity = PQERRORS_DEFAULT;
conn->inBuffer = (char *) malloc(conn->inBufSize);
conn->outBufSize = 16 * 1024;
conn->outBuffer = (char *) malloc(conn->outBufSize);
- conn->nonblocking = FALSE;
initPQExpBuffer(&conn->errorMessage);
initPQExpBuffer(&conn->workBuffer);
index 096ee1b7af40dcfda9130012e591fbd8dce70308..c8a5527a016930626a23e14a42e25b32bd8b0d02 100644 (file)
* 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.109 2005年11月22日 18:17:33 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.110 2006年02月13日 22:33:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/* Status indicators */
ConnStatusType status;
PGAsyncStatusType asyncStatus;
- PGTransactionStatusType xactStatus;
- /* note: xactStatus never changes to ACTIVE */
+ PGTransactionStatusType xactStatus; /* never changes to ACTIVE */
PGQueryClass queryclass;
+ bool options_valid; /* true if OK to attempt connection */
bool nonblocking; /* whether this connection is using nonblock
* sending semantics */
char copy_is_binary; /* 1 = copy binary, 0 = copy text */