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