PostgreSQL Source Code  git master
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-2021, 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
19 extern "C"
20 {
21 #endif
22 
23 #include <stdio.h>
24 
25 /*
26  * postgres_ext.h defines the backend's externally visible types,
27  * such as Oid.
28  */
29 #include "postgres_ext.h"
30 
31 /*
32  * Option flags for PQcopyResult
33  */
34 #define PG_COPYRES_ATTRS 0x01
35 #define PG_COPYRES_TUPLES 0x02 /* Implies PG_COPYRES_ATTRS */
36 #define PG_COPYRES_EVENTS 0x04
37 #define PG_COPYRES_NOTICEHOOKS 0x08
38 
39 /* Application-visible enum types */
40 
41 /*
42  * Although it is okay to add to these lists, values which become unused
43  * should never be removed, nor should constants be redefined - that would
44  * break compatibility with existing code.
45  */
46 
47 typedef enum
48 {
51  /* Non-blocking mode only below here */
52 
53  /*
54  * The existence of these should never be relied upon - they should only
55  * be used for user feedback or similar purposes.
56  */
57  CONNECTION_STARTED, /* Waiting for connection to be made. */
58  CONNECTION_MADE, /* Connection OK; waiting to send. */
59  CONNECTION_AWAITING_RESPONSE, /* Waiting for a response from the
60  * postmaster. */
61  CONNECTION_AUTH_OK, /* Received authentication; waiting for
62  * backend startup. */
63  CONNECTION_SETENV, /* This state is no longer used. */
64  CONNECTION_SSL_STARTUP, /* Negotiating SSL. */
65  CONNECTION_NEEDED, /* Internal state: connect() needed */
66  CONNECTION_CHECK_WRITABLE, /* Checking if session is read-write. */
67  CONNECTION_CONSUME, /* Consuming any extra messages. */
68  CONNECTION_GSS_STARTUP, /* Negotiating GSSAPI. */
69  CONNECTION_CHECK_TARGET, /* Checking target server properties. */
70  CONNECTION_CHECK_STANDBY /* Checking if server is in standby mode. */
72 
73 typedef enum
74 {
76  PGRES_POLLING_READING, /* These two indicate that one may */
77  PGRES_POLLING_WRITING, /* use select before polling again. */
79  PGRES_POLLING_ACTIVE /* unused; keep for awhile for backwards
80  * compatibility */
82 
83 typedef enum
84 {
85  PGRES_EMPTY_QUERY = 0, /* empty query string was executed */
86  PGRES_COMMAND_OK, /* a query command that doesn't return
87  * anything was executed properly by the
88  * backend */
89  PGRES_TUPLES_OK, /* a query command that returns tuples was
90  * executed properly by the backend, PGresult
91  * contains the result tuples */
92  PGRES_COPY_OUT, /* Copy Out data transfer in progress */
93  PGRES_COPY_IN, /* Copy In data transfer in progress */
94  PGRES_BAD_RESPONSE, /* an unexpected response was recv'd from the
95  * backend */
96  PGRES_NONFATAL_ERROR, /* notice or warning message */
97  PGRES_FATAL_ERROR, /* query failed */
98  PGRES_COPY_BOTH, /* Copy In/Out data transfer in progress */
99  PGRES_SINGLE_TUPLE /* single tuple from larger resultset */
101 
102 typedef enum
103 {
104  PQTRANS_IDLE, /* connection idle */
105  PQTRANS_ACTIVE, /* command in progress */
106  PQTRANS_INTRANS, /* idle, within transaction block */
107  PQTRANS_INERROR, /* idle, within failed transaction */
108  PQTRANS_UNKNOWN /* cannot determine status */
110 
111 typedef enum
112 {
113  PQERRORS_TERSE, /* single-line error messages */
114  PQERRORS_DEFAULT, /* recommended style */
115  PQERRORS_VERBOSE, /* all the facts, ma'am */
116  PQERRORS_SQLSTATE /* only error severity and SQLSTATE code */
117 } PGVerbosity;
118 
119 typedef enum
120 {
121  PQSHOW_CONTEXT_NEVER, /* never show CONTEXT field */
122  PQSHOW_CONTEXT_ERRORS, /* show CONTEXT for errors only (default) */
123  PQSHOW_CONTEXT_ALWAYS /* always show CONTEXT field */
125 
126 /*
127  * PGPing - The ordering of this enum should not be altered because the
128  * values are exposed externally via pg_isready.
129  */
130 
131 typedef enum
132 {
133  PQPING_OK, /* server is accepting connections */
134  PQPING_REJECT, /* server is alive but rejecting connections */
135  PQPING_NO_RESPONSE, /* could not establish connection */
136  PQPING_NO_ATTEMPT /* connection not attempted (bad params) */
137 } PGPing;
138 
139 /* PGconn encapsulates a connection to the backend.
140  * The contents of this struct are not supposed to be known to applications.
141  */
142 typedef struct pg_conn PGconn;
143 
144 /* PGresult encapsulates the result of a query (or more precisely, of a single
145  * SQL command --- a query string given to PQsendQuery can contain multiple
146  * commands and thus return multiple PGresult objects).
147  * The contents of this struct are not supposed to be known to applications.
148  */
149 typedef struct pg_result PGresult;
150 
151 /* PGcancel encapsulates the information needed to cancel a running
152  * query on an existing connection.
153  * The contents of this struct are not supposed to be known to applications.
154  */
155 typedef struct pg_cancel PGcancel;
156 
157 /* PGnotify represents the occurrence of a NOTIFY message.
158  * Ideally this would be an opaque typedef, but it's so simple that it's
159  * unlikely to change.
160  * NOTE: in Postgres 6.4 and later, the be_pid is the notifying backend's,
161  * whereas in earlier versions it was always your own backend's PID.
162  */
163 typedef struct pgNotify
164 {
165  char *relname; /* notification condition name */
166  int be_pid; /* process ID of notifying server process */
167  char *extra; /* notification parameter */
168  /* Fields below here are private to libpq; apps should not use 'em */
169  struct pgNotify *next; /* list link */
170 } PGnotify;
171 
172 /* Function types for notice-handling callbacks */
173 typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res);
174 typedef void (*PQnoticeProcessor) (void *arg, const char *message);
175 
176 /* Print options for PQprint() */
177 typedef char pqbool;
178 
179 typedef struct _PQprintOpt
180 {
181  pqbool header; /* print output field headings and row count */
182  pqbool align; /* fill align the fields */
183  pqbool standard; /* old brain dead format */
184  pqbool html3; /* output html tables */
185  pqbool expanded; /* expand tables */
186  pqbool pager; /* use pager for output if needed */
187  char *fieldSep; /* field separator */
188  char *tableOpt; /* insert to HTML <table ...> */
189  char *caption; /* HTML <caption> */
190  char **fieldName; /* null terminated array of replacement field
191  * names */
192 } PQprintOpt;
193 
194 /* ----------------
195  * Structure for the conninfo parameter definitions returned by PQconndefaults
196  * or PQconninfoParse.
197  *
198  * All fields except "val" point at static strings which must not be altered.
199  * "val" is either NULL or a malloc'd current-value string. PQconninfoFree()
200  * will release both the val strings and the PQconninfoOption array itself.
201  * ----------------
202  */
203 typedef struct _PQconninfoOption
204 {
205  char *keyword; /* The keyword of the option */
206  char *envvar; /* Fallback environment variable name */
207  char *compiled; /* Fallback compiled in default value */
208  char *val; /* Option's current value, or NULL */
209  char *label; /* Label for field in connect dialog */
210  char *dispchar; /* Indicates how to display this field in a
211  * connect dialog. Values are: "" Display
212  * entered value as is "*" Password field -
213  * hide value "D" Debug option - don't show
214  * by default */
215  int dispsize; /* Field size in characters for dialog */
217 
218 /* ----------------
219  * PQArgBlock -- structure for PQfn() arguments
220  * ----------------
221  */
222 typedef struct
223 {
224  int len;
225  int isint;
226  union
227  {
228  int *ptr; /* can't use void (dec compiler barfs) */
229  int integer;
230  } u;
231 } PQArgBlock;
232 
233 /* ----------------
234  * PGresAttDesc -- Data about a single attribute (column) of a query result
235  * ----------------
236  */
237 typedef struct pgresAttDesc
238 {
239  char *name; /* column name */
240  Oid tableid; /* source table, if known */
241  int columnid; /* source column, if known */
242  int format; /* format code for value (text/binary) */
243  Oid typid; /* type id */
244  int typlen; /* type size */
245  int atttypmod; /* type-specific modifier info */
246 } PGresAttDesc;
247 
248 /* ----------------
249  * Exported functions of libpq
250  * ----------------
251  */
252 
253 /* === in fe-connect.c === */
254 
255 /* make a new client connection to the backend */
256 /* Asynchronous (non-blocking) */
257 extern PGconn *PQconnectStart(const char *conninfo);
258 extern PGconn *PQconnectStartParams(const char *const *keywords,
259  const char *const *values, int expand_dbname);
260 extern PostgresPollingStatusType PQconnectPoll(PGconn *conn);
261 
262 /* Synchronous (blocking) */
263 extern PGconn *PQconnectdb(const char *conninfo);
264 extern PGconn *PQconnectdbParams(const char *const *keywords,
265  const char *const *values, int expand_dbname);
266 extern PGconn *PQsetdbLogin(const char *pghost, const char *pgport,
267  const char *pgoptions, const char *pgtty,
268  const char *dbName,
269  const char *login, const char *pwd);
270 
271 #define PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME) \
272  PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, NULL, NULL)
273 
274 /* close the current connection and free the PGconn data structure */
275 extern void PQfinish(PGconn *conn);
276 
277 /* get info about connection options known to PQconnectdb */
278 extern PQconninfoOption *PQconndefaults(void);
279 
280 /* parse connection options in same way as PQconnectdb */
281 extern PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
282 
283 /* return the connection options used by a live connection */
285 
286 /* free the data structure returned by PQconndefaults() or PQconninfoParse() */
287 extern void PQconninfoFree(PQconninfoOption *connOptions);
288 
289 /*
290  * close the current connection and reestablish a new one with the same
291  * parameters
292  */
293 /* Asynchronous (non-blocking) */
294 extern int PQresetStart(PGconn *conn);
295 extern PostgresPollingStatusType PQresetPoll(PGconn *conn);
296 
297 /* Synchronous (blocking) */
298 extern void PQreset(PGconn *conn);
299 
300 /* request a cancel structure */
301 extern PGcancel *PQgetCancel(PGconn *conn);
302 
303 /* free a cancel structure */
304 extern void PQfreeCancel(PGcancel *cancel);
305 
306 /* issue a cancel request */
307 extern int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize);
308 
309 /* backwards compatible version of PQcancel; not thread-safe */
310 extern int PQrequestCancel(PGconn *conn);
311 
312 /* Accessor functions for PGconn objects */
313 extern char *PQdb(const PGconn *conn);
314 extern char *PQuser(const PGconn *conn);
315 extern char *PQpass(const PGconn *conn);
316 extern char *PQhost(const PGconn *conn);
317 extern char *PQhostaddr(const PGconn *conn);
318 extern char *PQport(const PGconn *conn);
319 extern char *PQtty(const PGconn *conn);
320 extern char *PQoptions(const PGconn *conn);
321 extern ConnStatusType PQstatus(const PGconn *conn);
322 extern PGTransactionStatusType PQtransactionStatus(const PGconn *conn);
323 extern const char *PQparameterStatus(const PGconn *conn,
324  const char *paramName);
325 extern int PQprotocolVersion(const PGconn *conn);
326 extern int PQserverVersion(const PGconn *conn);
327 extern char *PQerrorMessage(const PGconn *conn);
328 extern int PQsocket(const PGconn *conn);
329 extern int PQbackendPID(const PGconn *conn);
330 extern int PQconnectionNeedsPassword(const PGconn *conn);
331 extern int PQconnectionUsedPassword(const PGconn *conn);
332 extern int PQclientEncoding(const PGconn *conn);
333 extern int PQsetClientEncoding(PGconn *conn, const char *encoding);
334 
335 /* SSL information functions */
336 extern int PQsslInUse(PGconn *conn);
337 extern void *PQsslStruct(PGconn *conn, const char *struct_name);
338 extern const char *PQsslAttribute(PGconn *conn, const char *attribute_name);
339 extern const char *const *PQsslAttributeNames(PGconn *conn);
340 
341 /* Get the OpenSSL structure associated with a connection. Returns NULL for
342  * unencrypted connections or if any other TLS library is in use. */
343 extern void *PQgetssl(PGconn *conn);
344 
345 /* Tell libpq whether it needs to initialize OpenSSL */
346 extern void PQinitSSL(int do_init);
347 
348 /* More detailed way to tell libpq whether it needs to initialize OpenSSL */
349 extern void PQinitOpenSSL(int do_ssl, int do_crypto);
350 
351 /* Return true if GSSAPI encryption is in use */
352 extern int PQgssEncInUse(PGconn *conn);
353 
354 /* Returns GSSAPI context if GSSAPI is in use */
355 extern void *PQgetgssctx(PGconn *conn);
356 
357 /* Set verbosity for PQerrorMessage and PQresultErrorMessage */
358 extern PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity);
359 
360 /* Set CONTEXT visibility for PQerrorMessage and PQresultErrorMessage */
361 extern PGContextVisibility PQsetErrorContextVisibility(PGconn *conn,
362  PGContextVisibility show_context);
363 
364 /* Enable/disable tracing */
365 extern void PQtrace(PGconn *conn, FILE *debug_port);
366 extern void PQuntrace(PGconn *conn);
367 
368 /* Override default notice handling routines */
370  PQnoticeReceiver proc,
371  void *arg);
373  PQnoticeProcessor proc,
374  void *arg);
375 
376 /*
377  * Used to set callback that prevents concurrent access to
378  * non-thread safe functions that libpq needs.
379  * The default implementation uses a libpq internal mutex.
380  * Only required for multithreaded apps that use kerberos
381  * both within their app and for postgresql connections.
382  */
383 typedef void (*pgthreadlock_t) (int acquire);
384 
386 
387 /* === in fe-exec.c === */
388 
389 /* Simple synchronous query */
390 extern PGresult *PQexec(PGconn *conn, const char *query);
392  const char *command,
393  int nParams,
394  const Oid *paramTypes,
395  const char *const *paramValues,
396  const int *paramLengths,
397  const int *paramFormats,
398  int resultFormat);
399 extern PGresult *PQprepare(PGconn *conn, const char *stmtName,
400  const char *query, int nParams,
401  const Oid *paramTypes);
403  const char *stmtName,
404  int nParams,
405  const char *const *paramValues,
406  const int *paramLengths,
407  const int *paramFormats,
408  int resultFormat);
409 
410 /* Interface for multiple-result or asynchronous queries */
411 extern int PQsendQuery(PGconn *conn, const char *query);
412 extern int PQsendQueryParams(PGconn *conn,
413  const char *command,
414  int nParams,
415  const Oid *paramTypes,
416  const char *const *paramValues,
417  const int *paramLengths,
418  const int *paramFormats,
419  int resultFormat);
420 extern int PQsendPrepare(PGconn *conn, const char *stmtName,
421  const char *query, int nParams,
422  const Oid *paramTypes);
423 extern int PQsendQueryPrepared(PGconn *conn,
424  const char *stmtName,
425  int nParams,
426  const char *const *paramValues,
427  const int *paramLengths,
428  const int *paramFormats,
429  int resultFormat);
430 extern int PQsetSingleRowMode(PGconn *conn);
431 extern PGresult *PQgetResult(PGconn *conn);
432 
433 /* Routines for managing an asynchronous query */
434 extern int PQisBusy(PGconn *conn);
435 extern int PQconsumeInput(PGconn *conn);
436 
437 /* LISTEN/NOTIFY support */
438 extern PGnotify *PQnotifies(PGconn *conn);
439 
440 /* Routines for copy in/out */
441 extern int PQputCopyData(PGconn *conn, const char *buffer, int nbytes);
442 extern int PQputCopyEnd(PGconn *conn, const char *errormsg);
443 extern int PQgetCopyData(PGconn *conn, char **buffer, int async);
444 
445 /* Deprecated routines for copy in/out */
446 extern int PQgetline(PGconn *conn, char *string, int length);
447 extern int PQputline(PGconn *conn, const char *string);
448 extern int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize);
449 extern int PQputnbytes(PGconn *conn, const char *buffer, int nbytes);
450 extern int PQendcopy(PGconn *conn);
451 
452 /* Set blocking/nonblocking connection to the backend */
453 extern int PQsetnonblocking(PGconn *conn, int arg);
454 extern int PQisnonblocking(const PGconn *conn);
455 extern int PQisthreadsafe(void);
456 extern PGPing PQping(const char *conninfo);
457 extern PGPing PQpingParams(const char *const *keywords,
458  const char *const *values, int expand_dbname);
459 
460 /* Force the write buffer to be written (or at least try) */
461 extern int PQflush(PGconn *conn);
462 
463 /*
464  * "Fast path" interface --- not really recommended for application
465  * use
466  */
467 extern PGresult *PQfn(PGconn *conn,
468  int fnid,
469  int *result_buf,
470  int *result_len,
471  int result_is_int,
472  const PQArgBlock *args,
473  int nargs);
474 
475 /* Accessor functions for PGresult objects */
476 extern ExecStatusType PQresultStatus(const PGresult *res);
477 extern char *PQresStatus(ExecStatusType status);
478 extern char *PQresultErrorMessage(const PGresult *res);
479 extern char *PQresultVerboseErrorMessage(const PGresult *res,
480  PGVerbosity verbosity,
481  PGContextVisibility show_context);
482 extern char *PQresultErrorField(const PGresult *res, int fieldcode);
483 extern int PQntuples(const PGresult *res);
484 extern int PQnfields(const PGresult *res);
485 extern int PQbinaryTuples(const PGresult *res);
486 extern char *PQfname(const PGresult *res, int field_num);
487 extern int PQfnumber(const PGresult *res, const char *field_name);
488 extern Oid PQftable(const PGresult *res, int field_num);
489 extern int PQftablecol(const PGresult *res, int field_num);
490 extern int PQfformat(const PGresult *res, int field_num);
491 extern Oid PQftype(const PGresult *res, int field_num);
492 extern int PQfsize(const PGresult *res, int field_num);
493 extern int PQfmod(const PGresult *res, int field_num);
494 extern char *PQcmdStatus(PGresult *res);
495 extern char *PQoidStatus(const PGresult *res); /* old and ugly */
496 extern Oid PQoidValue(const PGresult *res); /* new and improved */
497 extern char *PQcmdTuples(PGresult *res);
498 extern char *PQgetvalue(const PGresult *res, int tup_num, int field_num);
499 extern int PQgetlength(const PGresult *res, int tup_num, int field_num);
500 extern int PQgetisnull(const PGresult *res, int tup_num, int field_num);
501 extern int PQnparams(const PGresult *res);
502 extern Oid PQparamtype(const PGresult *res, int param_num);
503 
504 /* Describe prepared statements and portals */
505 extern PGresult *PQdescribePrepared(PGconn *conn, const char *stmt);
506 extern PGresult *PQdescribePortal(PGconn *conn, const char *portal);
507 extern int PQsendDescribePrepared(PGconn *conn, const char *stmt);
508 extern int PQsendDescribePortal(PGconn *conn, const char *portal);
509 
510 /* Delete a PGresult */
511 extern void PQclear(PGresult *res);
512 
513 /* For freeing other alloc'd results, such as PGnotify structs */
514 extern void PQfreemem(void *ptr);
515 
516 /* Exists for backward compatibility. bjm 2003-03-24 */
517 #define PQfreeNotify(ptr) PQfreemem(ptr)
518 
519 /* Error when no password was given. */
520 /* Note: depending on this is deprecated; use PQconnectionNeedsPassword(). */
521 #define PQnoPasswordSupplied "fe_sendauth: no password supplied\n"
522 
523 /* Create and manipulate PGresults */
524 extern PGresult *PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status);
525 extern PGresult *PQcopyResult(const PGresult *src, int flags);
526 extern int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs);
527 extern void *PQresultAlloc(PGresult *res, size_t nBytes);
528 extern size_t PQresultMemorySize(const PGresult *res);
529 extern int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len);
530 
531 /* Quoting strings before inclusion in queries. */
532 extern size_t PQescapeStringConn(PGconn *conn,
533  char *to, const char *from, size_t length,
534  int *error);
535 extern char *PQescapeLiteral(PGconn *conn, const char *str, size_t len);
536 extern char *PQescapeIdentifier(PGconn *conn, const char *str, size_t len);
537 extern unsigned char *PQescapeByteaConn(PGconn *conn,
538  const unsigned char *from, size_t from_length,
539  size_t *to_length);
540 extern unsigned char *PQunescapeBytea(const unsigned char *strtext,
541  size_t *retbuflen);
542 
543 /* These forms are deprecated! */
544 extern size_t PQescapeString(char *to, const char *from, size_t length);
545 extern unsigned char *PQescapeBytea(const unsigned char *from, size_t from_length,
546  size_t *to_length);
547 
548 
549 
550 /* === in fe-print.c === */
551 
552 extern void PQprint(FILE *fout, /* output stream */
553  const PGresult *res,
554  const PQprintOpt *ps); /* option structure */
555 
556 /*
557  * really old printing routines
558  */
559 extern void PQdisplayTuples(const PGresult *res,
560  FILE *fp, /* where to send the output */
561  int fillAlign, /* pad the fields with spaces */
562  const char *fieldSep, /* field separator */
563  int printHeader, /* display headers? */
564  int quiet);
565 
566 extern void PQprintTuples(const PGresult *res,
567  FILE *fout, /* output stream */
568  int PrintAttNames, /* print attribute names */
569  int TerseOutput, /* delimiter bars */
570  int colWidth); /* width of column, if 0, use
571  * variable width */
572 
573 
574 /* === in fe-lobj.c === */
575 
576 /* Large-object access routines */
577 extern int lo_open(PGconn *conn, Oid lobjId, int mode);
578 extern int lo_close(PGconn *conn, int fd);
579 extern int lo_read(PGconn *conn, int fd, char *buf, size_t len);
580 extern int lo_write(PGconn *conn, int fd, const char *buf, size_t len);
581 extern int lo_lseek(PGconn *conn, int fd, int offset, int whence);
582 extern pg_int64 lo_lseek64(PGconn *conn, int fd, pg_int64 offset, int whence);
583 extern Oid lo_creat(PGconn *conn, int mode);
584 extern Oid lo_create(PGconn *conn, Oid lobjId);
585 extern int lo_tell(PGconn *conn, int fd);
586 extern pg_int64 lo_tell64(PGconn *conn, int fd);
587 extern int lo_truncate(PGconn *conn, int fd, size_t len);
588 extern int lo_truncate64(PGconn *conn, int fd, pg_int64 len);
589 extern int lo_unlink(PGconn *conn, Oid lobjId);
590 extern Oid lo_import(PGconn *conn, const char *filename);
591 extern Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId);
592 extern int lo_export(PGconn *conn, Oid lobjId, const char *filename);
593 
594 /* === in fe-misc.c === */
595 
596 /* Get the version of the libpq library in use */
597 extern int PQlibVersion(void);
598 
599 /* Determine length of multibyte encoded char at *s */
600 extern int PQmblen(const char *s, int encoding);
601 
602 /* Determine display length of multibyte encoded char at *s */
603 extern int PQdsplen(const char *s, int encoding);
604 
605 /* Get encoding id from environment variable PGCLIENTENCODING */
606 extern int PQenv2encoding(void);
607 
608 /* === in fe-auth.c === */
609 
610 extern char *PQencryptPassword(const char *passwd, const char *user);
611 extern char *PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm);
612 
613 /* === in encnames.c === */
614 
615 extern int pg_char_to_encoding(const char *name);
616 extern const char *pg_encoding_to_char(int encoding);
617 extern int pg_valid_server_encoding_id(int encoding);
618 
619 /* === in fe-secure-openssl.c === */
620 
621 /* Support for overriding sslpassword handling with a callback */
622 typedef int (*PQsslKeyPassHook_OpenSSL_type) (char *buf, int size, PGconn *conn);
625 extern int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn);
626 
627 #ifdef __cplusplus
628 }
629 #endif
630 
631 #endif /* LIBPQ_FE_H */
int PQclientEncoding(const PGconn *conn)
Definition: fe-connect.c:6765
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:1913
void PQtrace(PGconn *conn, FILE *debug_port)
Definition: fe-connect.c:6839
int PQsocket(const PGconn *conn)
Definition: fe-connect.c:6723
void PQinitSSL(int do_init)
Definition: fe-secure.c:139
Oid PQftable(const PGresult *res, int field_num)
Definition: fe-exec.c:2837
char * PQport(const PGconn *conn)
Definition: fe-connect.c:6624
char * extra
Definition: libpq-fe.h:167
void * PQgetssl(PGconn *conn)
ConnStatusType
Definition: libpq-fe.h:47
static PgChecksumMode mode
Definition: pg_checksums.c:61
int PQnfields(const PGresult *res)
Definition: fe-exec.c:2640
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:1261
size_t PQescapeString(char *to, const char *from, size_t length)
Definition: fe-exec.c:3298
PQconninfoOption * PQconninfoParse(const char *conninfo, char **errmsg)
Definition: fe-connect.c:5302
void(* PQnoticeReceiver)(void *arg, const PGresult *res)
Definition: libpq-fe.h:173
int lo_tell(PGconn *conn, int fd)
Definition: fe-lobj.c:522
void * PQsslStruct(PGconn *conn, const char *struct_name)
int lo_export(PGconn *conn, Oid lobjId, const char *filename)
Definition: fe-lobj.c:757
PGPing PQping(const char *conninfo)
Definition: fe-connect.c:725
void PQuntrace(PGconn *conn)
Definition: fe-connect.c:6848
int PQgetCopyData(PGconn *conn, char **buffer, int async)
Definition: fe-exec.c:2361
static void error(void)
Definition: sql-dyntest.c:147
int PQfmod(const PGresult *res, int field_num)
Definition: fe-exec.c:2892
int PQisnonblocking(const PGconn *conn)
Definition: fe-exec.c:3131
int PQmblen(const char *s, int encoding)
Definition: fe-misc.c:1222
char * PQpass(const PGconn *conn)
Definition: fe-connect.c:6571
char * PQescapeIdentifier(PGconn *conn, const char *str, size_t len)
Definition: fe-exec.c:3442
PGresult * PQcopyResult(const PGresult *src, int flags)
Definition: fe-exec.c:295
int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize)
Definition: fe-exec.c:2447
char * PQuser(const PGconn *conn)
Definition: fe-connect.c:6563
int pg_valid_server_encoding_id(int encoding)
Definition: encnames.c:514
int PQputCopyData(PGconn *conn, const char *buffer, int nbytes)
Definition: fe-exec.c:2238
void PQreset(PGconn *conn)
Definition: fe-connect.c:4217
int PQresetStart(PGconn *conn)
Definition: fe-connect.c:4258
pg_int64 lo_tell64(PGconn *conn, int fd)
Definition: fe-lobj.c:555
int PQbinaryTuples(const PGresult *res)
Definition: fe-exec.c:2648
PGconn * PQconnectStartParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition: fe-connect.c:756
int lo_read(PGconn *conn, int fd, char *buf, size_t len)
Definition: fe-lobj.c:248
void PQfreeCancel(PGcancel *cancel)
Definition: fe-connect.c:4347
void(* PQnoticeProcessor)(void *arg, const char *message)
Definition: libpq-fe.h:174
char * PQdb(const PGconn *conn)
Definition: fe-connect.c:6555
int PQntuples(const PGresult *res)
Definition: fe-exec.c:2632
int PQisthreadsafe(void)
Definition: fe-exec.c:3138
PGcancel * PQgetCancel(PGconn *conn)
Definition: fe-connect.c:4324
unsigned char * PQescapeByteaConn(PGconn *conn, const unsigned char *from, size_t from_length, size_t *to_length)
Definition: fe-exec.c:3586
int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
Definition: fe-exec.c:432
int PQfformat(const PGresult *res, int field_num)
Definition: fe-exec.c:2859
const char * pghost
Definition: pgbench.c:244
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3026
void * PQgetgssctx(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:2526
char * PQcmdTuples(PGresult *res)
Definition: fe-exec.c:2973
int PQconnectionUsedPassword(const PGconn *conn)
Definition: fe-connect.c:6754
ExecStatusType
Definition: libpq-fe.h:83
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:1960
ExecStatusType PQresultStatus(const PGresult *res)
Definition: fe-exec.c:2562
PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
Definition: fe-connect.c:6877
pgthreadlock_t PQregisterThreadLock(pgthreadlock_t newhandler)
Definition: fe-connect.c:7271
void PQinitOpenSSL(int do_ssl, int do_crypto)
Definition: fe-secure.c:151
char * PQtty(const PGconn *conn)
Definition: fe-connect.c:6636
void PQfinish(PGconn *conn)
Definition: fe-connect.c:4203
unsigned int Oid
Definition: postgres_ext.h:31
int PQlibVersion(void)
Definition: fe-misc.c:66
pqbool standard
Definition: libpq-fe.h:183
const char *const * PQsslAttributeNames(PGconn *conn)
static int fd(const char *x, int i)
Definition: preproc-init.c:105
int columnid
Definition: libpq-fe.h:241
char * fieldSep
Definition: libpq-fe.h:187
const char * dbName
Definition: pgbench.c:247
PG_INT64_TYPE pg_int64
Definition: postgres_ext.h:47
Oid lo_create(PGconn *conn, Oid lobjId)
Definition: fe-lobj.c:480
PGTransactionStatusType PQtransactionStatus(const PGconn *conn)
Definition: fe-connect.c:6660
Oid lo_creat(PGconn *conn, int mode)
Definition: fe-lobj.c:444
PQconninfoOption * PQconndefaults(void)
Definition: fe-connect.c:1468
static struct @141 value
char * PQoptions(const PGconn *conn)
Definition: fe-connect.c:6644
PGconn * PQconnectStart(const char *conninfo)
Definition: fe-connect.c:837
void PQconninfoFree(PQconninfoOption *connOptions)
Definition: fe-connect.c:6537
int PQsetnonblocking(PGconn *conn, int arg)
Definition: fe-exec.c:3094
const char * pg_encoding_to_char(int encoding)
Definition: encnames.c:588
int PQnparams(const PGresult *res)
Definition: fe-exec.c:3065
int PQgetline(PGconn *conn, char *string, int length)
Definition: fe-exec.c:2400
int lo_close(PGconn *conn, int fd)
Definition: fe-lobj.c:96
int PQprotocolVersion(const PGconn *conn)
Definition: fe-connect.c:6685
PGconn * PQconnectdbParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition: fe-connect.c:653
int lo_lseek(PGconn *conn, int fd, int offset, int whence)
Definition: fe-lobj.c:349
void(* pgthreadlock_t)(int acquire)
Definition: libpq-fe.h:383
int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn)
int PQputCopyEnd(PGconn *conn, const char *errormsg)
Definition: fe-exec.c:2294
int PQsslInUse(PGconn *conn)
Definition: fe-secure.c:127
PGconn * conn
Definition: streamutil.c:54
int be_pid
Definition: libpq-fe.h:166
void PQprint(FILE *fout, const PGresult *res, const PQprintOpt *ps)
Definition: fe-print.c:68
int PQsendDescribePortal(PGconn *conn, const char *portal)
Definition: fe-exec.c:2134
int PQftablecol(const PGresult *res, int field_num)
Definition: fe-exec.c:2848
int lo_open(PGconn *conn, Oid lobjId, int mode)
Definition: fe-lobj.c:57
char * PQresultErrorField(const PGresult *res, int fieldcode)
Definition: fe-exec.c:2617
char * PQresultVerboseErrorMessage(const PGresult *res, PGVerbosity verbosity, PGContextVisibility show_context)
Definition: fe-exec.c:2586
static char * buf
Definition: pg_test_fsync.c:68
char * PQencryptPassword(const char *passwd, const char *user)
Definition: fe-auth.c:1150
int PQputline(PGconn *conn, const char *string)
Definition: fe-exec.c:2464
PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity)
Definition: fe-connect.c:6815
pqbool align
Definition: libpq-fe.h:182
size_t PQresultMemorySize(const PGresult *res)
Definition: fe-exec.c:635
char * relname
Definition: libpq-fe.h:165
PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook_OpenSSL(void)
PGresult * PQexec(PGconn *conn, const char *query)
Definition: fe-exec.c:1899
int PQgetlength(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3037
char * PQescapeLiteral(PGconn *conn, const char *str, size_t len)
Definition: fe-exec.c:3436
int PQsendDescribePrepared(PGconn *conn, const char *stmt)
Definition: fe-exec.c:2121
int PQrequestCancel(PGconn *conn)
Definition: fe-connect.c:4504
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
Definition: fe-connect.c:6670
int PQsendPrepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)
Definition: fe-exec.c:1306
void PQprintTuples(const PGresult *res, FILE *fout, int PrintAttNames, int TerseOutput, int colWidth)
Definition: fe-print.c:676
PQnoticeReceiver PQsetNoticeReceiver(PGconn *conn, PQnoticeReceiver proc, void *arg)
Definition: fe-connect.c:6860
char * PQhost(const PGconn *conn)
Definition: fe-connect.c:6588
int PQfnumber(const PGresult *res, const char *field_name)
Definition: fe-exec.c:2740
char * PQerrorMessage(const PGconn *conn)
Definition: fe-connect.c:6705
char * PQcmdStatus(PGresult *res)
Definition: fe-exec.c:2903
void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook)
char * PQhostaddr(const PGconn *conn)
Definition: fe-connect.c:6611
int PQsetSingleRowMode(PGconn *conn)
Definition: fe-exec.c:1640
char * caption
Definition: libpq-fe.h:189
PGPing PQpingParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition: fe-connect.c:672
char * PQresStatus(ExecStatusType status)
Definition: fe-exec.c:2570
pqbool pager
Definition: libpq-fe.h:186
Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId)
Definition: fe-lobj.c:649
int PQconsumeInput(PGconn *conn)
Definition: fe-exec.c:1667
char * PQresultErrorMessage(const PGresult *res)
Definition: fe-exec.c:2578
Oid PQftype(const PGresult *res, int field_num)
Definition: fe-exec.c:2870
PGContextVisibility
Definition: libpq-fe.h:119
int PQconnectionNeedsPassword(const PGconn *conn)
Definition: fe-connect.c:6739
struct pgNotify * next
Definition: libpq-fe.h:169
void * PQresultAlloc(PGresult *res, size_t nBytes)
Definition: fe-exec.c:519
PGVerbosity
Definition: libpq-fe.h:111
PostgresPollingStatusType PQresetPoll(PGconn *conn)
Definition: fe-connect.c:4277
int atttypmod
Definition: libpq-fe.h:245
unsigned char * PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
Definition: fe-exec.c:3626
const char * PQsslAttribute(PGconn *conn, const char *attribute_name)
struct pgresAttDesc PGresAttDesc
PGTransactionStatusType
Definition: libpq-fe.h:102
int PQgssEncInUse(PGconn *conn)
unsigned char * PQescapeBytea(const unsigned char *from, size_t from_length, size_t *to_length)
Definition: fe-exec.c:3601
PostgresPollingStatusType PQconnectPoll(PGconn *conn)
Definition: fe-connect.c:2246
Oid lo_import(PGconn *conn, const char *filename)
Definition: fe-lobj.c:634
struct _PQconninfoOption PQconninfoOption
int PQisBusy(PGconn *conn)
Definition: fe-exec.c:1714
int PQendcopy(PGconn *conn)
Definition: fe-exec.c:2495
char ** fieldName
Definition: libpq-fe.h:190
pqbool expanded
Definition: libpq-fe.h:185
PGconn * PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions, const char *pgtty, const char *dbName, const char *login, const char *pwd)
Definition: fe-connect.c:1506
int lo_unlink(PGconn *conn, Oid lobjId)
Definition: fe-lobj.c:597
int lo_truncate(PGconn *conn, int fd, size_t len)
Definition: fe-lobj.c:131
int PQgetisnull(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3051
int lo_write(PGconn *conn, int fd, const char *buf, size_t len)
Definition: fe-lobj.c:299
static void do_init(void)
Definition: pg_ctl.c:829
int32 encoding
Definition: pg_database.h:41
PGresult * PQprepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)
Definition: fe-exec.c:1943
PGresult * PQgetResult(PGconn *conn)
Definition: fe-exec.c:1738
int PQsetClientEncoding(PGconn *conn, const char *encoding)
Definition: fe-connect.c:6773
PGconn * PQconnectdb(const char *conninfo)
Definition: fe-connect.c:709
void PQfreemem(void *ptr)
Definition: fe-exec.c:3163
const char * name
Definition: encode.c:515
ConnStatusType PQstatus(const PGconn *conn)
Definition: fe-connect.c:6652
int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
Definition: fe-connect.c:4479
int PQfsize(const PGresult *res, int field_num)
Definition: fe-exec.c:2881
pqbool html3
Definition: libpq-fe.h:184
char * PQfname(const PGresult *res, int field_num)
Definition: fe-exec.c:2718
char * tableOpt
Definition: libpq-fe.h:188
static Datum values[MAXATTR]
Definition: bootstrap.c:165
PostgresPollingStatusType
Definition: libpq-fe.h:73
void PQclear(PGresult *res)
Definition: fe-exec.c:676
static char * filename
Definition: pg_dumpall.c:91
char * PQoidStatus(const PGresult *res)
Definition: fe-exec.c:2916
static char * user
Definition: pg_regress.c:95
Oid PQoidValue(const PGresult *res)
Definition: fe-exec.c:2944
int errmsg(const char *fmt,...)
Definition: elog.c:905
PQconninfoOption * PQconninfo(PGconn *conn)
Definition: fe-connect.c:6493
pqbool header
Definition: libpq-fe.h:181
int lo_truncate64(PGconn *conn, int fd, pg_int64 len)
Definition: fe-lobj.c:197
int PQdsplen(const char *s, int encoding)
Definition: fe-misc.c:1232
PGContextVisibility PQsetErrorContextVisibility(PGconn *conn, PGContextVisibility show_context)
Definition: fe-connect.c:6827
char * name
Definition: libpq-fe.h:239
PGresult * PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
Definition: fe-exec.c:142
void * arg
char * PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm)
Definition: fe-auth.c:1192
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:1395
int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs)
Definition: fe-exec.c:230
size_t PQescapeStringConn(PGconn *conn, char *to, const char *from, size_t length, int *error)
Definition: fe-exec.c:3277
PGPing
Definition: libpq-fe.h:131
int PQputnbytes(PGconn *conn, const char *buffer, int nbytes)
Definition: fe-exec.c:2474
int isint
Definition: libpq-fe.h:225
void PQdisplayTuples(const PGresult *res, FILE *fp, int fillAlign, const char *fieldSep, int printHeader, int quiet)
Definition: fe-print.c:578
int PQserverVersion(const PGconn *conn)
Definition: fe-connect.c:6695
int PQenv2encoding(void)
Definition: fe-misc.c:1241
static void static void status(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:227
int(* PQsslKeyPassHook_OpenSSL_type)(char *buf, int size, PGconn *conn)
Definition: libpq-fe.h:622
int PQbackendPID(const PGconn *conn)
Definition: fe-connect.c:6731
int PQflush(PGconn *conn)
Definition: fe-exec.c:3150
struct pgNotify PGnotify
char pqbool
Definition: libpq-fe.h:177
struct _PQprintOpt PQprintOpt
Oid PQparamtype(const PGresult *res, int param_num)
Definition: fe-exec.c:3076
PGresult * PQdescribePortal(PGconn *conn, const char *portal)
Definition: fe-exec.c:2104
int pg_char_to_encoding(const char *name)
Definition: encnames.c:550
int * ptr
Definition: libpq-fe.h:228
const char * pgport
Definition: pgbench.c:245
int integer
Definition: libpq-fe.h:229
pg_int64 lo_lseek64(PGconn *conn, int fd, pg_int64 offset, int whence)
Definition: fe-lobj.c:390
int PQsendQuery(PGconn *conn, const char *query)
Definition: fe-exec.c:1198
PGnotify * PQnotifies(PGconn *conn)
Definition: fe-exec.c:2210
PGresult * PQdescribePrepared(PGconn *conn, const char *stmt)
Definition: fe-exec.c:2085