| 
									
										
										
										
											2008-02-12 18:19:55 -05:00
										 |  |  | ! Copyright (C) 2007, 2008 Doug Coleman. | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2008-02-03 16:06:31 -05:00
										 |  |  | ! tested on debian linux with postgresql 8.1 | 
					
						
							| 
									
										
										
										
											2014-11-13 16:05:14 -05:00
										 |  |  | USING: alien alien.c-types alien.libraries alien.syntax | 
					
						
							|  |  |  | combinators system ;
 | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | IN: db.postgresql.ffi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-12 18:19:55 -05:00
										 |  |  | << "postgresql" { | 
					
						
							| 
									
										
										
										
											2014-11-13 16:05:14 -05:00
										 |  |  |     { [ os windows? ] [ "libpq.dll" ] } | 
					
						
							| 
									
										
										
										
											2008-04-08 20:43:54 -04:00
										 |  |  |     { [ os macosx? ] [ "libpq.dylib" ] } | 
					
						
							| 
									
										
										
										
											2014-11-13 16:05:14 -05:00
										 |  |  |     { [ os unix? ] [ "libpq.so" ] } | 
					
						
							| 
									
										
										
										
											2010-03-31 22:20:35 -04:00
										 |  |  | } cond cdecl add-library >> | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! ConnSatusType | 
					
						
							| 
									
										
										
										
											2011-11-23 21:49:33 -05:00
										 |  |  | CONSTANT: CONNECTION_OK                     0x0
 | 
					
						
							|  |  |  | CONSTANT: CONNECTION_BAD                    0x1
 | 
					
						
							|  |  |  | CONSTANT: CONNECTION_STARTED                0x2
 | 
					
						
							|  |  |  | CONSTANT: CONNECTION_MADE                   0x3
 | 
					
						
							|  |  |  | CONSTANT: CONNECTION_AWAITING_RESPONSE      0x4
 | 
					
						
							|  |  |  | CONSTANT: CONNECTION_AUTH_OK                0x5
 | 
					
						
							|  |  |  | CONSTANT: CONNECTION_SETENV                 0x6
 | 
					
						
							|  |  |  | CONSTANT: CONNECTION_SSL_STARTUP            0x7
 | 
					
						
							|  |  |  | CONSTANT: CONNECTION_NEEDED                 0x8
 | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! PostgresPollingStatusType | 
					
						
							| 
									
										
										
										
											2011-11-23 21:49:33 -05:00
										 |  |  | CONSTANT: PGRES_POLLING_FAILED              0x0
 | 
					
						
							|  |  |  | CONSTANT: PGRES_POLLING_READING             0x1
 | 
					
						
							|  |  |  | CONSTANT: PGRES_POLLING_WRITING             0x2
 | 
					
						
							|  |  |  | CONSTANT: PGRES_POLLING_OK                  0x3
 | 
					
						
							|  |  |  | CONSTANT: PGRES_POLLING_ACTIVE              0x4
 | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! ExecStatusType; | 
					
						
							| 
									
										
										
										
											2011-11-23 21:49:33 -05:00
										 |  |  | CONSTANT: PGRES_EMPTY_QUERY                 0x0
 | 
					
						
							|  |  |  | CONSTANT: PGRES_COMMAND_OK                  0x1
 | 
					
						
							|  |  |  | CONSTANT: PGRES_TUPLES_OK                   0x2
 | 
					
						
							|  |  |  | CONSTANT: PGRES_COPY_OUT                    0x3
 | 
					
						
							|  |  |  | CONSTANT: PGRES_COPY_IN                     0x4
 | 
					
						
							|  |  |  | CONSTANT: PGRES_BAD_RESPONSE                0x5
 | 
					
						
							|  |  |  | CONSTANT: PGRES_NONFATAL_ERROR              0x6
 | 
					
						
							|  |  |  | CONSTANT: PGRES_FATAL_ERROR                 0x7
 | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! PGTransactionStatusType; | 
					
						
							| 
									
										
										
										
											2011-11-23 21:49:33 -05:00
										 |  |  | CONSTANT: PQTRANS_IDLE                      0x0
 | 
					
						
							|  |  |  | CONSTANT: PQTRANS_ACTIVE                    0x1
 | 
					
						
							|  |  |  | CONSTANT: PQTRANS_INTRANS                   0x2
 | 
					
						
							|  |  |  | CONSTANT: PQTRANS_INERROR                   0x3
 | 
					
						
							|  |  |  | CONSTANT: PQTRANS_UNKNOWN                   0x4
 | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! PGVerbosity; | 
					
						
							| 
									
										
										
										
											2011-11-23 21:49:33 -05:00
										 |  |  | CONSTANT: PQERRORS_TERSE                    0x0
 | 
					
						
							|  |  |  | CONSTANT: PQERRORS_DEFAULT                  0x1
 | 
					
						
							|  |  |  | CONSTANT: PQERRORS_VERBOSE                  0x2
 | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-12 17:36:29 -05:00
										 |  |  | CONSTANT: InvalidOid 0
 | 
					
						
							| 
									
										
										
										
											2008-02-13 17:51:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | TYPEDEF: int ConnStatusType | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | TYPEDEF: int ExecStatusType | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | TYPEDEF: int PostgresPollingStatusType | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | TYPEDEF: int PGTransactionStatusType | 
					
						
							|  |  |  | TYPEDEF: int PGVerbosity | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-27 23:21:24 -04:00
										 |  |  | C-TYPE: PGconn | 
					
						
							|  |  |  | C-TYPE: PGresult | 
					
						
							|  |  |  | C-TYPE: PGcancel | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | TYPEDEF: uint Oid | 
					
						
							|  |  |  | TYPEDEF: char pqbool | 
					
						
							| 
									
										
										
										
											2009-09-27 23:21:24 -04:00
										 |  |  | C-TYPE: PQconninfoOption | 
					
						
							|  |  |  | C-TYPE: PGnotify | 
					
						
							|  |  |  | C-TYPE: PQArgBlock | 
					
						
							|  |  |  | C-TYPE: PQprintOpt | 
					
						
							|  |  |  | C-TYPE: SSL | 
					
						
							|  |  |  | C-TYPE: FILE | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | LIBRARY: postgresql | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Exported functions of libpq | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! make a new client connection to the backend | 
					
						
							|  |  |  | ! Asynchronous (non-blocking) | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: PGconn* PQconnectStart ( c-string conninfo ) | 
					
						
							|  |  |  | FUNCTION: PostgresPollingStatusType PQconnectPoll ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Synchronous (blocking) | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: PGconn* PQconnectdb ( c-string conninfo ) | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  | FUNCTION: PGconn* PQsetdbLogin ( c-string pghost, c-string pgport, | 
					
						
							|  |  |  |              c-string pgoptions, c-string pgtty, | 
					
						
							|  |  |  |              c-string dbName, | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  |              c-string login, c-string pwd ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : PQsetdb ( M_PGHOST M_PGPORT M_PGOPT M_PGTTY M_DBNAME -- PGconn* )
 | 
					
						
							|  |  |  |     f f PQsetdbLogin ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! close the current connection and free the PGconn data structure | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: void PQfinish ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! get info about connection options known to PQconnectdb | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: PQconninfoOption* PQconndefaults ( )
 | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! free the data structure returned by PQconndefaults() | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: void PQconninfoFree ( PQconninfoOption* connOptions ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Asynchronous (non-blocking) | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: int    PQresetStart ( PGconn* conn ) | 
					
						
							|  |  |  | FUNCTION: PostgresPollingStatusType PQresetPoll ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Synchronous (blocking) | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: void PQreset ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! request a cancel structure | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: PGcancel* PQgetCancel ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! free a cancel structure | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: void PQfreeCancel ( PGcancel* cancel ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! issue a cancel request | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: int    PQrequestCancel ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Accessor functions for PGconn objects | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: c-string PQdb ( PGconn* conn ) | 
					
						
							|  |  |  | FUNCTION: c-string PQuser ( PGconn* conn ) | 
					
						
							|  |  |  | FUNCTION: c-string PQpass ( PGconn* conn ) | 
					
						
							|  |  |  | FUNCTION: c-string PQhost ( PGconn* conn ) | 
					
						
							|  |  |  | FUNCTION: c-string PQport ( PGconn* conn ) | 
					
						
							|  |  |  | FUNCTION: c-string PQtty ( PGconn* conn ) | 
					
						
							|  |  |  | FUNCTION: c-string PQoptions ( PGconn* conn ) | 
					
						
							|  |  |  | FUNCTION: ConnStatusType PQstatus ( PGconn* conn ) | 
					
						
							|  |  |  | FUNCTION: PGTransactionStatusType PQtransactionStatus ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  | FUNCTION: c-string PQparameterStatus ( PGconn* conn, | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  |                   c-string paramName ) | 
					
						
							|  |  |  | FUNCTION: int PQprotocolVersion ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2015-07-19 20:45:52 -04:00
										 |  |  | ! FUNCTION: int PQServerVersion ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: c-string PQerrorMessage ( PGconn* conn ) | 
					
						
							|  |  |  | FUNCTION: int PQsocket ( PGconn* conn ) | 
					
						
							|  |  |  | FUNCTION: int PQbackendPID ( PGconn* conn ) | 
					
						
							|  |  |  | FUNCTION: int PQclientEncoding ( PGconn* conn ) | 
					
						
							|  |  |  | FUNCTION: int PQsetClientEncoding ( PGconn* conn, c-string encoding ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! May not be compiled into libpq | 
					
						
							|  |  |  | ! Get the SSL structure associated with a connection | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: SSL* PQgetssl ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Tell libpq whether it needs to initialize OpenSSL | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: void PQinitSSL ( int do_init ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Set verbosity for PQerrorMessage and PQresultErrorMessage | 
					
						
							|  |  |  | FUNCTION: PGVerbosity PQsetErrorVerbosity ( PGconn* conn, | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  |     PGVerbosity verbosity ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Enable/disable tracing | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: void PQtrace ( PGconn* conn, FILE* debug_port ) | 
					
						
							|  |  |  | FUNCTION: void PQuntrace ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! BROKEN | 
					
						
							|  |  |  | ! Function types for notice-handling callbacks | 
					
						
							|  |  |  | ! typedef void (*PQnoticeReceiver) (void *arg, PGresult *res); | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  | ! typedef void (*PQnoticeProcessor) (void *arg, c-string message); | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | ! ALIAS: void* PQnoticeReceiver | 
					
						
							|  |  |  | ! ALIAS: void* PQnoticeProcessor | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Override default notice handling routines | 
					
						
							|  |  |  | ! FUNCTION: PQnoticeReceiver PQsetNoticeReceiver ( PGconn* conn, | 
					
						
							|  |  |  |                     ! PQnoticeReceiver proc, | 
					
						
							| 
									
										
										
										
											2015-07-19 20:45:52 -04:00
										 |  |  |                     ! void* arg ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | ! FUNCTION: PQnoticeProcessor PQsetNoticeProcessor ( PGconn* conn, | 
					
						
							|  |  |  |                     ! PQnoticeProcessor proc, | 
					
						
							| 
									
										
										
										
											2015-07-19 20:45:52 -04:00
										 |  |  |                     ! void* arg ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | ! END BROKEN | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! === in fe-exec.c === | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Simple synchronous query | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: PGresult* PQexec ( PGconn* conn, c-string query ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | FUNCTION: PGresult* PQexecParams ( PGconn* conn, | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  |              c-string command, | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  |              int nParams, | 
					
						
							|  |  |  |              Oid* paramTypes, | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  |              c-string* paramValues, | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  |              int* paramLengths, | 
					
						
							|  |  |  |              int* paramFormats, | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  |              int resultFormat ) | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  | FUNCTION: PGresult* PQprepare ( PGconn* conn, c-string stmtName, | 
					
						
							|  |  |  |         c-string query, int nParams, | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  |         Oid* paramTypes ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | FUNCTION: PGresult* PQexecPrepared ( PGconn* conn, | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  |              c-string stmtName, | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  |              int nParams, | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  |              c-string* paramValues, | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  |              int* paramLengths, | 
					
						
							|  |  |  |              int* paramFormats, | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  |              int resultFormat ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Interface for multiple-result or asynchronous queries | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: int PQsendQuery ( PGconn* conn, c-string query ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | FUNCTION: int PQsendQueryParams ( PGconn* conn, | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  |                   c-string command, | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  |                   int nParams, | 
					
						
							|  |  |  |                   Oid* paramTypes, | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  |                   c-string* paramValues, | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  |                   int* paramLengths, | 
					
						
							|  |  |  |                   int* paramFormats, | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  |                   int resultFormat ) | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  | FUNCTION: PGresult* PQsendPrepare ( PGconn* conn, c-string stmtName, | 
					
						
							|  |  |  |             c-string query, int nParams, | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  |             Oid* paramTypes ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | FUNCTION: int PQsendQueryPrepared ( PGconn* conn, | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  |                   c-string stmtName, | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  |                   int nParams, | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  |                   c-string* paramValues, | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  |                   int *paramLengths, | 
					
						
							|  |  |  |                   int *paramFormats, | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  |                   int resultFormat ) | 
					
						
							|  |  |  | FUNCTION: PGresult* PQgetResult ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Routines for managing an asynchronous query | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: int    PQisBusy ( PGconn* conn ) | 
					
						
							|  |  |  | FUNCTION: int    PQconsumeInput ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! LISTEN/NOTIFY support | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: PGnotify* PQnotifies ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Routines for copy in/out | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: int    PQputCopyData ( PGconn* conn, c-string buffer, int nbytes ) | 
					
						
							|  |  |  | FUNCTION: int    PQputCopyEnd ( PGconn* conn, c-string errormsg ) | 
					
						
							|  |  |  | FUNCTION: int    PQgetCopyData ( PGconn* conn, c-string* buffer, int async ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Deprecated routines for copy in/out | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: int    PQgetline ( PGconn* conn, c-string string, int length ) | 
					
						
							|  |  |  | FUNCTION: int    PQputline ( PGconn* conn, c-string string ) | 
					
						
							|  |  |  | FUNCTION: int    PQgetlineAsync ( PGconn* conn, c-string buffer, int bufsize ) | 
					
						
							|  |  |  | FUNCTION: int    PQputnbytes ( PGconn* conn, c-string buffer, int nbytes ) | 
					
						
							|  |  |  | FUNCTION: int    PQendcopy ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Set blocking/nonblocking connection to the backend | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: int    PQsetnonblocking ( PGconn* conn, int arg ) | 
					
						
							|  |  |  | FUNCTION: int    PQisnonblocking ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Force the write buffer to be written (or at least try) | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: int    PQflush ( PGconn* conn ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  | !
 | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | ! * "Fast path" interface --- not really recommended for application | 
					
						
							|  |  |  | ! * use | 
					
						
							|  |  |  | !
 | 
					
						
							|  |  |  | FUNCTION: PGresult* PQfn ( PGconn* conn, | 
					
						
							|  |  |  |      int fnid, | 
					
						
							|  |  |  |      int* result_buf, | 
					
						
							|  |  |  |      int* result_len, | 
					
						
							|  |  |  |      int result_is_int, | 
					
						
							|  |  |  |      PQArgBlock* args, | 
					
						
							| 
									
										
										
										
											2015-07-19 20:43:09 -04:00
										 |  |  |      int nargs ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Accessor functions for PGresult objects | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: ExecStatusType PQresultStatus ( PGresult* res ) | 
					
						
							|  |  |  | FUNCTION: c-string PQresStatus ( ExecStatusType status ) | 
					
						
							|  |  |  | FUNCTION: c-string PQresultErrorMessage ( PGresult* res ) | 
					
						
							|  |  |  | FUNCTION: c-string PQresultErrorField ( PGresult* res, int fieldcode ) | 
					
						
							|  |  |  | FUNCTION: int   PQntuples ( PGresult* res ) | 
					
						
							|  |  |  | FUNCTION: int   PQnfields ( PGresult* res ) | 
					
						
							|  |  |  | FUNCTION: int   PQbinaryTuples ( PGresult* res ) | 
					
						
							|  |  |  | FUNCTION: c-string PQfname ( PGresult* res, int field_num ) | 
					
						
							|  |  |  | FUNCTION: int   PQfnumber ( PGresult* res, c-string field_name ) | 
					
						
							|  |  |  | FUNCTION: Oid   PQftable ( PGresult* res, int field_num ) | 
					
						
							|  |  |  | FUNCTION: int   PQftablecol ( PGresult* res, int field_num ) | 
					
						
							|  |  |  | FUNCTION: int   PQfformat ( PGresult* res, int field_num ) | 
					
						
							|  |  |  | FUNCTION: Oid   PQftype ( PGresult* res, int field_num ) | 
					
						
							|  |  |  | FUNCTION: int   PQfsize ( PGresult* res, int field_num ) | 
					
						
							|  |  |  | FUNCTION: int   PQfmod ( PGresult* res, int field_num ) | 
					
						
							|  |  |  | FUNCTION: c-string PQcmdStatus ( PGresult* res ) | 
					
						
							|  |  |  | FUNCTION: c-string PQoidStatus ( PGresult* res ) | 
					
						
							|  |  |  | FUNCTION: Oid   PQoidValue ( PGresult* res ) | 
					
						
							|  |  |  | FUNCTION: c-string PQcmdTuples ( PGresult* res ) | 
					
						
							| 
									
										
										
										
											2015-07-19 20:45:52 -04:00
										 |  |  | ! FUNCTION: c-string PQgetvalue ( PGresult* res, int tup_num, int field_num ) | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: void* PQgetvalue ( PGresult* res, int tup_num, int field_num ) | 
					
						
							|  |  |  | FUNCTION: int   PQgetlength ( PGresult* res, int tup_num, int field_num ) | 
					
						
							|  |  |  | FUNCTION: int   PQgetisnull ( PGresult* res, int tup_num, int field_num ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Delete a PGresult | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: void PQclear ( PGresult* res ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! For freeing other alloc'd results, such as PGnotify structs | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: void PQfreemem ( void* ptr ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Exists for backward compatibility. | 
					
						
							| 
									
										
										
										
											2008-06-09 03:14:14 -04:00
										 |  |  | : PQfreeNotify ( ptr -- ) PQfreemem ;
 | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | !
 | 
					
						
							|  |  |  | ! Make an empty PGresult with given status (some apps find this | 
					
						
							|  |  |  | ! useful). If conn is not NULL and status indicates an error, the | 
					
						
							|  |  |  | ! conn's errorMessage is copied. | 
					
						
							|  |  |  | !
 | 
					
						
							| 
									
										
										
										
											2015-07-19 20:45:52 -04:00
										 |  |  | FUNCTION: PGresult* PQmakeEmptyPGresult ( PGconn* conn, ExecStatusType status ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Quoting strings before inclusion in queries. | 
					
						
							|  |  |  | FUNCTION: size_t PQescapeStringConn ( PGconn* conn, | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  |                                     c-string to, c-string from, size_t length, | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  |                                     int* error ) | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  | FUNCTION: c-string PQescapeByteaConn ( PGconn* conn, | 
					
						
							|  |  |  |                                     c-string from, size_t length, | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  |                                     size_t* to_length ) | 
					
						
							|  |  |  | FUNCTION: void* PQunescapeBytea ( c-string strtext, size_t* retbuflen ) | 
					
						
							| 
									
										
										
										
											2015-07-19 20:45:52 -04:00
										 |  |  | ! FUNCTION: c-string PQunescapeBytea ( c-string strtext, size_t* retbuflen ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | ! These forms are deprecated! | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: size_t PQescapeString ( void* to, c-string from, size_t length ) | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  | FUNCTION: c-string PQescapeBytea ( c-string bintext, size_t binlen, | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  |               size_t* bytealen ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! === in fe-print.c === | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: void PQprint ( FILE* fout, PGresult* res, PQprintOpt* ps ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! really old printing routines | 
					
						
							|  |  |  | FUNCTION: void PQdisplayTuples ( PGresult* res, | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  |                                 FILE* fp, | 
					
						
							| 
									
										
										
										
											2008-02-02 01:29:47 -05:00
										 |  |  |                                 int fillAlign, | 
					
						
							| 
									
										
										
										
											2010-02-23 14:42:02 -05:00
										 |  |  |                                 c-string fieldSep, | 
					
						
							| 
									
										
										
										
											2008-02-02 01:29:47 -05:00
										 |  |  |                                 int printHeader, | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  |                                 int quiet ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | FUNCTION: void PQprintTuples ( PGresult* res, | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  |                           FILE* fout, | 
					
						
							| 
									
										
										
										
											2008-02-02 01:29:47 -05:00
										 |  |  |                           int printAttName, | 
					
						
							| 
									
										
										
										
											2015-06-29 19:43:15 -04:00
										 |  |  |                           int terseOutput, | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  |                           int width ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | ! === in fe-lobj.c === | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Large-object access routines | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: int    lo_open ( PGconn* conn, Oid lobjId, int mode ) | 
					
						
							|  |  |  | FUNCTION: int    lo_close ( PGconn* conn, int fd ) | 
					
						
							|  |  |  | FUNCTION: int    lo_read ( PGconn* conn, int fd, c-string buf, size_t len ) | 
					
						
							|  |  |  | FUNCTION: int    lo_write ( PGconn* conn, int fd, c-string buf, size_t len ) | 
					
						
							|  |  |  | FUNCTION: int    lo_lseek ( PGconn* conn, int fd, int offset, int whence ) | 
					
						
							|  |  |  | FUNCTION: Oid    lo_creat ( PGconn* conn, int mode ) | 
					
						
							| 
									
										
										
										
											2015-07-19 20:45:52 -04:00
										 |  |  | ! FUNCTION: Oid    lo_creat ( PGconn* conn, Oid lobjId ) | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: int    lo_tell ( PGconn* conn, int fd ) | 
					
						
							|  |  |  | FUNCTION: int    lo_unlink ( PGconn* conn, Oid lobjId ) | 
					
						
							|  |  |  | FUNCTION: Oid    lo_import ( PGconn* conn, c-string filename ) | 
					
						
							|  |  |  | FUNCTION: int    lo_export ( PGconn* conn, Oid lobjId, c-string filename ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! === in fe-misc.c === | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ! Determine length of multibyte encoded char at *s | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: int    PQmblen ( c-string s, int encoding ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Determine display length of multibyte encoded char at *s | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: int    PQdsplen ( c-string s, int encoding ) | 
					
						
							| 
									
										
										
										
											2008-02-01 18:43:44 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! Get encoding id from environment variable PGCLIENTENCODING | 
					
						
							| 
									
										
										
										
											2015-07-19 19:25:30 -04:00
										 |  |  | FUNCTION: int    PQenv2encoding ( )
 | 
					
						
							| 
									
										
										
										
											2008-03-11 01:05:22 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ! From git, include/catalog/pg_type.h | 
					
						
							| 
									
										
										
										
											2009-02-12 17:36:29 -05:00
										 |  |  | CONSTANT: BOOL-OID 16
 | 
					
						
							|  |  |  | CONSTANT: BYTEA-OID 17
 | 
					
						
							|  |  |  | CONSTANT: CHAR-OID 18
 | 
					
						
							|  |  |  | CONSTANT: NAME-OID 19
 | 
					
						
							|  |  |  | CONSTANT: INT8-OID 20
 | 
					
						
							|  |  |  | CONSTANT: INT2-OID 21
 | 
					
						
							|  |  |  | CONSTANT: INT4-OID 23
 | 
					
						
							|  |  |  | CONSTANT: TEXT-OID 23
 | 
					
						
							|  |  |  | CONSTANT: OID-OID 26
 | 
					
						
							|  |  |  | CONSTANT: FLOAT4-OID 700
 | 
					
						
							|  |  |  | CONSTANT: FLOAT8-OID 701
 | 
					
						
							|  |  |  | CONSTANT: VARCHAR-OID 1043
 | 
					
						
							|  |  |  | CONSTANT: DATE-OID 1082
 | 
					
						
							|  |  |  | CONSTANT: TIME-OID 1083
 | 
					
						
							|  |  |  | CONSTANT: TIMESTAMP-OID 1114
 | 
					
						
							|  |  |  | CONSTANT: TIMESTAMPTZ-OID 1184
 | 
					
						
							|  |  |  | CONSTANT: INTERVAL-OID 1186
 | 
					
						
							|  |  |  | CONSTANT: NUMERIC-OID 1700
 |