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