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