PostgreSQL Source Code git master
Loading...
Searching...
No Matches
libpq-fe.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * libpq-fe.h
4 * This file contains definitions for structures and
5 * externs for functions used by frontend postgres applications.
6 *
7 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/interfaces/libpq/libpq-fe.h
11 *
12 *-------------------------------------------------------------------------
13 */
14
15#ifndef LIBPQ_FE_H
16#define LIBPQ_FE_H
17
18#ifdef __cplusplus
19extern "C"
20{
21#endif
22
23#include <stdint.h>
24#include <stdio.h>
25
26/*
27 * postgres_ext.h defines the backend's externally visible types,
28 * such as Oid.
29 */
30#include "postgres_ext.h"
31
32/*
33 * These symbols may be used in compile-time #ifdef tests for the availability
34 * of v14-and-newer libpq features.
35 */
36/* Features added in PostgreSQL v14: */
37/* Indicates presence of PQenterPipelineMode and friends */
38#define LIBPQ_HAS_PIPELINING 1
39/* Indicates presence of PQsetTraceFlags; also new PQtrace output format */
40#define LIBPQ_HAS_TRACE_FLAGS 1
41
42/* Features added in PostgreSQL v15: */
43/* Indicates that PQsslAttribute(NULL, "library") is useful */
44#define LIBPQ_HAS_SSL_LIBRARY_DETECTION 1
45
46/* Features added in PostgreSQL v17: */
47/* Indicates presence of PGcancelConn typedef and associated routines */
48#define LIBPQ_HAS_ASYNC_CANCEL 1
49/* Indicates presence of PQchangePassword */
50#define LIBPQ_HAS_CHANGE_PASSWORD 1
51/* Indicates presence of PQsetChunkedRowsMode, PGRES_TUPLES_CHUNK */
52#define LIBPQ_HAS_CHUNK_MODE 1
53/* Indicates presence of PQclosePrepared, PQclosePortal, etc */
54#define LIBPQ_HAS_CLOSE_PREPARED 1
55/* Indicates presence of PQsendPipelineSync */
56#define LIBPQ_HAS_SEND_PIPELINE_SYNC 1
57/* Indicates presence of PQsocketPoll, PQgetCurrentTimeUSec */
58#define LIBPQ_HAS_SOCKET_POLL 1
59
60/* Features added in PostgreSQL v18: */
61/* Indicates presence of PQfullProtocolVersion */
62#define LIBPQ_HAS_FULL_PROTOCOL_VERSION 1
63/* Indicates presence of the PQAUTHDATA_PROMPT_OAUTH_DEVICE authdata hook */
64#define LIBPQ_HAS_PROMPT_OAUTH_DEVICE 1
65
66/* Features added in PostgreSQL v19: */
67/* Indicates presence of PQgetThreadLock */
68#define LIBPQ_HAS_GET_THREAD_LOCK 1
69/* Indicates presence of the PQAUTHDATA_OAUTH_BEARER_TOKEN_V2 authdata hook */
70#define LIBPQ_HAS_OAUTH_BEARER_TOKEN_V2 1
71
72/*
73 * Option flags for PQcopyResult
74 */
75#define PG_COPYRES_ATTRS 0x01
76#define PG_COPYRES_TUPLES 0x02 /* Implies PG_COPYRES_ATTRS */
77#define PG_COPYRES_EVENTS 0x04
78#define PG_COPYRES_NOTICEHOOKS 0x08
79
80/* Application-visible enum types */
81
82/*
83 * Although it is okay to add to these lists, values which become unused
84 * should never be removed, nor should constants be redefined - that would
85 * break compatibility with existing code.
86 */
87
88typedef enum
89{
92 /* Non-blocking mode only below here */
93
94 /*
95 * The existence of these should never be relied upon - they should only
96 * be used for user feedback or similar purposes.
97 */
98 CONNECTION_STARTED, /* Waiting for connection to be made. */
99 CONNECTION_MADE, /* Connection OK; waiting to send. */
100 CONNECTION_AWAITING_RESPONSE, /* Waiting for a response from the
101 * postmaster. */
102 CONNECTION_AUTH_OK, /* Received authentication; waiting for
103 * backend startup. */
104 CONNECTION_SETENV, /* This state is no longer used. */
105 CONNECTION_SSL_STARTUP, /* Performing SSL handshake. */
106 CONNECTION_NEEDED, /* Internal state: connect() needed. */
107 CONNECTION_CHECK_WRITABLE, /* Checking if session is read-write. */
108 CONNECTION_CONSUME, /* Consuming any extra messages. */
109 CONNECTION_GSS_STARTUP, /* Negotiating GSSAPI. */
110 CONNECTION_CHECK_TARGET, /* Internal state: checking target server
111 * properties. */
112 CONNECTION_CHECK_STANDBY, /* Checking if server is in standby mode. */
113 CONNECTION_ALLOCATED, /* Waiting for connection attempt to be
114 * started. */
115 CONNECTION_AUTHENTICATING, /* Authentication is in progress with some
116 * external system. */
118
119typedef enum
120{
122 PGRES_POLLING_READING, /* These two indicate that one may */
123 PGRES_POLLING_WRITING, /* use select before polling again. */
125 PGRES_POLLING_ACTIVE /* unused; keep for backwards compatibility */
127
128typedef enum
129{
130 PGRES_EMPTY_QUERY = 0, /* empty query string was executed */
131 PGRES_COMMAND_OK, /* a query command that doesn't return
132 * anything was executed properly by the
133 * backend */
134 PGRES_TUPLES_OK, /* a query command that returns tuples was
135 * executed properly by the backend, PGresult
136 * contains the result tuples */
137 PGRES_COPY_OUT, /* Copy Out data transfer in progress */
138 PGRES_COPY_IN, /* Copy In data transfer in progress */
139 PGRES_BAD_RESPONSE, /* an unexpected response was recv'd from the
140 * backend */
141 PGRES_NONFATAL_ERROR, /* notice or warning message */
142 PGRES_FATAL_ERROR, /* query failed */
143 PGRES_COPY_BOTH, /* Copy In/Out data transfer in progress */
144 PGRES_SINGLE_TUPLE, /* single tuple from larger resultset */
145 PGRES_PIPELINE_SYNC, /* pipeline synchronization point */
146 PGRES_PIPELINE_ABORTED, /* Command didn't run because of an abort
147 * earlier in a pipeline */
148 PGRES_TUPLES_CHUNK /* chunk of tuples from larger resultset */
150
151typedef enum
152{
153 PQTRANS_IDLE, /* connection idle */
154 PQTRANS_ACTIVE, /* command in progress */
155 PQTRANS_INTRANS, /* idle, within transaction block */
156 PQTRANS_INERROR, /* idle, within failed transaction */
157 PQTRANS_UNKNOWN /* cannot determine status */
159
160typedef enum
161{
162 PQERRORS_TERSE, /* single-line error messages */
163 PQERRORS_DEFAULT, /* recommended style */
164 PQERRORS_VERBOSE, /* all the facts, ma'am */
165 PQERRORS_SQLSTATE /* only error severity and SQLSTATE code */
167
168typedef enum
169{
170 PQSHOW_CONTEXT_NEVER, /* never show CONTEXT field */
171 PQSHOW_CONTEXT_ERRORS, /* show CONTEXT for errors only (default) */
172 PQSHOW_CONTEXT_ALWAYS /* always show CONTEXT field */
174
175/*
176 * PGPing - The ordering of this enum should not be altered because the
177 * values are exposed externally via pg_isready.
178 */
179
180typedef enum
181{
182 PQPING_OK, /* server is accepting connections */
183 PQPING_REJECT, /* server is alive but rejecting connections */
184 PQPING_NO_RESPONSE, /* could not establish connection */
185 PQPING_NO_ATTEMPT /* connection not attempted (bad params) */
187
188/*
189 * PGpipelineStatus - Current status of pipeline mode
190 */
197
198typedef enum
199{
200 PQAUTHDATA_PROMPT_OAUTH_DEVICE, /* user must visit a device-authorization
201 * URL */
202 PQAUTHDATA_OAUTH_BEARER_TOKEN, /* server requests an OAuth Bearer token
203 * (v2 is preferred; see below) */
204 PQAUTHDATA_OAUTH_BEARER_TOKEN_V2, /* newest API for OAuth Bearer tokens */
205} PGauthData;
206
207/*
208 * PGconn encapsulates a connection to the backend.
209 * The contents of this struct are not supposed to be known to applications.
210 */
211typedef struct pg_conn PGconn;
212
213/*
214 * PGcancelConn encapsulates a cancel connection to the backend.
215 * The contents of this struct are not supposed to be known to applications.
216 */
218
219/*
220 * PGresult encapsulates the result of a query (or more precisely, of a single
221 * SQL command --- a query string given to PQsendQuery can contain multiple
222 * commands and thus return multiple PGresult objects).
223 * The contents of this struct are not supposed to be known to applications.
224 */
225typedef struct pg_result PGresult;
226
227/*
228 * PGcancel encapsulates the information needed to cancel a running
229 * query on an existing connection.
230 * The contents of this struct are not supposed to be known to applications.
231 */
232typedef struct pg_cancel PGcancel;
233
234/*
235 * PGnotify represents the occurrence of a NOTIFY message.
236 * Ideally this would be an opaque typedef, but it's so simple that it's
237 * unlikely to change.
238 * NOTE: in Postgres 6.4 and later, the be_pid is the notifying backend's,
239 * whereas in earlier versions it was always your own backend's PID.
240 */
241typedef struct pgNotify
242{
243 char *relname; /* notification condition name */
244 int be_pid; /* process ID of notifying server process */
245 char *extra; /* notification parameter */
246 /* Fields below here are private to libpq; apps should not use 'em */
247 struct pgNotify *next; /* list link */
249
250/* pg_usec_time_t is like time_t, but with microsecond resolution */
252
253/* Function types for notice-handling callbacks */
254typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res);
255typedef void (*PQnoticeProcessor) (void *arg, const char *message);
256
257/* Print options for PQprint() */
258typedef char pqbool;
259
260typedef struct _PQprintOpt
261{
262 pqbool header; /* print output field headings and row count */
263 pqbool align; /* fill align the fields */
264 pqbool standard; /* old brain dead format */
265 pqbool html3; /* output html tables */
266 pqbool expanded; /* expand tables */
267 pqbool pager; /* use pager for output if needed */
268 char *fieldSep; /* field separator */
269 char *tableOpt; /* insert to HTML <table ...> */
270 char *caption; /* HTML <caption> */
271 char **fieldName; /* null terminated array of replacement field
272 * names */
274
275/* ----------------
276 * Structure for the conninfo parameter definitions returned by PQconndefaults
277 * or PQconninfoParse.
278 *
279 * All fields except "val" point at static strings which must not be altered.
280 * "val" is either NULL or a malloc'd current-value string. PQconninfoFree()
281 * will release both the val strings and the PQconninfoOption array itself.
282 * ----------------
283 */
284typedef struct _PQconninfoOption
285{
286 char *keyword; /* The keyword of the option */
287 char *envvar; /* Fallback environment variable name */
288 char *compiled; /* Fallback compiled in default value */
289 char *val; /* Option's current value, or NULL */
290 char *label; /* Label for field in connect dialog */
291 char *dispchar; /* Indicates how to display this field in a
292 * connect dialog. Values are: "" Display
293 * entered value as is "*" Password field -
294 * hide value "D" Debug option - don't show
295 * by default */
296 int dispsize; /* Field size in characters for dialog */
298
299/* ----------------
300 * PQArgBlock -- structure for PQfn() arguments
301 * ----------------
302 */
303typedef struct
304{
305 int len;
306 int isint;
307 union
308 {
309 int *ptr; /* can't use void (dec compiler barfs) */
311 } u;
312} PQArgBlock;
313
314/* ----------------
315 * PGresAttDesc -- Data about a single attribute (column) of a query result
316 * ----------------
317 */
318typedef struct pgresAttDesc
319{
320 char *name; /* column name */
321 Oid tableid; /* source table, if known */
322 int columnid; /* source column, if known */
323 int format; /* format code for value (text/binary) */
324 Oid typid; /* type id */
325 int typlen; /* type size */
326 int atttypmod; /* type-specific modifier info */
328
329/* ----------------
330 * Exported functions of libpq
331 * ----------------
332 */
333
334/* === in fe-connect.c === */
335
336/* make a new client connection to the backend */
337/* Asynchronous (non-blocking) */
338extern PGconn *PQconnectStart(const char *conninfo);
339extern PGconn *PQconnectStartParams(const char *const *keywords,
340 const char *const *values, int expand_dbname);
342
343/* Synchronous (blocking) */
344extern PGconn *PQconnectdb(const char *conninfo);
345extern PGconn *PQconnectdbParams(const char *const *keywords,
346 const char *const *values, int expand_dbname);
347extern PGconn *PQsetdbLogin(const char *pghost, const char *pgport,
348 const char *pgoptions, const char *pgtty,
349 const char *dbName,
350 const char *login, const char *pwd);
351
352#define PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME) \
353 PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, NULL, NULL)
354
355/* close the current connection and free the PGconn data structure */
356extern void PQfinish(PGconn *conn);
357
358/* get info about connection options known to PQconnectdb */
359extern PQconninfoOption *PQconndefaults(void);
360
361/* parse connection options in same way as PQconnectdb */
362extern PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
363
364/* return the connection options used by a live connection */
366
367/* free the data structure returned by PQconndefaults() or PQconninfoParse() */
369
370/*
371 * close the current connection and reestablish a new one with the same
372 * parameters
373 */
374/* Asynchronous (non-blocking) */
375extern int PQresetStart(PGconn *conn);
377
378/* Synchronous (blocking) */
379extern void PQreset(PGconn *conn);
380
381/* Create a PGcancelConn that's used to cancel a query on the given PGconn */
383
384/* issue a cancel request in a non-blocking manner */
386
387/* issue a blocking cancel request */
389
390/* poll a non-blocking cancel request */
393extern int PQcancelSocket(const PGcancelConn *cancelConn);
394extern char *PQcancelErrorMessage(const PGcancelConn *cancelConn);
397
398
399/* request a cancel structure */
401
402/* free a cancel structure */
403extern void PQfreeCancel(PGcancel *cancel);
404
405/* deprecated version of PQcancelBlocking, but one which is signal-safe */
406extern int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize);
407
408/* deprecated version of PQcancel; not thread-safe */
409extern int PQrequestCancel(PGconn *conn);
410
411/* Accessor functions for PGconn objects */
412extern char *PQdb(const PGconn *conn);
413extern char *PQuser(const PGconn *conn);
414extern char *PQpass(const PGconn *conn);
415extern char *PQhost(const PGconn *conn);
416extern char *PQhostaddr(const PGconn *conn);
417extern char *PQport(const PGconn *conn);
418extern char *PQtty(const PGconn *conn);
419extern char *PQoptions(const PGconn *conn);
420extern ConnStatusType PQstatus(const PGconn *conn);
422extern const char *PQparameterStatus(const PGconn *conn,
423 const char *paramName);
424extern int PQprotocolVersion(const PGconn *conn);
425extern int PQfullProtocolVersion(const PGconn *conn);
426extern int PQserverVersion(const PGconn *conn);
427extern char *PQerrorMessage(const PGconn *conn);
428extern int PQsocket(const PGconn *conn);
429extern int PQbackendPID(const PGconn *conn);
431extern int PQconnectionNeedsPassword(const PGconn *conn);
432extern int PQconnectionUsedPassword(const PGconn *conn);
433extern int PQconnectionUsedGSSAPI(const PGconn *conn);
434extern int PQclientEncoding(const PGconn *conn);
435extern int PQsetClientEncoding(PGconn *conn, const char *encoding);
436
437/* SSL information functions */
438extern int PQsslInUse(PGconn *conn);
439extern void *PQsslStruct(PGconn *conn, const char *struct_name);
440extern const char *PQsslAttribute(PGconn *conn, const char *attribute_name);
441extern const char *const *PQsslAttributeNames(PGconn *conn);
442
443/*
444 * Get the OpenSSL structure associated with a connection. Returns NULL for
445 * unencrypted connections or if any other TLS library is in use.
446 */
447extern void *PQgetssl(PGconn *conn);
448
449/* Tell libpq whether it needs to initialize OpenSSL */
450extern void PQinitSSL(int do_init);
451
452/* More detailed way to tell libpq whether it needs to initialize OpenSSL */
453extern void PQinitOpenSSL(int do_ssl, int do_crypto);
454
455/* Return true if GSSAPI encryption is in use */
456extern int PQgssEncInUse(PGconn *conn);
457
458/* Returns GSSAPI context if GSSAPI is in use */
459extern void *PQgetgssctx(PGconn *conn);
460
461/* Set verbosity for PQerrorMessage and PQresultErrorMessage */
463
464/* Set CONTEXT visibility for PQerrorMessage and PQresultErrorMessage */
466 PGContextVisibility show_context);
467
468/* Override default notice handling routines */
470 PQnoticeReceiver proc,
471 void *arg);
474 void *arg);
475
476/*
477 * Used to set callback that prevents concurrent access to
478 * non-thread safe functions that libpq needs.
479 * The default implementation uses a libpq internal mutex.
480 * Only required for multithreaded apps that use Kerberos or
481 * older (non-threadsafe) versions of Curl both within their
482 * app and for postgresql connections.
483 */
484typedef void (*pgthreadlock_t) (int acquire);
485
488
489/* === in fe-trace.c === */
490extern void PQtrace(PGconn *conn, FILE *debug_port);
491extern void PQuntrace(PGconn *conn);
492
493/* flags controlling trace output: */
494/* omit timestamps from each line */
495#define PQTRACE_SUPPRESS_TIMESTAMPS (1<<0)
496/* redact portions of some messages, for testing frameworks */
497#define PQTRACE_REGRESS_MODE (1<<1)
498extern void PQsetTraceFlags(PGconn *conn, int flags);
499
500/* === in fe-exec.c === */
501
502/* Simple synchronous query */
503extern PGresult *PQexec(PGconn *conn, const char *query);
505 const char *command,
506 int nParams,
507 const Oid *paramTypes,
508 const char *const *paramValues,
509 const int *paramLengths,
510 const int *paramFormats,
511 int resultFormat);
512extern PGresult *PQprepare(PGconn *conn, const char *stmtName,
513 const char *query, int nParams,
514 const Oid *paramTypes);
516 const char *stmtName,
517 int nParams,
518 const char *const *paramValues,
519 const int *paramLengths,
520 const int *paramFormats,
521 int resultFormat);
522
523/* Interface for multiple-result or asynchronous queries */
524#define PQ_QUERY_PARAM_MAX_LIMIT 65535
525
526extern int PQsendQuery(PGconn *conn, const char *query);
527extern int PQsendQueryParams(PGconn *conn,
528 const char *command,
529 int nParams,
530 const Oid *paramTypes,
531 const char *const *paramValues,
532 const int *paramLengths,
533 const int *paramFormats,
534 int resultFormat);
535extern int PQsendPrepare(PGconn *conn, const char *stmtName,
536 const char *query, int nParams,
537 const Oid *paramTypes);
539 const char *stmtName,
540 int nParams,
541 const char *const *paramValues,
542 const int *paramLengths,
543 const int *paramFormats,
544 int resultFormat);
545extern int PQsetSingleRowMode(PGconn *conn);
546extern int PQsetChunkedRowsMode(PGconn *conn, int chunkSize);
548
549/* Routines for managing an asynchronous query */
550extern int PQisBusy(PGconn *conn);
551extern int PQconsumeInput(PGconn *conn);
552
553/* Routines for pipeline mode management */
554extern int PQenterPipelineMode(PGconn *conn);
555extern int PQexitPipelineMode(PGconn *conn);
556extern int PQpipelineSync(PGconn *conn);
557extern int PQsendFlushRequest(PGconn *conn);
558extern int PQsendPipelineSync(PGconn *conn);
559
560/* LISTEN/NOTIFY support */
562
563/* Routines for copy in/out */
564extern int PQputCopyData(PGconn *conn, const char *buffer, int nbytes);
565extern int PQputCopyEnd(PGconn *conn, const char *errormsg);
566extern int PQgetCopyData(PGconn *conn, char **buffer, int async);
567
568/* Deprecated routines for copy in/out */
569extern int PQgetline(PGconn *conn, char *buffer, int length);
570extern int PQputline(PGconn *conn, const char *string);
571extern int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize);
572extern int PQputnbytes(PGconn *conn, const char *buffer, int nbytes);
573extern int PQendcopy(PGconn *conn);
574
575/* Set blocking/nonblocking connection to the backend */
576extern int PQsetnonblocking(PGconn *conn, int arg);
577extern int PQisnonblocking(const PGconn *conn);
578extern int PQisthreadsafe(void);
579extern PGPing PQping(const char *conninfo);
580extern PGPing PQpingParams(const char *const *keywords,
581 const char *const *values, int expand_dbname);
582
583/* Force the write buffer to be written (or at least try) */
584extern int PQflush(PGconn *conn);
585
586/*
587 * "Fast path" interface --- not really recommended for application
588 * use
589 */
590extern PGresult *PQfn(PGconn *conn,
591 int fnid,
592 int *result_buf,
593 int *result_len,
594 int result_is_int,
595 const PQArgBlock *args,
596 int nargs);
597
598/* Accessor functions for PGresult objects */
599extern ExecStatusType PQresultStatus(const PGresult *res);
600extern char *PQresStatus(ExecStatusType status);
601extern char *PQresultErrorMessage(const PGresult *res);
602extern char *PQresultVerboseErrorMessage(const PGresult *res,
603 PGVerbosity verbosity,
604 PGContextVisibility show_context);
605extern char *PQresultErrorField(const PGresult *res, int fieldcode);
606extern int PQntuples(const PGresult *res);
607extern int PQnfields(const PGresult *res);
608extern int PQbinaryTuples(const PGresult *res);
609extern char *PQfname(const PGresult *res, int field_num);
610extern int PQfnumber(const PGresult *res, const char *field_name);
611extern Oid PQftable(const PGresult *res, int field_num);
612extern int PQftablecol(const PGresult *res, int field_num);
613extern int PQfformat(const PGresult *res, int field_num);
614extern Oid PQftype(const PGresult *res, int field_num);
615extern int PQfsize(const PGresult *res, int field_num);
616extern int PQfmod(const PGresult *res, int field_num);
617extern char *PQcmdStatus(PGresult *res);
618extern char *PQoidStatus(const PGresult *res); /* old and ugly */
619extern Oid PQoidValue(const PGresult *res); /* new and improved */
620extern char *PQcmdTuples(PGresult *res);
621extern char *PQgetvalue(const PGresult *res, int tup_num, int field_num);
622extern int PQgetlength(const PGresult *res, int tup_num, int field_num);
623extern int PQgetisnull(const PGresult *res, int tup_num, int field_num);
624extern int PQnparams(const PGresult *res);
625extern Oid PQparamtype(const PGresult *res, int param_num);
626
627/* Describe prepared statements and portals */
628extern PGresult *PQdescribePrepared(PGconn *conn, const char *stmt);
629extern PGresult *PQdescribePortal(PGconn *conn, const char *portal);
630extern int PQsendDescribePrepared(PGconn *conn, const char *stmt);
631extern int PQsendDescribePortal(PGconn *conn, const char *portal);
632
633/* Close prepared statements and portals */
634extern PGresult *PQclosePrepared(PGconn *conn, const char *stmt);
635extern PGresult *PQclosePortal(PGconn *conn, const char *portal);
636extern int PQsendClosePrepared(PGconn *conn, const char *stmt);
637extern int PQsendClosePortal(PGconn *conn, const char *portal);
638
639/* Delete a PGresult */
640extern void PQclear(PGresult *res);
641
642/* For freeing other alloc'd results, such as PGnotify structs */
643extern void PQfreemem(void *ptr);
644
645/* Exists for backward compatibility. bjm 2003-03-24 */
646#define PQfreeNotify(ptr) PQfreemem(ptr)
647
648/* Error when no password was given. */
649/* Note: depending on this is deprecated; use PQconnectionNeedsPassword(). */
650#define PQnoPasswordSupplied "fe_sendauth: no password supplied\n"
651
652/* Create and manipulate PGresults */
654extern PGresult *PQcopyResult(const PGresult *src, int flags);
655extern int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs);
656extern void *PQresultAlloc(PGresult *res, size_t nBytes);
657extern size_t PQresultMemorySize(const PGresult *res);
658extern int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len);
659
660/* Quoting strings before inclusion in queries. */
661extern size_t PQescapeStringConn(PGconn *conn,
662 char *to, const char *from, size_t length,
663 int *error);
664extern char *PQescapeLiteral(PGconn *conn, const char *str, size_t len);
665extern char *PQescapeIdentifier(PGconn *conn, const char *str, size_t len);
666extern unsigned char *PQescapeByteaConn(PGconn *conn,
667 const unsigned char *from, size_t from_length,
668 size_t *to_length);
669extern unsigned char *PQunescapeBytea(const unsigned char *strtext,
670 size_t *retbuflen);
671
672/* These forms are deprecated! */
673extern size_t PQescapeString(char *to, const char *from, size_t length);
674extern unsigned char *PQescapeBytea(const unsigned char *from, size_t from_length,
675 size_t *to_length);
676
677
678
679/* === in fe-print.c === */
680
681extern void PQprint(FILE *fout, /* output stream */
682 const PGresult *res,
683 const PQprintOpt *po); /* option structure */
684
685/*
686 * really old printing routines
687 */
688extern void PQdisplayTuples(const PGresult *res,
689 FILE *fp, /* where to send the output */
690 int fillAlign, /* pad the fields with spaces */
691 const char *fieldSep, /* field separator */
692 int printHeader, /* display headers? */
693 int quiet);
694
695extern void PQprintTuples(const PGresult *res,
696 FILE *fout, /* output stream */
697 int PrintAttNames, /* print attribute names */
698 int TerseOutput, /* delimiter bars */
699 int colWidth); /* width of column, if 0, use
700 * variable width */
701
702
703/* === in fe-lobj.c === */
704
705/* Large-object access routines */
706extern int lo_open(PGconn *conn, Oid lobjId, int mode);
707extern int lo_close(PGconn *conn, int fd);
708extern int lo_read(PGconn *conn, int fd, char *buf, size_t len);
709extern int lo_write(PGconn *conn, int fd, const char *buf, size_t len);
710extern int lo_lseek(PGconn *conn, int fd, int offset, int whence);
711extern int64_t lo_lseek64(PGconn *conn, int fd, int64_t offset, int whence);
712extern Oid lo_creat(PGconn *conn, int mode);
714extern int lo_tell(PGconn *conn, int fd);
715extern int64_t lo_tell64(PGconn *conn, int fd);
716extern int lo_truncate(PGconn *conn, int fd, size_t len);
717extern int lo_truncate64(PGconn *conn, int fd, int64_t len);
718extern int lo_unlink(PGconn *conn, Oid lobjId);
719extern Oid lo_import(PGconn *conn, const char *filename);
720extern Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId);
721extern int lo_export(PGconn *conn, Oid lobjId, const char *filename);
722
723/* === in fe-misc.c === */
724
725/* Get the version of the libpq library in use */
726extern int PQlibVersion(void);
727
728/* Poll a socket for reading and/or writing with an optional timeout */
729extern int PQsocketPoll(int sock, int forRead, int forWrite,
731
732/* Get current time in the form PQsocketPoll wants */
734
735/* Determine length of multibyte encoded char at *s */
736extern int PQmblen(const char *s, int encoding);
737
738/* Same, but not more than the distance to the end of string s */
739extern int PQmblenBounded(const char *s, int encoding);
740
741/* Determine display length of multibyte encoded char at *s */
742extern int PQdsplen(const char *s, int encoding);
743
744/* Get encoding id from environment variable PGCLIENTENCODING */
745extern int PQenv2encoding(void);
746
747/* === in fe-auth.c === */
748
749/* Authdata for PQAUTHDATA_PROMPT_OAUTH_DEVICE */
751{
752 const char *verification_uri; /* verification URI to visit */
753 const char *user_code; /* user code to enter */
754 const char *verification_uri_complete; /* optional combination of URI and
755 * code, or NULL */
756 int expires_in; /* seconds until user code expires */
758
759/*
760 * For PGoauthBearerRequest.async(). This macro just allows clients to avoid
761 * depending on libpq-int.h or Winsock for the "socket" type; it's undefined
762 * immediately below.
763 */
764#ifdef _WIN32
765#define PQ_SOCKTYPE uintptr_t /* avoids depending on winsock2.h for SOCKET */
766#else
767#define PQ_SOCKTYPE int
768#endif
769
770/* Authdata for PQAUTHDATA_OAUTH_BEARER_TOKEN */
772{
773 /* Hook inputs (constant across all calls) */
774 const char *openid_configuration; /* OIDC discovery URI */
775 const char *scope; /* required scope(s), or NULL */
776
777 /* Hook outputs */
778
779 /*---------
780 * Callback implementing a custom asynchronous OAuth flow.
781 *
782 * The callback may return
783 * - PGRES_POLLING_READING/WRITING, to indicate that a socket descriptor
784 * has been stored in *altsock and libpq should wait until it is
785 * readable or writable before calling back;
786 * - PGRES_POLLING_OK, to indicate that the flow is complete and
787 * request->token has been set; or
788 * - PGRES_POLLING_FAILED, to indicate that token retrieval has failed.
789 *
790 * This callback is optional. If the token can be obtained without
791 * blocking during the original call to the PQAUTHDATA_OAUTH_BEARER_TOKEN
792 * hook, it may be returned directly, but one of request->async or
793 * request->token must be set by the hook.
794 *
795 * The (PQ_SOCKTYPE *) in the signature is a placeholder for the platform's
796 * native socket type: (SOCKET *) on Windows, and (int *) everywhere else.
797 */
800 PQ_SOCKTYPE * altsock);
801
802 /*
803 * Callback to clean up custom allocations. A hook implementation may use
804 * this to free request->token and any resources in request->user. V2
805 * implementations should additionally free request->error, if set.
806 *
807 * This is technically optional, but highly recommended, because there is
808 * no other indication as to when it is safe to free the token.
809 */
811
812 /*
813 * The hook should set this to the Bearer token contents for the
814 * connection, once the flow is completed. The token contents must remain
815 * available to libpq until the hook's cleanup callback is called.
816 */
817 char *token;
818
819 /*
820 * Hook-defined data. libpq will not modify this pointer across calls to
821 * the async callback, so it can be used to keep track of
822 * application-specific state. Resources allocated here should be freed by
823 * the cleanup callback.
824 */
825 void *user;
827
828#undef PQ_SOCKTYPE
829
830/* Authdata for PQAUTHDATA_OAUTH_BEARER_TOKEN_V2 */
831typedef struct
832{
833 PGoauthBearerRequest v1; /* see the PGoauthBearerRequest struct, above */
834
835 /* Hook inputs (constant across all calls) */
836 const char *issuer; /* the issuer identifier (RFC 9207) in use, as
837 * derived from the connection's oauth_issuer */
838
839 /* Hook outputs */
840
841 /*
842 * Hook-defined error message which will be included in the connection's
843 * PQerrorMessage() output when the flow fails. libpq does not take
844 * ownership of this pointer; any allocations should be freed during the
845 * cleanup callback.
846 */
847 const char *error;
849
850extern char *PQencryptPassword(const char *passwd, const char *user);
851extern char *PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm);
852extern PGresult *PQchangePassword(PGconn *conn, const char *user, const char *passwd);
853
855extern void PQsetAuthDataHook(PQauthDataHook_type hook);
858
859/* === in encnames.c === */
860
861extern int pg_char_to_encoding(const char *name);
862extern const char *pg_encoding_to_char(int encoding);
864
865/* === in fe-secure-openssl.c === */
866
867/* Support for overriding sslpassword handling with a callback */
868typedef int (*PQsslKeyPassHook_OpenSSL_type) (char *buf, int size, PGconn *conn);
871extern int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn);
872
873#ifdef __cplusplus
874}
875#endif
876
877#endif /* LIBPQ_FE_H */
static Datum values[MAXATTR]
Definition bootstrap.c:190
static PGcancel *volatile cancelConn
Definition cancel.c:43
Datum arg
Definition elog.c:1323
const char * str
#define stmt
#define bufsize
static struct @177 value
static char * encoding
Definition initdb.c:139
static const JsonPathKeyword keywords[]
#define PQresultErrorMessage
#define PQgetvalue
#define PQgetResult
#define PQcmdStatus
#define PQgetlength
#define PQclear
#define PQresultErrorField
#define PQcmdTuples
#define PQnfields
#define PQresultStatus
#define PQgetisnull
#define PQfname
#define PQntuples
ConnStatusType
Definition libpq-fe.h:89
@ CONNECTION_CONSUME
Definition libpq-fe.h:108
@ CONNECTION_AUTHENTICATING
Definition libpq-fe.h:115
@ CONNECTION_CHECK_STANDBY
Definition libpq-fe.h:112
@ CONNECTION_STARTED
Definition libpq-fe.h:98
@ CONNECTION_AWAITING_RESPONSE
Definition libpq-fe.h:100
@ CONNECTION_MADE
Definition libpq-fe.h:99
@ CONNECTION_CHECK_WRITABLE
Definition libpq-fe.h:107
@ CONNECTION_BAD
Definition libpq-fe.h:91
@ CONNECTION_OK
Definition libpq-fe.h:90
@ CONNECTION_GSS_STARTUP
Definition libpq-fe.h:109
@ CONNECTION_ALLOCATED
Definition libpq-fe.h:113
@ CONNECTION_SSL_STARTUP
Definition libpq-fe.h:105
@ CONNECTION_AUTH_OK
Definition libpq-fe.h:102
@ CONNECTION_CHECK_TARGET
Definition libpq-fe.h:110
@ CONNECTION_NEEDED
Definition libpq-fe.h:106
@ CONNECTION_SETENV
Definition libpq-fe.h:104
int PQserverVersion(const PGconn *conn)
char * PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm)
Definition fe-auth.c:1406
int PQprotocolVersion(const PGconn *conn)
char pqbool
Definition libpq-fe.h:258
int PQresetStart(PGconn *conn)
int PQsendQueryParams(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
Definition fe-exec.c:1509
int PQsetSingleRowMode(PGconn *conn)
Definition fe-exec.c:1965
void PQsetAuthDataHook(PQauthDataHook_type hook)
Definition fe-auth.c:1595
char * PQoptions(const PGconn *conn)
int PQbinaryTuples(const PGresult *res)
Definition fe-exec.c:3528
int PQflush(PGconn *conn)
Definition fe-exec.c:4036
PGresult * PQcopyResult(const PGresult *src, int flags)
Definition fe-exec.c:319
void PQfreemem(void *ptr)
Definition fe-exec.c:4068
void PQdisplayTuples(const PGresult *res, FILE *fp, int fillAlign, const char *fieldSep, int printHeader, int quiet)
Definition fe-print.c:605
int PQgetline(PGconn *conn, char *buffer, int length)
Definition fe-exec.c:2871
int(* PQauthDataHook_type)(PGauthData type, PGconn *conn, void *data)
Definition libpq-fe.h:854
ExecStatusType
Definition libpq-fe.h:129
@ PGRES_COPY_IN
Definition libpq-fe.h:138
@ PGRES_COPY_BOTH
Definition libpq-fe.h:143
@ PGRES_COMMAND_OK
Definition libpq-fe.h:131
@ PGRES_TUPLES_CHUNK
Definition libpq-fe.h:148
@ PGRES_FATAL_ERROR
Definition libpq-fe.h:142
@ PGRES_SINGLE_TUPLE
Definition libpq-fe.h:144
@ PGRES_COPY_OUT
Definition libpq-fe.h:137
@ PGRES_EMPTY_QUERY
Definition libpq-fe.h:130
@ PGRES_PIPELINE_SYNC
Definition libpq-fe.h:145
@ PGRES_BAD_RESPONSE
Definition libpq-fe.h:139
@ PGRES_PIPELINE_ABORTED
Definition libpq-fe.h:146
@ PGRES_NONFATAL_ERROR
Definition libpq-fe.h:141
@ PGRES_TUPLES_OK
Definition libpq-fe.h:134
char * PQdb(const PGconn *conn)
void PQinitSSL(int do_init)
Definition fe-secure.c:117
Oid PQftype(const PGresult *res, int field_num)
Definition fe-exec.c:3750
PGresult * PQchangePassword(PGconn *conn, const char *user, const char *passwd)
Definition fe-auth.c:1531
void(* pgthreadlock_t)(int acquire)
Definition libpq-fe.h:484
int lo_tell(PGconn *conn, int fd)
Definition fe-lobj.c:515
void * PQgetssl(PGconn *conn)
char * PQresultVerboseErrorMessage(const PGresult *res, PGVerbosity verbosity, PGContextVisibility show_context)
Definition fe-exec.c:3466
PGresult * PQdescribePrepared(PGconn *conn, const char *stmt)
Definition fe-exec.c:2472
PGresult * PQexecParams(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
Definition fe-exec.c:2293
int PQexitPipelineMode(PGconn *conn)
Definition fe-exec.c:3104
PGresult * PQexecPrepared(PGconn *conn, const char *stmtName, int nParams, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
Definition fe-exec.c:2340
int PQsendClosePortal(PGconn *conn, const char *portal)
Definition fe-exec.c:2586
PGPing
Definition libpq-fe.h:181
@ PQPING_OK
Definition libpq-fe.h:182
@ PQPING_REJECT
Definition libpq-fe.h:183
@ PQPING_NO_RESPONSE
Definition libpq-fe.h:184
@ PQPING_NO_ATTEMPT
Definition libpq-fe.h:185
PGcancel * PQgetCancel(PGconn *conn)
Definition fe-cancel.c:368
int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs)
Definition fe-exec.c:250
PGContextVisibility
Definition libpq-fe.h:169
@ PQSHOW_CONTEXT_NEVER
Definition libpq-fe.h:170
@ PQSHOW_CONTEXT_ALWAYS
Definition libpq-fe.h:172
@ PQSHOW_CONTEXT_ERRORS
Definition libpq-fe.h:171
void PQcancelReset(PGcancelConn *cancelConn)
Definition fe-cancel.c:337
int lo_close(PGconn *conn, int fd)
Definition fe-lobj.c:96
struct _PQconninfoOption PQconninfoOption
unsigned char * PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
Definition fe-exec.c:4636
int PQenv2encoding(void)
Definition fe-misc.c:1285
PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook_OpenSSL(void)
void * PQsslStruct(PGconn *conn, const char *struct_name)
int PQfullProtocolVersion(const PGconn *conn)
void PQreset(PGconn *conn)
int PQenterPipelineMode(PGconn *conn)
Definition fe-exec.c:3073
int PQsocketPoll(int sock, int forRead, int forWrite, pg_usec_time_t end_time)
Definition fe-misc.c:1141
int lo_truncate64(PGconn *conn, int fd, int64_t len)
Definition fe-lobj.c:195
size_t PQescapeStringConn(PGconn *conn, char *to, const char *from, size_t length, int *error)
Definition fe-exec.c:4213
void PQtrace(PGconn *conn, FILE *debug_port)
Definition fe-trace.c:35
char * PQport(const PGconn *conn)
PGresult * PQclosePrepared(PGconn *conn, const char *stmt)
Definition fe-exec.c:2538
PGTransactionStatusType PQtransactionStatus(const PGconn *conn)
PGcancelConn * PQcancelCreate(PGconn *conn)
Definition fe-cancel.c:68
PGTransactionStatusType
Definition libpq-fe.h:152
@ PQTRANS_INTRANS
Definition libpq-fe.h:155
@ PQTRANS_IDLE
Definition libpq-fe.h:153
@ PQTRANS_ACTIVE
Definition libpq-fe.h:154
@ PQTRANS_UNKNOWN
Definition libpq-fe.h:157
@ PQTRANS_INERROR
Definition libpq-fe.h:156
PQauthDataHook_type PQgetAuthDataHook(void)
Definition fe-auth.c:1589
void * PQgetgssctx(PGconn *conn)
PGresult * PQclosePortal(PGconn *conn, const char *portal)
Definition fe-exec.c:2556
Oid PQparamtype(const PGresult *res, int param_num)
Definition fe-exec.c:3961
PGconn * PQconnectdb(const char *conninfo)
Definition fe-connect.c:830
char * PQhost(const PGconn *conn)
int PQnparams(const PGresult *res)
Definition fe-exec.c:3949
int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn)
void PQprintTuples(const PGresult *res, FILE *fout, int PrintAttNames, int TerseOutput, int colWidth)
Definition fe-print.c:702
int PQsendClosePrepared(PGconn *conn, const char *stmt)
Definition fe-exec.c:2573
struct _PQprintOpt PQprintOpt
int PQconnectionUsedPassword(const PGconn *conn)
PQconninfoOption * PQconninfo(PGconn *conn)
int PQfformat(const PGresult *res, int field_num)
Definition fe-exec.c:3739
void(* PQnoticeReceiver)(void *arg, const PGresult *res)
Definition libpq-fe.h:254
int PQlibVersion(void)
Definition fe-misc.c:63
int64_t pg_usec_time_t
Definition libpq-fe.h:251
void(* PQnoticeProcessor)(void *arg, const char *message)
Definition libpq-fe.h:255
int PQendcopy(PGconn *conn)
Definition fe-exec.c:2966
int PQgssEncInUse(PGconn *conn)
PostgresPollingStatusType PQconnectPoll(PGconn *conn)
int PQdefaultAuthDataHook(PGauthData type, PGconn *conn, void *data)
Definition fe-auth.c:1601
int PQputCopyEnd(PGconn *conn, const char *errormsg)
Definition fe-exec.c:2766
void PQconninfoFree(PQconninfoOption *connOptions)
Oid lo_creat(PGconn *conn, int mode)
Definition fe-lobj.c:438
int PQsendPipelineSync(PGconn *conn)
Definition fe-exec.c:3313
pgthreadlock_t PQgetThreadLock(void)
int(* PQsslKeyPassHook_OpenSSL_type)(char *buf, int size, PGconn *conn)
Definition libpq-fe.h:868
int lo_read(PGconn *conn, int fd, char *buf, size_t len)
Definition fe-lobj.c:245
int lo_lseek(PGconn *conn, int fd, int offset, int whence)
Definition fe-lobj.c:344
int PQputnbytes(PGconn *conn, const char *buffer, int nbytes)
Definition fe-exec.c:2945
void PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
Definition fe-print.c:69
int PQmblen(const char *s, int encoding)
Definition fe-misc.c:1255
int PQputline(PGconn *conn, const char *string)
Definition fe-exec.c:2935
int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize)
Definition fe-exec.c:2918
int lo_open(PGconn *conn, Oid lobjId, int mode)
Definition fe-lobj.c:57
PostgresPollingStatusType
Definition libpq-fe.h:120
@ PGRES_POLLING_ACTIVE
Definition libpq-fe.h:125
@ PGRES_POLLING_OK
Definition libpq-fe.h:124
@ PGRES_POLLING_READING
Definition libpq-fe.h:122
@ PGRES_POLLING_WRITING
Definition libpq-fe.h:123
@ PGRES_POLLING_FAILED
Definition libpq-fe.h:121
char * PQtty(const PGconn *conn)
int PQputCopyData(PGconn *conn, const char *buffer, int nbytes)
Definition fe-exec.c:2712
PQconninfoOption * PQconninfoParse(const char *conninfo, char **errmsg)
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
PGresult * PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
Definition fe-exec.c:160
ConnStatusType PQcancelStatus(const PGcancelConn *cancelConn)
Definition fe-cancel.c:302
int64_t lo_lseek64(PGconn *conn, int fd, int64_t offset, int whence)
Definition fe-lobj.c:385
PGresult * PQprepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)
Definition fe-exec.c:2323
int64_t lo_tell64(PGconn *conn, int fd)
Definition fe-lobj.c:548
int lo_write(PGconn *conn, int fd, const char *buf, size_t len)
Definition fe-lobj.c:295
int PQisthreadsafe(void)
Definition fe-exec.c:4028
int PQconnectionNeedsPassword(const PGconn *conn)
char * PQencryptPassword(const char *passwd, const char *user)
Definition fe-auth.c:1363
char * PQpass(const PGconn *conn)
void PQinitOpenSSL(int do_ssl, int do_crypto)
Definition fe-secure.c:129
int PQcancelBlocking(PGcancelConn *cancelConn)
Definition fe-cancel.c:190
int lo_truncate(PGconn *conn, int fd, size_t len)
Definition fe-lobj.c:131
int PQsendDescribePrepared(PGconn *conn, const char *stmt)
Definition fe-exec.c:2508
Oid lo_create(PGconn *conn, Oid lobjId)
Definition fe-lobj.c:474
PostgresPollingStatusType PQresetPoll(PGconn *conn)
int PQsslInUse(PGconn *conn)
Definition fe-secure.c:103
int PQconnectionUsedGSSAPI(const PGconn *conn)
size_t PQescapeString(char *to, const char *from, size_t length)
Definition fe-exec.c:4235
int PQconsumeInput(PGconn *conn)
Definition fe-exec.c:2001
int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
Definition fe-cancel.c:548
PGauthData
Definition libpq-fe.h:199
@ PQAUTHDATA_PROMPT_OAUTH_DEVICE
Definition libpq-fe.h:200
@ PQAUTHDATA_OAUTH_BEARER_TOKEN
Definition libpq-fe.h:202
@ PQAUTHDATA_OAUTH_BEARER_TOKEN_V2
Definition libpq-fe.h:204
struct pgNotify PGnotify
ConnStatusType PQstatus(const PGconn *conn)
PGconn * PQconnectStart(const char *conninfo)
Definition fe-connect.c:958
Oid PQftable(const PGresult *res, int field_num)
Definition fe-exec.c:3717
int PQfnumber(const PGresult *res, const char *field_name)
Definition fe-exec.c:3620
unsigned char * PQescapeBytea(const unsigned char *from, size_t from_length, size_t *to_length)
Definition fe-exec.c:4611
int PQsetnonblocking(PGconn *conn, int arg)
Definition fe-exec.c:3980
int PQclientEncoding(const PGconn *conn)
PGconn * PQconnectStartParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition fe-connect.c:877
char * PQescapeLiteral(PGconn *conn, const char *str, size_t len)
Definition fe-exec.c:4418
void PQfinish(PGconn *conn)
PGresult * PQfn(PGconn *conn, int fnid, int *result_buf, int *result_len, int result_is_int, const PQArgBlock *args, int nargs)
Definition fe-exec.c:2997
PGPing PQping(const char *conninfo)
Definition fe-connect.c:846
int PQsendPrepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)
Definition fe-exec.c:1553
PGresult * PQdescribePortal(PGconn *conn, const char *portal)
Definition fe-exec.c:2491
int PQfmod(const PGresult *res, int field_num)
Definition fe-exec.c:3772
PGContextVisibility PQsetErrorContextVisibility(PGconn *conn, PGContextVisibility show_context)
PGpipelineStatus
Definition libpq-fe.h:192
@ PQ_PIPELINE_OFF
Definition libpq-fe.h:193
@ PQ_PIPELINE_ABORTED
Definition libpq-fe.h:195
@ PQ_PIPELINE_ON
Definition libpq-fe.h:194
int PQdsplen(const char *s, int encoding)
Definition fe-misc.c:1276
int PQftablecol(const PGresult *res, int field_num)
Definition fe-exec.c:3728
int PQsetChunkedRowsMode(PGconn *conn, int chunkSize)
Definition fe-exec.c:1982
const char * PQsslAttribute(PGconn *conn, const char *attribute_name)
int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
Definition fe-exec.c:453
int PQsendQuery(PGconn *conn, const char *query)
Definition fe-exec.c:1433
int PQpipelineSync(PGconn *conn)
Definition fe-exec.c:3303
PostgresPollingStatusType PQcancelPoll(PGcancelConn *cancelConn)
Definition fe-cancel.c:226
char * PQoidStatus(const PGresult *res)
Definition fe-exec.c:3796
PQnoticeReceiver PQsetNoticeReceiver(PGconn *conn, PQnoticeReceiver proc, void *arg)
int PQsendDescribePortal(PGconn *conn, const char *portal)
Definition fe-exec.c:2521
void PQcancelFinish(PGcancelConn *cancelConn)
Definition fe-cancel.c:353
PGconn * PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions, const char *pgtty, const char *dbName, const char *login, const char *pwd)
struct _PGpromptOAuthDevice PGpromptOAuthDevice
void PQsetTraceFlags(PGconn *conn, int flags)
Definition fe-trace.c:64
char * PQhostaddr(const PGconn *conn)
char * PQresStatus(ExecStatusType status)
Definition fe-exec.c:3450
size_t PQresultMemorySize(const PGresult *res)
Definition fe-exec.c:669
int PQbackendPID(const PGconn *conn)
void * PQresultAlloc(PGresult *res, size_t nBytes)
Definition fe-exec.c:544
PQconninfoOption * PQconndefaults(void)
int PQisBusy(PGconn *conn)
Definition fe-exec.c:2048
PGresult * PQexec(PGconn *conn, const char *query)
Definition fe-exec.c:2279
pg_usec_time_t PQgetCurrentTimeUSec(void)
Definition fe-misc.c:1235
unsigned char * PQescapeByteaConn(PGconn *conn, const unsigned char *from, size_t from_length, size_t *to_length)
Definition fe-exec.c:4595
int PQsendQueryPrepared(PGconn *conn, const char *stmtName, int nParams, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
Definition fe-exec.c:1650
char * PQescapeIdentifier(PGconn *conn, const char *str, size_t len)
Definition fe-exec.c:4424
PGVerbosity
Definition libpq-fe.h:161
@ PQERRORS_VERBOSE
Definition libpq-fe.h:164
@ PQERRORS_DEFAULT
Definition libpq-fe.h:163
@ PQERRORS_TERSE
Definition libpq-fe.h:162
@ PQERRORS_SQLSTATE
Definition libpq-fe.h:165
int PQsendFlushRequest(PGconn *conn)
Definition fe-exec.c:3402
int PQrequestCancel(PGconn *conn)
Definition fe-cancel.c:752
void PQfreeCancel(PGcancel *cancel)
Definition fe-cancel.c:502
char * PQuser(const PGconn *conn)
#define PQ_SOCKTYPE
Definition libpq-fe.h:767
int PQcancelSocket(const PGcancelConn *cancelConn)
Definition fe-cancel.c:313
PGpipelineStatus PQpipelineStatus(const PGconn *conn)
int lo_unlink(PGconn *conn, Oid lobjId)
Definition fe-lobj.c:589
int PQisnonblocking(const PGconn *conn)
Definition fe-exec.c:4019
void PQuntrace(PGconn *conn)
Definition fe-trace.c:49
PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity)
PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
char * PQcancelErrorMessage(const PGcancelConn *cancelConn)
Definition fe-cancel.c:325
Oid lo_import(PGconn *conn, const char *filename)
Definition fe-lobj.c:626
Oid PQoidValue(const PGresult *res)
Definition fe-exec.c:3824
int PQmblenBounded(const char *s, int encoding)
Definition fe-misc.c:1266
int lo_export(PGconn *conn, Oid lobjId, const char *filename)
Definition fe-lobj.c:748
const char *const * PQsslAttributeNames(PGconn *conn)
int PQcancelStart(PGcancelConn *cancelConn)
Definition fe-cancel.c:204
char * PQerrorMessage(const PGconn *conn)
Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId)
Definition fe-lobj.c:641
void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook)
PGPing PQpingParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition fe-connect.c:793
int PQsocket(const PGconn *conn)
int PQfsize(const PGresult *res, int field_num)
Definition fe-exec.c:3761
PGnotify * PQnotifies(PGconn *conn)
Definition fe-exec.c:2684
int PQsetClientEncoding(PGconn *conn, const char *encoding)
PGconn * PQconnectdbParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition fe-connect.c:775
struct pgresAttDesc PGresAttDesc
pgthreadlock_t PQregisterThreadLock(pgthreadlock_t newhandler)
int PQgetCopyData(PGconn *conn, char **buffer, int async)
Definition fe-exec.c:2833
static char * errmsg
static PgChecksumMode mode
const void size_t len
const void * data
static void do_init(void)
Definition pg_ctl.c:903
static Archive * fout
Definition pg_dumpall.c:139
static char * filename
Definition pg_dumpall.c:133
static char * user
Definition pg_regress.c:121
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define pg_encoding_to_char
Definition pg_wchar.h:483
#define pg_valid_server_encoding_id
Definition pg_wchar.h:485
#define pg_char_to_encoding
Definition pg_wchar.h:482
static int64 end_time
Definition pgbench.c:176
static const char * pghost
Definition pgbench.c:295
static const char * pgport
Definition pgbench.c:296
static const char * dbName
Definition pgbench.c:298
unsigned int Oid
static int fd(const char *x, int i)
static int fb(int x)
static void error(void)
PGconn * conn
Definition streamutil.c:52
const char * error
Definition libpq-fe.h:847
PGoauthBearerRequest v1
Definition libpq-fe.h:833
const char * issuer
Definition libpq-fe.h:836
const char * scope
Definition libpq-fe.h:775
void(* cleanup)(PGconn *conn, struct PGoauthBearerRequest *request)
Definition libpq-fe.h:810
const char * openid_configuration
Definition libpq-fe.h:774
PostgresPollingStatusType(* async)(PGconn *conn, struct PGoauthBearerRequest *request, PQ_SOCKTYPE *altsock)
Definition libpq-fe.h:798
int * ptr
Definition libpq-fe.h:309
int integer
Definition libpq-fe.h:310
const char * verification_uri_complete
Definition libpq-fe.h:754
const char * verification_uri
Definition libpq-fe.h:752
const char * user_code
Definition libpq-fe.h:753
pqbool align
Definition libpq-fe.h:263
pqbool pager
Definition libpq-fe.h:267
pqbool standard
Definition libpq-fe.h:264
pqbool html3
Definition libpq-fe.h:265
char * caption
Definition libpq-fe.h:270
pqbool header
Definition libpq-fe.h:262
pqbool expanded
Definition libpq-fe.h:266
char * fieldSep
Definition libpq-fe.h:268
char ** fieldName
Definition libpq-fe.h:271
char * tableOpt
Definition libpq-fe.h:269
struct pgNotify * next
Definition libpq-fe.h:247
int be_pid
Definition libpq-fe.h:244
char * relname
Definition libpq-fe.h:243
char * extra
Definition libpq-fe.h:245
char * name
Definition libpq-fe.h:320
const char * type
const char * name