libpq-fe.h 21 KB

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