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