Header And Logo

PostgreSQL
| The world's most advanced open source database.

libpq-fe.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * libpq-fe.h
00004  *    This file contains definitions for structures and
00005  *    externs for functions used by frontend postgres applications.
00006  *
00007  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00008  * Portions Copyright (c) 1994, Regents of the University of California
00009  *
00010  * src/interfaces/libpq/libpq-fe.h
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 
00015 #ifndef LIBPQ_FE_H
00016 #define LIBPQ_FE_H
00017 
00018 #ifdef __cplusplus
00019 extern      "C"
00020 {
00021 #endif
00022 
00023 #include <stdio.h>
00024 
00025 /*
00026  * postgres_ext.h defines the backend's externally visible types,
00027  * such as Oid.
00028  */
00029 #include "postgres_ext.h"
00030 
00031 /*
00032  * Option flags for PQcopyResult
00033  */
00034 #define PG_COPYRES_ATTRS          0x01
00035 #define PG_COPYRES_TUPLES         0x02  /* Implies PG_COPYRES_ATTRS */
00036 #define PG_COPYRES_EVENTS         0x04
00037 #define PG_COPYRES_NOTICEHOOKS    0x08
00038 
00039 /* Application-visible enum types */
00040 
00041 /*
00042  * Although it is okay to add to these lists, values which become unused
00043  * should never be removed, nor should constants be redefined - that would
00044  * break compatibility with existing code.
00045  */
00046 
00047 typedef enum
00048 {
00049     CONNECTION_OK,
00050     CONNECTION_BAD,
00051     /* Non-blocking mode only below here */
00052 
00053     /*
00054      * The existence of these should never be relied upon - they should only
00055      * be used for user feedback or similar purposes.
00056      */
00057     CONNECTION_STARTED,         /* Waiting for connection to be made.  */
00058     CONNECTION_MADE,            /* Connection OK; waiting to send.     */
00059     CONNECTION_AWAITING_RESPONSE,       /* Waiting for a response from the
00060                                          * postmaster.        */
00061     CONNECTION_AUTH_OK,         /* Received authentication; waiting for
00062                                  * backend startup. */
00063     CONNECTION_SETENV,          /* Negotiating environment. */
00064     CONNECTION_SSL_STARTUP,     /* Negotiating SSL. */
00065     CONNECTION_NEEDED           /* Internal state: connect() needed */
00066 } ConnStatusType;
00067 
00068 typedef enum
00069 {
00070     PGRES_POLLING_FAILED = 0,
00071     PGRES_POLLING_READING,      /* These two indicate that one may    */
00072     PGRES_POLLING_WRITING,      /* use select before polling again.   */
00073     PGRES_POLLING_OK,
00074     PGRES_POLLING_ACTIVE        /* unused; keep for awhile for backwards
00075                                  * compatibility */
00076 } PostgresPollingStatusType;
00077 
00078 typedef enum
00079 {
00080     PGRES_EMPTY_QUERY = 0,      /* empty query string was executed */
00081     PGRES_COMMAND_OK,           /* a query command that doesn't return
00082                                  * anything was executed properly by the
00083                                  * backend */
00084     PGRES_TUPLES_OK,            /* a query command that returns tuples was
00085                                  * executed properly by the backend, PGresult
00086                                  * contains the result tuples */
00087     PGRES_COPY_OUT,             /* Copy Out data transfer in progress */
00088     PGRES_COPY_IN,              /* Copy In data transfer in progress */
00089     PGRES_BAD_RESPONSE,         /* an unexpected response was recv'd from the
00090                                  * backend */
00091     PGRES_NONFATAL_ERROR,       /* notice or warning message */
00092     PGRES_FATAL_ERROR,          /* query failed */
00093     PGRES_COPY_BOTH,            /* Copy In/Out data transfer in progress */
00094     PGRES_SINGLE_TUPLE          /* single tuple from larger resultset */
00095 } ExecStatusType;
00096 
00097 typedef enum
00098 {
00099     PQTRANS_IDLE,               /* connection idle */
00100     PQTRANS_ACTIVE,             /* command in progress */
00101     PQTRANS_INTRANS,            /* idle, within transaction block */
00102     PQTRANS_INERROR,            /* idle, within failed transaction */
00103     PQTRANS_UNKNOWN             /* cannot determine status */
00104 } PGTransactionStatusType;
00105 
00106 typedef enum
00107 {
00108     PQERRORS_TERSE,             /* single-line error messages */
00109     PQERRORS_DEFAULT,           /* recommended style */
00110     PQERRORS_VERBOSE            /* all the facts, ma'am */
00111 } PGVerbosity;
00112 
00113 /*
00114  * PGPing - The ordering of this enum should not be altered because the
00115  * values are exposed externally via pg_isready.
00116  */
00117 
00118 typedef enum
00119 {
00120     PQPING_OK,                  /* server is accepting connections */
00121     PQPING_REJECT,              /* server is alive but rejecting connections */
00122     PQPING_NO_RESPONSE,         /* could not establish connection */
00123     PQPING_NO_ATTEMPT           /* connection not attempted (bad params) */
00124 } PGPing;
00125 
00126 /* PGconn encapsulates a connection to the backend.
00127  * The contents of this struct are not supposed to be known to applications.
00128  */
00129 typedef struct pg_conn PGconn;
00130 
00131 /* PGresult encapsulates the result of a query (or more precisely, of a single
00132  * SQL command --- a query string given to PQsendQuery can contain multiple
00133  * commands and thus return multiple PGresult objects).
00134  * The contents of this struct are not supposed to be known to applications.
00135  */
00136 typedef struct pg_result PGresult;
00137 
00138 /* PGcancel encapsulates the information needed to cancel a running
00139  * query on an existing connection.
00140  * The contents of this struct are not supposed to be known to applications.
00141  */
00142 typedef struct pg_cancel PGcancel;
00143 
00144 /* PGnotify represents the occurrence of a NOTIFY message.
00145  * Ideally this would be an opaque typedef, but it's so simple that it's
00146  * unlikely to change.
00147  * NOTE: in Postgres 6.4 and later, the be_pid is the notifying backend's,
00148  * whereas in earlier versions it was always your own backend's PID.
00149  */
00150 typedef struct pgNotify
00151 {
00152     char       *relname;        /* notification condition name */
00153     int         be_pid;         /* process ID of notifying server process */
00154     char       *extra;          /* notification parameter */
00155     /* Fields below here are private to libpq; apps should not use 'em */
00156     struct pgNotify *next;      /* list link */
00157 } PGnotify;
00158 
00159 /* Function types for notice-handling callbacks */
00160 typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res);
00161 typedef void (*PQnoticeProcessor) (void *arg, const char *message);
00162 
00163 /* Print options for PQprint() */
00164 typedef char pqbool;
00165 
00166 typedef struct _PQprintOpt
00167 {
00168     pqbool      header;         /* print output field headings and row count */
00169     pqbool      align;          /* fill align the fields */
00170     pqbool      standard;       /* old brain dead format */
00171     pqbool      html3;          /* output html tables */
00172     pqbool      expanded;       /* expand tables */
00173     pqbool      pager;          /* use pager for output if needed */
00174     char       *fieldSep;       /* field separator */
00175     char       *tableOpt;       /* insert to HTML <table ...> */
00176     char       *caption;        /* HTML <caption> */
00177     char      **fieldName;      /* null terminated array of replacement field
00178                                  * names */
00179 } PQprintOpt;
00180 
00181 /* ----------------
00182  * Structure for the conninfo parameter definitions returned by PQconndefaults
00183  * or PQconninfoParse.
00184  *
00185  * All fields except "val" point at static strings which must not be altered.
00186  * "val" is either NULL or a malloc'd current-value string.  PQconninfoFree()
00187  * will release both the val strings and the PQconninfoOption array itself.
00188  * ----------------
00189  */
00190 typedef struct _PQconninfoOption
00191 {
00192     char       *keyword;        /* The keyword of the option            */
00193     char       *envvar;         /* Fallback environment variable name   */
00194     char       *compiled;       /* Fallback compiled in default value   */
00195     char       *val;            /* Option's current value, or NULL       */
00196     char       *label;          /* Label for field in connect dialog    */
00197     char       *dispchar;       /* Indicates how to display this field in a
00198                                  * connect dialog. Values are: "" Display
00199                                  * entered value as is "*" Password field -
00200                                  * hide value "D"  Debug option - don't show
00201                                  * by default */
00202     int         dispsize;       /* Field size in characters for dialog  */
00203 } PQconninfoOption;
00204 
00205 /* ----------------
00206  * PQArgBlock -- structure for PQfn() arguments
00207  * ----------------
00208  */
00209 typedef struct
00210 {
00211     int         len;
00212     int         isint;
00213     union
00214     {
00215         int        *ptr;        /* can't use void (dec compiler barfs)   */
00216         int         integer;
00217     }           u;
00218 } PQArgBlock;
00219 
00220 /* ----------------
00221  * PGresAttDesc -- Data about a single attribute (column) of a query result
00222  * ----------------
00223  */
00224 typedef struct pgresAttDesc
00225 {
00226     char       *name;           /* column name */
00227     Oid         tableid;        /* source table, if known */
00228     int         columnid;       /* source column, if known */
00229     int         format;         /* format code for value (text/binary) */
00230     Oid         typid;          /* type id */
00231     int         typlen;         /* type size */
00232     int         atttypmod;      /* type-specific modifier info */
00233 } PGresAttDesc;
00234 
00235 /* ----------------
00236  * Exported functions of libpq
00237  * ----------------
00238  */
00239 
00240 /* ===  in fe-connect.c === */
00241 
00242 /* make a new client connection to the backend */
00243 /* Asynchronous (non-blocking) */
00244 extern PGconn *PQconnectStart(const char *conninfo);
00245 extern PGconn *PQconnectStartParams(const char *const * keywords,
00246                      const char *const * values, int expand_dbname);
00247 extern PostgresPollingStatusType PQconnectPoll(PGconn *conn);
00248 
00249 /* Synchronous (blocking) */
00250 extern PGconn *PQconnectdb(const char *conninfo);
00251 extern PGconn *PQconnectdbParams(const char *const * keywords,
00252                   const char *const * values, int expand_dbname);
00253 extern PGconn *PQsetdbLogin(const char *pghost, const char *pgport,
00254              const char *pgoptions, const char *pgtty,
00255              const char *dbName,
00256              const char *login, const char *pwd);
00257 
00258 #define PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME)  \
00259     PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, NULL, NULL)
00260 
00261 /* close the current connection and free the PGconn data structure */
00262 extern void PQfinish(PGconn *conn);
00263 
00264 /* get info about connection options known to PQconnectdb */
00265 extern PQconninfoOption *PQconndefaults(void);
00266 
00267 /* parse connection options in same way as PQconnectdb */
00268 extern PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
00269 
00270 /* return the connection options used by a live connection */
00271 extern PQconninfoOption *PQconninfo(PGconn *conn);
00272 
00273 /* free the data structure returned by PQconndefaults() or PQconninfoParse() */
00274 extern void PQconninfoFree(PQconninfoOption *connOptions);
00275 
00276 /*
00277  * close the current connection and restablish a new one with the same
00278  * parameters
00279  */
00280 /* Asynchronous (non-blocking) */
00281 extern int  PQresetStart(PGconn *conn);
00282 extern PostgresPollingStatusType PQresetPoll(PGconn *conn);
00283 
00284 /* Synchronous (blocking) */
00285 extern void PQreset(PGconn *conn);
00286 
00287 /* request a cancel structure */
00288 extern PGcancel *PQgetCancel(PGconn *conn);
00289 
00290 /* free a cancel structure */
00291 extern void PQfreeCancel(PGcancel *cancel);
00292 
00293 /* issue a cancel request */
00294 extern int  PQcancel(PGcancel *cancel, char *errbuf, int errbufsize);
00295 
00296 /* backwards compatible version of PQcancel; not thread-safe */
00297 extern int  PQrequestCancel(PGconn *conn);
00298 
00299 /* Accessor functions for PGconn objects */
00300 extern char *PQdb(const PGconn *conn);
00301 extern char *PQuser(const PGconn *conn);
00302 extern char *PQpass(const PGconn *conn);
00303 extern char *PQhost(const PGconn *conn);
00304 extern char *PQport(const PGconn *conn);
00305 extern char *PQtty(const PGconn *conn);
00306 extern char *PQoptions(const PGconn *conn);
00307 extern ConnStatusType PQstatus(const PGconn *conn);
00308 extern PGTransactionStatusType PQtransactionStatus(const PGconn *conn);
00309 extern const char *PQparameterStatus(const PGconn *conn,
00310                   const char *paramName);
00311 extern int  PQprotocolVersion(const PGconn *conn);
00312 extern int  PQserverVersion(const PGconn *conn);
00313 extern char *PQerrorMessage(const PGconn *conn);
00314 extern int  PQsocket(const PGconn *conn);
00315 extern int  PQbackendPID(const PGconn *conn);
00316 extern int  PQconnectionNeedsPassword(const PGconn *conn);
00317 extern int  PQconnectionUsedPassword(const PGconn *conn);
00318 extern int  PQclientEncoding(const PGconn *conn);
00319 extern int  PQsetClientEncoding(PGconn *conn, const char *encoding);
00320 
00321 /* Get the OpenSSL structure associated with a connection. Returns NULL for
00322  * unencrypted connections or if any other TLS library is in use. */
00323 extern void *PQgetssl(PGconn *conn);
00324 
00325 /* Tell libpq whether it needs to initialize OpenSSL */
00326 extern void PQinitSSL(int do_init);
00327 
00328 /* More detailed way to tell libpq whether it needs to initialize OpenSSL */
00329 extern void PQinitOpenSSL(int do_ssl, int do_crypto);
00330 
00331 /* Set verbosity for PQerrorMessage and PQresultErrorMessage */
00332 extern PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity);
00333 
00334 /* Enable/disable tracing */
00335 extern void PQtrace(PGconn *conn, FILE *debug_port);
00336 extern void PQuntrace(PGconn *conn);
00337 
00338 /* Override default notice handling routines */
00339 extern PQnoticeReceiver PQsetNoticeReceiver(PGconn *conn,
00340                     PQnoticeReceiver proc,
00341                     void *arg);
00342 extern PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn,
00343                      PQnoticeProcessor proc,
00344                      void *arg);
00345 
00346 /*
00347  *     Used to set callback that prevents concurrent access to
00348  *     non-thread safe functions that libpq needs.
00349  *     The default implementation uses a libpq internal mutex.
00350  *     Only required for multithreaded apps that use kerberos
00351  *     both within their app and for postgresql connections.
00352  */
00353 typedef void (*pgthreadlock_t) (int acquire);
00354 
00355 extern pgthreadlock_t PQregisterThreadLock(pgthreadlock_t newhandler);
00356 
00357 /* === in fe-exec.c === */
00358 
00359 /* Simple synchronous query */
00360 extern PGresult *PQexec(PGconn *conn, const char *query);
00361 extern PGresult *PQexecParams(PGconn *conn,
00362              const char *command,
00363              int nParams,
00364              const Oid *paramTypes,
00365              const char *const * paramValues,
00366              const int *paramLengths,
00367              const int *paramFormats,
00368              int resultFormat);
00369 extern PGresult *PQprepare(PGconn *conn, const char *stmtName,
00370           const char *query, int nParams,
00371           const Oid *paramTypes);
00372 extern PGresult *PQexecPrepared(PGconn *conn,
00373                const char *stmtName,
00374                int nParams,
00375                const char *const * paramValues,
00376                const int *paramLengths,
00377                const int *paramFormats,
00378                int resultFormat);
00379 
00380 /* Interface for multiple-result or asynchronous queries */
00381 extern int  PQsendQuery(PGconn *conn, const char *query);
00382 extern int PQsendQueryParams(PGconn *conn,
00383                   const char *command,
00384                   int nParams,
00385                   const Oid *paramTypes,
00386                   const char *const * paramValues,
00387                   const int *paramLengths,
00388                   const int *paramFormats,
00389                   int resultFormat);
00390 extern int PQsendPrepare(PGconn *conn, const char *stmtName,
00391               const char *query, int nParams,
00392               const Oid *paramTypes);
00393 extern int PQsendQueryPrepared(PGconn *conn,
00394                     const char *stmtName,
00395                     int nParams,
00396                     const char *const * paramValues,
00397                     const int *paramLengths,
00398                     const int *paramFormats,
00399                     int resultFormat);
00400 extern int  PQsetSingleRowMode(PGconn *conn);
00401 extern PGresult *PQgetResult(PGconn *conn);
00402 
00403 /* Routines for managing an asynchronous query */
00404 extern int  PQisBusy(PGconn *conn);
00405 extern int  PQconsumeInput(PGconn *conn);
00406 
00407 /* LISTEN/NOTIFY support */
00408 extern PGnotify *PQnotifies(PGconn *conn);
00409 
00410 /* Routines for copy in/out */
00411 extern int  PQputCopyData(PGconn *conn, const char *buffer, int nbytes);
00412 extern int  PQputCopyEnd(PGconn *conn, const char *errormsg);
00413 extern int  PQgetCopyData(PGconn *conn, char **buffer, int async);
00414 
00415 /* Deprecated routines for copy in/out */
00416 extern int  PQgetline(PGconn *conn, char *string, int length);
00417 extern int  PQputline(PGconn *conn, const char *string);
00418 extern int  PQgetlineAsync(PGconn *conn, char *buffer, int bufsize);
00419 extern int  PQputnbytes(PGconn *conn, const char *buffer, int nbytes);
00420 extern int  PQendcopy(PGconn *conn);
00421 
00422 /* Set blocking/nonblocking connection to the backend */
00423 extern int  PQsetnonblocking(PGconn *conn, int arg);
00424 extern int  PQisnonblocking(const PGconn *conn);
00425 extern int  PQisthreadsafe(void);
00426 extern PGPing PQping(const char *conninfo);
00427 extern PGPing PQpingParams(const char *const * keywords,
00428              const char *const * values, int expand_dbname);
00429 
00430 /* Force the write buffer to be written (or at least try) */
00431 extern int  PQflush(PGconn *conn);
00432 
00433 /*
00434  * "Fast path" interface --- not really recommended for application
00435  * use
00436  */
00437 extern PGresult *PQfn(PGconn *conn,
00438      int fnid,
00439      int *result_buf,
00440      int *result_len,
00441      int result_is_int,
00442      const PQArgBlock *args,
00443      int nargs);
00444 
00445 /* Accessor functions for PGresult objects */
00446 extern ExecStatusType PQresultStatus(const PGresult *res);
00447 extern char *PQresStatus(ExecStatusType status);
00448 extern char *PQresultErrorMessage(const PGresult *res);
00449 extern char *PQresultErrorField(const PGresult *res, int fieldcode);
00450 extern int  PQntuples(const PGresult *res);
00451 extern int  PQnfields(const PGresult *res);
00452 extern int  PQbinaryTuples(const PGresult *res);
00453 extern char *PQfname(const PGresult *res, int field_num);
00454 extern int  PQfnumber(const PGresult *res, const char *field_name);
00455 extern Oid  PQftable(const PGresult *res, int field_num);
00456 extern int  PQftablecol(const PGresult *res, int field_num);
00457 extern int  PQfformat(const PGresult *res, int field_num);
00458 extern Oid  PQftype(const PGresult *res, int field_num);
00459 extern int  PQfsize(const PGresult *res, int field_num);
00460 extern int  PQfmod(const PGresult *res, int field_num);
00461 extern char *PQcmdStatus(PGresult *res);
00462 extern char *PQoidStatus(const PGresult *res);  /* old and ugly */
00463 extern Oid  PQoidValue(const PGresult *res);    /* new and improved */
00464 extern char *PQcmdTuples(PGresult *res);
00465 extern char *PQgetvalue(const PGresult *res, int tup_num, int field_num);
00466 extern int  PQgetlength(const PGresult *res, int tup_num, int field_num);
00467 extern int  PQgetisnull(const PGresult *res, int tup_num, int field_num);
00468 extern int  PQnparams(const PGresult *res);
00469 extern Oid  PQparamtype(const PGresult *res, int param_num);
00470 
00471 /* Describe prepared statements and portals */
00472 extern PGresult *PQdescribePrepared(PGconn *conn, const char *stmt);
00473 extern PGresult *PQdescribePortal(PGconn *conn, const char *portal);
00474 extern int  PQsendDescribePrepared(PGconn *conn, const char *stmt);
00475 extern int  PQsendDescribePortal(PGconn *conn, const char *portal);
00476 
00477 /* Delete a PGresult */
00478 extern void PQclear(PGresult *res);
00479 
00480 /* For freeing other alloc'd results, such as PGnotify structs */
00481 extern void PQfreemem(void *ptr);
00482 
00483 /* Exists for backward compatibility.  bjm 2003-03-24 */
00484 #define PQfreeNotify(ptr) PQfreemem(ptr)
00485 
00486 /* Error when no password was given. */
00487 /* Note: depending on this is deprecated; use PQconnectionNeedsPassword(). */
00488 #define PQnoPasswordSupplied    "fe_sendauth: no password supplied\n"
00489 
00490 /* Create and manipulate PGresults */
00491 extern PGresult *PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status);
00492 extern PGresult *PQcopyResult(const PGresult *src, int flags);
00493 extern int  PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs);
00494 extern void *PQresultAlloc(PGresult *res, size_t nBytes);
00495 extern int  PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len);
00496 
00497 /* Quoting strings before inclusion in queries. */
00498 extern size_t PQescapeStringConn(PGconn *conn,
00499                    char *to, const char *from, size_t length,
00500                    int *error);
00501 extern char *PQescapeLiteral(PGconn *conn, const char *str, size_t len);
00502 extern char *PQescapeIdentifier(PGconn *conn, const char *str, size_t len);
00503 extern unsigned char *PQescapeByteaConn(PGconn *conn,
00504                   const unsigned char *from, size_t from_length,
00505                   size_t *to_length);
00506 extern unsigned char *PQunescapeBytea(const unsigned char *strtext,
00507                 size_t *retbuflen);
00508 
00509 /* These forms are deprecated! */
00510 extern size_t PQescapeString(char *to, const char *from, size_t length);
00511 extern unsigned char *PQescapeBytea(const unsigned char *from, size_t from_length,
00512               size_t *to_length);
00513 
00514 
00515 
00516 /* === in fe-print.c === */
00517 
00518 extern void PQprint(FILE *fout,             /* output stream */
00519         const PGresult *res,
00520         const PQprintOpt *ps);  /* option structure */
00521 
00522 /*
00523  * really old printing routines
00524  */
00525 extern void PQdisplayTuples(const PGresult *res,
00526                 FILE *fp,       /* where to send the output */
00527                 int fillAlign,  /* pad the fields with spaces */
00528                 const char *fieldSep,   /* field separator */
00529                 int printHeader,    /* display headers? */
00530                 int quiet);
00531 
00532 extern void PQprintTuples(const PGresult *res,
00533               FILE *fout,       /* output stream */
00534               int printAttName, /* print attribute names */
00535               int terseOutput,  /* delimiter bars */
00536               int width);       /* width of column, if 0, use variable width */
00537 
00538 
00539 /* === in fe-lobj.c === */
00540 
00541 /* Large-object access routines */
00542 extern int  lo_open(PGconn *conn, Oid lobjId, int mode);
00543 extern int  lo_close(PGconn *conn, int fd);
00544 extern int  lo_read(PGconn *conn, int fd, char *buf, size_t len);
00545 extern int  lo_write(PGconn *conn, int fd, const char *buf, size_t len);
00546 extern int  lo_lseek(PGconn *conn, int fd, int offset, int whence);
00547 extern pg_int64 lo_lseek64(PGconn *conn, int fd, pg_int64 offset, int whence);
00548 extern Oid  lo_creat(PGconn *conn, int mode);
00549 extern Oid  lo_create(PGconn *conn, Oid lobjId);
00550 extern int  lo_tell(PGconn *conn, int fd);
00551 extern pg_int64 lo_tell64(PGconn *conn, int fd);
00552 extern int  lo_truncate(PGconn *conn, int fd, size_t len);
00553 extern int  lo_truncate64(PGconn *conn, int fd, pg_int64 len);
00554 extern int  lo_unlink(PGconn *conn, Oid lobjId);
00555 extern Oid  lo_import(PGconn *conn, const char *filename);
00556 extern Oid  lo_import_with_oid(PGconn *conn, const char *filename, Oid lobjId);
00557 extern int  lo_export(PGconn *conn, Oid lobjId, const char *filename);
00558 
00559 /* === in fe-misc.c === */
00560 
00561 /* Get the version of the libpq library in use */
00562 extern int  PQlibVersion(void);
00563 
00564 /* Determine length of multibyte encoded char at *s */
00565 extern int  PQmblen(const char *s, int encoding);
00566 
00567 /* Determine display length of multibyte encoded char at *s */
00568 extern int  PQdsplen(const char *s, int encoding);
00569 
00570 /* Get encoding id from environment variable PGCLIENTENCODING */
00571 extern int  PQenv2encoding(void);
00572 
00573 /* === in fe-auth.c === */
00574 
00575 extern char *PQencryptPassword(const char *passwd, const char *user);
00576 
00577 /* === in encnames.c === */
00578 
00579 extern int  pg_char_to_encoding(const char *name);
00580 extern const char *pg_encoding_to_char(int encoding);
00581 extern int  pg_valid_server_encoding_id(int encoding);
00582 
00583 #ifdef __cplusplus
00584 }
00585 #endif
00586 
00587 #endif   /* LIBPQ_FE_H */