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