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