PostgreSQL Source Code  git master
libpq-int.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * libpq-int.h
4  * This file contains internal definitions meant to be used only by
5  * the frontend libpq library, not by applications that call it.
6  *
7  * An application can include this file if it wants to bypass the
8  * official API defined by libpq-fe.h, but code that does so is much
9  * more likely to break across PostgreSQL releases than code that uses
10  * only the official API.
11  *
12  * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
13  * Portions Copyright (c) 1994, Regents of the University of California
14  *
15  * src/interfaces/libpq/libpq-int.h
16  *
17  *-------------------------------------------------------------------------
18  */
19 
20 #ifndef LIBPQ_INT_H
21 #define LIBPQ_INT_H
22 
23 /* We assume libpq-fe.h has already been included. */
24 #include "libpq-events.h"
25 
26 #include <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 *sslrootcert; /* root certificate filename */
388  char *sslcrl; /* certificate revocation list filename */
389  char *sslcrldir; /* certificate revocation list directory name */
390  char *sslsni; /* use SSL SNI extension (0 or 1) */
391  char *requirepeer; /* required peer credentials for local sockets */
392  char *gssencmode; /* GSS mode (require,prefer,disable) */
393  char *krbsrvname; /* Kerberos service name */
394  char *gsslib; /* What GSS library to use ("gssapi" or
395  * "sspi") */
396  char *ssl_min_protocol_version; /* minimum TLS protocol version */
397  char *ssl_max_protocol_version; /* maximum TLS protocol version */
398  char *target_session_attrs; /* desired session properties */
399 
400  /* Optional file to write trace info to */
401  FILE *Pfdebug;
403 
404  /* Callback procedures for notice message processing */
406 
407  /* Event procs registered via PQregisterEventProc */
408  PGEvent *events; /* expandable array of event data */
409  int nEvents; /* number of active events */
410  int eventArraySize; /* allocated array size */
411 
412  /* Status indicators */
415  PGTransactionStatusType xactStatus; /* never changes to ACTIVE */
416  char last_sqlstate[6]; /* last reported SQLSTATE */
417  bool options_valid; /* true if OK to attempt connection */
418  bool nonblocking; /* whether this connection is using nonblock
419  * sending semantics */
420  PGpipelineStatus pipelineStatus; /* status of pipeline mode */
421  bool singleRowMode; /* return current query result row-by-row? */
422  char copy_is_binary; /* 1 = copy binary, 0 = copy text */
423  int copy_already_done; /* # bytes already returned in COPY OUT */
424  PGnotify *notifyHead; /* oldest unreported Notify msg */
425  PGnotify *notifyTail; /* newest unreported Notify msg */
426 
427  /* Support for multiple hosts in connection string */
428  int nconnhost; /* # of hosts named in conn string */
429  int whichhost; /* host we're currently trying/connected to */
430  pg_conn_host *connhost; /* details about each named host */
431  char *connip; /* IP address for current network connection */
432 
433  /*
434  * The pending command queue as a singly-linked list. Head is the command
435  * currently in execution, tail is where new commands are added.
436  */
439 
440  /*
441  * To save malloc traffic, we don't free entries right away; instead we
442  * save them in this list for possible reuse.
443  */
445 
446  /* Connection data */
447  pgsocket sock; /* FD for socket, PGINVALID_SOCKET if
448  * unconnected */
449  SockAddr laddr; /* Local address */
450  SockAddr raddr; /* Remote address */
451  ProtocolVersion pversion; /* FE/BE protocol version in use */
452  int sversion; /* server version, e.g. 70401 for 7.4.1 */
453  bool auth_req_received; /* true if any type of auth req received */
454  bool password_needed; /* true if server demanded a password */
455  bool sigpipe_so; /* have we masked SIGPIPE via SO_NOSIGPIPE? */
456  bool sigpipe_flag; /* can we mask SIGPIPE via MSG_NOSIGNAL? */
457  bool write_failed; /* have we had a write failure on sock? */
458  char *write_err_msg; /* write error message, or NULL if OOM */
459 
460  /* Transient state needed while establishing connection */
461  PGTargetServerType target_server_type; /* desired session properties */
462  bool try_next_addr; /* time to advance to next address/host? */
463  bool try_next_host; /* time to advance to next connhost[]? */
464  struct addrinfo *addrlist; /* list of addresses for current connhost */
465  struct addrinfo *addr_cur; /* the one currently being tried */
466  int addrlist_family; /* needed to know how to free addrlist */
467  bool send_appname; /* okay to send application_name? */
468 
469  /* Miscellaneous stuff */
470  int be_pid; /* PID of backend --- needed for cancels */
471  int be_key; /* key of backend --- needed for cancels */
472  pgParameterStatus *pstatus; /* ParameterStatus data */
473  int client_encoding; /* encoding id */
474  bool std_strings; /* standard_conforming_strings */
475  PGTernaryBool default_transaction_read_only; /* default_transaction_read_only */
476  PGTernaryBool in_hot_standby; /* in_hot_standby */
477  PGVerbosity verbosity; /* error/notice message verbosity */
478  PGContextVisibility show_context; /* whether to show CONTEXT field */
479  PGlobjfuncs *lobjfuncs; /* private state for large-object access fns */
480 
481  /* Buffer for data received from backend and not yet processed */
482  char *inBuffer; /* currently allocated buffer */
483  int inBufSize; /* allocated size of buffer */
484  int inStart; /* offset to first unconsumed data in buffer */
485  int inCursor; /* next byte to tentatively consume */
486  int inEnd; /* offset to first position after avail data */
487 
488  /* Buffer for data not yet sent to backend */
489  char *outBuffer; /* currently allocated buffer */
490  int outBufSize; /* allocated size of buffer */
491  int outCount; /* number of chars waiting in buffer */
492 
493  /* State for constructing messages in outBuffer */
494  int outMsgStart; /* offset to msg start (length word); if -1,
495  * msg has no length word */
496  int outMsgEnd; /* offset to msg end (so far) */
497 
498  /* Row processor interface workspace */
499  PGdataValue *rowBuf; /* array for passing values to rowProcessor */
500  int rowBufLen; /* number of entries allocated in rowBuf */
501 
502  /*
503  * Status for asynchronous result construction. If result isn't NULL, it
504  * is a result being constructed or ready to return. If result is NULL
505  * and error_result is true, then we need to return a PGRES_FATAL_ERROR
506  * result, but haven't yet constructed it; text for the error has been
507  * appended to conn->errorMessage. (Delaying construction simplifies
508  * dealing with out-of-memory cases.) If next_result isn't NULL, it is a
509  * PGresult that will replace "result" after we return that one.
510  */
511  PGresult *result; /* result being constructed */
512  bool error_result; /* do we need to make an ERROR result? */
513  PGresult *next_result; /* next result (used in single-row mode) */
514 
515  /* Assorted state for SASL, SSL, GSS, etc */
517  void *sasl_state;
518 
519  /* SSL structures */
521 
522 #ifdef USE_SSL
523  bool allow_ssl_try; /* Allowed to try SSL negotiation */
524  bool wait_ssl_try; /* Delay SSL negotiation until after
525  * attempting normal connection */
526 #ifdef USE_OPENSSL
527  SSL *ssl; /* SSL status, if have SSL connection */
528  X509 *peer; /* X509 cert of server */
529 #ifdef USE_SSL_ENGINE
530  ENGINE *engine; /* SSL engine, if any */
531 #else
532  void *engine; /* dummy field to keep struct the same if
533  * OpenSSL version changes */
534 #endif
535  bool crypto_loaded; /* Track if libcrypto locking callbacks have
536  * been done for this connection. This can be
537  * removed once support for OpenSSL 1.0.2 is
538  * removed as this locking is handled
539  * internally in OpenSSL >= 1.1.0. */
540 #endif /* USE_OPENSSL */
541 #endif /* USE_SSL */
542 
543 #ifdef ENABLE_GSS
544  gss_ctx_id_t gctx; /* GSS context */
545  gss_name_t gtarg_nam; /* GSS target name */
546 
547  /* The following are encryption-only */
548  bool try_gss; /* GSS attempting permitted */
549  bool gssenc; /* GSS encryption is usable */
550  gss_cred_id_t gcred; /* GSS credential temp storage. */
551 
552  /* GSS encryption I/O state --- see fe-secure-gssapi.c */
553  char *gss_SendBuffer; /* Encrypted data waiting to be sent */
554  int gss_SendLength; /* End of data available in gss_SendBuffer */
555  int gss_SendNext; /* Next index to send a byte from
556  * gss_SendBuffer */
557  int gss_SendConsumed; /* Number of *unencrypted* bytes consumed
558  * for current contents of gss_SendBuffer */
559  char *gss_RecvBuffer; /* Received, encrypted data */
560  int gss_RecvLength; /* End of data available in gss_RecvBuffer */
561  char *gss_ResultBuffer; /* Decryption of data in gss_RecvBuffer */
562  int gss_ResultLength; /* End of data available in
563  * gss_ResultBuffer */
564  int gss_ResultNext; /* Next index to read a byte from
565  * gss_ResultBuffer */
566  uint32 gss_MaxPktSize; /* Maximum size we can encrypt and fit the
567  * results into our output buffer */
568 #endif
569 
570 #ifdef ENABLE_SSPI
571  CredHandle *sspicred; /* SSPI credentials handle */
572  CtxtHandle *sspictx; /* SSPI context */
573  char *sspitarget; /* SSPI target name */
574  int usesspi; /* Indicate if SSPI is in use on the
575  * connection */
576 #endif
577 
578  /*
579  * Buffer for current error message. This is cleared at the start of any
580  * connection attempt or query cycle; after that, all code should append
581  * messages to it, never overwrite.
582  *
583  * In some situations we might report an error more than once in a query
584  * cycle. If so, errorMessage accumulates text from all the errors, and
585  * errorReported tracks how much we've already reported, so that the
586  * individual error PGresult objects don't contain duplicative text.
587  */
588  PQExpBufferData errorMessage; /* expansible string */
589  int errorReported; /* # bytes of string already reported */
590 
591  /* Buffer for receiving various parts of messages */
592  PQExpBufferData workBuffer; /* expansible string */
593 };
594 
595 /* PGcancel stores all data necessary to cancel a connection. A copy of this
596  * data is required to safely cancel a connection running on a different
597  * thread.
598  */
599 struct pg_cancel
600 {
601  SockAddr raddr; /* Remote address */
602  int be_pid; /* PID of backend --- needed for cancels */
603  int be_key; /* key of backend --- needed for cancels */
604  int pgtcp_user_timeout; /* tcp user timeout */
605  int keepalives; /* use TCP keepalives? */
606  int keepalives_idle; /* time between TCP keepalives */
607  int keepalives_interval; /* time between TCP keepalive
608  * retransmits */
609  int keepalives_count; /* maximum number of TCP keepalive
610  * retransmits */
611 };
612 
613 
614 /* String descriptions of the ExecStatusTypes.
615  * direct use of this array is deprecated; call PQresStatus() instead.
616  */
617 extern char *const pgresStatus[];
618 
619 
620 #ifdef USE_SSL
621 
622 #ifndef WIN32
623 #define USER_CERT_FILE ".postgresql/postgresql.crt"
624 #define USER_KEY_FILE ".postgresql/postgresql.key"
625 #define ROOT_CERT_FILE ".postgresql/root.crt"
626 #define ROOT_CRL_FILE ".postgresql/root.crl"
627 #else
628 /* On Windows, the "home" directory is already PostgreSQL-specific */
629 #define USER_CERT_FILE "postgresql.crt"
630 #define USER_KEY_FILE "postgresql.key"
631 #define ROOT_CERT_FILE "root.crt"
632 #define ROOT_CRL_FILE "root.crl"
633 #endif
634 
635 #endif /* USE_SSL */
636 
637 /* ----------------
638  * Internal functions of libpq
639  * Functions declared here need to be visible across files of libpq,
640  * but are not intended to be called by applications. We use the
641  * convention "pqXXX" for internal functions, vs. the "PQxxx" names
642  * used for application-visible routines.
643  * ----------------
644  */
645 
646 /* === in fe-connect.c === */
647 
648 extern void pqDropConnection(PGconn *conn, bool flushInput);
649 extern int pqPacketSend(PGconn *conn, char pack_type,
650  const void *buf, size_t buf_len);
651 extern bool pqGetHomeDirectory(char *buf, int bufsize);
652 
653 #ifdef ENABLE_THREAD_SAFETY
655 
656 #define pglock_thread() pg_g_threadlock(true)
657 #define pgunlock_thread() pg_g_threadlock(false)
658 #else
659 #define pglock_thread() ((void) 0)
660 #define pgunlock_thread() ((void) 0)
661 #endif
662 
663 /* === in fe-exec.c === */
664 
665 extern void pqSetResultError(PGresult *res, PQExpBuffer errorMessage, int offset);
666 extern void *pqResultAlloc(PGresult *res, size_t nBytes, bool isBinary);
667 extern char *pqResultStrdup(PGresult *res, const char *str);
668 extern void pqClearAsyncResult(PGconn *conn);
669 extern void pqSaveErrorResult(PGconn *conn);
671 extern void pqInternalNotice(const PGNoticeHooks *hooks, const char *fmt,...) pg_attribute_printf(2, 3);
672 extern void pqSaveMessageField(PGresult *res, char code,
673  const char *value);
674 extern void pqSaveParameterStatus(PGconn *conn, const char *name,
675  const char *value);
676 extern int pqRowProcessor(PGconn *conn, const char **errmsgp);
677 extern void pqCommandQueueAdvance(PGconn *conn);
678 extern int PQsendQueryContinue(PGconn *conn, const char *query);
679 
680 /* === in fe-protocol3.c === */
681 
682 extern char *pqBuildStartupPacket3(PGconn *conn, int *packetlen,
684 extern void pqParseInput3(PGconn *conn);
685 extern int pqGetErrorNotice3(PGconn *conn, bool isError);
686 extern void pqBuildErrorMessage3(PQExpBuffer msg, const PGresult *res,
687  PGVerbosity verbosity, PGContextVisibility show_context);
689 extern int pqGetCopyData3(PGconn *conn, char **buffer, int async);
690 extern int pqGetline3(PGconn *conn, char *s, int maxlen);
691 extern int pqGetlineAsync3(PGconn *conn, char *buffer, int bufsize);
692 extern int pqEndcopy3(PGconn *conn);
693 extern PGresult *pqFunctionCall3(PGconn *conn, Oid fnid,
694  int *result_buf, int *actual_result_len,
695  int result_is_int,
696  const PQArgBlock *args, int nargs);
697 
698 /* === in fe-misc.c === */
699 
700  /*
701  * "Get" and "Put" routines return 0 if successful, EOF if not. Note that for
702  * Get, EOF merely means the buffer is exhausted, not that there is
703  * necessarily any error.
704  */
705 extern int pqCheckOutBufferSpace(size_t bytes_needed, PGconn *conn);
706 extern int pqCheckInBufferSpace(size_t bytes_needed, PGconn *conn);
707 extern int pqGetc(char *result, PGconn *conn);
708 extern int pqPutc(char c, PGconn *conn);
709 extern int pqGets(PQExpBuffer buf, PGconn *conn);
710 extern int pqGets_append(PQExpBuffer buf, PGconn *conn);
711 extern int pqPuts(const char *s, PGconn *conn);
712 extern int pqGetnchar(char *s, size_t len, PGconn *conn);
713 extern int pqSkipnchar(size_t len, PGconn *conn);
714 extern int pqPutnchar(const char *s, size_t len, PGconn *conn);
715 extern int pqGetInt(int *result, size_t bytes, PGconn *conn);
716 extern int pqPutInt(int value, size_t bytes, PGconn *conn);
717 extern int pqPutMsgStart(char msg_type, PGconn *conn);
718 extern int pqPutMsgEnd(PGconn *conn);
719 extern int pqReadData(PGconn *conn);
720 extern int pqFlush(PGconn *conn);
721 extern int pqWait(int forRead, int forWrite, PGconn *conn);
722 extern int pqWaitTimed(int forRead, int forWrite, PGconn *conn,
723  time_t finish_time);
724 extern int pqReadReady(PGconn *conn);
725 extern int pqWriteReady(PGconn *conn);
726 
727 /* === in fe-secure.c === */
728 
729 extern int pqsecure_initialize(PGconn *, bool, bool);
731 extern void pqsecure_close(PGconn *);
732 extern ssize_t pqsecure_read(PGconn *, void *ptr, size_t len);
733 extern ssize_t pqsecure_write(PGconn *, const void *ptr, size_t len);
734 extern ssize_t pqsecure_raw_read(PGconn *, void *ptr, size_t len);
735 extern ssize_t pqsecure_raw_write(PGconn *, const void *ptr, size_t len);
736 
737 #if defined(ENABLE_THREAD_SAFETY) && !defined(WIN32)
738 extern int pq_block_sigpipe(sigset_t *osigset, bool *sigpipe_pending);
739 extern void pq_reset_sigpipe(sigset_t *osigset, bool sigpipe_pending,
740  bool got_epipe);
741 #endif
742 
743 /* === SSL === */
744 
745 /*
746  * The SSL implementation provides these functions.
747  */
748 
749 /*
750  * Implementation of PQinitSSL().
751  */
752 extern void pgtls_init_library(bool do_ssl, int do_crypto);
753 
754 /*
755  * Initialize SSL library.
756  *
757  * The conn parameter is only used to be able to pass back an error
758  * message - no connection-local setup is made here. do_ssl controls
759  * if SSL is initialized, and do_crypto does the same for the crypto
760  * part.
761  *
762  * Returns 0 if OK, -1 on failure (adding a message to conn->errorMessage).
763  */
764 extern int pgtls_init(PGconn *conn, bool do_ssl, bool do_crypto);
765 
766 /*
767  * Begin or continue negotiating a secure session.
768  */
770 
771 /*
772  * Close SSL connection.
773  */
774 extern void pgtls_close(PGconn *conn);
775 
776 /*
777  * Read data from a secure connection.
778  *
779  * On failure, this function is responsible for appending a suitable message
780  * to conn->errorMessage. The caller must still inspect errno, but only
781  * to determine whether to continue/retry after error.
782  */
783 extern ssize_t pgtls_read(PGconn *conn, void *ptr, size_t len);
784 
785 /*
786  * Is there unread data waiting in the SSL read buffer?
787  */
788 extern bool pgtls_read_pending(PGconn *conn);
789 
790 /*
791  * Write data to a secure connection.
792  *
793  * On failure, this function is responsible for appending a suitable message
794  * to conn->errorMessage. The caller must still inspect errno, but only
795  * to determine whether to continue/retry after error.
796  */
797 extern ssize_t pgtls_write(PGconn *conn, const void *ptr, size_t len);
798 
799 /*
800  * Get the hash of the server certificate, for SCRAM channel binding type
801  * tls-server-end-point.
802  *
803  * NULL is sent back to the caller in the event of an error, with an
804  * error message for the caller to consume.
805  *
806  * This is not supported with old versions of OpenSSL that don't have
807  * the X509_get_signature_nid() function.
808  */
809 #if defined(USE_OPENSSL) && defined(HAVE_X509_GET_SIGNATURE_NID)
810 #define HAVE_PGTLS_GET_PEER_CERTIFICATE_HASH
811 extern char *pgtls_get_peer_certificate_hash(PGconn *conn, size_t *len);
812 #endif
813 
814 /*
815  * Verify that the server certificate matches the host name we connected to.
816  *
817  * The certificate's Common Name and Subject Alternative Names are considered.
818  *
819  * Returns 1 if the name matches, and 0 if it does not. On error, returns
820  * -1, and sets the libpq error message.
821  *
822  */
824  int *names_examined,
825  char **first_name);
826 
827 /* === GSSAPI === */
828 
829 #ifdef ENABLE_GSS
830 
831 /*
832  * Establish a GSSAPI-encrypted connection.
833  */
835 
836 /*
837  * Read and write functions for GSSAPI-encrypted connections, with internal
838  * buffering to handle nonblocking sockets.
839  */
840 extern ssize_t pg_GSS_write(PGconn *conn, const void *ptr, size_t len);
841 extern ssize_t pg_GSS_read(PGconn *conn, void *ptr, size_t len);
842 #endif
843 
844 /* === in libpq-trace.c === */
845 
846 extern void pqTraceOutputMessage(PGconn *conn, const char *message,
847  bool toServer);
848 extern void pqTraceOutputNoTypeByteMessage(PGconn *conn, const char *message);
849 
850 /* === miscellaneous macros === */
851 
852 /*
853  * Reset the conn's error-reporting state.
854  */
855 #define pqClearConnErrorState(conn) \
856  (resetPQExpBuffer(&(conn)->errorMessage), \
857  (conn)->errorReported = 0)
858 
859 /*
860  * Check whether we have a PGresult pending to be returned --- either a
861  * constructed one in conn->result, or a "virtual" error result that we
862  * don't intend to materialize until the end of the query cycle.
863  */
864 #define pgHavePendingResult(conn) \
865  ((conn)->result != NULL || (conn)->error_result)
866 
867 /*
868  * this is so that we can check if a connection is non-blocking internally
869  * without the overhead of a function call
870  */
871 #define pqIsnonblocking(conn) ((conn)->nonblocking)
872 
873 /*
874  * Connection's outbuffer threshold, for pipeline mode.
875  */
876 #define OUTBUFFER_THRESHOLD 65536
877 
878 #ifdef ENABLE_NLS
879 extern char *libpq_gettext(const char *msgid) pg_attribute_format_arg(1);
880 extern char *libpq_ngettext(const char *msgid, const char *msgid_plural, unsigned long n) pg_attribute_format_arg(1) pg_attribute_format_arg(2);
881 #else
882 #define libpq_gettext(x) (x)
883 #define libpq_ngettext(s, p, n) ((n) == 1 ? (s) : (p))
884 #endif
885 /*
886  * libpq code should use the above, not _(), since that would use the
887  * surrounding programs's message catalog.
888  */
889 #undef _
890 
891 extern void libpq_append_error(PQExpBuffer errorMessage, const char *fmt, ...) pg_attribute_printf(2, 3);
892 extern void libpq_append_conn_error(PGconn *conn, const char *fmt, ...) pg_attribute_printf(2, 3);
893 
894 /*
895  * These macros are needed to let error-handling code be portable between
896  * Unix and Windows. (ugh)
897  */
898 #ifdef WIN32
899 #define SOCK_ERRNO (WSAGetLastError())
900 #define SOCK_STRERROR winsock_strerror
901 #define SOCK_ERRNO_SET(e) WSASetLastError(e)
902 #else
903 #define SOCK_ERRNO errno
904 #define SOCK_STRERROR strerror_r
905 #define SOCK_ERRNO_SET(e) (errno = (e))
906 #endif
907 
908 #endif /* LIBPQ_INT_H */
unsigned int uint32
Definition: c.h:442
#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:362
const char * name
Definition: encode.c:561
pgthreadlock_t pg_g_threadlock
Definition: fe-connect.c:430
ssize_t pg_GSS_read(PGconn *conn, void *ptr, size_t len)
ssize_t pg_GSS_write(PGconn *conn, const void *ptr, size_t len)
PostgresPollingStatusType pqsecure_open_gss(PGconn *conn)
static struct @143 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:446
int PQsendQueryContinue(PGconn *conn, const char *query)
Definition: fe-exec.c:1424
int pqPutInt(int value, size_t bytes, PGconn *conn)
Definition: fe-misc.c:254
#define libpq_gettext(x)
Definition: libpq-int.h:882
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:7240
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:1202
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:883
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:4605
void pqCommandQueueAdvance(PGconn *conn)
Definition: fe-exec.c:3011
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:604
int keepalives_interval
Definition: libpq-int.h:607
int keepalives_idle
Definition: libpq-int.h:606
int keepalives_count
Definition: libpq-int.h:609
SockAddr raddr
Definition: libpq-int.h:601
int be_pid
Definition: libpq-int.h:602
int keepalives
Definition: libpq-int.h:605
int be_key
Definition: libpq-int.h:603
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:449
bool try_next_host
Definition: libpq-int.h:463
struct addrinfo * addrlist
Definition: libpq-int.h:464
char * replication
Definition: libpq-int.h:370
char * write_err_msg
Definition: libpq-int.h:458
PGnotify * notifyHead
Definition: libpq-int.h:424
char * sslrootcert
Definition: libpq-int.h:387
PGdataValue * rowBuf
Definition: libpq-int.h:499
char * sslcompression
Definition: libpq-int.h:383
bool sigpipe_flag
Definition: libpq-int.h:456
bool singleRowMode
Definition: libpq-int.h:421
int nconnhost
Definition: libpq-int.h:428
pgsocket sock
Definition: libpq-int.h:447
char * inBuffer
Definition: libpq-int.h:482
char * channel_binding
Definition: libpq-int.h:374
ProtocolVersion pversion
Definition: libpq-int.h:451
int addrlist_family
Definition: libpq-int.h:466
PGresult * next_result
Definition: libpq-int.h:513
bool std_strings
Definition: libpq-int.h:474
int errorReported
Definition: libpq-int.h:589
bool write_failed
Definition: libpq-int.h:457
char * sslcrldir
Definition: libpq-int.h:389
char * pgoptions
Definition: libpq-int.h:366
bool send_appname
Definition: libpq-int.h:467
PGTransactionStatusType xactStatus
Definition: libpq-int.h:415
char * sslcrl
Definition: libpq-int.h:388
char * pghost
Definition: libpq-int.h:353
const pg_fe_sasl_mech * sasl
Definition: libpq-int.h:516
int inCursor
Definition: libpq-int.h:485
char * ssl_max_protocol_version
Definition: libpq-int.h:397
PGTernaryBool in_hot_standby
Definition: libpq-int.h:476
char * pgpass
Definition: libpq-int.h:372
int be_pid
Definition: libpq-int.h:470
PGcmdQueueEntry * cmd_queue_recycle
Definition: libpq-int.h:444
char * dbName
Definition: libpq-int.h:369
int inEnd
Definition: libpq-int.h:486
char * fbappname
Definition: libpq-int.h:368
char * sslcert
Definition: libpq-int.h:385
char * target_session_attrs
Definition: libpq-int.h:398
PGcmdQueueEntry * cmd_queue_tail
Definition: libpq-int.h:438
int be_key
Definition: libpq-int.h:471
PGnotify * notifyTail
Definition: libpq-int.h:425
int copy_already_done
Definition: libpq-int.h:423
int inBufSize
Definition: libpq-int.h:483
char * sslpassword
Definition: libpq-int.h:386
bool nonblocking
Definition: libpq-int.h:418
int client_encoding
Definition: libpq-int.h:473
PQExpBufferData workBuffer
Definition: libpq-int.h:592
int inStart
Definition: libpq-int.h:484
char * keepalives_idle
Definition: libpq-int.h:377
char * connip
Definition: libpq-int.h:431
int sversion
Definition: libpq-int.h:452
bool auth_req_received
Definition: libpq-int.h:453
PGTernaryBool default_transaction_read_only
Definition: libpq-int.h:475
pgParameterStatus * pstatus
Definition: libpq-int.h:472
char * pguser
Definition: libpq-int.h:371
char * keepalives
Definition: libpq-int.h:376
PGresult * result
Definition: libpq-int.h:511
bool sigpipe_so
Definition: libpq-int.h:455
PGVerbosity verbosity
Definition: libpq-int.h:477
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:396
struct addrinfo * addr_cur
Definition: libpq-int.h:465
PQExpBufferData errorMessage
Definition: libpq-int.h:588
char * gssencmode
Definition: libpq-int.h:392
int nEvents
Definition: libpq-int.h:409
char * pghostaddr
Definition: libpq-int.h:357
char * sslkey
Definition: libpq-int.h:384
bool error_result
Definition: libpq-int.h:512
int rowBufLen
Definition: libpq-int.h:500
char * pgpassfile
Definition: libpq-int.h:373
char last_sqlstate[6]
Definition: libpq-int.h:416
PGAsyncStatusType asyncStatus
Definition: libpq-int.h:414
char * connect_timeout
Definition: libpq-int.h:363
char * krbsrvname
Definition: libpq-int.h:393
PGpipelineStatus pipelineStatus
Definition: libpq-int.h:420
char copy_is_binary
Definition: libpq-int.h:422
char * gsslib
Definition: libpq-int.h:394
PGlobjfuncs * lobjfuncs
Definition: libpq-int.h:479
int outBufSize
Definition: libpq-int.h:490
bool options_valid
Definition: libpq-int.h:417
PGNoticeHooks noticeHooks
Definition: libpq-int.h:405
PGTargetServerType target_server_type
Definition: libpq-int.h:461
FILE * Pfdebug
Definition: libpq-int.h:401
void * sasl_state
Definition: libpq-int.h:517
PGcmdQueueEntry * cmd_queue_head
Definition: libpq-int.h:437
int outMsgStart
Definition: libpq-int.h:494
SockAddr raddr
Definition: libpq-int.h:450
bool try_next_addr
Definition: libpq-int.h:462
int outCount
Definition: libpq-int.h:491
char * pgport
Definition: libpq-int.h:361
int eventArraySize
Definition: libpq-int.h:410
int traceFlags
Definition: libpq-int.h:402
int outMsgEnd
Definition: libpq-int.h:496
int whichhost
Definition: libpq-int.h:429
PGContextVisibility show_context
Definition: libpq-int.h:478
char * keepalives_count
Definition: libpq-int.h:380
char * requirepeer
Definition: libpq-int.h:391
char * sslsni
Definition: libpq-int.h:390
pg_conn_host * connhost
Definition: libpq-int.h:430
bool ssl_in_use
Definition: libpq-int.h:520
PGEvent * events
Definition: libpq-int.h:408
bool password_needed
Definition: libpq-int.h:454
char * outBuffer
Definition: libpq-int.h:489
ConnStatusType status
Definition: libpq-int.h:413
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