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/* PGconn encapsulates a connection to the backend.
208 * The contents of this struct are not supposed to be known to applications.
209 */
210typedef struct pg_conn PGconn;
211
212/* PGcancelConn encapsulates a cancel connection to the backend.
213 * The contents of this struct are not supposed to be known to applications.
214 */
216
217/* PGresult encapsulates the result of a query (or more precisely, of a single
218 * SQL command --- a query string given to PQsendQuery can contain multiple
219 * commands and thus return multiple PGresult objects).
220 * The contents of this struct are not supposed to be known to applications.
221 */
222typedef struct pg_result PGresult;
223
224/* PGcancel encapsulates the information needed to cancel a running
225 * query on an existing connection.
226 * The contents of this struct are not supposed to be known to applications.
227 */
228typedef struct pg_cancel PGcancel;
229
230/* PGnotify represents the occurrence of a NOTIFY message.
231 * Ideally this would be an opaque typedef, but it's so simple that it's
232 * unlikely to change.
233 * NOTE: in Postgres 6.4 and later, the be_pid is the notifying backend's,
234 * whereas in earlier versions it was always your own backend's PID.
235 */
236typedef struct pgNotify
237{
238 char *relname; /* notification condition name */
239 int be_pid; /* process ID of notifying server process */
240 char *extra; /* notification parameter */
241 /* Fields below here are private to libpq; apps should not use 'em */
242 struct pgNotify *next; /* list link */
244
245/* pg_usec_time_t is like time_t, but with microsecond resolution */
247
248/* Function types for notice-handling callbacks */
249typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res);
250typedef void (*PQnoticeProcessor) (void *arg, const char *message);
251
252/* Print options for PQprint() */
253typedef char pqbool;
254
255typedef struct _PQprintOpt
256{
257 pqbool header; /* print output field headings and row count */
258 pqbool align; /* fill align the fields */
259 pqbool standard; /* old brain dead format */
260 pqbool html3; /* output html tables */
261 pqbool expanded; /* expand tables */
262 pqbool pager; /* use pager for output if needed */
263 char *fieldSep; /* field separator */
264 char *tableOpt; /* insert to HTML <table ...> */
265 char *caption; /* HTML <caption> */
266 char **fieldName; /* null terminated array of replacement field
267 * names */
269
270/* ----------------
271 * Structure for the conninfo parameter definitions returned by PQconndefaults
272 * or PQconninfoParse.
273 *
274 * All fields except "val" point at static strings which must not be altered.
275 * "val" is either NULL or a malloc'd current-value string. PQconninfoFree()
276 * will release both the val strings and the PQconninfoOption array itself.
277 * ----------------
278 */
279typedef struct _PQconninfoOption
280{
281 char *keyword; /* The keyword of the option */
282 char *envvar; /* Fallback environment variable name */
283 char *compiled; /* Fallback compiled in default value */
284 char *val; /* Option's current value, or NULL */
285 char *label; /* Label for field in connect dialog */
286 char *dispchar; /* Indicates how to display this field in a
287 * connect dialog. Values are: "" Display
288 * entered value as is "*" Password field -
289 * hide value "D" Debug option - don't show
290 * by default */
291 int dispsize; /* Field size in characters for dialog */
293
294/* ----------------
295 * PQArgBlock -- structure for PQfn() arguments
296 * ----------------
297 */
298typedef struct
299{
300 int len;
301 int isint;
302 union
303 {
304 int *ptr; /* can't use void (dec compiler barfs) */
306 } u;
307} PQArgBlock;
308
309/* ----------------
310 * PGresAttDesc -- Data about a single attribute (column) of a query result
311 * ----------------
312 */
313typedef struct pgresAttDesc
314{
315 char *name; /* column name */
316 Oid tableid; /* source table, if known */
317 int columnid; /* source column, if known */
318 int format; /* format code for value (text/binary) */
319 Oid typid; /* type id */
320 int typlen; /* type size */
321 int atttypmod; /* type-specific modifier info */
323
324/* ----------------
325 * Exported functions of libpq
326 * ----------------
327 */
328
329/* === in fe-connect.c === */
330
331/* make a new client connection to the backend */
332/* Asynchronous (non-blocking) */
333extern PGconn *PQconnectStart(const char *conninfo);
334extern PGconn *PQconnectStartParams(const char *const *keywords,
335 const char *const *values, int expand_dbname);
337
338/* Synchronous (blocking) */
339extern PGconn *PQconnectdb(const char *conninfo);
340extern PGconn *PQconnectdbParams(const char *const *keywords,
341 const char *const *values, int expand_dbname);
342extern PGconn *PQsetdbLogin(const char *pghost, const char *pgport,
343 const char *pgoptions, const char *pgtty,
344 const char *dbName,
345 const char *login, const char *pwd);
346
347#define PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME) \
348 PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, NULL, NULL)
349
350/* close the current connection and free the PGconn data structure */
351extern void PQfinish(PGconn *conn);
352
353/* get info about connection options known to PQconnectdb */
354extern PQconninfoOption *PQconndefaults(void);
355
356/* parse connection options in same way as PQconnectdb */
357extern PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
358
359/* return the connection options used by a live connection */
361
362/* free the data structure returned by PQconndefaults() or PQconninfoParse() */
364
365/*
366 * close the current connection and reestablish a new one with the same
367 * parameters
368 */
369/* Asynchronous (non-blocking) */
370extern int PQresetStart(PGconn *conn);
372
373/* Synchronous (blocking) */
374extern void PQreset(PGconn *conn);
375
376/* Create a PGcancelConn that's used to cancel a query on the given PGconn */
378
379/* issue a cancel request in a non-blocking manner */
381
382/* issue a blocking cancel request */
384
385/* poll a non-blocking cancel request */
388extern int PQcancelSocket(const PGcancelConn *cancelConn);
389extern char *PQcancelErrorMessage(const PGcancelConn *cancelConn);
392
393
394/* request a cancel structure */
396
397/* free a cancel structure */
398extern void PQfreeCancel(PGcancel *cancel);
399
400/* deprecated version of PQcancelBlocking, but one which is signal-safe */
401extern int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize);
402
403/* deprecated version of PQcancel; not thread-safe */
404extern int PQrequestCancel(PGconn *conn);
405
406/* Accessor functions for PGconn objects */
407extern char *PQdb(const PGconn *conn);
408extern char *PQuser(const PGconn *conn);
409extern char *PQpass(const PGconn *conn);
410extern char *PQhost(const PGconn *conn);
411extern char *PQhostaddr(const PGconn *conn);
412extern char *PQport(const PGconn *conn);
413extern char *PQtty(const PGconn *conn);
414extern char *PQoptions(const PGconn *conn);
415extern ConnStatusType PQstatus(const PGconn *conn);
417extern const char *PQparameterStatus(const PGconn *conn,
418 const char *paramName);
419extern int PQprotocolVersion(const PGconn *conn);
420extern int PQfullProtocolVersion(const PGconn *conn);
421extern int PQserverVersion(const PGconn *conn);
422extern char *PQerrorMessage(const PGconn *conn);
423extern int PQsocket(const PGconn *conn);
424extern int PQbackendPID(const PGconn *conn);
426extern int PQconnectionNeedsPassword(const PGconn *conn);
427extern int PQconnectionUsedPassword(const PGconn *conn);
428extern int PQconnectionUsedGSSAPI(const PGconn *conn);
429extern int PQclientEncoding(const PGconn *conn);
430extern int PQsetClientEncoding(PGconn *conn, const char *encoding);
431
432/* SSL information functions */
433extern int PQsslInUse(PGconn *conn);
434extern void *PQsslStruct(PGconn *conn, const char *struct_name);
435extern const char *PQsslAttribute(PGconn *conn, const char *attribute_name);
436extern const char *const *PQsslAttributeNames(PGconn *conn);
437
438/* Get the OpenSSL structure associated with a connection. Returns NULL for
439 * unencrypted connections or if any other TLS library is in use. */
440extern void *PQgetssl(PGconn *conn);
441
442/* Tell libpq whether it needs to initialize OpenSSL */
443extern void PQinitSSL(int do_init);
444
445/* More detailed way to tell libpq whether it needs to initialize OpenSSL */
446extern void PQinitOpenSSL(int do_ssl, int do_crypto);
447
448/* Return true if GSSAPI encryption is in use */
449extern int PQgssEncInUse(PGconn *conn);
450
451/* Returns GSSAPI context if GSSAPI is in use */
452extern void *PQgetgssctx(PGconn *conn);
453
454/* Set verbosity for PQerrorMessage and PQresultErrorMessage */
456
457/* Set CONTEXT visibility for PQerrorMessage and PQresultErrorMessage */
459 PGContextVisibility show_context);
460
461/* Override default notice handling routines */
463 PQnoticeReceiver proc,
464 void *arg);
467 void *arg);
468
469/*
470 * Used to set callback that prevents concurrent access to
471 * non-thread safe functions that libpq needs.
472 * The default implementation uses a libpq internal mutex.
473 * Only required for multithreaded apps that use Kerberos or
474 * older (non-threadsafe) versions of Curl both within their
475 * app and for postgresql connections.
476 */
477typedef void (*pgthreadlock_t) (int acquire);
478
481
482/* === in fe-trace.c === */
483extern void PQtrace(PGconn *conn, FILE *debug_port);
484extern void PQuntrace(PGconn *conn);
485
486/* flags controlling trace output: */
487/* omit timestamps from each line */
488#define PQTRACE_SUPPRESS_TIMESTAMPS (1<<0)
489/* redact portions of some messages, for testing frameworks */
490#define PQTRACE_REGRESS_MODE (1<<1)
491extern void PQsetTraceFlags(PGconn *conn, int flags);
492
493/* === in fe-exec.c === */
494
495/* Simple synchronous query */
496extern PGresult *PQexec(PGconn *conn, const char *query);
498 const char *command,
499 int nParams,
500 const Oid *paramTypes,
501 const char *const *paramValues,
502 const int *paramLengths,
503 const int *paramFormats,
504 int resultFormat);
505extern PGresult *PQprepare(PGconn *conn, const char *stmtName,
506 const char *query, int nParams,
507 const Oid *paramTypes);
509 const char *stmtName,
510 int nParams,
511 const char *const *paramValues,
512 const int *paramLengths,
513 const int *paramFormats,
514 int resultFormat);
515
516/* Interface for multiple-result or asynchronous queries */
517#define PQ_QUERY_PARAM_MAX_LIMIT 65535
518
519extern int PQsendQuery(PGconn *conn, const char *query);
520extern int PQsendQueryParams(PGconn *conn,
521 const char *command,
522 int nParams,
523 const Oid *paramTypes,
524 const char *const *paramValues,
525 const int *paramLengths,
526 const int *paramFormats,
527 int resultFormat);
528extern int PQsendPrepare(PGconn *conn, const char *stmtName,
529 const char *query, int nParams,
530 const Oid *paramTypes);
532 const char *stmtName,
533 int nParams,
534 const char *const *paramValues,
535 const int *paramLengths,
536 const int *paramFormats,
537 int resultFormat);
538extern int PQsetSingleRowMode(PGconn *conn);
539extern int PQsetChunkedRowsMode(PGconn *conn, int chunkSize);
541
542/* Routines for managing an asynchronous query */
543extern int PQisBusy(PGconn *conn);
544extern int PQconsumeInput(PGconn *conn);
545
546/* Routines for pipeline mode management */
547extern int PQenterPipelineMode(PGconn *conn);
548extern int PQexitPipelineMode(PGconn *conn);
549extern int PQpipelineSync(PGconn *conn);
550extern int PQsendFlushRequest(PGconn *conn);
551extern int PQsendPipelineSync(PGconn *conn);
552
553/* LISTEN/NOTIFY support */
555
556/* Routines for copy in/out */
557extern int PQputCopyData(PGconn *conn, const char *buffer, int nbytes);
558extern int PQputCopyEnd(PGconn *conn, const char *errormsg);
559extern int PQgetCopyData(PGconn *conn, char **buffer, int async);
560
561/* Deprecated routines for copy in/out */
562extern int PQgetline(PGconn *conn, char *buffer, int length);
563extern int PQputline(PGconn *conn, const char *string);
564extern int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize);
565extern int PQputnbytes(PGconn *conn, const char *buffer, int nbytes);
566extern int PQendcopy(PGconn *conn);
567
568/* Set blocking/nonblocking connection to the backend */
569extern int PQsetnonblocking(PGconn *conn, int arg);
570extern int PQisnonblocking(const PGconn *conn);
571extern int PQisthreadsafe(void);
572extern PGPing PQping(const char *conninfo);
573extern PGPing PQpingParams(const char *const *keywords,
574 const char *const *values, int expand_dbname);
575
576/* Force the write buffer to be written (or at least try) */
577extern int PQflush(PGconn *conn);
578
579/*
580 * "Fast path" interface --- not really recommended for application
581 * use
582 */
583extern PGresult *PQfn(PGconn *conn,
584 int fnid,
585 int *result_buf,
586 int *result_len,
587 int result_is_int,
588 const PQArgBlock *args,
589 int nargs);
590
591/* Accessor functions for PGresult objects */
592extern ExecStatusType PQresultStatus(const PGresult *res);
593extern char *PQresStatus(ExecStatusType status);
594extern char *PQresultErrorMessage(const PGresult *res);
595extern char *PQresultVerboseErrorMessage(const PGresult *res,
596 PGVerbosity verbosity,
597 PGContextVisibility show_context);
598extern char *PQresultErrorField(const PGresult *res, int fieldcode);
599extern int PQntuples(const PGresult *res);
600extern int PQnfields(const PGresult *res);
601extern int PQbinaryTuples(const PGresult *res);
602extern char *PQfname(const PGresult *res, int field_num);
603extern int PQfnumber(const PGresult *res, const char *field_name);
604extern Oid PQftable(const PGresult *res, int field_num);
605extern int PQftablecol(const PGresult *res, int field_num);
606extern int PQfformat(const PGresult *res, int field_num);
607extern Oid PQftype(const PGresult *res, int field_num);
608extern int PQfsize(const PGresult *res, int field_num);
609extern int PQfmod(const PGresult *res, int field_num);
610extern char *PQcmdStatus(PGresult *res);
611extern char *PQoidStatus(const PGresult *res); /* old and ugly */
612extern Oid PQoidValue(const PGresult *res); /* new and improved */
613extern char *PQcmdTuples(PGresult *res);
614extern char *PQgetvalue(const PGresult *res, int tup_num, int field_num);
615extern int PQgetlength(const PGresult *res, int tup_num, int field_num);
616extern int PQgetisnull(const PGresult *res, int tup_num, int field_num);
617extern int PQnparams(const PGresult *res);
618extern Oid PQparamtype(const PGresult *res, int param_num);
619
620/* Describe prepared statements and portals */
621extern PGresult *PQdescribePrepared(PGconn *conn, const char *stmt);
622extern PGresult *PQdescribePortal(PGconn *conn, const char *portal);
623extern int PQsendDescribePrepared(PGconn *conn, const char *stmt);
624extern int PQsendDescribePortal(PGconn *conn, const char *portal);
625
626/* Close prepared statements and portals */
627extern PGresult *PQclosePrepared(PGconn *conn, const char *stmt);
628extern PGresult *PQclosePortal(PGconn *conn, const char *portal);
629extern int PQsendClosePrepared(PGconn *conn, const char *stmt);
630extern int PQsendClosePortal(PGconn *conn, const char *portal);
631
632/* Delete a PGresult */
633extern void PQclear(PGresult *res);
634
635/* For freeing other alloc'd results, such as PGnotify structs */
636extern void PQfreemem(void *ptr);
637
638/* Exists for backward compatibility. bjm 2003-03-24 */
639#define PQfreeNotify(ptr) PQfreemem(ptr)
640
641/* Error when no password was given. */
642/* Note: depending on this is deprecated; use PQconnectionNeedsPassword(). */
643#define PQnoPasswordSupplied "fe_sendauth: no password supplied\n"
644
645/* Create and manipulate PGresults */
647extern PGresult *PQcopyResult(const PGresult *src, int flags);
648extern int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs);
649extern void *PQresultAlloc(PGresult *res, size_t nBytes);
650extern size_t PQresultMemorySize(const PGresult *res);
651extern int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len);
652
653/* Quoting strings before inclusion in queries. */
654extern size_t PQescapeStringConn(PGconn *conn,
655 char *to, const char *from, size_t length,
656 int *error);
657extern char *PQescapeLiteral(PGconn *conn, const char *str, size_t len);
658extern char *PQescapeIdentifier(PGconn *conn, const char *str, size_t len);
659extern unsigned char *PQescapeByteaConn(PGconn *conn,
660 const unsigned char *from, size_t from_length,
661 size_t *to_length);
662extern unsigned char *PQunescapeBytea(const unsigned char *strtext,
663 size_t *retbuflen);
664
665/* These forms are deprecated! */
666extern size_t PQescapeString(char *to, const char *from, size_t length);
667extern unsigned char *PQescapeBytea(const unsigned char *from, size_t from_length,
668 size_t *to_length);
669
670
671
672/* === in fe-print.c === */
673
674extern void PQprint(FILE *fout, /* output stream */
675 const PGresult *res,
676 const PQprintOpt *po); /* option structure */
677
678/*
679 * really old printing routines
680 */
681extern void PQdisplayTuples(const PGresult *res,
682 FILE *fp, /* where to send the output */
683 int fillAlign, /* pad the fields with spaces */
684 const char *fieldSep, /* field separator */
685 int printHeader, /* display headers? */
686 int quiet);
687
688extern void PQprintTuples(const PGresult *res,
689 FILE *fout, /* output stream */
690 int PrintAttNames, /* print attribute names */
691 int TerseOutput, /* delimiter bars */
692 int colWidth); /* width of column, if 0, use
693 * variable width */
694
695
696/* === in fe-lobj.c === */
697
698/* Large-object access routines */
699extern int lo_open(PGconn *conn, Oid lobjId, int mode);
700extern int lo_close(PGconn *conn, int fd);
701extern int lo_read(PGconn *conn, int fd, char *buf, size_t len);
702extern int lo_write(PGconn *conn, int fd, const char *buf, size_t len);
703extern int lo_lseek(PGconn *conn, int fd, int offset, int whence);
704extern int64_t lo_lseek64(PGconn *conn, int fd, int64_t offset, int whence);
705extern Oid lo_creat(PGconn *conn, int mode);
707extern int lo_tell(PGconn *conn, int fd);
708extern int64_t lo_tell64(PGconn *conn, int fd);
709extern int lo_truncate(PGconn *conn, int fd, size_t len);
710extern int lo_truncate64(PGconn *conn, int fd, int64_t len);
711extern int lo_unlink(PGconn *conn, Oid lobjId);
712extern Oid lo_import(PGconn *conn, const char *filename);
713extern Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId);
714extern int lo_export(PGconn *conn, Oid lobjId, const char *filename);
715
716/* === in fe-misc.c === */
717
718/* Get the version of the libpq library in use */
719extern int PQlibVersion(void);
720
721/* Poll a socket for reading and/or writing with an optional timeout */
722extern int PQsocketPoll(int sock, int forRead, int forWrite,
724
725/* Get current time in the form PQsocketPoll wants */
727
728/* Determine length of multibyte encoded char at *s */
729extern int PQmblen(const char *s, int encoding);
730
731/* Same, but not more than the distance to the end of string s */
732extern int PQmblenBounded(const char *s, int encoding);
733
734/* Determine display length of multibyte encoded char at *s */
735extern int PQdsplen(const char *s, int encoding);
736
737/* Get encoding id from environment variable PGCLIENTENCODING */
738extern int PQenv2encoding(void);
739
740/* === in fe-auth.c === */
741
742/* Authdata for PQAUTHDATA_PROMPT_OAUTH_DEVICE */
744{
745 const char *verification_uri; /* verification URI to visit */
746 const char *user_code; /* user code to enter */
747 const char *verification_uri_complete; /* optional combination of URI and
748 * code, or NULL */
749 int expires_in; /* seconds until user code expires */
751
752/*
753 * For PGoauthBearerRequest.async(). This macro just allows clients to avoid
754 * depending on libpq-int.h or Winsock for the "socket" type; it's undefined
755 * immediately below.
756 */
757#ifdef _WIN32
758#define PQ_SOCKTYPE uintptr_t /* avoids depending on winsock2.h for SOCKET */
759#else
760#define PQ_SOCKTYPE int
761#endif
762
763/* Authdata for PQAUTHDATA_OAUTH_BEARER_TOKEN */
765{
766 /* Hook inputs (constant across all calls) */
767 const char *openid_configuration; /* OIDC discovery URI */
768 const char *scope; /* required scope(s), or NULL */
769
770 /* Hook outputs */
771
772 /*---------
773 * Callback implementing a custom asynchronous OAuth flow.
774 *
775 * The callback may return
776 * - PGRES_POLLING_READING/WRITING, to indicate that a socket descriptor
777 * has been stored in *altsock and libpq should wait until it is
778 * readable or writable before calling back;
779 * - PGRES_POLLING_OK, to indicate that the flow is complete and
780 * request->token has been set; or
781 * - PGRES_POLLING_FAILED, to indicate that token retrieval has failed.
782 *
783 * This callback is optional. If the token can be obtained without
784 * blocking during the original call to the PQAUTHDATA_OAUTH_BEARER_TOKEN
785 * hook, it may be returned directly, but one of request->async or
786 * request->token must be set by the hook.
787 *
788 * The (PQ_SOCKTYPE *) in the signature is a placeholder for the platform's
789 * native socket type: (SOCKET *) on Windows, and (int *) everywhere else.
790 */
793 PQ_SOCKTYPE * altsock);
794
795 /*
796 * Callback to clean up custom allocations. A hook implementation may use
797 * this to free request->token and any resources in request->user. V2
798 * implementations should additionally free request->error, if set.
799 *
800 * This is technically optional, but highly recommended, because there is
801 * no other indication as to when it is safe to free the token.
802 */
804
805 /*
806 * The hook should set this to the Bearer token contents for the
807 * connection, once the flow is completed. The token contents must remain
808 * available to libpq until the hook's cleanup callback is called.
809 */
810 char *token;
811
812 /*
813 * Hook-defined data. libpq will not modify this pointer across calls to
814 * the async callback, so it can be used to keep track of
815 * application-specific state. Resources allocated here should be freed by
816 * the cleanup callback.
817 */
818 void *user;
820
821#undef PQ_SOCKTYPE
822
823/* Authdata for PQAUTHDATA_OAUTH_BEARER_TOKEN_V2 */
824typedef struct
825{
826 PGoauthBearerRequest v1; /* see the PGoauthBearerRequest struct, above */
827
828 /* Hook inputs (constant across all calls) */
829 const char *issuer; /* the issuer identifier (RFC 9207) in use, as
830 * derived from the connection's oauth_issuer */
831
832 /* Hook outputs */
833
834 /*
835 * Hook-defined error message which will be included in the connection's
836 * PQerrorMessage() output when the flow fails. libpq does not take
837 * ownership of this pointer; any allocations should be freed during the
838 * cleanup callback.
839 */
840 const char *error;
842
843extern char *PQencryptPassword(const char *passwd, const char *user);
844extern char *PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm);
845extern PGresult *PQchangePassword(PGconn *conn, const char *user, const char *passwd);
846
848extern void PQsetAuthDataHook(PQauthDataHook_type hook);
851
852/* === in encnames.c === */
853
854extern int pg_char_to_encoding(const char *name);
855extern const char *pg_encoding_to_char(int encoding);
857
858/* === in fe-secure-openssl.c === */
859
860/* Support for overriding sslpassword handling with a callback */
861typedef int (*PQsslKeyPassHook_OpenSSL_type) (char *buf, int size, PGconn *conn);
864extern int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn);
865
866#ifdef __cplusplus
867}
868#endif
869
870#endif /* LIBPQ_FE_H */
static Datum values[MAXATTR]
Definition bootstrap.c:188
static PGcancel *volatile cancelConn
Definition cancel.c:43
Datum arg
Definition elog.c:1322
const char * str
#define stmt
#define bufsize
static struct @174 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:253
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:3514
int PQflush(PGconn *conn)
Definition fe-exec.c:4017
PGresult * PQcopyResult(const PGresult *src, int flags)
Definition fe-exec.c:319
void PQfreemem(void *ptr)
Definition fe-exec.c:4049
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:847
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:3736
PGresult * PQchangePassword(PGconn *conn, const char *user, const char *passwd)
Definition fe-auth.c:1531
void(* pgthreadlock_t)(int acquire)
Definition libpq-fe.h:477
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:3452
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:3090
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:4617
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:3059
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:4194
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:3943
PGconn * PQconnectdb(const char *conninfo)
Definition fe-connect.c:826
char * PQhost(const PGconn *conn)
int PQnparams(const PGresult *res)
Definition fe-exec.c:3932
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:3725
void(* PQnoticeReceiver)(void *arg, const PGresult *res)
Definition libpq-fe.h:249
int PQlibVersion(void)
Definition fe-misc.c:63
int64_t pg_usec_time_t
Definition libpq-fe.h:246
void(* PQnoticeProcessor)(void *arg, const char *message)
Definition libpq-fe.h:250
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:3299
pgthreadlock_t PQgetThreadLock(void)
int(* PQsslKeyPassHook_OpenSSL_type)(char *buf, int size, PGconn *conn)
Definition libpq-fe.h:861
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:4009
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:4216
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:954
Oid PQftable(const PGresult *res, int field_num)
Definition fe-exec.c:3703
int PQfnumber(const PGresult *res, const char *field_name)
Definition fe-exec.c:3606
unsigned char * PQescapeBytea(const unsigned char *from, size_t from_length, size_t *to_length)
Definition fe-exec.c:4592
int PQsetnonblocking(PGconn *conn, int arg)
Definition fe-exec.c:3961
int PQclientEncoding(const PGconn *conn)
PGconn * PQconnectStartParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition fe-connect.c:873
char * PQescapeLiteral(PGconn *conn, const char *str, size_t len)
Definition fe-exec.c:4399
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:842
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:3758
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:3714
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:3289
PostgresPollingStatusType PQcancelPoll(PGcancelConn *cancelConn)
Definition fe-cancel.c:226
char * PQoidStatus(const PGresult *res)
Definition fe-exec.c:3782
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:3436
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:4576
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:4405
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:3388
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:760
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:4000
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:3810
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:789
int PQsocket(const PGconn *conn)
int PQfsize(const PGresult *res, int field_num)
Definition fe-exec.c:3747
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:771
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:119
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define pg_encoding_to_char
Definition pg_wchar.h:630
#define pg_valid_server_encoding_id
Definition pg_wchar.h:632
#define pg_char_to_encoding
Definition pg_wchar.h:629
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:840
PGoauthBearerRequest v1
Definition libpq-fe.h:826
const char * issuer
Definition libpq-fe.h:829
const char * scope
Definition libpq-fe.h:768
void(* cleanup)(PGconn *conn, struct PGoauthBearerRequest *request)
Definition libpq-fe.h:803
const char * openid_configuration
Definition libpq-fe.h:767
PostgresPollingStatusType(* async)(PGconn *conn, struct PGoauthBearerRequest *request, PQ_SOCKTYPE *altsock)
Definition libpq-fe.h:791
int * ptr
Definition libpq-fe.h:304
int integer
Definition libpq-fe.h:305
const char * verification_uri_complete
Definition libpq-fe.h:747
const char * verification_uri
Definition libpq-fe.h:745
const char * user_code
Definition libpq-fe.h:746
pqbool align
Definition libpq-fe.h:258
pqbool pager
Definition libpq-fe.h:262
pqbool standard
Definition libpq-fe.h:259
pqbool html3
Definition libpq-fe.h:260
char * caption
Definition libpq-fe.h:265
pqbool header
Definition libpq-fe.h:257
pqbool expanded
Definition libpq-fe.h:261
char * fieldSep
Definition libpq-fe.h:263
char ** fieldName
Definition libpq-fe.h:266
char * tableOpt
Definition libpq-fe.h:264
struct pgNotify * next
Definition libpq-fe.h:242
int be_pid
Definition libpq-fe.h:239
char * relname
Definition libpq-fe.h:238
char * extra
Definition libpq-fe.h:240
char * name
Definition libpq-fe.h:315
const char * type
const char * name