* more likely to break across PostgreSQL releases than code that uses
* only the official API.
*
- * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
+ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq-int.h,v 1.18 2000/01/26 05:58:46 momjian Exp $
+ * $Id: libpq-int.h,v 1.35 2001/07/06 19:04:23 petere Exp $
*
*-------------------------------------------------------------------------
*/
#define LIBPQ_INT_H
/* We assume libpq-fe.h has already been included. */
+#include "postgres_fe.h"
/* include stuff common to fe and be */
#include "libpq/pqcomm.h"
* POSTGRES backend dependent Constants.
*/
+#define PQERRORMSG_LENGTH 1024
#define CMDSTATUS_LEN 40
/*
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 */
int len; /* length in bytes of the value */
char *value; /* actual value, plus terminating zero
* byte */
-} PGresAttValue;
+} PGresAttValue;
struct pg_result
{
* last query */
int binary; /* binary tuple values if binary == 1,
* otherwise ASCII */
- PGconn *conn; /* connection we did the query on, if any */
+
+ /*
+ * The conn link in PGresult is no longer used by any libpq code. It
+ * should be removed entirely, because it could be a dangling link
+ * (the application could keep the PGresult around longer than it
+ * keeps the PGconn!) But there may be apps out there that depend on
+ * it, so we will leave it here at least for a release or so.
+ */
+ PGconn *xconn; /* connection we did the query on, if any */
+
+ /*
+ * These fields are copied from the originating PGconn, so that
+ * operations on the PGresult don't have to reference the PGconn.
+ */
+ PQnoticeProcessor noticeHook; /* notice/error message processor */
+ void *noticeArg;
+ int client_encoding;/* encoding id */
+
+
char *errMsg; /* error message, or NULL if no error */
/* All NULL attributes in the query result point to this null string */
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;
+
+/* 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
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
* to a backend.
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
+ * 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 *pgtty; /* tty on which the backend messages is
* displayed (NOT ACTUALLY USED???) */
char *pgoptions; /* options to start the backend with */
int inEnd; /* offset to first position after avail
* data */
- int nonblocking; /* whether this connection is using a blocking
- * socket to the backend or not */
+ int nonblocking; /* whether this connection is using a
+ * blocking socket to the backend or not */
/* Buffer for data not yet sent to backend */
char *outBuffer; /* currently allocated buffer */
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 */
- SSL *ssl; /* SSL status, if have SSL connection */
+ bool allow_ssl_try; /* Allowed to try SSL negotiation */
+ bool require_ssl; /* Require SSL to make connection */
+ SSL *ssl; /* SSL status, if have SSL connection */
#endif
/* Buffer for current error message */
- PQExpBufferData errorMessage; /* expansible string */
+ PQExpBufferData errorMessage; /* expansible string */
/* Buffer for receiving various parts of messages */
- PQExpBufferData workBuffer; /* expansible string */
+ PQExpBufferData workBuffer; /* expansible string */
- int client_encoding; /* encoding id */
+ int client_encoding;/* encoding id */
};
+/* String descriptions of the ExecStatusTypes.
+ * direct use of this array is deprecated; call PQresStatus() instead.
+ */
+extern char *const pgresStatus[];
+
/* ----------------
* Internal functions of libpq
* Functions declared here need to be visible across files of libpq,
* necessarily any error.
*/
extern int pqGetc(char *result, PGconn *conn);
+extern int pqPutc(char c, PGconn *conn);
extern int pqGets(PQExpBuffer buf, PGconn *conn);
extern int pqPuts(const char *s, PGconn *conn);
extern int pqGetnchar(char *s, size_t len, PGconn *conn);
#define DefaultAuthtype ""
#define DefaultPassword ""
-/* supply an implementation of strerror() macro if system doesn't have it */
-#ifndef strerror
-#if defined(sun) && defined(__sparc__) && !defined(__SVR4)
-extern char *sys_errlist[];
-
-#define strerror(A) (sys_errlist[(A)])
-#endif /* sunos4 */
-#endif /* !strerror */
-
-/*
+/*
* this is so that we can check is a connection is non-blocking internally
* without the overhead of a function call
*/
-#define pqIsnonblocking(conn) (conn->nonblocking)
+#define pqIsnonblocking(conn) ((conn)->nonblocking)
#endif /* LIBPQ_INT_H */