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