PostgreSQL Source Code  git master
libpq-int.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * libpq-int.h
4  * This file contains internal definitions meant to be used only by
5  * the frontend libpq library, not by applications that call it.
6  *
7  * An application can include this file if it wants to bypass the
8  * official API defined by libpq-fe.h, but code that does so is much
9  * more likely to break across PostgreSQL releases than code that uses
10  * only the official API.
11  *
12  * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
13  * Portions Copyright (c) 1994, Regents of the University of California
14  *
15  * src/interfaces/libpq/libpq-int.h
16  *
17  *-------------------------------------------------------------------------
18  */
19 
20 #ifndef LIBPQ_INT_H
21 #define LIBPQ_INT_H
22 
23 /* We assume libpq-fe.h has already been included. */
24 #include "libpq-events.h"
25 
26 #include <time.h>
27 #ifndef WIN32
28 #include <sys/time.h>
29 #endif
30 
31 #ifdef ENABLE_THREAD_SAFETY
32 #ifdef WIN32
33 #include "pthread-win32.h"
34 #else
35 #include <pthread.h>
36 #endif
37 #include <signal.h>
38 #endif
39 
40 /* include stuff common to fe and be */
41 #include "getaddrinfo.h"
42 #include "libpq/pqcomm.h"
43 /* include stuff found in fe only */
44 #include "fe-auth-sasl.h"
45 #include "pqexpbuffer.h"
46 
47 #ifdef ENABLE_GSS
48 #if defined(HAVE_GSSAPI_H)
49 #include <gssapi.h>
50 #else
51 #include <gssapi/gssapi.h>
52 #endif
53 #endif
54 
55 #ifdef ENABLE_SSPI
56 #define SECURITY_WIN32
57 #if defined(WIN32) && !defined(_MSC_VER)
58 #include <ntsecapi.h>
59 #endif
60 #include <security.h>
61 #undef SECURITY_WIN32
62 
63 #ifndef ENABLE_GSS
64 /*
65  * Define a fake structure compatible with GSSAPI on Unix.
66  */
67 typedef struct
68 {
69  void *value;
70  int length;
71 } gss_buffer_desc;
72 #endif
73 #endif /* ENABLE_SSPI */
74 
75 #ifdef USE_OPENSSL
76 #include <openssl/ssl.h>
77 #include <openssl/err.h>
78 
79 #ifndef OPENSSL_NO_ENGINE
80 #define USE_SSL_ENGINE
81 #endif
82 #endif /* USE_OPENSSL */
83 
84 /*
85  * POSTGRES backend dependent Constants.
86  */
87 #define CMDSTATUS_LEN 64 /* should match COMPLETION_TAG_BUFSIZE */
88 
89 /*
90  * PGresult and the subsidiary types PGresAttDesc, PGresAttValue
91  * represent the result of a query (or more precisely, of a single SQL
92  * command --- a query string given to PQexec can contain multiple commands).
93  * Note we assume that a single command can return at most one tuple group,
94  * hence there is no need for multiple descriptor sets.
95  */
96 
97 /* Subsidiary-storage management structure for PGresult.
98  * See space management routines in fe-exec.c for details.
99  * Note that space[k] refers to the k'th byte starting from the physical
100  * head of the block --- it's a union, not a struct!
101  */
102 typedef union pgresult_data PGresult_data;
103 
105 {
106  PGresult_data *next; /* link to next block, or NULL */
107  char space[1]; /* dummy for accessing block as bytes */
108 };
109 
110 /* Data about a single parameter of a prepared statement */
111 typedef struct pgresParamDesc
112 {
113  Oid typid; /* type id */
115 
116 /*
117  * Data for a single attribute of a single tuple
118  *
119  * We use char* for Attribute values.
120  *
121  * The value pointer always points to a null-terminated area; we add a
122  * null (zero) byte after whatever the backend sends us. This is only
123  * particularly useful for text values ... with a binary value, the
124  * value might have embedded nulls, so the application can't use C string
125  * operators on it. But we add a null anyway for consistency.
126  * Note that the value itself does not contain a length word.
127  *
128  * A NULL attribute is a special case in two ways: its len field is NULL_LEN
129  * and its value field points to null_field in the owning PGresult. All the
130  * NULL attributes in a query result point to the same place (there's no need
131  * to store a null string separately for each one).
132  */
133 
134 #define NULL_LEN (-1) /* pg_result len for NULL value */
135 
136 typedef struct pgresAttValue
137 {
138  int len; /* length in bytes of the value */
139  char *value; /* actual value, plus terminating zero byte */
141 
142 /* Typedef for message-field list entries */
143 typedef struct pgMessageField
144 {
145  struct pgMessageField *next; /* list link */
146  char code; /* field code */
147  char contents[FLEXIBLE_ARRAY_MEMBER]; /* value, nul-terminated */
149 
150 /* Fields needed for notice handling */
151 typedef struct
152 {
153  PQnoticeReceiver noticeRec; /* notice message receiver */
155  PQnoticeProcessor noticeProc; /* notice message processor */
157 } PGNoticeHooks;
158 
159 typedef struct PGEvent
160 {
161  PGEventProc proc; /* the function to call on events */
162  char *name; /* used only for error messages */
163  void *passThrough; /* pointer supplied at registration time */
164  void *data; /* optional state (instance) data */
165  bool resultInitialized; /* T if RESULTCREATE/COPY succeeded */
167 
168 struct pg_result
169 {
170  int ntups;
173  PGresAttValue **tuples; /* each PGresult tuple is an array of
174  * PGresAttValue's */
175  int tupArrSize; /* allocated size of tuples array */
179  char cmdStatus[CMDSTATUS_LEN]; /* cmd status from the query */
180  int binary; /* binary tuple values if binary == 1,
181  * otherwise text */
182 
183  /*
184  * These fields are copied from the originating PGconn, so that operations
185  * on the PGresult don't have to reference the PGconn.
186  */
189  int nEvents;
190  int client_encoding; /* encoding id */
191 
192  /*
193  * Error information (all NULL if not an error result). errMsg is the
194  * "overall" error message returned by PQresultErrorMessage. If we have
195  * per-field info then it is stored in a linked list.
196  */
197  char *errMsg; /* error message, or NULL if no error */
198  PGMessageField *errFields; /* message broken into fields */
199  char *errQuery; /* text of triggering query, if available */
200 
201  /* All NULL attributes in the query result point to this null string */
202  char null_field[1];
203 
204  /*
205  * Space management information. Note that attDescs and error stuff, if
206  * not null, point into allocated blocks. But tuples points to a
207  * separately malloc'd block, so that we can realloc it.
208  */
209  PGresult_data *curBlock; /* most recently allocated block */
210  int curOffset; /* start offset of free space in block */
211  int spaceLeft; /* number of free bytes remaining in block */
212 
213  size_t memorySize; /* total space allocated for this PGresult */
214 };
215 
216 /* PGAsyncStatusType defines the state of the query-execution state machine */
217 typedef enum
218 {
219  PGASYNC_IDLE, /* nothing's happening, dude */
220  PGASYNC_BUSY, /* query in progress */
221  PGASYNC_READY, /* query done, waiting for client to fetch
222  * result */
223  PGASYNC_READY_MORE, /* query done, waiting for client to fetch
224  * result, more results expected from this
225  * query */
226  PGASYNC_COPY_IN, /* Copy In data transfer in progress */
227  PGASYNC_COPY_OUT, /* Copy Out data transfer in progress */
228  PGASYNC_COPY_BOTH /* Copy In/Out data transfer in progress */
230 
231 /* Target server type (decoded value of target_session_attrs) */
232 typedef enum
233 {
234  SERVER_TYPE_ANY = 0, /* Any server (default) */
235  SERVER_TYPE_READ_WRITE, /* Read-write server */
236  SERVER_TYPE_READ_ONLY, /* Read-only server */
237  SERVER_TYPE_PRIMARY, /* Primary server */
238  SERVER_TYPE_STANDBY, /* Standby server */
239  SERVER_TYPE_PREFER_STANDBY, /* Prefer standby server */
240  SERVER_TYPE_PREFER_STANDBY_PASS2 /* second pass - behaves same as ANY */
242 
243 /* Boolean value plus a not-known state, for GUCs we might have to fetch */
244 typedef enum
245 {
246  PG_BOOL_UNKNOWN = 0, /* Currently unknown */
247  PG_BOOL_YES, /* Yes (true) */
248  PG_BOOL_NO /* No (false) */
250 
251 /* Typedef for the EnvironmentOptions[] array */
252 typedef struct PQEnvironmentOption
253 {
254  const char *envName, /* name of an environment variable */
255  *pgName; /* name of corresponding SET variable */
257 
258 /* Typedef for parameter-status list entries */
259 typedef struct pgParameterStatus
260 {
261  struct pgParameterStatus *next; /* list link */
262  char *name; /* parameter name */
263  char *value; /* parameter value */
264  /* Note: name and value are stored in same malloc block as struct is */
266 
267 /* large-object-access data ... allocated only if large-object code is used. */
268 typedef struct pgLobjfuncs
269 {
270  Oid fn_lo_open; /* OID of backend function lo_open */
271  Oid fn_lo_close; /* OID of backend function lo_close */
272  Oid fn_lo_creat; /* OID of backend function lo_creat */
273  Oid fn_lo_create; /* OID of backend function lo_create */
274  Oid fn_lo_unlink; /* OID of backend function lo_unlink */
275  Oid fn_lo_lseek; /* OID of backend function lo_lseek */
276  Oid fn_lo_lseek64; /* OID of backend function lo_lseek64 */
277  Oid fn_lo_tell; /* OID of backend function lo_tell */
278  Oid fn_lo_tell64; /* OID of backend function lo_tell64 */
279  Oid fn_lo_truncate; /* OID of backend function lo_truncate */
280  Oid fn_lo_truncate64; /* OID of function lo_truncate64 */
281  Oid fn_lo_read; /* OID of backend function LOread */
282  Oid fn_lo_write; /* OID of backend function LOwrite */
284 
285 /* PGdataValue represents a data field value being passed to a row processor.
286  * It could be either text or binary data; text data is not zero-terminated.
287  * A SQL NULL is represented by len < 0; then value is still valid but there
288  * are no data bytes there.
289  */
290 typedef struct pgDataValue
291 {
292  int len; /* data length in bytes, or <0 if NULL */
293  const char *value; /* data value, without zero-termination */
295 
296 /* Host address type enum for struct pg_conn_host */
297 typedef enum pg_conn_host_type
298 {
303 
304 /*
305  * PGQueryClass tracks which query protocol is in use for each command queue
306  * entry, or special operation in execution
307  */
308 typedef enum
309 {
310  PGQUERY_SIMPLE, /* simple Query protocol (PQexec) */
311  PGQUERY_EXTENDED, /* full Extended protocol (PQexecParams) */
312  PGQUERY_PREPARE, /* Parse only (PQprepare) */
313  PGQUERY_DESCRIBE, /* Describe Statement or Portal */
314  PGQUERY_SYNC /* Sync (at end of a pipeline) */
316 
317 /*
318  * An entry in the pending command queue.
319  */
320 typedef struct PGcmdQueueEntry
321 {
322  PGQueryClass queryclass; /* Query type */
323  char *query; /* SQL command, or NULL if none/unknown/OOM */
324  struct PGcmdQueueEntry *next; /* list link */
326 
327 /*
328  * pg_conn_host stores all information about each of possibly several hosts
329  * mentioned in the connection string. Most fields are derived by splitting
330  * the relevant connection parameter (e.g., pghost) at commas.
331  */
332 typedef struct pg_conn_host
333 {
334  pg_conn_host_type type; /* type of host address */
335  char *host; /* host name or socket path */
336  char *hostaddr; /* host numeric IP address */
337  char *port; /* port number (always provided) */
338  char *password; /* password for this host, read from the
339  * password file; NULL if not sought or not
340  * found in password file. */
342 
343 /*
344  * PGconn stores all the state data associated with a single connection
345  * to a backend.
346  */
347 struct pg_conn
348 {
349  /* Saved values of connection options */
350  char *pghost; /* the machine on which the server is running,
351  * or a path to a UNIX-domain socket, or a
352  * comma-separated list of machines and/or
353  * paths; if NULL, use DEFAULT_PGSOCKET_DIR */
354  char *pghostaddr; /* the numeric IP address of the machine on
355  * which the server is running, or a
356  * comma-separated list of same. Takes
357  * precedence over pghost. */
358  char *pgport; /* the server's communication port number, or
359  * a comma-separated list of ports */
360  char *connect_timeout; /* connection timeout (numeric string) */
361  char *pgtcp_user_timeout; /* tcp user timeout (numeric string) */
362  char *client_encoding_initial; /* encoding to use */
363  char *pgoptions; /* options to start the backend with */
364  char *appname; /* application name */
365  char *fbappname; /* fallback application name */
366  char *dbName; /* database name */
367  char *replication; /* connect as the replication standby? */
368  char *pguser; /* Postgres username and password, if any */
369  char *pgpass;
370  char *pgpassfile; /* path to a file containing password(s) */
371  char *channel_binding; /* channel binding mode
372  * (require,prefer,disable) */
373  char *keepalives; /* use TCP keepalives? */
374  char *keepalives_idle; /* time between TCP keepalives */
375  char *keepalives_interval; /* time between TCP keepalive
376  * retransmits */
377  char *keepalives_count; /* maximum number of TCP keepalive
378  * retransmits */
379  char *sslmode; /* SSL mode (require,prefer,allow,disable) */
380  char *sslcompression; /* SSL compression (0 or 1) */
381  char *sslkey; /* client key filename */
382  char *sslcert; /* client certificate filename */
383  char *sslpassword; /* client key file password */
384  char *sslrootcert; /* root certificate filename */
385  char *sslcrl; /* certificate revocation list filename */
386  char *sslcrldir; /* certificate revocation list directory name */
387  char *sslsni; /* use SSL SNI extension (0 or 1) */
388  char *requirepeer; /* required peer credentials for local sockets */
389  char *gssencmode; /* GSS mode (require,prefer,disable) */
390  char *krbsrvname; /* Kerberos service name */
391  char *gsslib; /* What GSS library to use ("gssapi" or
392  * "sspi") */
393  char *ssl_min_protocol_version; /* minimum TLS protocol version */
394  char *ssl_max_protocol_version; /* maximum TLS protocol version */
395  char *target_session_attrs; /* desired session properties */
396 
397  /* Optional file to write trace info to */
398  FILE *Pfdebug;
400 
401  /* Callback procedures for notice message processing */
403 
404  /* Event procs registered via PQregisterEventProc */
405  PGEvent *events; /* expandable array of event data */
406  int nEvents; /* number of active events */
407  int eventArraySize; /* allocated array size */
408 
409  /* Status indicators */
412  PGTransactionStatusType xactStatus; /* never changes to ACTIVE */
413  char last_sqlstate[6]; /* last reported SQLSTATE */
414  bool options_valid; /* true if OK to attempt connection */
415  bool nonblocking; /* whether this connection is using nonblock
416  * sending semantics */
417  PGpipelineStatus pipelineStatus; /* status of pipeline mode */
418  bool singleRowMode; /* return current query result row-by-row? */
419  char copy_is_binary; /* 1 = copy binary, 0 = copy text */
420  int copy_already_done; /* # bytes already returned in COPY OUT */
421  PGnotify *notifyHead; /* oldest unreported Notify msg */
422  PGnotify *notifyTail; /* newest unreported Notify msg */
423 
424  /* Support for multiple hosts in connection string */
425  int nconnhost; /* # of hosts named in conn string */
426  int whichhost; /* host we're currently trying/connected to */
427  pg_conn_host *connhost; /* details about each named host */
428  char *connip; /* IP address for current network connection */
429 
430  /*
431  * The pending command queue as a singly-linked list. Head is the command
432  * currently in execution, tail is where new commands are added.
433  */
436 
437  /*
438  * To save malloc traffic, we don't free entries right away; instead we
439  * save them in this list for possible reuse.
440  */
442 
443  /* Connection data */
444  pgsocket sock; /* FD for socket, PGINVALID_SOCKET if
445  * unconnected */
446  SockAddr laddr; /* Local address */
447  SockAddr raddr; /* Remote address */
448  ProtocolVersion pversion; /* FE/BE protocol version in use */
449  int sversion; /* server version, e.g. 70401 for 7.4.1 */
450  bool auth_req_received; /* true if any type of auth req received */
451  bool password_needed; /* true if server demanded a password */
452  bool sigpipe_so; /* have we masked SIGPIPE via SO_NOSIGPIPE? */
453  bool sigpipe_flag; /* can we mask SIGPIPE via MSG_NOSIGNAL? */
454  bool write_failed; /* have we had a write failure on sock? */
455  char *write_err_msg; /* write error message, or NULL if OOM */
456 
457  /* Transient state needed while establishing connection */
458  PGTargetServerType target_server_type; /* desired session properties */
459  bool try_next_addr; /* time to advance to next address/host? */
460  bool try_next_host; /* time to advance to next connhost[]? */
461  struct addrinfo *addrlist; /* list of addresses for current connhost */
462  struct addrinfo *addr_cur; /* the one currently being tried */
463  int addrlist_family; /* needed to know how to free addrlist */
464  bool send_appname; /* okay to send application_name? */
465 
466  /* Miscellaneous stuff */
467  int be_pid; /* PID of backend --- needed for cancels */
468  int be_key; /* key of backend --- needed for cancels */
469  pgParameterStatus *pstatus; /* ParameterStatus data */
470  int client_encoding; /* encoding id */
471  bool std_strings; /* standard_conforming_strings */
472  PGTernaryBool default_transaction_read_only; /* default_transaction_read_only */
473  PGTernaryBool in_hot_standby; /* in_hot_standby */
474  PGVerbosity verbosity; /* error/notice message verbosity */
475  PGContextVisibility show_context; /* whether to show CONTEXT field */
476  PGlobjfuncs *lobjfuncs; /* private state for large-object access fns */
477 
478  /* Buffer for data received from backend and not yet processed */
479  char *inBuffer; /* currently allocated buffer */
480  int inBufSize; /* allocated size of buffer */
481  int inStart; /* offset to first unconsumed data in buffer */
482  int inCursor; /* next byte to tentatively consume */
483  int inEnd; /* offset to first position after avail data */
484 
485  /* Buffer for data not yet sent to backend */
486  char *outBuffer; /* currently allocated buffer */
487  int outBufSize; /* allocated size of buffer */
488  int outCount; /* number of chars waiting in buffer */
489 
490  /* State for constructing messages in outBuffer */
491  int outMsgStart; /* offset to msg start (length word); if -1,
492  * msg has no length word */
493  int outMsgEnd; /* offset to msg end (so far) */
494 
495  /* Row processor interface workspace */
496  PGdataValue *rowBuf; /* array for passing values to rowProcessor */
497  int rowBufLen; /* number of entries allocated in rowBuf */
498 
499  /*
500  * Status for asynchronous result construction. If result isn't NULL, it
501  * is a result being constructed or ready to return. If result is NULL
502  * and error_result is true, then we need to return a PGRES_FATAL_ERROR
503  * result, but haven't yet constructed it; text for the error has been
504  * appended to conn->errorMessage. (Delaying construction simplifies
505  * dealing with out-of-memory cases.) If next_result isn't NULL, it is a
506  * PGresult that will replace "result" after we return that one.
507  */
508  PGresult *result; /* result being constructed */
509  bool error_result; /* do we need to make an ERROR result? */
510  PGresult *next_result; /* next result (used in single-row mode) */
511 
512  /* Assorted state for SASL, SSL, GSS, etc */
514  void *sasl_state;
515 
516  /* SSL structures */
518 
519 #ifdef USE_SSL
520  bool allow_ssl_try; /* Allowed to try SSL negotiation */
521  bool wait_ssl_try; /* Delay SSL negotiation until after
522  * attempting normal connection */
523 #ifdef USE_OPENSSL
524  SSL *ssl; /* SSL status, if have SSL connection */
525  X509 *peer; /* X509 cert of server */
526 #ifdef USE_SSL_ENGINE
527  ENGINE *engine; /* SSL engine, if any */
528 #else
529  void *engine; /* dummy field to keep struct the same if
530  * OpenSSL version changes */
531 #endif
532  bool crypto_loaded; /* Track if libcrypto locking callbacks have
533  * been done for this connection. This can be
534  * removed once support for OpenSSL 1.0.2 is
535  * removed as this locking is handled
536  * internally in OpenSSL >= 1.1.0. */
537 #endif /* USE_OPENSSL */
538 #endif /* USE_SSL */
539 
540 #ifdef ENABLE_GSS
541  gss_ctx_id_t gctx; /* GSS context */
542  gss_name_t gtarg_nam; /* GSS target name */
543 
544  /* The following are encryption-only */
545  bool try_gss; /* GSS attempting permitted */
546  bool gssenc; /* GSS encryption is usable */
547  gss_cred_id_t gcred; /* GSS credential temp storage. */
548 
549  /* GSS encryption I/O state --- see fe-secure-gssapi.c */
550  char *gss_SendBuffer; /* Encrypted data waiting to be sent */
551  int gss_SendLength; /* End of data available in gss_SendBuffer */
552  int gss_SendNext; /* Next index to send a byte from
553  * gss_SendBuffer */
554  int gss_SendConsumed; /* Number of *unencrypted* bytes consumed
555  * for current contents of gss_SendBuffer */
556  char *gss_RecvBuffer; /* Received, encrypted data */
557  int gss_RecvLength; /* End of data available in gss_RecvBuffer */
558  char *gss_ResultBuffer; /* Decryption of data in gss_RecvBuffer */
559  int gss_ResultLength; /* End of data available in
560  * gss_ResultBuffer */
561  int gss_ResultNext; /* Next index to read a byte from
562  * gss_ResultBuffer */
563  uint32 gss_MaxPktSize; /* Maximum size we can encrypt and fit the
564  * results into our output buffer */
565 #endif
566 
567 #ifdef ENABLE_SSPI
568  CredHandle *sspicred; /* SSPI credentials handle */
569  CtxtHandle *sspictx; /* SSPI context */
570  char *sspitarget; /* SSPI target name */
571  int usesspi; /* Indicate if SSPI is in use on the
572  * connection */
573 #endif
574 
575  /*
576  * Buffer for current error message. This is cleared at the start of any
577  * connection attempt or query cycle; after that, all code should append
578  * messages to it, never overwrite.
579  *
580  * In some situations we might report an error more than once in a query
581  * cycle. If so, errorMessage accumulates text from all the errors, and
582  * errorReported tracks how much we've already reported, so that the
583  * individual error PGresult objects don't contain duplicative text.
584  */
585  PQExpBufferData errorMessage; /* expansible string */
586  int errorReported; /* # bytes of string already reported */
587 
588  /* Buffer for receiving various parts of messages */
589  PQExpBufferData workBuffer; /* expansible string */
590 };
591 
592 /* PGcancel stores all data necessary to cancel a connection. A copy of this
593  * data is required to safely cancel a connection running on a different
594  * thread.
595  */
596 struct pg_cancel
597 {
598  SockAddr raddr; /* Remote address */
599  int be_pid; /* PID of backend --- needed for cancels */
600  int be_key; /* key of backend --- needed for cancels */
601  int pgtcp_user_timeout; /* tcp user timeout */
602  int keepalives; /* use TCP keepalives? */
603  int keepalives_idle; /* time between TCP keepalives */
604  int keepalives_interval; /* time between TCP keepalive
605  * retransmits */
606  int keepalives_count; /* maximum number of TCP keepalive
607  * retransmits */
608 };
609 
610 
611 /* String descriptions of the ExecStatusTypes.
612  * direct use of this array is deprecated; call PQresStatus() instead.
613  */
614 extern char *const pgresStatus[];
615 
616 
617 #ifdef USE_SSL
618 
619 #ifndef WIN32
620 #define USER_CERT_FILE ".postgresql/postgresql.crt"
621 #define USER_KEY_FILE ".postgresql/postgresql.key"
622 #define ROOT_CERT_FILE ".postgresql/root.crt"
623 #define ROOT_CRL_FILE ".postgresql/root.crl"
624 #else
625 /* On Windows, the "home" directory is already PostgreSQL-specific */
626 #define USER_CERT_FILE "postgresql.crt"
627 #define USER_KEY_FILE "postgresql.key"
628 #define ROOT_CERT_FILE "root.crt"
629 #define ROOT_CRL_FILE "root.crl"
630 #endif
631 
632 #endif /* USE_SSL */
633 
634 /* ----------------
635  * Internal functions of libpq
636  * Functions declared here need to be visible across files of libpq,
637  * but are not intended to be called by applications. We use the
638  * convention "pqXXX" for internal functions, vs. the "PQxxx" names
639  * used for application-visible routines.
640  * ----------------
641  */
642 
643 /* === in fe-connect.c === */
644 
645 extern void pqDropConnection(PGconn *conn, bool flushInput);
646 extern int pqPacketSend(PGconn *conn, char pack_type,
647  const void *buf, size_t buf_len);
648 extern bool pqGetHomeDirectory(char *buf, int bufsize);
649 
650 #ifdef ENABLE_THREAD_SAFETY
652 
653 #define pglock_thread() pg_g_threadlock(true)
654 #define pgunlock_thread() pg_g_threadlock(false)
655 #else
656 #define pglock_thread() ((void) 0)
657 #define pgunlock_thread() ((void) 0)
658 #endif
659 
660 /* === in fe-exec.c === */
661 
662 extern void pqSetResultError(PGresult *res, PQExpBuffer errorMessage, int offset);
663 extern void *pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary);
664 extern char *pqResultStrdup(PGresult *res, const char *str);
665 extern void pqClearAsyncResult(PGconn *conn);
666 extern void pqSaveErrorResult(PGconn *conn);
668 extern void pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...) pg_attribute_printf(2, 3);
669 extern void pqSaveMessageField(PGresult *res, char code,
670  const char *value);
671 extern void pqSaveParameterStatus(PGconn *conn, const char *name,
672  const char *value);
673 extern int pqRowProcessor(PGconn *conn, const char **errmsgp);
674 extern void pqCommandQueueAdvance(PGconn *conn);
675 extern int PQsendQueryContinue(PGconn *conn, const char *query);
676 
677 /* === in fe-protocol3.c === */
678 
679 extern char *pqBuildStartupPacket3(PGconn *conn, int *packetlen,
681 extern void pqParseInput3(PGconn *conn);
682 extern int pqGetErrorNotice3(PGconn *conn, bool isError);
683 extern void pqBuildErrorMessage3(PQExpBuffer msg, const PGresult *res,
684  PGVerbosity verbosity, PGContextVisibility show_context);
685 extern int pqGetCopyData3(PGconn *conn, char **buffer, int async);
686 extern int pqGetline3(PGconn *conn, char *s, int maxlen);
687 extern int pqGetlineAsync3(PGconn *conn, char *buffer, int bufsize);
688 extern int pqEndcopy3(PGconn *conn);
689 extern PGresult *pqFunctionCall3(PGconn *conn, Oid fnid,
690  int *result_buf, int *actual_result_len,
691  int result_is_int,
692  const PQArgBlock *args, int nargs);
693 
694 /* === in fe-misc.c === */
695 
696  /*
697  * "Get" and "Put" routines return 0 if successful, EOF if not. Note that for
698  * Get, EOF merely means the buffer is exhausted, not that there is
699  * necessarily any error.
700  */
701 extern int pqCheckOutBufferSpace(size_t bytes_needed, PGconn *conn);
702 extern int pqCheckInBufferSpace(size_t bytes_needed, PGconn *conn);
703 extern int pqGetc(char *result, PGconn *conn);
704 extern int pqPutc(char c, PGconn *conn);
705 extern int pqGets(PQExpBuffer buf, PGconn *conn);
706 extern int pqGets_append(PQExpBuffer buf, PGconn *conn);
707 extern int pqPuts(const char *s, PGconn *conn);
708 extern int pqGetnchar(char *s, size_t len, PGconn *conn);
709 extern int pqSkipnchar(size_t len, PGconn *conn);
710 extern int pqPutnchar(const char *s, size_t len, PGconn *conn);
711 extern int pqGetInt(int *result, size_t bytes, PGconn *conn);
712 extern int pqPutInt(int value, size_t bytes, PGconn *conn);
713 extern int pqPutMsgStart(char msg_type, PGconn *conn);
714 extern int pqPutMsgEnd(PGconn *conn);
715 extern int pqReadData(PGconn *conn);
716 extern int pqFlush(PGconn *conn);
717 extern int pqWait(int forRead, int forWrite, PGconn *conn);
718 extern int pqWaitTimed(int forRead, int forWrite, PGconn *conn,
719  time_t finish_time);
720 extern int pqReadReady(PGconn *conn);
721 extern int pqWriteReady(PGconn *conn);
722 
723 /* === in fe-secure.c === */
724 
725 extern int pqsecure_initialize(PGconn *, bool, bool);
727 extern void pqsecure_close(PGconn *);
728 extern ssize_t pqsecure_read(PGconn *, void *ptr, size_t len);
729 extern ssize_t pqsecure_write(PGconn *, const void *ptr, size_t len);
730 extern ssize_t pqsecure_raw_read(PGconn *, void *ptr, size_t len);
731 extern ssize_t pqsecure_raw_write(PGconn *, const void *ptr, size_t len);
732 
733 #if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
734 extern int pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending);
735 extern void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending,
736  bool got_epipe);
737 #endif
738 
739 /* === SSL === */
740 
741 /*
742  * The SSL implementation provides these functions.
743  */
744 
745 /*
746  * Implementation of PQinitSSL().
747  */
748 extern void pgtls_init_library(bool do_ssl, int do_crypto);
749 
750 /*
751  * Initialize SSL library.
752  *
753  * The conn parameter is only used to be able to pass back an error
754  * message - no connection-local setup is made here. do_ssl controls
755  * if SSL is initialized, and do_crypto does the same for the crypto
756  * part.
757  *
758  * Returns 0 if OK, -1 on failure (adding a message to conn->errorMessage).
759  */
760 extern int pgtls_init(PGconn *conn, bool do_ssl, bool do_crypto);
761 
762 /*
763  * Begin or continue negotiating a secure session.
764  */
766 
767 /*
768  * Close SSL connection.
769  */
770 extern void pgtls_close(PGconn *conn);
771 
772 /*
773  * Read data from a secure connection.
774  *
775  * On failure, this function is responsible for appending a suitable message
776  * to conn->errorMessage. The caller must still inspect errno, but only
777  * to determine whether to continue/retry after error.
778  */
779 extern ssize_t pgtls_read(PGconn *conn, void *ptr, size_t len);
780 
781 /*
782  * Is there unread data waiting in the SSL read buffer?
783  */
784 extern bool pgtls_read_pending(PGconn *conn);
785 
786 /*
787  * Write data to a secure connection.
788  *
789  * On failure, this function is responsible for appending a suitable message
790  * to conn->errorMessage. The caller must still inspect errno, but only
791  * to determine whether to continue/retry after error.
792  */
793 extern ssize_t pgtls_write(PGconn *conn, const void *ptr, size_t len);
794 
795 /*
796  * Get the hash of the server certificate, for SCRAM channel binding type
797  * tls-server-end-point.
798  *
799  * NULL is sent back to the caller in the event of an error, with an
800  * error message for the caller to consume.
801  *
802  * This is not supported with old versions of OpenSSL that don't have
803  * the X509_get_signature_nid() function.
804  */
805 #if defined(USE_OPENSSL) && defined(HAVE_X509_GET_SIGNATURE_NID)
806 #define HAVE_PGTLS_GET_PEER_CERTIFICATE_HASH
807 extern char *pgtls_get_peer_certificate_hash(PGconn *conn, size_t *len);
808 #endif
809 
810 /*
811  * Verify that the server certificate matches the host name we connected to.
812  *
813  * The certificate's Common Name and Subject Alternative Names are considered.
814  *
815  * Returns 1 if the name matches, and 0 if it does not. On error, returns
816  * -1, and sets the libpq error message.
817  *
818  */
820  int *names_examined,
821  char **first_name);
822 
823 /* === GSSAPI === */
824 
825 #ifdef ENABLE_GSS
826 
827 /*
828  * Establish a GSSAPI-encrypted connection.
829  */
831 
832 /*
833  * Read and write functions for GSSAPI-encrypted connections, with internal
834  * buffering to handle nonblocking sockets.
835  */
836 extern ssize_t pg_GSS_write(PGconn *conn, const void *ptr, size_t len);
837 extern ssize_t pg_GSS_read(PGconn *conn, void *ptr, size_t len);
838 #endif
839 
840 /* === in libpq-trace.c === */
841 
842 extern void pqTraceOutputMessage(PGconn *conn, const char *message,
843  bool toServer);
844 extern void pqTraceOutputNoTypeByteMessage(PGconn *conn, const char *message);
845 
846 /* === miscellaneous macros === */
847 
848 /*
849  * Reset the conn's error-reporting state.
850  */
851 #define pqClearConnErrorState(conn) \
852  (resetPQExpBuffer(&(conn)->errorMessage), \
853  (conn)->errorReported = 0)
854 
855 /*
856  * Check whether we have a PGresult pending to be returned --- either a
857  * constructed one in conn->result, or a "virtual" error result that we
858  * don't intend to materialize until the end of the query cycle.
859  */
860 #define pgHavePendingResult(conn) \
861  ((conn)->result != NULL || (conn)->error_result)
862 
863 /*
864  * this is so that we can check if a connection is non-blocking internally
865  * without the overhead of a function call
866  */
867 #define pqIsnonblocking(conn) ((conn)->nonblocking)
868 
869 /*
870  * Connection's outbuffer threshold, for pipeline mode.
871  */
872 #define OUTBUFFER_THRESHOLD 65536
873 
874 #ifdef ENABLE_NLS
875 extern char *libpq_gettext(const char *msgid) pg_attribute_format_arg(1);
876 extern char *libpq_ngettext(const char *msgid, const char *msgid_plural, unsigned long n) pg_attribute_format_arg(1) pg_attribute_format_arg(2);
877 #else
878 #define libpq_gettext(x) (x)
879 #define libpq_ngettext(s, p, n) ((n) == 1 ? (s) : (p))
880 #endif
881 
882 /*
883  * These macros are needed to let error-handling code be portable between
884  * Unix and Windows. (ugh)
885  */
886 #ifdef WIN32
887 #define SOCK_ERRNO (WSAGetLastError())
888 #define SOCK_STRERROR winsock_strerror
889 #define SOCK_ERRNO_SET(e) WSASetLastError(e)
890 #else
891 #define SOCK_ERRNO errno
892 #define SOCK_STRERROR strerror_r
893 #define SOCK_ERRNO_SET(e) (errno = (e))
894 #endif
895 
896 #endif /* LIBPQ_INT_H */
unsigned int uint32
Definition: c.h:452
#define pg_attribute_format_arg(a)
Definition: c.h:174
#define pg_attribute_printf(f, a)
Definition: c.h:175
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:361
const char * name
Definition: encode.c:561
pgthreadlock_t pg_g_threadlock
Definition: fe-connect.c:433
ssize_t pg_GSS_read(PGconn *conn, void *ptr, size_t len)
ssize_t pg_GSS_write(PGconn *conn, const void *ptr, size_t len)
PostgresPollingStatusType pqsecure_open_gss(PGconn *conn)
static struct @151 value
int(* PGEventProc)(PGEventId evtId, void *evtInfo, void *passThrough)
Definition: libpq-events.h:69
ConnStatusType
Definition: libpq-fe.h:59
ExecStatusType
Definition: libpq-fe.h:95
void(* pgthreadlock_t)(int acquire)
Definition: libpq-fe.h:404
PGContextVisibility
Definition: libpq-fe.h:134
PGTransactionStatusType
Definition: libpq-fe.h:117
void(* PQnoticeReceiver)(void *arg, const PGresult *res)
Definition: libpq-fe.h:197
void(* PQnoticeProcessor)(void *arg, const char *message)
Definition: libpq-fe.h:198
PostgresPollingStatusType
Definition: libpq-fe.h:85
PGpipelineStatus
Definition: libpq-fe.h:157
PGVerbosity
Definition: libpq-fe.h:126
int pqPutc(char c, PGconn *conn)
Definition: fe-misc.c:95
struct PGEvent PGEvent
int pqReadData(PGconn *conn)
Definition: fe-misc.c:568
PGAsyncStatusType
Definition: libpq-int.h:218
@ PGASYNC_COPY_OUT
Definition: libpq-int.h:227
@ PGASYNC_READY_MORE
Definition: libpq-int.h:223
@ PGASYNC_READY
Definition: libpq-int.h:221
@ PGASYNC_COPY_BOTH
Definition: libpq-int.h:228
@ PGASYNC_IDLE
Definition: libpq-int.h:219
@ PGASYNC_COPY_IN
Definition: libpq-int.h:226
@ PGASYNC_BUSY
Definition: libpq-int.h:220
void pqDropConnection(PGconn *conn, bool flushInput)
Definition: fe-connect.c:449
int PQsendQueryContinue(PGconn *conn, const char *query)
Definition: fe-exec.c:1426
int pqPutInt(int value, size_t bytes, PGconn *conn)
Definition: fe-misc.c:256
#define libpq_gettext(x)
Definition: libpq-int.h:878
int pqCheckOutBufferSpace(size_t bytes_needed, PGconn *conn)
Definition: fe-misc.c:290
ssize_t pqsecure_raw_write(PGconn *, const void *ptr, size_t len)
Definition: fe-secure.c:350
int pqFlush(PGconn *conn)
Definition: fe-misc.c:958
PGQueryClass
Definition: libpq-int.h:309
@ PGQUERY_SIMPLE
Definition: libpq-int.h:310
@ PGQUERY_SYNC
Definition: libpq-int.h:314
@ PGQUERY_EXTENDED
Definition: libpq-int.h:311
@ PGQUERY_DESCRIBE
Definition: libpq-int.h:313
@ PGQUERY_PREPARE
Definition: libpq-int.h:312
void pqBuildErrorMessage3(PQExpBuffer msg, const PGresult *res, PGVerbosity verbosity, PGContextVisibility show_context)
#define CMDSTATUS_LEN
Definition: libpq-int.h:87
void pqParseInput3(PGconn *conn)
Definition: fe-protocol3.c:63
ssize_t pqsecure_raw_read(PGconn *, void *ptr, size_t len)
Definition: fe-secure.c:232
int pqReadReady(PGconn *conn)
Definition: fe-misc.c:1020
ssize_t pqsecure_write(PGconn *, const void *ptr, size_t len)
Definition: fe-secure.c:301
int pqPutMsgStart(char msg_type, PGconn *conn)
Definition: fe-misc.c:461
int pqSkipnchar(size_t len, PGconn *conn)
Definition: fe-misc.c:190
int pqEndcopy3(PGconn *conn)
PGresult * pqFunctionCall3(PGconn *conn, Oid fnid, int *result_buf, int *actual_result_len, int result_is_int, const PQArgBlock *args, int nargs)
bool pqGetHomeDirectory(char *buf, int bufsize)
Definition: fe-connect.c:7333
int pgtls_verify_peer_name_matches_certificate_guts(PGconn *conn, int *names_examined, char **first_name)
void pqSetResultError(PGresult *res, PQExpBuffer errorMessage, int offset)
Definition: fe-exec.c:689
struct pg_conn_host pg_conn_host
void pqSaveErrorResult(PGconn *conn)
Definition: fe-exec.c:800
char *const pgresStatus[]
Definition: fe-exec.c:32
PostgresPollingStatusType pgtls_open_client(PGconn *conn)
bool pgtls_read_pending(PGconn *conn)
char * pqResultStrdup(PGresult *res, const char *str)
Definition: fe-exec.c:672
int pqGetlineAsync3(PGconn *conn, char *buffer, int bufsize)
int pqGetCopyData3(PGconn *conn, char **buffer, int async)
int pqRowProcessor(PGconn *conn, const char **errmsgp)
Definition: fe-exec.c:1204
struct pgresParamDesc PGresParamDesc
int pqGetc(char *result, PGconn *conn)
Definition: fe-misc.c:80
struct PGcmdQueueEntry PGcmdQueueEntry
int pqsecure_initialize(PGconn *, bool, bool)
Definition: fe-secure.c:162
void pgtls_init_library(bool do_ssl, int do_crypto)
int pqGetInt(int *result, size_t bytes, PGconn *conn)
Definition: fe-misc.c:219
int pqGetnchar(char *s, size_t len, PGconn *conn)
Definition: fe-misc.c:168
ssize_t pgtls_read(PGconn *conn, void *ptr, size_t len)
void pqsecure_close(PGconn *)
Definition: fe-secure.c:191
void void pqSaveMessageField(PGresult *res, char code, const char *value)
Definition: fe-exec.c:1057
ssize_t pgtls_write(PGconn *conn, const void *ptr, size_t len)
int pqWait(int forRead, int forWrite, PGconn *conn)
Definition: fe-misc.c:983
pg_conn_host_type
Definition: libpq-int.h:298
@ CHT_UNIX_SOCKET
Definition: libpq-int.h:301
@ CHT_HOST_ADDRESS
Definition: libpq-int.h:300
@ CHT_HOST_NAME
Definition: libpq-int.h:299
PostgresPollingStatusType pqsecure_open_client(PGconn *)
Definition: fe-secure.c:177
int pgtls_init(PGconn *conn, bool do_ssl, bool do_crypto)
struct pgParameterStatus pgParameterStatus
int pqGets(PQExpBuffer buf, PGconn *conn)
Definition: fe-misc.c:139
struct pgMessageField PGMessageField
void pqSaveParameterStatus(PGconn *conn, const char *name, const char *value)
Definition: fe-exec.c:1078
void pqClearAsyncResult(PGconn *conn)
Definition: fe-exec.c:776
void pqTraceOutputMessage(PGconn *conn, const char *message, bool toServer)
Definition: fe-trace.c:529
int pqCheckInBufferSpace(size_t bytes_needed, PGconn *conn)
Definition: fe-misc.c:354
int pqPutnchar(const char *s, size_t len, PGconn *conn)
Definition: fe-misc.c:205
struct pgDataValue PGdataValue
PGTernaryBool
Definition: libpq-int.h:245
@ PG_BOOL_YES
Definition: libpq-int.h:247
@ PG_BOOL_NO
Definition: libpq-int.h:248
@ PG_BOOL_UNKNOWN
Definition: libpq-int.h:246
void pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...) pg_attribute_printf(2
#define libpq_ngettext(s, p, n)
Definition: libpq-int.h:879
void * pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary)
Definition: fe-exec.c:560
int pqPuts(const char *s, PGconn *conn)
Definition: fe-misc.c:155
ssize_t pqsecure_read(PGconn *, void *ptr, size_t len)
Definition: fe-secure.c:206
struct PQEnvironmentOption PQEnvironmentOption
int pqWaitTimed(int forRead, int forWrite, PGconn *conn, time_t finish_time)
Definition: fe-misc.c:996
PGTargetServerType
Definition: libpq-int.h:233
@ SERVER_TYPE_STANDBY
Definition: libpq-int.h:238
@ SERVER_TYPE_PRIMARY
Definition: libpq-int.h:237
@ SERVER_TYPE_ANY
Definition: libpq-int.h:234
@ SERVER_TYPE_READ_WRITE
Definition: libpq-int.h:235
@ SERVER_TYPE_PREFER_STANDBY_PASS2
Definition: libpq-int.h:240
@ SERVER_TYPE_PREFER_STANDBY
Definition: libpq-int.h:239
@ SERVER_TYPE_READ_ONLY
Definition: libpq-int.h:236
int pqGetline3(PGconn *conn, char *s, int maxlen)
int pqGetErrorNotice3(PGconn *conn, bool isError)
Definition: fe-protocol3.c:890
void pgtls_close(PGconn *conn)
char * pqBuildStartupPacket3(PGconn *conn, int *packetlen, const PQEnvironmentOption *options)
struct pgLobjfuncs PGlobjfuncs
void pqTraceOutputNoTypeByteMessage(PGconn *conn, const char *message)
Definition: fe-trace.c:694
int pqGets_append(PQExpBuffer buf, PGconn *conn)
Definition: fe-misc.c:145
PGresult * pqPrepareAsyncResult(PGconn *conn)
Definition: fe-exec.c:847
int pqWriteReady(PGconn *conn)
Definition: fe-misc.c:1030
int pqPutMsgEnd(PGconn *conn)
Definition: fe-misc.c:520
struct pgresAttValue PGresAttValue
int pqPacketSend(PGconn *conn, char pack_type, const void *buf, size_t buf_len)
Definition: fe-connect.c:4673
void pqCommandQueueAdvance(PGconn *conn)
Definition: fe-exec.c:3057
static void const char * fmt
const void size_t len
static char * buf
Definition: pg_test_fsync.c:67
int pgsocket
Definition: port.h:29
unsigned int Oid
Definition: postgres_ext.h:31
uint32 ProtocolVersion
Definition: pqcomm.h:125
char * c
PGconn * conn
Definition: streamutil.c:54
void * passThrough
Definition: libpq-int.h:163
char * name
Definition: libpq-int.h:162
void * data
Definition: libpq-int.h:164
PGEventProc proc
Definition: libpq-int.h:161
bool resultInitialized
Definition: libpq-int.h:165
void * noticeProcArg
Definition: libpq-int.h:156
PQnoticeReceiver noticeRec
Definition: libpq-int.h:153
PQnoticeProcessor noticeProc
Definition: libpq-int.h:155
void * noticeRecArg
Definition: libpq-int.h:154
PGQueryClass queryclass
Definition: libpq-int.h:322
struct PGcmdQueueEntry * next
Definition: libpq-int.h:324
const char * pgName
Definition: libpq-int.h:255
const char * envName
Definition: libpq-int.h:254
const char * value
Definition: libpq-int.h:293
Oid fn_lo_tell64
Definition: libpq-int.h:278
Oid fn_lo_write
Definition: libpq-int.h:282
Oid fn_lo_creat
Definition: libpq-int.h:272
Oid fn_lo_unlink
Definition: libpq-int.h:274
Oid fn_lo_open
Definition: libpq-int.h:270
Oid fn_lo_truncate64
Definition: libpq-int.h:280
Oid fn_lo_close
Definition: libpq-int.h:271
Oid fn_lo_create
Definition: libpq-int.h:273
Oid fn_lo_truncate
Definition: libpq-int.h:279
Oid fn_lo_lseek
Definition: libpq-int.h:275
Oid fn_lo_tell
Definition: libpq-int.h:277
Oid fn_lo_lseek64
Definition: libpq-int.h:276
Oid fn_lo_read
Definition: libpq-int.h:281
struct pgMessageField * next
Definition: libpq-int.h:145
char contents[FLEXIBLE_ARRAY_MEMBER]
Definition: libpq-int.h:147
struct pgParameterStatus * next
Definition: libpq-int.h:261
int pgtcp_user_timeout
Definition: libpq-int.h:601
int keepalives_interval
Definition: libpq-int.h:604
int keepalives_idle
Definition: libpq-int.h:603
int keepalives_count
Definition: libpq-int.h:606
SockAddr raddr
Definition: libpq-int.h:598
int be_pid
Definition: libpq-int.h:599
int keepalives
Definition: libpq-int.h:602
int be_key
Definition: libpq-int.h:600
char * host
Definition: libpq-int.h:335
char * password
Definition: libpq-int.h:338
char * port
Definition: libpq-int.h:337
char * hostaddr
Definition: libpq-int.h:336
pg_conn_host_type type
Definition: libpq-int.h:334
SockAddr laddr
Definition: libpq-int.h:446
bool try_next_host
Definition: libpq-int.h:460
struct addrinfo * addrlist
Definition: libpq-int.h:461
char * replication
Definition: libpq-int.h:367
char * write_err_msg
Definition: libpq-int.h:455
PGnotify * notifyHead
Definition: libpq-int.h:421
char * sslrootcert
Definition: libpq-int.h:384
PGdataValue * rowBuf
Definition: libpq-int.h:496
char * sslcompression
Definition: libpq-int.h:380
bool sigpipe_flag
Definition: libpq-int.h:453
bool singleRowMode
Definition: libpq-int.h:418
int nconnhost
Definition: libpq-int.h:425
pgsocket sock
Definition: libpq-int.h:444
char * inBuffer
Definition: libpq-int.h:479
char * channel_binding
Definition: libpq-int.h:371
ProtocolVersion pversion
Definition: libpq-int.h:448
int addrlist_family
Definition: libpq-int.h:463
PGresult * next_result
Definition: libpq-int.h:510
bool std_strings
Definition: libpq-int.h:471
int errorReported
Definition: libpq-int.h:586
bool write_failed
Definition: libpq-int.h:454
char * sslcrldir
Definition: libpq-int.h:386
char * pgoptions
Definition: libpq-int.h:363
bool send_appname
Definition: libpq-int.h:464
PGTransactionStatusType xactStatus
Definition: libpq-int.h:412
char * sslcrl
Definition: libpq-int.h:385
char * pghost
Definition: libpq-int.h:350
const pg_fe_sasl_mech * sasl
Definition: libpq-int.h:513
int inCursor
Definition: libpq-int.h:482
char * ssl_max_protocol_version
Definition: libpq-int.h:394
PGTernaryBool in_hot_standby
Definition: libpq-int.h:473
char * pgpass
Definition: libpq-int.h:369
int be_pid
Definition: libpq-int.h:467
PGcmdQueueEntry * cmd_queue_recycle
Definition: libpq-int.h:441
char * dbName
Definition: libpq-int.h:366
int inEnd
Definition: libpq-int.h:483
char * fbappname
Definition: libpq-int.h:365
char * sslcert
Definition: libpq-int.h:382
char * target_session_attrs
Definition: libpq-int.h:395
PGcmdQueueEntry * cmd_queue_tail
Definition: libpq-int.h:435
int be_key
Definition: libpq-int.h:468
PGnotify * notifyTail
Definition: libpq-int.h:422
int copy_already_done
Definition: libpq-int.h:420
int inBufSize
Definition: libpq-int.h:480
char * sslpassword
Definition: libpq-int.h:383
bool nonblocking
Definition: libpq-int.h:415
int client_encoding
Definition: libpq-int.h:470
PQExpBufferData workBuffer
Definition: libpq-int.h:589
int inStart
Definition: libpq-int.h:481
char * keepalives_idle
Definition: libpq-int.h:374
char * connip
Definition: libpq-int.h:428
int sversion
Definition: libpq-int.h:449
bool auth_req_received
Definition: libpq-int.h:450
PGTernaryBool default_transaction_read_only
Definition: libpq-int.h:472
pgParameterStatus * pstatus
Definition: libpq-int.h:469
char * pguser
Definition: libpq-int.h:368
char * keepalives
Definition: libpq-int.h:373
PGresult * result
Definition: libpq-int.h:508
bool sigpipe_so
Definition: libpq-int.h:452
PGVerbosity verbosity
Definition: libpq-int.h:474
char * client_encoding_initial
Definition: libpq-int.h:362
char * keepalives_interval
Definition: libpq-int.h:375
char * appname
Definition: libpq-int.h:364
char * sslmode
Definition: libpq-int.h:379
char * pgtcp_user_timeout
Definition: libpq-int.h:361
char * ssl_min_protocol_version
Definition: libpq-int.h:393
struct addrinfo * addr_cur
Definition: libpq-int.h:462
PQExpBufferData errorMessage
Definition: libpq-int.h:585
char * gssencmode
Definition: libpq-int.h:389
int nEvents
Definition: libpq-int.h:406
char * pghostaddr
Definition: libpq-int.h:354
char * sslkey
Definition: libpq-int.h:381
bool error_result
Definition: libpq-int.h:509
int rowBufLen
Definition: libpq-int.h:497
char * pgpassfile
Definition: libpq-int.h:370
char last_sqlstate[6]
Definition: libpq-int.h:413
PGAsyncStatusType asyncStatus
Definition: libpq-int.h:411
char * connect_timeout
Definition: libpq-int.h:360
char * krbsrvname
Definition: libpq-int.h:390
PGpipelineStatus pipelineStatus
Definition: libpq-int.h:417
char copy_is_binary
Definition: libpq-int.h:419
char * gsslib
Definition: libpq-int.h:391
PGlobjfuncs * lobjfuncs
Definition: libpq-int.h:476
int outBufSize
Definition: libpq-int.h:487
bool options_valid
Definition: libpq-int.h:414
PGNoticeHooks noticeHooks
Definition: libpq-int.h:402
PGTargetServerType target_server_type
Definition: libpq-int.h:458
FILE * Pfdebug
Definition: libpq-int.h:398
void * sasl_state
Definition: libpq-int.h:514
PGcmdQueueEntry * cmd_queue_head
Definition: libpq-int.h:434
int outMsgStart
Definition: libpq-int.h:491
SockAddr raddr
Definition: libpq-int.h:447
bool try_next_addr
Definition: libpq-int.h:459
int outCount
Definition: libpq-int.h:488
char * pgport
Definition: libpq-int.h:358
int eventArraySize
Definition: libpq-int.h:407
int traceFlags
Definition: libpq-int.h:399
int outMsgEnd
Definition: libpq-int.h:493
int whichhost
Definition: libpq-int.h:426
PGContextVisibility show_context
Definition: libpq-int.h:475
char * keepalives_count
Definition: libpq-int.h:377
char * requirepeer
Definition: libpq-int.h:388
char * sslsni
Definition: libpq-int.h:387
pg_conn_host * connhost
Definition: libpq-int.h:427
bool ssl_in_use
Definition: libpq-int.h:517
PGEvent * events
Definition: libpq-int.h:405
bool password_needed
Definition: libpq-int.h:451
char * outBuffer
Definition: libpq-int.h:486
ConnStatusType status
Definition: libpq-int.h:410
size_t memorySize
Definition: libpq-int.h:213
int ntups
Definition: libpq-int.h:170
int curOffset
Definition: libpq-int.h:210
int binary
Definition: libpq-int.h:180
PGNoticeHooks noticeHooks
Definition: libpq-int.h:187
char null_field[1]
Definition: libpq-int.h:202
char * errMsg
Definition: libpq-int.h:197
int nEvents
Definition: libpq-int.h:189
PGresAttValue ** tuples
Definition: libpq-int.h:173
int numParameters
Definition: libpq-int.h:176
int spaceLeft
Definition: libpq-int.h:211
PGresAttDesc * attDescs
Definition: libpq-int.h:172
int numAttributes
Definition: libpq-int.h:171
char cmdStatus[CMDSTATUS_LEN]
Definition: libpq-int.h:179
PGMessageField * errFields
Definition: libpq-int.h:198
PGresParamDesc * paramDescs
Definition: libpq-int.h:177
PGEvent * events
Definition: libpq-int.h:188
PGresult_data * curBlock
Definition: libpq-int.h:209
int tupArrSize
Definition: libpq-int.h:175
ExecStatusType resultStatus
Definition: libpq-int.h:178
char * errQuery
Definition: libpq-int.h:199
int client_encoding
Definition: libpq-int.h:190
char * value
Definition: libpq-int.h:139
PGresult_data * next
Definition: libpq-int.h:106
char space[1]
Definition: libpq-int.h:107