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 */
100  PGRES_PIPELINE_SYNC, /* pipeline synchronization point */
101  PGRES_PIPELINE_ABORTED, /* Command didn't run because of an abort
102  * earlier in a pipeline */
104 
105 typedef enum
106 {
107  PQTRANS_IDLE, /* connection idle */
108  PQTRANS_ACTIVE, /* command in progress */
109  PQTRANS_INTRANS, /* idle, within transaction block */
110  PQTRANS_INERROR, /* idle, within failed transaction */
111  PQTRANS_UNKNOWN /* cannot determine status */
113 
114 typedef enum
115 {
116  PQERRORS_TERSE, /* single-line error messages */
117  PQERRORS_DEFAULT, /* recommended style */
118  PQERRORS_VERBOSE, /* all the facts, ma'am */
119  PQERRORS_SQLSTATE /* only error severity and SQLSTATE code */
120 } PGVerbosity;
121 
122 typedef enum
123 {
124  PQSHOW_CONTEXT_NEVER, /* never show CONTEXT field */
125  PQSHOW_CONTEXT_ERRORS, /* show CONTEXT for errors only (default) */
126  PQSHOW_CONTEXT_ALWAYS /* always show CONTEXT field */
128 
129 /*
130  * PGPing - The ordering of this enum should not be altered because the
131  * values are exposed externally via pg_isready.
132  */
133 
134 typedef enum
135 {
136  PQPING_OK, /* server is accepting connections */
137  PQPING_REJECT, /* server is alive but rejecting connections */
138  PQPING_NO_RESPONSE, /* could not establish connection */
139  PQPING_NO_ATTEMPT /* connection not attempted (bad params) */
140 } PGPing;
141 
142 /*
143  * PGpipelineStatus - Current status of pipeline mode
144  */
145 typedef enum
146 {
151 
152 /* PGconn encapsulates a connection to the backend.
153  * The contents of this struct are not supposed to be known to applications.
154  */
155 typedef struct pg_conn PGconn;
156 
157 /* PGresult encapsulates the result of a query (or more precisely, of a single
158  * SQL command --- a query string given to PQsendQuery can contain multiple
159  * commands and thus return multiple PGresult objects).
160  * The contents of this struct are not supposed to be known to applications.
161  */
162 typedef struct pg_result PGresult;
163 
164 /* PGcancel encapsulates the information needed to cancel a running
165  * query on an existing connection.
166  * The contents of this struct are not supposed to be known to applications.
167  */
168 typedef struct pg_cancel PGcancel;
169 
170 /* PGnotify represents the occurrence of a NOTIFY message.
171  * Ideally this would be an opaque typedef, but it's so simple that it's
172  * unlikely to change.
173  * NOTE: in Postgres 6.4 and later, the be_pid is the notifying backend's,
174  * whereas in earlier versions it was always your own backend's PID.
175  */
176 typedef struct pgNotify
177 {
178  char *relname; /* notification condition name */
179  int be_pid; /* process ID of notifying server process */
180  char *extra; /* notification parameter */
181  /* Fields below here are private to libpq; apps should not use 'em */
182  struct pgNotify *next; /* list link */
183 } PGnotify;
184 
185 /* Function types for notice-handling callbacks */
186 typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res);
187 typedef void (*PQnoticeProcessor) (void *arg, const char *message);
188 
189 /* Print options for PQprint() */
190 typedef char pqbool;
191 
192 typedef struct _PQprintOpt
193 {
194  pqbool header; /* print output field headings and row count */
195  pqbool align; /* fill align the fields */
196  pqbool standard; /* old brain dead format */
197  pqbool html3; /* output html tables */
198  pqbool expanded; /* expand tables */
199  pqbool pager; /* use pager for output if needed */
200  char *fieldSep; /* field separator */
201  char *tableOpt; /* insert to HTML <table ...> */
202  char *caption; /* HTML <caption> */
203  char **fieldName; /* null terminated array of replacement field
204  * names */
205 } PQprintOpt;
206 
207 /* ----------------
208  * Structure for the conninfo parameter definitions returned by PQconndefaults
209  * or PQconninfoParse.
210  *
211  * All fields except "val" point at static strings which must not be altered.
212  * "val" is either NULL or a malloc'd current-value string. PQconninfoFree()
213  * will release both the val strings and the PQconninfoOption array itself.
214  * ----------------
215  */
216 typedef struct _PQconninfoOption
217 {
218  char *keyword; /* The keyword of the option */
219  char *envvar; /* Fallback environment variable name */
220  char *compiled; /* Fallback compiled in default value */
221  char *val; /* Option's current value, or NULL */
222  char *label; /* Label for field in connect dialog */
223  char *dispchar; /* Indicates how to display this field in a
224  * connect dialog. Values are: "" Display
225  * entered value as is "*" Password field -
226  * hide value "D" Debug option - don't show
227  * by default */
228  int dispsize; /* Field size in characters for dialog */
230 
231 /* ----------------
232  * PQArgBlock -- structure for PQfn() arguments
233  * ----------------
234  */
235 typedef struct
236 {
237  int len;
238  int isint;
239  union
240  {
241  int *ptr; /* can't use void (dec compiler barfs) */
242  int integer;
243  } u;
244 } PQArgBlock;
245 
246 /* ----------------
247  * PGresAttDesc -- Data about a single attribute (column) of a query result
248  * ----------------
249  */
250 typedef struct pgresAttDesc
251 {
252  char *name; /* column name */
253  Oid tableid; /* source table, if known */
254  int columnid; /* source column, if known */
255  int format; /* format code for value (text/binary) */
256  Oid typid; /* type id */
257  int typlen; /* type size */
258  int atttypmod; /* type-specific modifier info */
259 } PGresAttDesc;
260 
261 /* ----------------
262  * Exported functions of libpq
263  * ----------------
264  */
265 
266 /* === in fe-connect.c === */
267 
268 /* make a new client connection to the backend */
269 /* Asynchronous (non-blocking) */
270 extern PGconn *PQconnectStart(const char *conninfo);
271 extern PGconn *PQconnectStartParams(const char *const *keywords,
272  const char *const *values, int expand_dbname);
273 extern PostgresPollingStatusType PQconnectPoll(PGconn *conn);
274 
275 /* Synchronous (blocking) */
276 extern PGconn *PQconnectdb(const char *conninfo);
277 extern PGconn *PQconnectdbParams(const char *const *keywords,
278  const char *const *values, int expand_dbname);
279 extern PGconn *PQsetdbLogin(const char *pghost, const char *pgport,
280  const char *pgoptions, const char *pgtty,
281  const char *dbName,
282  const char *login, const char *pwd);
283 
284 #define PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME) \
285  PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, NULL, NULL)
286 
287 /* close the current connection and free the PGconn data structure */
288 extern void PQfinish(PGconn *conn);
289 
290 /* get info about connection options known to PQconnectdb */
291 extern PQconninfoOption *PQconndefaults(void);
292 
293 /* parse connection options in same way as PQconnectdb */
294 extern PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
295 
296 /* return the connection options used by a live connection */
298 
299 /* free the data structure returned by PQconndefaults() or PQconninfoParse() */
300 extern void PQconninfoFree(PQconninfoOption *connOptions);
301 
302 /*
303  * close the current connection and reestablish a new one with the same
304  * parameters
305  */
306 /* Asynchronous (non-blocking) */
307 extern int PQresetStart(PGconn *conn);
308 extern PostgresPollingStatusType PQresetPoll(PGconn *conn);
309 
310 /* Synchronous (blocking) */
311 extern void PQreset(PGconn *conn);
312 
313 /* request a cancel structure */
314 extern PGcancel *PQgetCancel(PGconn *conn);
315 
316 /* free a cancel structure */
317 extern void PQfreeCancel(PGcancel *cancel);
318 
319 /* issue a cancel request */
320 extern int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize);
321 
322 /* backwards compatible version of PQcancel; not thread-safe */
323 extern int PQrequestCancel(PGconn *conn);
324 
325 /* Accessor functions for PGconn objects */
326 extern char *PQdb(const PGconn *conn);
327 extern char *PQuser(const PGconn *conn);
328 extern char *PQpass(const PGconn *conn);
329 extern char *PQhost(const PGconn *conn);
330 extern char *PQhostaddr(const PGconn *conn);
331 extern char *PQport(const PGconn *conn);
332 extern char *PQtty(const PGconn *conn);
333 extern char *PQoptions(const PGconn *conn);
334 extern ConnStatusType PQstatus(const PGconn *conn);
335 extern PGTransactionStatusType PQtransactionStatus(const PGconn *conn);
336 extern const char *PQparameterStatus(const PGconn *conn,
337  const char *paramName);
338 extern int PQprotocolVersion(const PGconn *conn);
339 extern int PQserverVersion(const PGconn *conn);
340 extern char *PQerrorMessage(const PGconn *conn);
341 extern int PQsocket(const PGconn *conn);
342 extern int PQbackendPID(const PGconn *conn);
343 extern PGpipelineStatus PQpipelineStatus(const PGconn *conn);
344 extern int PQconnectionNeedsPassword(const PGconn *conn);
345 extern int PQconnectionUsedPassword(const PGconn *conn);
346 extern int PQclientEncoding(const PGconn *conn);
347 extern int PQsetClientEncoding(PGconn *conn, const char *encoding);
348 
349 /* SSL information functions */
350 extern int PQsslInUse(PGconn *conn);
351 extern void *PQsslStruct(PGconn *conn, const char *struct_name);
352 extern const char *PQsslAttribute(PGconn *conn, const char *attribute_name);
353 extern const char *const *PQsslAttributeNames(PGconn *conn);
354 
355 /* Get the OpenSSL structure associated with a connection. Returns NULL for
356  * unencrypted connections or if any other TLS library is in use. */
357 extern void *PQgetssl(PGconn *conn);
358 
359 /* Tell libpq whether it needs to initialize OpenSSL */
360 extern void PQinitSSL(int do_init);
361 
362 /* More detailed way to tell libpq whether it needs to initialize OpenSSL */
363 extern void PQinitOpenSSL(int do_ssl, int do_crypto);
364 
365 /* Return true if GSSAPI encryption is in use */
366 extern int PQgssEncInUse(PGconn *conn);
367 
368 /* Returns GSSAPI context if GSSAPI is in use */
369 extern void *PQgetgssctx(PGconn *conn);
370 
371 /* Set verbosity for PQerrorMessage and PQresultErrorMessage */
372 extern PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity);
373 
374 /* Set CONTEXT visibility for PQerrorMessage and PQresultErrorMessage */
375 extern PGContextVisibility PQsetErrorContextVisibility(PGconn *conn,
376  PGContextVisibility show_context);
377 
378 /* Override default notice handling routines */
380  PQnoticeReceiver proc,
381  void *arg);
383  PQnoticeProcessor proc,
384  void *arg);
385 
386 /*
387  * Used to set callback that prevents concurrent access to
388  * non-thread safe functions that libpq needs.
389  * The default implementation uses a libpq internal mutex.
390  * Only required for multithreaded apps that use kerberos
391  * both within their app and for postgresql connections.
392  */
393 typedef void (*pgthreadlock_t) (int acquire);
394 
396 
397 /* === in fe-trace.c === */
398 extern void PQtrace(PGconn *conn, FILE *debug_port);
399 extern void PQuntrace(PGconn *conn);
400 
401 /* flags controlling trace output */
402 /* omit timestamps from each line */
403 #define PQTRACE_SUPPRESS_TIMESTAMPS (1<<0)
404 /* redact portions of some messages, for testing frameworks */
405 #define PQTRACE_REGRESS_MODE (1<<1)
406 extern void PQtraceSetFlags(PGconn *conn, int flags);
407 
408 /* === in fe-exec.c === */
409 
410 /* Simple synchronous query */
411 extern PGresult *PQexec(PGconn *conn, const char *query);
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 PGresult *PQprepare(PGconn *conn, const char *stmtName,
421  const char *query, int nParams,
422  const Oid *paramTypes);
424  const char *stmtName,
425  int nParams,
426  const char *const *paramValues,
427  const int *paramLengths,
428  const int *paramFormats,
429  int resultFormat);
430 
431 /* Interface for multiple-result or asynchronous queries */
432 extern int PQsendQuery(PGconn *conn, const char *query);
433 extern int PQsendQueryParams(PGconn *conn,
434  const char *command,
435  int nParams,
436  const Oid *paramTypes,
437  const char *const *paramValues,
438  const int *paramLengths,
439  const int *paramFormats,
440  int resultFormat);
441 extern int PQsendPrepare(PGconn *conn, const char *stmtName,
442  const char *query, int nParams,
443  const Oid *paramTypes);
444 extern int PQsendQueryPrepared(PGconn *conn,
445  const char *stmtName,
446  int nParams,
447  const char *const *paramValues,
448  const int *paramLengths,
449  const int *paramFormats,
450  int resultFormat);
451 extern int PQsetSingleRowMode(PGconn *conn);
452 extern PGresult *PQgetResult(PGconn *conn);
453 
454 /* Routines for managing an asynchronous query */
455 extern int PQisBusy(PGconn *conn);
456 extern int PQconsumeInput(PGconn *conn);
457 
458 /* Routines for pipeline mode management */
459 extern int PQenterPipelineMode(PGconn *conn);
460 extern int PQexitPipelineMode(PGconn *conn);
461 extern int PQpipelineSync(PGconn *conn);
462 
463 /* LISTEN/NOTIFY support */
464 extern PGnotify *PQnotifies(PGconn *conn);
465 
466 /* Routines for copy in/out */
467 extern int PQputCopyData(PGconn *conn, const char *buffer, int nbytes);
468 extern int PQputCopyEnd(PGconn *conn, const char *errormsg);
469 extern int PQgetCopyData(PGconn *conn, char **buffer, int async);
470 
471 /* Deprecated routines for copy in/out */
472 extern int PQgetline(PGconn *conn, char *string, int length);
473 extern int PQputline(PGconn *conn, const char *string);
474 extern int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize);
475 extern int PQputnbytes(PGconn *conn, const char *buffer, int nbytes);
476 extern int PQendcopy(PGconn *conn);
477 
478 /* Set blocking/nonblocking connection to the backend */
479 extern int PQsetnonblocking(PGconn *conn, int arg);
480 extern int PQisnonblocking(const PGconn *conn);
481 extern int PQisthreadsafe(void);
482 extern PGPing PQping(const char *conninfo);
483 extern PGPing PQpingParams(const char *const *keywords,
484  const char *const *values, int expand_dbname);
485 
486 /* Force the write buffer to be written (or at least try) */
487 extern int PQflush(PGconn *conn);
488 
489 /*
490  * "Fast path" interface --- not really recommended for application
491  * use
492  */
493 extern PGresult *PQfn(PGconn *conn,
494  int fnid,
495  int *result_buf,
496  int *result_len,
497  int result_is_int,
498  const PQArgBlock *args,
499  int nargs);
500 
501 /* Accessor functions for PGresult objects */
502 extern ExecStatusType PQresultStatus(const PGresult *res);
503 extern char *PQresStatus(ExecStatusType status);
504 extern char *PQresultErrorMessage(const PGresult *res);
505 extern char *PQresultVerboseErrorMessage(const PGresult *res,
506  PGVerbosity verbosity,
507  PGContextVisibility show_context);
508 extern char *PQresultErrorField(const PGresult *res, int fieldcode);
509 extern int PQntuples(const PGresult *res);
510 extern int PQnfields(const PGresult *res);
511 extern int PQbinaryTuples(const PGresult *res);
512 extern char *PQfname(const PGresult *res, int field_num);
513 extern int PQfnumber(const PGresult *res, const char *field_name);
514 extern Oid PQftable(const PGresult *res, int field_num);
515 extern int PQftablecol(const PGresult *res, int field_num);
516 extern int PQfformat(const PGresult *res, int field_num);
517 extern Oid PQftype(const PGresult *res, int field_num);
518 extern int PQfsize(const PGresult *res, int field_num);
519 extern int PQfmod(const PGresult *res, int field_num);
520 extern char *PQcmdStatus(PGresult *res);
521 extern char *PQoidStatus(const PGresult *res); /* old and ugly */
522 extern Oid PQoidValue(const PGresult *res); /* new and improved */
523 extern char *PQcmdTuples(PGresult *res);
524 extern char *PQgetvalue(const PGresult *res, int tup_num, int field_num);
525 extern int PQgetlength(const PGresult *res, int tup_num, int field_num);
526 extern int PQgetisnull(const PGresult *res, int tup_num, int field_num);
527 extern int PQnparams(const PGresult *res);
528 extern Oid PQparamtype(const PGresult *res, int param_num);
529 
530 /* Describe prepared statements and portals */
531 extern PGresult *PQdescribePrepared(PGconn *conn, const char *stmt);
532 extern PGresult *PQdescribePortal(PGconn *conn, const char *portal);
533 extern int PQsendDescribePrepared(PGconn *conn, const char *stmt);
534 extern int PQsendDescribePortal(PGconn *conn, const char *portal);
535 
536 /* Delete a PGresult */
537 extern void PQclear(PGresult *res);
538 
539 /* For freeing other alloc'd results, such as PGnotify structs */
540 extern void PQfreemem(void *ptr);
541 
542 /* Exists for backward compatibility. bjm 2003-03-24 */
543 #define PQfreeNotify(ptr) PQfreemem(ptr)
544 
545 /* Error when no password was given. */
546 /* Note: depending on this is deprecated; use PQconnectionNeedsPassword(). */
547 #define PQnoPasswordSupplied "fe_sendauth: no password supplied\n"
548 
549 /* Create and manipulate PGresults */
550 extern PGresult *PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status);
551 extern PGresult *PQcopyResult(const PGresult *src, int flags);
552 extern int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs);
553 extern void *PQresultAlloc(PGresult *res, size_t nBytes);
554 extern size_t PQresultMemorySize(const PGresult *res);
555 extern int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len);
556 
557 /* Quoting strings before inclusion in queries. */
558 extern size_t PQescapeStringConn(PGconn *conn,
559  char *to, const char *from, size_t length,
560  int *error);
561 extern char *PQescapeLiteral(PGconn *conn, const char *str, size_t len);
562 extern char *PQescapeIdentifier(PGconn *conn, const char *str, size_t len);
563 extern unsigned char *PQescapeByteaConn(PGconn *conn,
564  const unsigned char *from, size_t from_length,
565  size_t *to_length);
566 extern unsigned char *PQunescapeBytea(const unsigned char *strtext,
567  size_t *retbuflen);
568 
569 /* These forms are deprecated! */
570 extern size_t PQescapeString(char *to, const char *from, size_t length);
571 extern unsigned char *PQescapeBytea(const unsigned char *from, size_t from_length,
572  size_t *to_length);
573 
574 
575 
576 /* === in fe-print.c === */
577 
578 extern void PQprint(FILE *fout, /* output stream */
579  const PGresult *res,
580  const PQprintOpt *ps); /* option structure */
581 
582 /*
583  * really old printing routines
584  */
585 extern void PQdisplayTuples(const PGresult *res,
586  FILE *fp, /* where to send the output */
587  int fillAlign, /* pad the fields with spaces */
588  const char *fieldSep, /* field separator */
589  int printHeader, /* display headers? */
590  int quiet);
591 
592 extern void PQprintTuples(const PGresult *res,
593  FILE *fout, /* output stream */
594  int PrintAttNames, /* print attribute names */
595  int TerseOutput, /* delimiter bars */
596  int colWidth); /* width of column, if 0, use
597  * variable width */
598 
599 
600 /* === in fe-lobj.c === */
601 
602 /* Large-object access routines */
603 extern int lo_open(PGconn *conn, Oid lobjId, int mode);
604 extern int lo_close(PGconn *conn, int fd);
605 extern int lo_read(PGconn *conn, int fd, char *buf, size_t len);
606 extern int lo_write(PGconn *conn, int fd, const char *buf, size_t len);
607 extern int lo_lseek(PGconn *conn, int fd, int offset, int whence);
608 extern pg_int64 lo_lseek64(PGconn *conn, int fd, pg_int64 offset, int whence);
609 extern Oid lo_creat(PGconn *conn, int mode);
610 extern Oid lo_create(PGconn *conn, Oid lobjId);
611 extern int lo_tell(PGconn *conn, int fd);
612 extern pg_int64 lo_tell64(PGconn *conn, int fd);
613 extern int lo_truncate(PGconn *conn, int fd, size_t len);
614 extern int lo_truncate64(PGconn *conn, int fd, pg_int64 len);
615 extern int lo_unlink(PGconn *conn, Oid lobjId);
616 extern Oid lo_import(PGconn *conn, const char *filename);
617 extern Oid lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId);
618 extern int lo_export(PGconn *conn, Oid lobjId, const char *filename);
619 
620 /* === in fe-misc.c === */
621 
622 /* Get the version of the libpq library in use */
623 extern int PQlibVersion(void);
624 
625 /* Determine length of multibyte encoded char at *s */
626 extern int PQmblen(const char *s, int encoding);
627 
628 /* Determine display length of multibyte encoded char at *s */
629 extern int PQdsplen(const char *s, int encoding);
630 
631 /* Get encoding id from environment variable PGCLIENTENCODING */
632 extern int PQenv2encoding(void);
633 
634 /* === in fe-auth.c === */
635 
636 extern char *PQencryptPassword(const char *passwd, const char *user);
637 extern char *PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm);
638 
639 /* === in encnames.c === */
640 
641 extern int pg_char_to_encoding(const char *name);
642 extern const char *pg_encoding_to_char(int encoding);
643 extern int pg_valid_server_encoding_id(int encoding);
644 
645 /* === in fe-secure-openssl.c === */
646 
647 /* Support for overriding sslpassword handling with a callback */
648 typedef int (*PQsslKeyPassHook_OpenSSL_type) (char *buf, int size, PGconn *conn);
651 extern int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn);
652 
653 #ifdef __cplusplus
654 }
655 #endif
656 
657 #endif /* LIBPQ_FE_H */
int PQclientEncoding(const PGconn *conn)
Definition: fe-connect.c:6804
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:2156
void PQtrace(PGconn *conn, FILE *debug_port)
Definition: fe-trace.c:35
int PQsocket(const PGconn *conn)
Definition: fe-connect.c:6753
void PQinitSSL(int do_init)
Definition: fe-secure.c:139
Oid PQftable(const PGresult *res, int field_num)
Definition: fe-exec.c:3372
char * PQport(const PGconn *conn)
Definition: fe-connect.c:6650
char * extra
Definition: libpq-fe.h:180
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:3175
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:1387
size_t PQescapeString(char *to, const char *from, size_t length)
Definition: fe-exec.c:3850
PQconninfoOption * PQconninfoParse(const char *conninfo, char **errmsg)
Definition: fe-connect.c:5328
void(* PQnoticeReceiver)(void *arg, const PGresult *res)
Definition: libpq-fe.h:186
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:734
void PQuntrace(PGconn *conn)
Definition: fe-trace.c:49
int PQgetCopyData(PGconn *conn, char **buffer, int async)
Definition: fe-exec.c:2618
static struct @142 value
static void error(void)
Definition: sql-dyntest.c:147
int PQfmod(const PGresult *res, int field_num)
Definition: fe-exec.c:3427
int PQisnonblocking(const PGconn *conn)
Definition: fe-exec.c:3666
int PQmblen(const char *s, int encoding)
Definition: fe-misc.c:1187
char * PQpass(const PGconn *conn)
Definition: fe-connect.c:6597
char * PQescapeIdentifier(PGconn *conn, const char *str, size_t len)
Definition: fe-exec.c:3994
PGresult * PQcopyResult(const PGresult *src, int flags)
Definition: fe-exec.c:299
int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize)
Definition: fe-exec.c:2704
char * PQuser(const PGconn *conn)
Definition: fe-connect.c:6589
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:2494
void PQreset(PGconn *conn)
Definition: fe-connect.c:4243
int PQresetStart(PGconn *conn)
Definition: fe-connect.c:4284
pg_int64 lo_tell64(PGconn *conn, int fd)
Definition: fe-lobj.c:555
int PQbinaryTuples(const PGresult *res)
Definition: fe-exec.c:3183
PGconn * PQconnectStartParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition: fe-connect.c:765
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:4373
void(* PQnoticeProcessor)(void *arg, const char *message)
Definition: libpq-fe.h:187
char * PQdb(const PGconn *conn)
Definition: fe-connect.c:6581
int PQntuples(const PGresult *res)
Definition: fe-exec.c:3167
int PQisthreadsafe(void)
Definition: fe-exec.c:3673
PGcancel * PQgetCancel(PGconn *conn)
Definition: fe-connect.c:4350
unsigned char * PQescapeByteaConn(PGconn *conn, const unsigned char *from, size_t from_length, size_t *to_length)
Definition: fe-exec.c:4138
int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len)
Definition: fe-exec.c:436
int PQfformat(const PGresult *res, int field_num)
Definition: fe-exec.c:3394
const char * pghost
Definition: pgbench.c:278
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3561
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:2783
char * PQcmdTuples(PGresult *res)
Definition: fe-exec.c:3508
int PQconnectionUsedPassword(const PGconn *conn)
Definition: fe-connect.c:6793
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:2203
ExecStatusType PQresultStatus(const PGresult *res)
Definition: fe-exec.c:3097
PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn, PQnoticeProcessor proc, void *arg)
Definition: fe-connect.c:6895
pgthreadlock_t PQregisterThreadLock(pgthreadlock_t newhandler)
Definition: fe-connect.c:7289
void PQinitOpenSSL(int do_ssl, int do_crypto)
Definition: fe-secure.c:151
char * PQtty(const PGconn *conn)
Definition: fe-connect.c:6666
void PQfinish(PGconn *conn)
Definition: fe-connect.c:4229
unsigned int Oid
Definition: postgres_ext.h:31
int PQlibVersion(void)
Definition: fe-misc.c:66
pqbool standard
Definition: libpq-fe.h:196
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:254
char * fieldSep
Definition: libpq-fe.h:200
const char * dbName
Definition: pgbench.c:281
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:6690
Oid lo_creat(PGconn *conn, int mode)
Definition: fe-lobj.c:444
PQconninfoOption * PQconndefaults(void)
Definition: fe-connect.c:1477
char * PQoptions(const PGconn *conn)
Definition: fe-connect.c:6674
PGconn * PQconnectStart(const char *conninfo)
Definition: fe-connect.c:846
void PQconninfoFree(PQconninfoOption *connOptions)
Definition: fe-connect.c:6563
int PQpipelineSync(PGconn *conn)
Definition: fe-exec.c:3027
int PQsetnonblocking(PGconn *conn, int arg)
Definition: fe-exec.c:3629
const char * pg_encoding_to_char(int encoding)
Definition: encnames.c:588
int PQnparams(const PGresult *res)
Definition: fe-exec.c:3600
int PQgetline(PGconn *conn, char *string, int length)
Definition: fe-exec.c:2657
int lo_close(PGconn *conn, int fd)
Definition: fe-lobj.c:96
int PQprotocolVersion(const PGconn *conn)
Definition: fe-connect.c:6715
PGconn * PQconnectdbParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition: fe-connect.c:662
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:393
int PQdefaultSSLKeyPassHook_OpenSSL(char *buf, int size, PGconn *conn)
int PQputCopyEnd(PGconn *conn, const char *errormsg)
Definition: fe-exec.c:2550
int PQsslInUse(PGconn *conn)
Definition: fe-secure.c:127
PGconn * conn
Definition: streamutil.c:54
int be_pid
Definition: libpq-fe.h:179
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:2384
int PQftablecol(const PGresult *res, int field_num)
Definition: fe-exec.c:3383
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:3152
char * PQresultVerboseErrorMessage(const PGresult *res, PGVerbosity verbosity, PGContextVisibility show_context)
Definition: fe-exec.c:3121
static char * buf
Definition: pg_test_fsync.c:68
char * PQencryptPassword(const char *passwd, const char *user)
Definition: fe-auth.c:1150
PGpipelineStatus PQpipelineStatus(const PGconn *conn)
Definition: fe-connect.c:6769
int PQputline(PGconn *conn, const char *string)
Definition: fe-exec.c:2721
PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity)
Definition: fe-connect.c:6854
pqbool align
Definition: libpq-fe.h:195
size_t PQresultMemorySize(const PGresult *res)
Definition: fe-exec.c:639
char * relname
Definition: libpq-fe.h:178
PQsslKeyPassHook_OpenSSL_type PQgetSSLKeyPassHook_OpenSSL(void)
PGresult * PQexec(PGconn *conn, const char *query)
Definition: fe-exec.c:2142
int PQgetlength(const PGresult *res, int tup_num, int field_num)
Definition: fe-exec.c:3572
char * PQescapeLiteral(PGconn *conn, const char *str, size_t len)
Definition: fe-exec.c:3988
int PQsendDescribePrepared(PGconn *conn, const char *stmt)
Definition: fe-exec.c:2371
int PQrequestCancel(PGconn *conn)
Definition: fe-connect.c:4530
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
Definition: fe-connect.c:6700
int PQsendPrepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)
Definition: fe-exec.c:1432
void PQprintTuples(const PGresult *res, FILE *fout, int PrintAttNames, int TerseOutput, int colWidth)
Definition: fe-print.c:676
int PQenterPipelineMode(PGconn *conn)
Definition: fe-exec.c:2844
PQnoticeReceiver PQsetNoticeReceiver(PGconn *conn, PQnoticeReceiver proc, void *arg)
Definition: fe-connect.c:6878
char * PQhost(const PGconn *conn)
Definition: fe-connect.c:6614
int PQfnumber(const PGresult *res, const char *field_name)
Definition: fe-exec.c:3275
char * PQerrorMessage(const PGconn *conn)
Definition: fe-connect.c:6735
char * PQcmdStatus(PGresult *res)
Definition: fe-exec.c:3438
void PQsetSSLKeyPassHook_OpenSSL(PQsslKeyPassHook_OpenSSL_type hook)
char * PQhostaddr(const PGconn *conn)
Definition: fe-connect.c:6637
int PQsetSingleRowMode(PGconn *conn)
Definition: fe-exec.c:1825
char * caption
Definition: libpq-fe.h:202
PGPing PQpingParams(const char *const *keywords, const char *const *values, int expand_dbname)
Definition: fe-connect.c:681
char * PQresStatus(ExecStatusType status)
Definition: fe-exec.c:3105
pqbool pager
Definition: libpq-fe.h:199
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:1853
char * PQresultErrorMessage(const PGresult *res)
Definition: fe-exec.c:3113
Oid PQftype(const PGresult *res, int field_num)
Definition: fe-exec.c:3405
PGContextVisibility
Definition: libpq-fe.h:122
int PQconnectionNeedsPassword(const PGconn *conn)
Definition: fe-connect.c:6778
struct pgNotify * next
Definition: libpq-fe.h:182
void * PQresultAlloc(PGresult *res, size_t nBytes)
Definition: fe-exec.c:523
PGVerbosity
Definition: libpq-fe.h:114
PostgresPollingStatusType PQresetPoll(PGconn *conn)
Definition: fe-connect.c:4303
int atttypmod
Definition: libpq-fe.h:258
PGpipelineStatus
Definition: libpq-fe.h:145
unsigned char * PQunescapeBytea(const unsigned char *strtext, size_t *retbuflen)
Definition: fe-exec.c:4178
const char * PQsslAttribute(PGconn *conn, const char *attribute_name)
struct pgresAttDesc PGresAttDesc
PGTransactionStatusType
Definition: libpq-fe.h:105
int PQgssEncInUse(PGconn *conn)
int PQexitPipelineMode(PGconn *conn)
Definition: fe-exec.c:2876
unsigned char * PQescapeBytea(const unsigned char *from, size_t from_length, size_t *to_length)
Definition: fe-exec.c:4153
PostgresPollingStatusType PQconnectPoll(PGconn *conn)
Definition: fe-connect.c:2251
Oid lo_import(PGconn *conn, const char *filename)
Definition: fe-lobj.c:634
struct _PQconninfoOption PQconninfoOption
int PQisBusy(PGconn *conn)
Definition: fe-exec.c:1900
int PQendcopy(PGconn *conn)
Definition: fe-exec.c:2752
char ** fieldName
Definition: libpq-fe.h:203
pqbool expanded
Definition: libpq-fe.h:198
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:1515
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:3586
void PQtraceSetFlags(PGconn *conn, int flags)
Definition: fe-trace.c:64
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:2186
PGresult * PQgetResult(PGconn *conn)
Definition: fe-exec.c:1927
int PQsetClientEncoding(PGconn *conn, const char *encoding)
Definition: fe-connect.c:6812
PGconn * PQconnectdb(const char *conninfo)
Definition: fe-connect.c:718
void PQfreemem(void *ptr)
Definition: fe-exec.c:3715
const char * name
Definition: encode.c:515
ConnStatusType PQstatus(const PGconn *conn)
Definition: fe-connect.c:6682
int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize)
Definition: fe-connect.c:4505
int PQfsize(const PGresult *res, int field_num)
Definition: fe-exec.c:3416
pqbool html3
Definition: libpq-fe.h:197
char * PQfname(const PGresult *res, int field_num)
Definition: fe-exec.c:3253
char * tableOpt
Definition: libpq-fe.h:201
static Datum values[MAXATTR]
Definition: bootstrap.c:166
PostgresPollingStatusType
Definition: libpq-fe.h:73
void PQclear(PGresult *res)
Definition: fe-exec.c:680
static char * filename
Definition: pg_dumpall.c:91
char * PQoidStatus(const PGresult *res)
Definition: fe-exec.c:3451
static char * user
Definition: pg_regress.c:95
Oid PQoidValue(const PGresult *res)
Definition: fe-exec.c:3479
int errmsg(const char *fmt,...)
Definition: elog.c:909
PQconninfoOption * PQconninfo(PGconn *conn)
Definition: fe-connect.c:6519
pqbool header
Definition: libpq-fe.h:194
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:1197
PGContextVisibility PQsetErrorContextVisibility(PGconn *conn, PGContextVisibility show_context)
Definition: fe-connect.c:6866
char * name
Definition: libpq-fe.h:252
PGresult * PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status)
Definition: fe-exec.c:146
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:1533
int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs)
Definition: fe-exec.c:234
size_t PQescapeStringConn(PGconn *conn, char *to, const char *from, size_t length, int *error)
Definition: fe-exec.c:3829
PGPing
Definition: libpq-fe.h:134
int PQputnbytes(PGconn *conn, const char *buffer, int nbytes)
Definition: fe-exec.c:2731
int isint
Definition: libpq-fe.h:238
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:6725
int PQenv2encoding(void)
Definition: fe-misc.c:1206
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:648
int PQbackendPID(const PGconn *conn)
Definition: fe-connect.c:6761
int PQflush(PGconn *conn)
Definition: fe-exec.c:3685
struct pgNotify PGnotify
char pqbool
Definition: libpq-fe.h:190
struct _PQprintOpt PQprintOpt
Oid PQparamtype(const PGresult *res, int param_num)
Definition: fe-exec.c:3611
PGresult * PQdescribePortal(PGconn *conn, const char *portal)
Definition: fe-exec.c:2354
int pg_char_to_encoding(const char *name)
Definition: encnames.c:550
int * ptr
Definition: libpq-fe.h:241
const char * pgport
Definition: pgbench.c:279
int integer
Definition: libpq-fe.h:242
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:1279
PGnotify * PQnotifies(PGconn *conn)
Definition: fe-exec.c:2466
PGresult * PQdescribePrepared(PGconn *conn, const char *stmt)
Definition: fe-exec.c:2335