gooderp18绿色标准版
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

624 lines
22KB

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