Commit 0edcee34 authored by Tom Lane's avatar Tom Lane

Fold PQsetenv working state into PGconn, rather than trying to maintain

it in a separate object.  There's no value in keeping the state separate,
and it creates dangling-pointer problems.  Also, remove PQsetenv routines
from public API, until and unless they are redesigned to have a safer
interface.  Since they were never part of the documented API before 7.0,
it's unlikely that anyone is calling them.
parent 5b1f92ea
......@@ -629,63 +629,6 @@ int PQbackendPID(const PGconn *conn);
server host, not the local host!
</para>
</listitem>
<listitem>
<para>
<function>PQsetenvStart</function>
<function>PQsetenvPoll</function>
<function>PQsetenvAbort</function>
Perform an environment negotiation.
<synopsis>
PGsetenvHandle *PQsetenvStart(PGconn *conn)
</synopsis>
<synopsis>
PostgresPollingStatusType *PQsetenvPoll(PGsetenvHandle handle)
</synopsis>
<synopsis>
void PQsetenvAbort(PGsetenvHandle handle)
</synopsis>
These two routines can be used to re-perform the environment negotiation
that occurs during the opening of a connection to a database
server. I have
no idea why this might be useful (XXX anyone?) but it might prove useful
for users to be able to reconfigure their character encodings
on-the-fly, for example.
</para>
<para>
These functions will not block, subject to the restrictions applied to
PQconnectStart and PQconnectPoll.
</para>
<para>
To begin, call handle=PQsetenvStart(conn), where conn is an open connection
to the database server. If handle is NULL, then libpq has been unable to
allocate a new PGsetenvHandle structure. Otherwise, a valid handle is
returned. This handle is intended to be opaque - you may only use it to
call other functions in libpq (PQsetenvPoll, for example).
</para>
<para>
Poll the procedure using PQsetenvPoll, in exactly the same way as you would
create a connection using PQconnectPoll.
</para>
<para>
The procedure may be aborted at any time by calling PQsetenvAbort(handle).
</para>
</listitem>
<listitem>
<para>
<function>PQsetenv</function>
Perform an environment negotiation.
<synopsis>
int PQsetenv(PGconn *conn)
</synopsis>
This function performs the same duties as PQsetenvStart and
PQsetenvPoll, but
blocks to do so. It returns 1 on success and 0 on failure.
</para>
</listitem>
</itemizedlist>
</para>
</sect1>
......
This diff is collapsed.
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq-fe.h,v 1.62 2000/03/23 15:00:11 momjian Exp $
* $Id: libpq-fe.h,v 1.63 2000/03/24 01:39:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -86,12 +86,6 @@ extern "C"
*/
typedef struct pg_result PGresult;
/* PGsetenvHandle is an opaque handle which is returned by PQsetenvStart and
* which should be passed to PQsetenvPoll or PQsetenvAbort in order to refer
* to the particular process being performed.
*/
typedef struct pg_setenv_state *PGsetenvHandle;
/* PGnotify represents the occurrence of a NOTIFY message.
* Ideally this would be an opaque typedef, but it's so simple that it's
* unlikely to change.
......@@ -231,15 +225,6 @@ extern "C"
/* Override default notice processor */
extern PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg);
/* Passing of environment variables */
/* Asynchronous (non-blocking) */
extern PGsetenvHandle PQsetenvStart(PGconn *conn);
extern PostgresPollingStatusType PQsetenvPoll(PGconn *conn);
extern void PQsetenvAbort(PGsetenvHandle handle);
/* Synchronous (blocking) */
extern int PQsetenv(PGconn *conn);
/* === in fe-exec.c === */
/* Simple synchronous query */
......
......@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq-int.h,v 1.21 2000/03/14 23:59:23 tgl Exp $
* $Id: libpq-int.h,v 1.22 2000/03/24 01:39:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -164,6 +164,17 @@ typedef enum
PGASYNC_COPY_OUT /* Copy Out data transfer in progress */
} PGAsyncStatusType;
/* PGSetenvStatusType defines the state of the PQSetenv state machine */
typedef enum
{
SETENV_STATE_OPTION_SEND, /* About to send an Environment Option */
SETENV_STATE_OPTION_WAIT, /* Waiting for above send to complete */
/* these next two are only used in MULTIBYTE mode */
SETENV_STATE_ENCODINGS_SEND, /* About to send an "encodings" query */
SETENV_STATE_ENCODINGS_WAIT, /* Waiting for query to complete */
SETENV_STATE_IDLE
} PGSetenvStatusType;
/* large-object-access data ... allocated only if large-object code is used. */
typedef struct pgLobjfuncs
{
......@@ -244,8 +255,9 @@ struct pg_conn
PGresult *result; /* result being constructed */
PGresAttValue *curTuple; /* tuple currently being read */
/* Handle for setenv request. Used during connection only. */
PGsetenvHandle setenv_handle;
/* Status for sending environment info. Used during PQSetenv only. */
PGSetenvStatusType setenv_state;
const struct EnvironmentOptions *next_eo;
#ifdef USE_SSL
bool allow_ssl_try; /* Allowed to try SSL negotiation */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment