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-2019, 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, /* Negotiating environment. */
64  CONNECTION_SSL_STARTUP, /* Negotiating SSL. */
65  CONNECTION_NEEDED, /* Internal state: connect() needed */
66  CONNECTION_CHECK_WRITABLE, /* Check if we could make a writable
67  * connection. */
68  CONNECTION_CONSUME, /* Wait for any pending message and consume
69  * them. */
70  CONNECTION_GSS_STARTUP, /* Negotiating GSSAPI. */
71  CONNECTION_CHECK_TARGET /* Check if we have a proper target connection */
73 
74 typedef enum
75 {
77  PGRES_POLLING_READING, /* These two indicate that one may */
78  PGRES_POLLING_WRITING, /* use select before polling again. */
80  PGRES_POLLING_ACTIVE /* unused; keep for awhile for backwards
81  * compatibility */
83 
84 typedef enum
85 {
86  PGRES_EMPTY_QUERY = 0, /* empty query string was executed */
87  PGRES_COMMAND_OK, /* a query command that doesn't return
88  * anything was executed properly by the
89  * backend */
90  PGRES_TUPLES_OK, /* a query command that returns tuples was
91  * executed properly by the backend, PGresult
92  * contains the result tuples */
93  PGRES_COPY_OUT, /* Copy Out data transfer in progress */
94  PGRES_COPY_IN, /* Copy In data transfer in progress */
95  PGRES_BAD_RESPONSE, /* an unexpected response was recv'd from the
96  * backend */
97  PGRES_NONFATAL_ERROR, /* notice or warning message */
98  PGRES_FATAL_ERROR, /* query failed */
99  PGRES_COPY_BOTH, /* Copy In/Out data transfer in progress */
100  PGRES_SINGLE_TUPLE /* single tuple from larger resultset */
102 
103 typedef enum
104 {
105  PQTRANS_IDLE, /* connection idle */
106  PQTRANS_ACTIVE, /* command in progress */
107  PQTRANS_INTRANS, /* idle, within transaction block */
108  PQTRANS_INERROR, /* idle, within failed transaction */
109  PQTRANS_UNKNOWN /* cannot determine status */
111 
112 typedef enum
113 {
114  PQERRORS_TERSE, /* single-line error messages */
115  PQERRORS_DEFAULT, /* recommended style */
116  PQERRORS_VERBOSE, /* all the facts, ma'am */
117  PQERRORS_SQLSTATE /* only error severity and SQLSTATE code */
118 } PGVerbosity;
119 
120 typedef enum
121 {
122  PQSHOW_CONTEXT_NEVER, /* never show CONTEXT field */
123  PQSHOW_CONTEXT_ERRORS, /* show CONTEXT for errors only (default) */
124  PQSHOW_CONTEXT_ALWAYS /* always show CONTEXT field */
126 
127 /*
128  * PGPing - The ordering of this enum should not be altered because the
129  * values are exposed externally via pg_isready.
130  */
131 
132 typedef enum
133 {
134  PQPING_OK, /* server is accepting connections */
135  PQPING_REJECT, /* server is alive but rejecting connections */
136  PQPING_NO_RESPONSE, /* could not establish connection */
137  PQPING_NO_ATTEMPT /* connection not attempted (bad params) */
138 } PGPing;
139 
140 /* PGconn encapsulates a connection to the backend.
141  * The contents of this struct are not supposed to be known to applications.
142  */
143 typedef struct pg_conn PGconn;
144 
145 /* PGresult encapsulates the result of a query (or more precisely, of a single
146  * SQL command --- a query string given to PQsendQuery can contain multiple
147  * commands and thus return multiple PGresult objects).
148  * The contents of this struct are not supposed to be known to applications.
149  */
150 typedef struct pg_result PGresult;
151 
152 /* PGcancel encapsulates the information needed to cancel a running
153  * query on an existing connection.
154  * The contents of this struct are not supposed to be known to applications.
155  */
156 typedef struct pg_cancel PGcancel;
157 
158 /* PGnotify represents the occurrence of a NOTIFY message.
159  * Ideally this would be an opaque typedef, but it's so simple that it's
160  * unlikely to change.
161  * NOTE: in Postgres 6.4 and later, the be_pid is the notifying backend's,
162  * whereas in earlier versions it was always your own backend's PID.
163  */
164 typedef struct pgNotify
165 {
166  char *relname; /* notification condition name */
167  int be_pid; /* process ID of notifying server process */
168  char *extra; /* notification parameter */
169  /* Fields below here are private to libpq; apps should not use 'em */
170  struct pgNotify *next; /* list link */
171 } PGnotify;
172 
173 /* Function types for notice-handling callbacks */
174 typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res);
175 typedef void (*PQnoticeProcessor) (void *arg, const char *message);
176 
177 /* Print options for PQprint() */
178 typedef char pqbool;
179 
180 typedef struct _PQprintOpt
181 {
182  pqbool header; /* print output field headings and row count */
183  pqbool align; /* fill align the fields */
184  pqbool standard; /* old brain dead format */
185  pqbool html3; /* output html tables */
186  pqbool expanded; /* expand tables */
187  pqbool pager; /* use pager for output if needed */
188  char *fieldSep; /* field separator */
189  char *tableOpt; /* insert to HTML <table ...> */
190  char *caption; /* HTML <caption> */
191  char **fieldName; /* null terminated array of replacement field
192  * names */
193 } PQprintOpt;
194 
195 /* ----------------
196  * Structure for the conninfo parameter definitions returned by PQconndefaults
197  * or PQconninfoParse.
198  *
199  * All fields except "val" point at static strings which must not be altered.
200  * "val" is either NULL or a malloc'd current-value string. PQconninfoFree()
201  * will release both the val strings and the PQconninfoOption array itself.
202  * ----------------
203  */
204 typedef struct _PQconninfoOption
205 {
206  char *keyword; /* The keyword of the option */
207  char *envvar; /* Fallback environment variable name */
208  char *compiled; /* Fallback compiled in default value */
209  char *val; /* Option's current value, or NULL */
210  char *label; /* Label for field in connect dialog */
211  char *dispchar; /* Indicates how to display this field in a
212  * connect dialog. Values are: "" Display
213  * entered value as is "*" Password field -
214  * hide value "D" Debug option - don't show
215  * by default */
216  int dispsize; /* Field size in characters for dialog */
218 
219 /* ----------------
220  * PQArgBlock -- structure for PQfn() arguments
221  * ----------------
222  */
223 typedef struct
224 {
225  int len;
226  int isint;
227  union
228  {
229  int *ptr; /* can't use void (dec compiler barfs) */
230  int integer;
231  } u;
232 } PQArgBlock;
233 
234 /* ----------------
235  * PGresAttDesc -- Data about a single attribute (column) of a query result
236  * ----------------
237  */
238 typedef struct pgresAttDesc
239 {
240  char *name; /* column name */
241  Oid tableid; /* source table, if known */
242  int columnid; /* source column, if known */
243  int format; /* format code for value (text/binary) */
244  Oid typid; /* type id */
245  int typlen; /* type size */
246  int atttypmod; /* type-specific modifier info */
247 } PGresAttDesc;
248 
249 /* ----------------
250  * Exported functions of libpq
251  * ----------------
252  */
253 
254 /* === in fe-connect.c === */
255 
256 /* make a new client connection to the backend */
257 /* Asynchronous (non-blocking) */
258 extern PGconn *PQconnectStart(const char *conninfo);
259 extern PGconn *PQconnectStartParams(const char *const *keywords,
260  const char *const *values, int expand_dbname);
261 extern PostgresPollingStatusType PQconnectPoll(PGconn *conn);
262 
263 /* Synchronous (blocking) */
264 extern PGconn *PQconnectdb(const char *conninfo);
265 extern PGconn *PQconnectdbParams(const char *const *keywords,
266  const char *const *values, int expand_dbname);
267 extern PGconn *PQsetdbLogin(const char *pghost, const char *pgport,
268  const char *pgoptions, const char *pgtty,
269  const char *dbName,
270  const char *login, const char *pwd);
271 
272 #define PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME) \
273  PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, NULL, NULL)
274 
275 /* close the current connection and free the PGconn data structure */
276 extern void PQfinish(PGconn *conn);
277 
278 /* get info about connection options known to PQconnectdb */
279 extern PQconninfoOption *PQconndefaults(void);
280 
281 /* parse connection options in same way as PQconnectdb */
282 extern PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
283 
284 /* return the connection options used by a live connection */
286 
287 /* free the data structure returned by PQconndefaults() or PQconninfoParse() */
288 extern void PQconninfoFree(PQconninfoOption *connOptions);
289 
290 /*
291  * close the current connection and reestablish a new one with the same
292  * parameters
293  */
294 /* Asynchronous (non-blocking) */
295 extern int PQresetStart(PGconn *conn);
296 extern PostgresPollingStatusType PQresetPoll(PGconn *conn);
297 
298 /* Synchronous (blocking) */
299 extern void PQreset(PGconn *conn);
300 
301 /* request a cancel structure */
302 extern PGcancel *PQgetCancel(PGconn *conn);
303 
304 /* free a cancel structure */
305 extern void PQfreeCancel(PGcancel *cancel);
306 
307 /* issue a cancel request */
308 extern int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize);
309 
310 /* backwards compatible version of PQcancel; not thread-safe */
311 extern int PQrequestCancel(PGconn *conn);
312 
313 /* Accessor functions for PGconn objects */
314 extern char *PQdb(const PGconn *conn);
315 extern char *PQuser(const PGconn *conn);
316 extern char *PQpass(const PGconn *conn);
317 extern char *PQhost(const PGconn *conn);
318 extern char *PQhostaddr(const PGconn *conn);
319 extern char *PQport(const PGconn *conn);
320 extern char *PQtty(const PGconn *conn);
321 extern char *PQoptions(const PGconn *conn);
322 extern ConnStatusType PQstatus(const PGconn *conn);
323 extern PGTransactionStatusType PQtransactionStatus(const PGconn *conn);
324 extern const char *PQparameterStatus(const PGconn *conn,
325  const char *paramName);
326 extern int PQprotocolVersion(const PGconn *conn);
327 extern int PQserverVersion(const PGconn *conn);
328 extern char *PQerrorMessage(const PGconn *conn);
329 extern int PQsocket(const PGconn *conn);
330 extern int PQbackendPID(const PGconn *conn);
331 extern int PQconnectionNeedsPassword(const PGconn *conn);
332 extern int PQconnectionUsedPassword(const PGconn *conn);
333 extern int PQclientEncoding(const PGconn *conn);
334 extern int PQsetClientEncoding(PGconn *conn, const char *encoding);
335 
336 /* SSL information functions */
337 extern int PQsslInUse(PGconn *conn);
338 extern void *PQsslStruct(PGconn *conn, const char *struct_name);
339 extern const char *PQsslAttribute(PGconn *conn, const char *attribute_name);
340 extern const char *const *PQsslAttributeNames(PGconn *conn);
341 
342 /* Get the OpenSSL structure associated with a connection. Returns NULL for
343  * unencrypted connections or if any other TLS library is in use. */
344 extern void *PQgetssl(PGconn *conn);
345 
346 /* Tell libpq whether it needs to initialize OpenSSL */
347 extern void PQinitSSL(int do_init);
348 
349 /* More detailed way to tell libpq whether it needs to initialize OpenSSL */
350 extern void PQinitOpenSSL(int do_ssl, int do_crypto);
351 
352 /* Return true if GSSAPI encryption is in use */
353 extern int PQgssEncInUse(PGconn *conn);
354 
355 /* Returns GSSAPI context if GSSAPI is in use */
356 extern void *PQgetgssctx(PGconn *conn);
357 
358 /* Set verbosity for PQerrorMessage and PQresultErrorMessage */
359 extern PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity);
360 
361 /* Set CONTEXT visibility for PQerrorMessage and PQresultErrorMessage */
362 extern PGContextVisibility PQsetErrorContextVisibility(PGconn *conn,
363  PGContextVisibility show_context);
364 
365 /* Enable/disable tracing */
366 extern void PQtrace(PGconn *conn, FILE *debug_port);
367 extern void PQuntrace(PGconn *conn);
368 
369 /* Override default notice handling routines */
371  PQnoticeReceiver proc,
372  void *arg);
374  PQnoticeProcessor proc,
375  void *arg);
376 
377 /*
378  * Used to set callback that prevents concurrent access to
379  * non-thread safe functions that libpq needs.
380  * The default implementation uses a libpq internal mutex.
381  * Only required for multithreaded apps that use kerberos
382  * both within their app and for postgresql connections.
383  */
384 typedef void (*pgthreadlock_t) (int acquire);
385 
387 
388 /* === in fe-exec.c === */
389 
390 /* Simple synchronous query */
391 extern PGresult *PQexec(PGconn *conn, const char *query);
393  const char *command,
394  int nParams,
395  const Oid *paramTypes,
396  const char *const *paramValues,
397  const int *paramLengths,
398  const int *paramFormats,
399  int resultFormat);
400 extern PGresult *PQprepare(PGconn *conn, const char *stmtName,
401  const char *query, int nParams,
402  const Oid *paramTypes);
404  const char *stmtName,
405  int nParams,
406  const char *const *paramValues,
407  const int *paramLengths,
408  const int *paramFormats,
409  int resultFormat);
410 
411 /* Interface for multiple-result or asynchronous queries */
412 extern int PQsendQuery(PGconn *conn, const char *query);
413 extern int PQsendQueryParams(PGconn *conn,
414  const char *command,
415  int nParams,
416  const Oid *paramTypes,
417  const char *const *paramValues,
418  const int *paramLengths,
419  const int *paramFormats,
420  int resultFormat);
421 extern int PQsendPrepare(PGconn *conn, const char *stmtName,
422  const char *query, int nParams,
423  const Oid *paramTypes);
424 extern int PQsendQueryPrepared(PGconn *conn,
425  const char *stmtName,
426  int nParams,
427  const char *const *paramValues,
428  const int *paramLengths,
429  const int *paramFormats,
430  int resultFormat);
431 extern int PQsetSingleRowMode(PGconn *conn);
432 extern PGresult *PQgetResult(PGconn *conn);
433 
434 /* Routines for managing an asynchronous query */
435 extern int PQisBusy(PGconn *conn);
436 extern int PQconsumeInput(PGconn *conn);
437 
438 /* LISTEN/NOTIFY support */
439 extern PGnotify *PQnotifies(PGconn *conn);
440 
441 /* Routines for copy in/out */
442 extern int PQputCopyData(PGconn *conn, const char *buffer, int nbytes);
443 extern int PQputCopyEnd(PGconn *conn, const char *errormsg);
444 extern int PQgetCopyData(PGconn *conn, char **buffer, int async);
445 
446 /* Deprecated routines for copy in/out */
447 extern int PQgetline(PGconn *conn, char *string, int length);
448 extern int PQputline(PGconn *conn, const char *string);
449 extern int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize);
450 extern int PQputnbytes(PGconn *conn, const char *buffer, int nbytes);
451 extern int PQendcopy(PGconn *conn);
452 
453 /* Set blocking/nonblocking connection to the backend */
454 extern int PQsetnonblocking(PGconn *conn, int arg);
455 extern int PQisnonblocking(const PGconn *conn);
456 extern int PQisthreadsafe(void);
457 extern PGPing PQping(const char *conninfo);
458 extern PGPing PQpingParams(const char *const *keywords,
459  const char *const *values, int expand_dbname);
460 
461 /* Force the write buffer to be written (or at least try) */
462 extern int PQflush(PGconn *conn);
463 
464 /*
465  * "Fast path" interface --- not really recommended for application
466  * use
467  */
468 extern PGresult *PQfn(PGconn *conn,
469  int fnid,
470  int *result_buf,
471  int *result_len,
472  int result_is_int,
473  const PQArgBlock *args,
474  int nargs);
475 
476 /* Accessor functions for PGresult objects */
477 extern ExecStatusType PQresultStatus(const PGresult *res);
478 extern char *PQresStatus(ExecStatusType status);
479 extern char *PQresultErrorMessage(const PGresult *res);
480 extern char *PQresultVerboseErrorMessage(const PGresult *res,
481  PGVerbosity verbosity,
482  PGContextVisibility show_context);
483 extern char *PQresultErrorField(const PGresult *res, int fieldcode);
484 extern int PQntuples(const PGresult *res);
485 extern int PQnfields(const PGresult *res);
486 extern int PQbinaryTuples(const PGresult *res);
487 extern char *PQfname(const PGresult *res, int field_num);
488 extern int PQfnumber(const PGresult *res, const char *field_name);
489 extern Oid PQftable(const PGresult *res, int field_num);
490 extern int PQftablecol(const PGresult *res, int field_num);
491 extern int PQfformat(const PGresult *res, int field_num);
492 extern Oid PQftype(const PGresult *res, int field_num);
493 extern int PQfsize(const PGresult *res, int field_num);
494 extern int PQfmod(const PGresult *res, int field_num);
495 extern char *PQcmdStatus(PGresult *res);
496 extern char *PQoidStatus(const PGresult *res); /* old and ugly */
497 extern Oid PQoidValue(const PGresult *res); /* new and improved */
498 extern char *PQcmdTuples(PGresult *res);
499 extern char *PQgetvalue(const PGresult *res, int tup_num, int field_num);
500 extern int PQgetlength(const PGresult *res, int tup_num, int field_num);
501 extern int PQgetisnull(const PGresult *res, int tup_num, int field_num);
502 extern int PQnparams(const PGresult *res);
503 extern Oid PQparamtype(const PGresult *res, int param_num);
504 
505 /* Describe prepared statements and portals */
506 extern PGresult *PQdescribePrepared(PGconn *conn, const char *stmt);
507 extern PGresult *PQdescribePortal(PGconn *conn, const char *portal);
508 extern int PQsendDescribePrepared(PGconn *conn, const char *stmt);
509 extern int PQsendDescribePortal(PGconn *conn, const char *portal);
510 
511 /* Delete a PGresult */
512 extern void PQclear(PGresult *res);
513 
514 /* For freeing other alloc'd results, such as PGnotify structs */
515 extern void PQfreemem(void *ptr);
516 
517 /* Exists for backward compatibility. bjm 2003-03-24 */
518 #define PQfreeNotify(ptr) PQfreemem(ptr)
519 
520 /* Error when no password was given. */
521 /* Note: depending on this is deprecated; use PQconnectionNeedsPassword(). */
522 #define PQnoPasswordSupplied "fe_sendauth: no password supplied\n"
523 
524 /* Create and manipulate PGresults */
525 extern PGresult *PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status);
526 extern PGresult *PQcopyResult(const PGresult *src, int flags);
527 extern int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs);
528 extern void *PQresultAlloc(PGresult *res, size_t nBytes);
529 extern size_t PQresultMemorySize(const PGresult *res);
530 extern int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len);
531 
532 /* Quoting strings before inclusion in queries. */
533 extern size_t PQescapeStringConn(PGconn *conn,
534  char *to, const char *from, size_t length,
535  int *error);
536 extern char *PQescapeLiteral(PGconn *conn, const char *str, size_t len);
537 extern char *PQescapeIdentifier(PGconn *conn, const char *str, size_t len);
538 extern unsigned char *PQescapeByteaConn(PGconn *conn,
539  const unsigned char *from, size_t from_length,
540  size_t *to_length);
541 extern unsigned char *PQunescapeBytea(const unsigned char *strtext,
542  size_t *retbuflen);
543 
544 /* These forms are deprecated! */
545 extern size_t PQescapeString(char *to, const char *from, size_t length);
546 extern unsigned char *PQescapeBytea(const unsigned char *from, size_t from_length,
547  size_t *to_length);
548 
549 
550 
551 /* === in fe-print.c === */
552 
553 extern void PQprint(FILE *fout, /* output stream */
554  const PGresult *res,
555  const PQprintOpt *ps); /* option structure */
556 
557 /*
558  * really old printing routines
559  */
560 extern void PQdisplayTuples(const PGresult *res,
561  FILE *fp, /* where to send the output */
562  int fillAlign, /* pad the fields with spaces */
563  const char *fieldSep, /* field separator */
564  int printHeader, /* display headers? */
565  int quiet);
566 
567 extern void PQprintTuples(const PGresult *res,
568  FILE *fout, /* output stream */
569  int PrintAttNames, /* print attribute names */
570  int TerseOutput, /* delimiter bars */
571  int colWidth); /* width of column, if 0, use
572  * variable width */
573 
574 
575 /* === in fe-lobj.c === */
576 
577 /* Large-object access routines */
578 extern int lo_open(PGconn *conn, Oid lobjId, int mode);
579 extern int lo_close(PGconn *conn, int fd);
580 extern int lo_read(PGconn *conn, int fd, char *buf, size_t len);
581 extern int lo_write(PGconn *conn, int fd, const char *buf, size_t len);
582 extern int lo_lseek(PGconn *conn, int fd, int offset, int whence);
583 extern pg_int64 lo_lseek64(PGconn *conn, int fd, pg_int64 offset, int whence);
584 extern Oid lo_creat(PGconn *conn, int mode);
585 extern Oid lo_create(PGconn *conn, Oid lobjId);
586 extern int lo_tell(PGconn *conn, int fd);
587 extern pg_int64 lo_tell64(PGconn *conn, int fd);
588 extern int lo_truncate(PGconn *conn, int fd, size_t len);
589 extern int lo_truncate64(PGconn *conn, int fd, pg_int64 len);
590 extern int lo_unlink(PGconn *conn, Oid lobjId);
591 extern Oid lo_import(PGconn *conn, const char *filename);
592 extern Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId);
593 extern int lo_export(PGconn *conn, Oid lobjId, const char *filename);
594 
595 /* === in fe-misc.c === */
596 
597 /* Get the version of the libpq library in use */
598 extern int PQlibVersion(void);
599 
600 /* Determine length of multibyte encoded char at *s */
601 extern int PQmblen(const char *s, int encoding);
602 
603 /* Determine display length of multibyte encoded char at *s */
604 extern int PQdsplen(const char *s, int encoding);
605 
606 /* Get encoding id from environment variable PGCLIENTENCODING */
607 extern int PQenv2encoding(void);
608 
609 /* === in fe-auth.c === */
610 
611 extern char *PQencryptPassword(const char *passwd, const char *user);
612 extern char *PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm);
613 
614 /* === in encnames.c === */
615 
616 extern int pg_char_to_encoding(const char *name);
617 extern const char *pg_encoding_to_char(int encoding);
618 extern int pg_valid_server_encoding_id(int encoding);
619 
620 #ifdef __cplusplus
621 }
622 #endif
623 
624 #endif /* LIBPQ_FE_H */
int PQclientEncoding(const PGconn *conn)
Definition: fe-connect.c:6677
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:1953
void PQtrace(PGconn *conn, FILE *debug_port)
Definition: fe-connect.c:6755
int PQsocket(const PGconn *conn)
Definition: fe-connect.c:6635
void PQinitSSL(int do_init)
Definition: fe-secure.c:145
Oid PQftable(const PGresult *res, int field_num)
Definition: fe-exec.c:2974
char * PQport(const PGconn *conn)
Definition: fe-connect.c:6536
char * extra
Definition: libpq-fe.h:168
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:2777
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:1285
size_t PQescapeString(char *to, const char *from, size_t length)
Definition: fe-exec.c:3428
PQconninfoOption * PQconninfoParse(const char *conninfo, char **errmsg)
Definition: fe-connect.c:5219
void(* PQnoticeReceiver)(void *arg, const PGresult *res)
Definition: libpq-fe.h:174
int lo_tell(PGconn *conn, int fd)
Definition: fe-lobj.c:548
void * PQsslStruct(PGconn *conn, const char *struct_name)
int lo_export(PGconn *conn, Oid lobjId, const char *filename)
Definition: fe-lobj.c:784
PGPing PQping(const char *conninfo)
Definition: fe-connect.c:692
void PQuntrace(PGconn *conn)
Definition: fe-connect.c:6764
int PQgetCopyData(PGconn *conn, char **buffer, int async)
Definition: fe-exec.c:2473
static void error(void)
Definition: sql-dyntest.c:147
int PQfmod(const PGresult *res, int field_num)
Definition: fe-exec.c:3029
int PQisnonblocking(const PGconn *conn)
Definition: fe-exec.c:3264
int PQmblen(const char *s, int encoding)
Definition: fe-misc.c:1216
char * PQpass(const PGconn *conn)
Definition: fe-connect.c:6483
char * PQescapeIdentifier(PGconn *conn, const char *str, size_t len)
Definition: fe-exec.c:3570
PGresult * PQcopyResult(const PGresult *src, int flags)
Definition: fe-exec.c:294
int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize)
Definition: fe-exec.c:2565
char * PQuser(const PGconn *conn)
Definition: fe-connect.c:6475
int pg_valid_server_encoding_id(int encoding)
Definition: encnames.c:515
int PQputCopyData(PGconn *conn, const char *buffer, int nbytes)
Definition: fe-exec.c:2317
void PQreset(PGconn *conn)
Definition: fe-connect.c:4133
int PQresetStart(PGconn *conn)
Definition: fe-connect.c:4174
pg_int64 lo_tell64(PGconn *conn, int fd)
Definition: fe-lobj.c:584
int PQbinaryTuples(const PGresult *res)
Definition: fe-exec.c:2785
PGconn * PQconnectStartParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition: fe-connect.c:723
int lo_read(PGconn *conn, int fd, char *buf, size_t len)
Definition: fe-lobj.c:258
void PQfreeCancel(PGcancel *cancel)
Definition: fe-connect.c:4263
void(* PQnoticeProcessor)(void *arg, const char *message)
Definition: libpq-fe.h:175
char * PQdb(const PGconn *conn)
Definition: fe-connect.c:6467
int PQntuples(const PGresult *res)
Definition: fe-exec.c:2769
int PQisthreadsafe(void)
Definition: fe-exec.c:3271
static struct @145 value
PGcancel * PQgetCancel(PGconn *conn)
Definition: fe-connect.c:4240
unsigned char * PQescapeByteaConn(PGconn *conn, const unsigned char *from, size_t from_length, size_t *to_length)
Definition: fe-exec.c:3714
int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
Definition: fe-exec.c:431
int PQfformat(const PGresult *res, int field_num)
Definition: fe-exec.c:2996
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3163
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:2652
char * PQcmdTuples(PGresult *res)
Definition: fe-exec.c:3110
int PQconnectionUsedPassword(const PGconn *conn)
Definition: fe-connect.c:6666
ExecStatusType
Definition: libpq-fe.h:84
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:2000
ExecStatusType PQresultStatus(const PGresult *res)
Definition: fe-exec.c:2692
PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
Definition: fe-connect.c:6793
pgthreadlock_t PQregisterThreadLock(pgthreadlock_t newhandler)
Definition: fe-connect.c:7104
void PQinitOpenSSL(int do_ssl, int do_crypto)
Definition: fe-secure.c:157
char * PQtty(const PGconn *conn)
Definition: fe-connect.c:6548
void PQfinish(PGconn *conn)
Definition: fe-connect.c:4119
unsigned int Oid
Definition: postgres_ext.h:31
int PQlibVersion(void)
Definition: fe-misc.c:66
pqbool standard
Definition: libpq-fe.h:184
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:242
char * fieldSep
Definition: libpq-fe.h:188
PG_INT64_TYPE pg_int64
Definition: postgres_ext.h:47
Oid lo_create(PGconn *conn, Oid lobjId)
Definition: fe-lobj.c:504
PGTransactionStatusType PQtransactionStatus(const PGconn *conn)
Definition: fe-connect.c:6572
Oid lo_creat(PGconn *conn, int mode)
Definition: fe-lobj.c:465
PQconninfoOption * PQconndefaults(void)
Definition: fe-connect.c:1372
char * PQoptions(const PGconn *conn)
Definition: fe-connect.c:6556
PGconn * PQconnectStart(const char *conninfo)
Definition: fe-connect.c:802
void PQconninfoFree(PQconninfoOption *connOptions)
Definition: fe-connect.c:6449
int PQsetnonblocking(PGconn *conn, int arg)
Definition: fe-exec.c:3231
const char * pg_encoding_to_char(int encoding)
Definition: encnames.c:607
int PQnparams(const PGresult *res)
Definition: fe-exec.c:3202
int PQgetline(PGconn *conn, char *string, int length)
Definition: fe-exec.c:2515
int lo_close(PGconn *conn, int fd)
Definition: fe-lobj.c:99
int PQprotocolVersion(const PGconn *conn)
Definition: fe-connect.c:6597
PGconn * PQconnectdbParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition: fe-connect.c:620
int lo_lseek(PGconn *conn, int fd, int offset, int whence)
Definition: fe-lobj.c:365
void(* pgthreadlock_t)(int acquire)
Definition: libpq-fe.h:384
int PQputCopyEnd(PGconn *conn, const char *errormsg)
Definition: fe-exec.c:2384
int PQsslInUse(PGconn *conn)
Definition: fe-secure.c:133
PGconn * conn
Definition: streamutil.c:54
int be_pid
Definition: libpq-fe.h:167
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:2205
int PQftablecol(const PGresult *res, int field_num)
Definition: fe-exec.c:2985
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:2754
char * PQresultVerboseErrorMessage(const PGresult *res, PGVerbosity verbosity, PGContextVisibility show_context)
Definition: fe-exec.c:2716
static char * buf
Definition: pg_test_fsync.c:67
char * PQencryptPassword(const char *passwd, const char *user)
Definition: fe-auth.c:1147
int PQputline(PGconn *conn, const char *string)
Definition: fe-exec.c:2585
PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity)
Definition: fe-connect.c:6731
pqbool align
Definition: libpq-fe.h:183
size_t PQresultMemorySize(const PGresult *res)
Definition: fe-exec.c:634
char * relname
Definition: libpq-fe.h:166
PGresult * PQexec(PGconn *conn, const char *query)
Definition: fe-exec.c:1939
int PQgetlength(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3174
char * PQescapeLiteral(PGconn *conn, const char *str, size_t len)
Definition: fe-exec.c:3564
int PQsendDescribePrepared(PGconn *conn, const char *stmt)
Definition: fe-exec.c:2192
int PQrequestCancel(PGconn *conn)
Definition: fe-connect.c:4420
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
Definition: fe-connect.c:6582
int PQsendPrepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)
Definition: fe-exec.c:1330
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:6776
char * PQhost(const PGconn *conn)
Definition: fe-connect.c:6500
int PQfnumber(const PGresult *res, const char *field_name)
Definition: fe-exec.c:2877
char * PQerrorMessage(const PGconn *conn)
Definition: fe-connect.c:6617
char * PQcmdStatus(PGresult *res)
Definition: fe-exec.c:3040
char * PQhostaddr(const PGconn *conn)
Definition: fe-connect.c:6523
int PQsetSingleRowMode(PGconn *conn)
Definition: fe-exec.c:1677
char * caption
Definition: libpq-fe.h:190
char * pghost
Definition: pgbench.c:242
PGPing PQpingParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition: fe-connect.c:639
char * PQresStatus(ExecStatusType status)
Definition: fe-exec.c:2700
pqbool pager
Definition: libpq-fe.h:187
Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId)
Definition: fe-lobj.c:683
int PQconsumeInput(PGconn *conn)
Definition: fe-exec.c:1704
char * PQresultErrorMessage(const PGresult *res)
Definition: fe-exec.c:2708
Oid PQftype(const PGresult *res, int field_num)
Definition: fe-exec.c:3007
PGContextVisibility
Definition: libpq-fe.h:120
int PQconnectionNeedsPassword(const PGconn *conn)
Definition: fe-connect.c:6651
struct pgNotify * next
Definition: libpq-fe.h:170
void * PQresultAlloc(PGresult *res, size_t nBytes)
Definition: fe-exec.c:518
PGVerbosity
Definition: libpq-fe.h:112
PostgresPollingStatusType PQresetPoll(PGconn *conn)
Definition: fe-connect.c:4193
int atttypmod
Definition: libpq-fe.h:246
unsigned char * PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
Definition: fe-exec.c:3751
const char * PQsslAttribute(PGconn *conn, const char *attribute_name)
struct pgresAttDesc PGresAttDesc
PGTransactionStatusType
Definition: libpq-fe.h:103
int PQgssEncInUse(PGconn *conn)
unsigned char * PQescapeBytea(const unsigned char *from, size_t from_length, size_t *to_length)
Definition: fe-exec.c:3726
PostgresPollingStatusType PQconnectPoll(PGconn *conn)
Definition: fe-connect.c:2192
Oid lo_import(PGconn *conn, const char *filename)
Definition: fe-lobj.c:668
struct _PQconninfoOption PQconninfoOption
int PQisBusy(PGconn *conn)
Definition: fe-exec.c:1754
int PQendcopy(PGconn *conn)
Definition: fe-exec.c:2618
char ** fieldName
Definition: libpq-fe.h:191
pqbool expanded
Definition: libpq-fe.h:186
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:1410
int lo_unlink(PGconn *conn, Oid lobjId)
Definition: fe-lobj.c:628
int lo_truncate(PGconn *conn, int fd, size_t len)
Definition: fe-lobj.c:137
int PQgetisnull(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3188
int lo_write(PGconn *conn, int fd, const char *buf, size_t len)
Definition: fe-lobj.c:312
static void do_init(void)
Definition: pg_ctl.c:797
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:1983
PGresult * PQgetResult(PGconn *conn)
Definition: fe-exec.c:1778
int PQsetClientEncoding(PGconn *conn, const char *encoding)
Definition: fe-connect.c:6685
PGconn * PQconnectdb(const char *conninfo)
Definition: fe-connect.c:676
void PQfreemem(void *ptr)
Definition: fe-exec.c:3296
const char * name
Definition: encode.c:521
ConnStatusType PQstatus(const PGconn *conn)
Definition: fe-connect.c:6564
int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
Definition: fe-connect.c:4395
int PQfsize(const PGresult *res, int field_num)
Definition: fe-exec.c:3018
pqbool html3
Definition: libpq-fe.h:185
char * PQfname(const PGresult *res, int field_num)
Definition: fe-exec.c:2855
char * tableOpt
Definition: libpq-fe.h:189
static Datum values[MAXATTR]
Definition: bootstrap.c:167
PostgresPollingStatusType
Definition: libpq-fe.h:74
void PQclear(PGresult *res)
Definition: fe-exec.c:694
static char * filename
Definition: pg_dumpall.c:90
char * PQoidStatus(const PGresult *res)
Definition: fe-exec.c:3053
static char * user
Definition: pg_regress.c:94
Oid PQoidValue(const PGresult *res)
Definition: fe-exec.c:3081
char * dbName
Definition: pgbench.c:245
int errmsg(const char *fmt,...)
Definition: elog.c:822
PQconninfoOption * PQconninfo(PGconn *conn)
Definition: fe-connect.c:6408
pqbool header
Definition: libpq-fe.h:182
int lo_truncate64(PGconn *conn, int fd, pg_int64 len)
Definition: fe-lobj.c:205
int PQdsplen(const char *s, int encoding)
Definition: fe-misc.c:1226
PGContextVisibility PQsetErrorContextVisibility(PGconn *conn, PGContextVisibility show_context)
Definition: fe-connect.c:6743
char * name
Definition: libpq-fe.h:240
PGresult * PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
Definition: fe-exec.c:141
void * arg
char * PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm)
Definition: fe-auth.c:1189
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:1427
int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs)
Definition: fe-exec.c:229
size_t PQescapeStringConn(PGconn *conn, char *to, const char *from, size_t length, int *error)
Definition: fe-exec.c:3410
PGPing
Definition: libpq-fe.h:132
int PQputnbytes(PGconn *conn, const char *buffer, int nbytes)
Definition: fe-exec.c:2595
int isint
Definition: libpq-fe.h:226
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:6607
int PQenv2encoding(void)
Definition: fe-misc.c:1235
static void static void status(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:226
int PQbackendPID(const PGconn *conn)
Definition: fe-connect.c:6643
int PQflush(PGconn *conn)
Definition: fe-exec.c:3283
struct pgNotify PGnotify
char pqbool
Definition: libpq-fe.h:178
struct _PQprintOpt PQprintOpt
Oid PQparamtype(const PGresult *res, int param_num)
Definition: fe-exec.c:3213
PGresult * PQdescribePortal(PGconn *conn, const char *portal)
Definition: fe-exec.c:2175
char * pgport
Definition: pgbench.c:243
int pg_char_to_encoding(const char *name)
Definition: encnames.c:551
int * ptr
Definition: libpq-fe.h:229
char * login
Definition: pgbench.c:244
int integer
Definition: libpq-fe.h:230
pg_int64 lo_lseek64(PGconn *conn, int fd, pg_int64 offset, int whence)
Definition: fe-lobj.c:409
int PQsendQuery(PGconn *conn, const char *query)
Definition: fe-exec.c:1234
PGnotify * PQnotifies(PGconn *conn)
Definition: fe-exec.c:2289
PGresult * PQdescribePrepared(PGconn *conn, const char *stmt)
Definition: fe-exec.c:2156