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

source code of include/postgresql/libpq-fe.h