1 ! See http://factor.sf.net/license.txt for BSD license.
3 ! adapted from libpq-fe.h version 7.4.7
4 ! tested on debian linux with postgresql 7.4.7
12 : CONNECTION_OK HEX: 0 ; inline
13 : CONNECTION_BAD HEX: 1 ; inline
14 : CONNECTION_STARTED HEX: 2 ; inline
15 : CONNECTION_MADE HEX: 3 ; inline
16 : CONNECTION_AWAITING_RESPONSE HEX: 4 ; inline
17 : CONNECTION_AUTH_OK HEX: 5 ; inline
18 : CONNECTION_SETENV HEX: 6 ; inline
19 : CONNECTION_SSL_STARTUP HEX: 7 ; inline
20 : CONNECTION_NEEDED HEX: 8 ; inline
22 ! PostgresPollingStatusType
23 : PGRES_POLLING_FAILED HEX: 0 ; inline
24 : PGRES_POLLING_READING HEX: 1 ; inline
25 : PGRES_POLLING_WRITING HEX: 2 ; inline
26 : PGRES_POLLING_OK HEX: 3 ; inline
27 : PGRES_POLLING_ACTIVE HEX: 4 ; inline
30 : PGRES_EMPTY_QUERY HEX: 0 ; inline
31 : PGRES_COMMAND_OK HEX: 1 ; inline
32 : PGRES_TUPLES_OK HEX: 2 ; inline
33 : PGRES_COPY_OUT HEX: 3 ; inline
34 : PGRES_COPY_IN HEX: 4 ; inline
35 : PGRES_BAD_RESPONSE HEX: 5 ; inline
36 : PGRES_NONFATAL_ERROR HEX: 6 ; inline
37 : PGRES_FATAL_ERROR HEX: 7 ; inline
39 ! PGTransactionStatusType;
40 : PQTRANS_IDLE HEX: 0 ; inline
41 : PQTRANS_ACTIVE HEX: 1 ; inline
42 : PQTRANS_INTRANS HEX: 2 ; inline
43 : PQTRANS_INERROR HEX: 3 ; inline
44 : PQTRANS_UNKNOWN HEX: 4 ; inline
47 : PQERRORS_TERSE HEX: 0 ; inline
48 : PQERRORS_DEFAULT HEX: 1 ; inline
49 : PQERRORS_VERBOSE HEX: 2 ; inline
53 TYPEDEF: int ConnStatusType
54 TYPEDEF: int ExecStatusType
55 TYPEDEF: int PostgresPollingStatusType
56 TYPEDEF: int PGTransactionStatusType
57 TYPEDEF: int PGVerbosity
59 TYPEDEF: void* PGconn*
60 TYPEDEF: void* PGresult*
61 TYPEDEF: void* PGcancel*
65 TYPEDEF: void* PQconninfoOption*
66 TYPEDEF: void* PGnotify*
67 TYPEDEF: void* PQArgBlock*
68 TYPEDEF: void* PQprintOpt*
75 ! Exported functions of libpq
76 ! === in fe-connect.c ===
78 ! make a new client connection to the backend
79 ! Asynchronous (non-blocking)
80 FUNCTION: PGconn* PQconnectStart ( char* conninfo ) ;
81 FUNCTION: PostgresPollingStatusType PQconnectPoll ( PGconn* conn ) ;
83 ! Synchronous (blocking)
84 FUNCTION: PGconn* PQconnectdb ( char* conninfo ) ;
85 FUNCTION: PGconn* PQsetdbLogin ( char* pghost, char* pgport,
86 char* pgoptions, char* pgtty,
88 char* login, char* pwd ) ;
90 : PQsetdb ( M_PGHOST M_PGPORT M_PGOPT M_PGTTY M_DBNAME -- PGconn* )
93 ! close the current connection and free the PGconn data structure
94 FUNCTION: void PQfinish ( PGconn* conn ) ;
96 ! get info about connection options known to PQconnectdb
97 FUNCTION: PQconninfoOption* PQconndefaults ( ) ;
99 ! free the data structure returned by PQconndefaults()
100 FUNCTION: void PQconninfoFree ( PQconninfoOption* connOptions ) ;
103 ! close the current connection and restablish a new one with the same
106 ! Asynchronous (non-blocking)
107 FUNCTION: int PQresetStart ( PGconn* conn ) ;
108 FUNCTION: PostgresPollingStatusType PQresetPoll ( PGconn* conn ) ;
110 ! Synchronous (blocking)
111 FUNCTION: void PQreset ( PGconn* conn ) ;
113 ! request a cancel structure
114 FUNCTION: PGcancel* PQgetCancel ( PGconn* conn ) ;
116 ! free a cancel structure
117 FUNCTION: void PQfreeCancel ( PGcancel* cancel ) ;
119 ! issue a cancel request
120 FUNCTION: int PQrequestCancel ( PGconn* conn ) ;
122 ! Accessor functions for PGconn objects
123 FUNCTION: char* PQdb ( PGconn* conn ) ;
124 FUNCTION: char* PQuser ( PGconn* conn ) ;
125 FUNCTION: char* PQpass ( PGconn* conn ) ;
126 FUNCTION: char* PQhost ( PGconn* conn ) ;
127 FUNCTION: char* PQport ( PGconn* conn ) ;
128 FUNCTION: char* PQtty ( PGconn* conn ) ;
129 FUNCTION: char* PQoptions ( PGconn* conn ) ;
130 FUNCTION: ConnStatusType PQstatus ( PGconn* conn ) ;
131 FUNCTION: PGTransactionStatusType PQtransactionStatus ( PGconn* conn ) ;
132 FUNCTION: char* PQparameterStatus ( PGconn* conn,
134 FUNCTION: int PQprotocolVersion ( PGconn* conn ) ;
135 FUNCTION: int PQServerVersion ( PGconn* conn ) ;
136 FUNCTION: char* PQerrorMessage ( PGconn* conn ) ;
137 FUNCTION: int PQsocket ( PGconn* conn ) ;
138 FUNCTION: int PQbackendPID ( PGconn* conn ) ;
139 FUNCTION: int PQclientEncoding ( PGconn* conn ) ;
140 FUNCTION: int PQsetClientEncoding ( PGconn* conn, char* encoding ) ;
142 ! May not be compiled into libpq
143 ! Get the SSL structure associated with a connection
144 FUNCTION: SSL* PQgetssl ( PGconn* conn ) ;
146 ! Tell libpq whether it needs to initialize OpenSSL
147 FUNCTION: void PQinitSSL ( int do_init ) ;
149 ! Set verbosity for PQerrorMessage and PQresultErrorMessage
150 FUNCTION: PGVerbosity PQsetErrorVerbosity ( PGconn* conn,
151 PGVerbosity verbosity ) ;
153 ! Enable/disable tracing
154 FUNCTION: void PQtrace ( PGconn* conn, FILE* debug_port ) ;
155 FUNCTION: void PQuntrace ( PGconn* conn ) ;
158 ! Function types for notice-handling callbacks
159 ! typedef void (*PQnoticeReceiver) (void *arg, PGresult *res);
160 ! typedef void (*PQnoticeProcessor) (void *arg, char* message);
161 ! ALIAS: void* PQnoticeReceiver
162 ! ALIAS: void* PQnoticeProcessor
164 ! Override default notice handling routines
165 ! FUNCTION: PQnoticeReceiver PQsetNoticeReceiver ( PGconn* conn,
166 ! PQnoticeReceiver proc,
168 ! FUNCTION: PQnoticeProcessor PQsetNoticeProcessor ( PGconn* conn,
169 ! PQnoticeProcessor proc,
173 ! === in fe-exec.c ===
175 ! Simple synchronous query
176 FUNCTION: PGresult* PQexec ( PGconn* conn, char* query ) ;
177 FUNCTION: PGresult* PQexecParams ( PGconn* conn,
185 FUNCTION: PGresult* PQprepare ( PGconn* conn, char* stmtName,
186 char* query, int nParams,
188 FUNCTION: PGresult* PQexecPrepared ( PGconn* conn,
196 ! Interface for multiple-result or asynchronous queries
197 FUNCTION: int PQsendQuery ( PGconn* conn, char* query ) ;
198 FUNCTION: int PQsendQueryParams ( PGconn* conn,
206 FUNCTION: PGresult* PQsendPrepare ( PGconn* conn, char* stmtName,
207 char* query, int nParams,
209 FUNCTION: int PQsendQueryPrepared ( PGconn* conn,
216 FUNCTION: PGresult* PQgetResult ( PGconn* conn ) ;
218 ! Routines for managing an asynchronous query
219 FUNCTION: int PQisBusy ( PGconn* conn ) ;
220 FUNCTION: int PQconsumeInput ( PGconn* conn ) ;
222 ! LISTEN/NOTIFY support
223 FUNCTION: PGnotify* PQnotifies ( PGconn* conn ) ;
225 ! Routines for copy in/out
226 FUNCTION: int PQputCopyData ( PGconn* conn, char* buffer, int nbytes ) ;
227 FUNCTION: int PQputCopyEnd ( PGconn* conn, char* errormsg ) ;
228 FUNCTION: int PQgetCopyData ( PGconn* conn, char** buffer, int async ) ;
230 ! Deprecated routines for copy in/out
231 FUNCTION: int PQgetline ( PGconn* conn, char* string, int length ) ;
232 FUNCTION: int PQputline ( PGconn* conn, char* string ) ;
233 FUNCTION: int PQgetlineAsync ( PGconn* conn, char* buffer, int bufsize ) ;
234 FUNCTION: int PQputnbytes ( PGconn* conn, char* buffer, int nbytes ) ;
235 FUNCTION: int PQendcopy ( PGconn* conn ) ;
237 ! Set blocking/nonblocking connection to the backend
238 FUNCTION: int PQsetnonblocking ( PGconn* conn, int arg ) ;
239 FUNCTION: int PQisnonblocking ( PGconn* conn ) ;
241 ! Force the write buffer to be written (or at least try)
242 FUNCTION: int PQflush ( PGconn* conn ) ;
245 ! * "Fast path" interface --- not really recommended for application
248 FUNCTION: PGresult* PQfn ( PGconn* conn,
256 ! Accessor functions for PGresult objects
257 FUNCTION: ExecStatusType PQresultStatus ( PGresult* res ) ;
258 FUNCTION: char* PQresStatus ( ExecStatusType status ) ;
259 FUNCTION: char* PQresultErrorMessage ( PGresult* res ) ;
260 FUNCTION: char* PQresultErrorField ( PGresult* res, int fieldcode ) ;
261 FUNCTION: int PQntuples ( PGresult* res ) ;
262 FUNCTION: int PQnfields ( PGresult* res ) ;
263 FUNCTION: int PQbinaryTuples ( PGresult* res ) ;
264 FUNCTION: char* PQfname ( PGresult* res, int field_num ) ;
265 FUNCTION: int PQfnumber ( PGresult* res, char* field_name ) ;
266 FUNCTION: Oid PQftable ( PGresult* res, int field_num ) ;
267 FUNCTION: int PQftablecol ( PGresult* res, int field_num ) ;
268 FUNCTION: int PQfformat ( PGresult* res, int field_num ) ;
269 FUNCTION: Oid PQftype ( PGresult* res, int field_num ) ;
270 FUNCTION: int PQfsize ( PGresult* res, int field_num ) ;
271 FUNCTION: int PQfmod ( PGresult* res, int field_num ) ;
272 FUNCTION: char* PQcmdStatus ( PGresult* res ) ;
273 FUNCTION: char* PQoidStatus ( PGresult* res ) ;
274 FUNCTION: Oid PQoidValue ( PGresult* res ) ;
275 FUNCTION: char* PQcmdTuples ( PGresult* res ) ;
276 FUNCTION: char* PQgetvalue ( PGresult* res, int tup_num, int field_num ) ;
277 FUNCTION: int PQgetlength ( PGresult* res, int tup_num, int field_num ) ;
278 FUNCTION: int PQgetisnull ( PGresult* res, int tup_num, int field_num ) ;
281 FUNCTION: void PQclear ( PGresult* res ) ;
283 ! For freeing other alloc'd results, such as PGnotify structs
284 FUNCTION: void PQfreemem ( void* ptr ) ;
286 ! Exists for backward compatibility.
287 : PQfreeNotify PQfreemem ;
290 ! Make an empty PGresult with given status (some apps find this
291 ! useful). If conn is not NULL and status indicates an error, the
292 ! conn's errorMessage is copied.
294 FUNCTION: PGresult* PQmakeEmptyPGresult ( PGconn* conn, ExecStatusType status ) ;
296 ! Quoting strings before inclusion in queries.
297 FUNCTION: size_t PQescapeStringConn ( PGconn* conn,
298 char* to, char* from, size_t length,
300 FUNCTION: uchar* PQescapeByteaConn ( PGconn* conn,
301 char* from, size_t length,
302 size_t* to_length ) ;
303 FUNCTION: uchar* PQunescapeBytea ( uchar* strtext,
304 size_t* retbuflen ) ;
305 ! These forms are deprecated!
306 FUNCTION: size_t PQescapeString ( void* to, char* from, size_t length ) ;
307 FUNCTION: uchar* PQescapeBytea ( uchar* bintext, size_t binlen,
310 ! === in fe-print.c ===
312 FUNCTION: void PQprint ( FILE* fout, PGresult* res, PQprintOpt* ps ) ;
314 ! really old printing routines
315 FUNCTION: void PQdisplayTuples ( PGresult* res,
322 FUNCTION: void PQprintTuples ( PGresult* res,
328 ! === in fe-lobj.c ===
330 ! Large-object access routines
331 FUNCTION: int lo_open ( PGconn* conn, Oid lobjId, int mode ) ;
332 FUNCTION: int lo_close ( PGconn* conn, int fd ) ;
333 FUNCTION: int lo_read ( PGconn* conn, int fd, char* buf, size_t len ) ;
334 FUNCTION: int lo_write ( PGconn* conn, int fd, char* buf, size_t len ) ;
335 FUNCTION: int lo_lseek ( PGconn* conn, int fd, int offset, int whence ) ;
336 FUNCTION: Oid lo_creat ( PGconn* conn, int mode ) ;
337 FUNCTION: Oid lo_creat ( PGconn* conn, Oid lobjId ) ;
338 FUNCTION: int lo_tell ( PGconn* conn, int fd ) ;
339 FUNCTION: int lo_unlink ( PGconn* conn, Oid lobjId ) ;
340 FUNCTION: Oid lo_import ( PGconn* conn, char* filename ) ;
341 FUNCTION: int lo_export ( PGconn* conn, Oid lobjId, char* filename ) ;
343 ! === in fe-misc.c ===
345 ! Determine length of multibyte encoded char at *s
346 FUNCTION: int PQmblen ( uchar* s, int encoding ) ;
348 ! Determine display length of multibyte encoded char at *s
349 FUNCTION: int PQdsplen ( uchar* s, int encoding ) ;
351 ! Get encoding id from environment variable PGCLIENTENCODING
352 FUNCTION: int PQenv2encoding ( ) ;