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