2
0

postgres3dyn.pp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. {
  2. Contains the Postgres protocol 3 functions calls
  3. Call InitialisePostgres3 before using any of the calls, and call ReleasePostgres3
  4. when finished.
  5. }
  6. unit postgres3dyn;
  7. {$mode objfpc}{$H+}
  8. interface
  9. uses
  10. dynlibs, SysUtils, dllistdyn;
  11. {$IFDEF Unix}
  12. const
  13. pqlib = 'libpq.so';
  14. {$ENDIF}
  15. {$IFDEF Win32}
  16. const
  17. pqlib = 'libpq.dll';
  18. {$ENDIF}
  19. {$PACKRECORDS C}
  20. {$i postgres3types.inc}
  21. var
  22. { ----------------
  23. * Exported functions of libpq
  24. * ----------------
  25. }
  26. { === in fe-connect.c === }
  27. { make a new client connection to the backend }
  28. { Asynchronous (non-blocking) }
  29. (* Const before type ignored *)
  30. PQconnectStart : function (conninfo:Pchar):PPGconn;cdecl;
  31. PQconnectPoll : function (conn:PPGconn):PostgresPollingStatusType;cdecl;
  32. { Synchronous (blocking) }
  33. (* Const before type ignored *)
  34. PQconnectdb : function (conninfo:Pchar):PPGconn;cdecl;
  35. PQsetdbLogin : function (pghost:Pchar; pgport:Pchar; pgoptions:Pchar; pgtty:Pchar; dbName:Pchar;login:Pchar; pwd:Pchar):PPGconn;cdecl;
  36. { was #define dname(params) para_def_expr }
  37. { argument types are unknown }
  38. { return type might be wrong }
  39. { close the current connection and free the PGconn data structure }
  40. PQfinish : procedure (conn:PPGconn);cdecl;
  41. { get info about connection options known to PQconnectdb }
  42. PQconndefaults : function : PPQconninfoOption;cdecl;
  43. { free the data structure returned by PQconndefaults() }
  44. PQconninfoFree : procedure (connOptions:PPQconninfoOption);cdecl;
  45. {
  46. * close the current connection and restablish a new one with the same
  47. * parameters
  48. }
  49. { Asynchronous (non-blocking) }
  50. PQresetStart : function (conn:PPGconn):longint;cdecl;
  51. PQresetPoll : function (conn:PPGconn):PostgresPollingStatusType;cdecl;
  52. { Synchronous (blocking) }
  53. PQreset : procedure (conn:PPGconn);cdecl;
  54. { issue a cancel request }
  55. PQrequestCancel : function (conn:PPGconn):longint;cdecl;
  56. { Accessor functions for PGconn objects }
  57. PQdb : function (conn:PPGconn):Pchar;cdecl;
  58. PQuser : function (conn:PPGconn):Pchar;cdecl;
  59. PQpass : function (conn:PPGconn):Pchar;cdecl;
  60. PQhost : function (conn:PPGconn):Pchar;cdecl;
  61. PQport : function (conn:PPGconn):Pchar;cdecl;
  62. PQtty : function (conn:PPGconn):Pchar;cdecl;
  63. PQoptions : function (conn:PPGconn):Pchar;cdecl;
  64. PQstatus : function (conn:PPGconn):TConnStatusType;cdecl;
  65. PQtransactionStatus : function (conn:PPGconn):PGTransactionStatusType;cdecl;
  66. PQparameterStatus : function (conn:PPGconn; paramName:Pchar):Pchar;cdecl;
  67. PQprotocolVersion : function (conn:PPGconn):longint;cdecl;
  68. PQerrorMessage : function (conn:PPGconn):Pchar;cdecl;
  69. PQsocket : function (conn:PPGconn):longint;cdecl;
  70. PQbackendPID : function (conn:PPGconn):longint;cdecl;
  71. PQclientEncoding : function (conn:PPGconn):longint;cdecl;
  72. PQsetClientEncoding : function (conn:PPGconn; encoding:Pchar):longint;cdecl;
  73. {$ifdef USE_SSL}
  74. { Get the SSL structure associated with a connection }
  75. PQgetssl : function (conn:PPGconn):PSSL;cdecl;
  76. {$endif}
  77. { Set verbosity for PQerrorMessage and PQresultErrorMessage }
  78. PQsetErrorVerbosity : function (conn:PPGconn; verbosity:PGVerbosity):PGVerbosity;cdecl;
  79. { Enable/disable tracing }
  80. PQtrace : procedure (conn:PPGconn; debug_port:PFILE);cdecl;
  81. PQuntrace : procedure (conn:PPGconn);cdecl;
  82. { Override default notice handling routines }
  83. PQsetNoticeReceiver : function (conn:PPGconn; proc:PQnoticeReceiver; arg:pointer):PQnoticeReceiver;cdecl;
  84. PQsetNoticeProcessor : function (conn:PPGconn; proc:PQnoticeProcessor; arg:pointer):PQnoticeProcessor;cdecl;
  85. { === in fe-exec.c === }
  86. { Simple synchronous query }
  87. PQexec : function (conn:PPGconn; query:Pchar):PPGresult;cdecl;
  88. PQexecParams : function (conn:PPGconn; command:Pchar; nParams:longint; paramTypes:POid; paramValues:PPchar;paramLengths:Plongint; paramFormats:Plongint; resultFormat:longint):PPGresult;cdecl;
  89. PQexecPrepared : function (conn:PPGconn; stmtName:Pchar; nParams:longint; paramValues:PPchar; paramLengths:Plongint;paramFormats:Plongint; resultFormat:longint):PPGresult;cdecl;
  90. { Interface for multiple-result or asynchronous queries }
  91. PQsendQuery : function (conn:PPGconn; query:Pchar):longint;cdecl;
  92. PQsendQueryParams : function (conn:PPGconn; command:Pchar; nParams:longint; paramTypes:POid; paramValues:PPchar;paramLengths:Plongint; paramFormats:Plongint; resultFormat:longint):longint;cdecl;
  93. PQsendQueryPrepared : function (conn:PPGconn; stmtName:Pchar; nParams:longint; paramValues:PPchar; paramLengths:Plongint;paramFormats:Plongint; resultFormat:longint):longint;cdecl;
  94. PQgetResult : function (conn:PPGconn):PPGresult;cdecl;
  95. { Routines for managing an asynchronous query }
  96. PQisBusy : function (conn:PPGconn):longint;cdecl;
  97. PQconsumeInput : function (conn:PPGconn):longint;cdecl;
  98. { LISTEN/NOTIFY support }
  99. PQnotifies : function (conn:PPGconn):PPGnotify;cdecl;
  100. { Routines for copy in/out }
  101. PQputCopyData : function (conn:PPGconn; buffer:Pchar; nbytes:longint):longint;cdecl;
  102. PQputCopyEnd : function (conn:PPGconn; errormsg:Pchar):longint;cdecl;
  103. PQgetCopyData : function (conn:PPGconn; buffer:PPchar; async:longint):longint;cdecl;
  104. { Deprecated routines for copy in/out }
  105. PQgetline : function (conn:PPGconn; _string:Pchar; length:longint):longint;cdecl;
  106. PQputline : function (conn:PPGconn; _string:Pchar):longint;cdecl;
  107. PQgetlineAsync : function (conn:PPGconn; buffer:Pchar; bufsize:longint):longint;cdecl;
  108. PQputnbytes : function (conn:PPGconn; buffer:Pchar; nbytes:longint):longint;cdecl;
  109. PQendcopy : function (conn:PPGconn):longint;cdecl;
  110. { Set blocking/nonblocking connection to the backend }
  111. PQsetnonblocking : function (conn:PPGconn; arg:longint):longint;cdecl;
  112. PQisnonblocking : function (conn:PPGconn):longint;cdecl;
  113. { Force the write buffer to be written (or at least try) }
  114. PQflush : function (conn:PPGconn):longint;cdecl;
  115. {
  116. * "Fast path" interface --- not really recommended for application
  117. * use
  118. }
  119. PQfn : function (conn:PPGconn; fnid:longint; result_buf:Plongint; result_len:Plongint; result_is_int:longint;args:PPQArgBlock; nargs:longint):PPGresult;cdecl;
  120. { Accessor functions for PGresult objects }
  121. PQresultStatus : function (res:PPGresult):TExecStatusType;cdecl;
  122. PQresStatus : function (status:TExecStatusType):Pchar;cdecl;
  123. PQresultErrorMessage : function (res:PPGresult):Pchar;cdecl;
  124. PQresultErrorField : function (res:PPGresult; fieldcode:longint):Pchar;cdecl;
  125. PQntuples : function (res:PPGresult):longint;cdecl;
  126. PQnfields : function (res:PPGresult):longint;cdecl;
  127. PQbinaryTuples : function (res:PPGresult):longint;cdecl;
  128. PQfname : function (res:PPGresult; field_num:longint):Pchar;cdecl;
  129. PQfnumber : function (res:PPGresult; field_name:Pchar):longint;cdecl;
  130. PQftable : function (res:PPGresult; field_num:longint):Oid;cdecl;
  131. PQftablecol : function (res:PPGresult; field_num:longint):longint;cdecl;
  132. PQfformat : function (res:PPGresult; field_num:longint):longint;cdecl;
  133. PQftype : function (res:PPGresult; field_num:longint):Oid;cdecl;
  134. PQfsize : function (res:PPGresult; field_num:longint):longint;cdecl;
  135. PQfmod : function (res:PPGresult; field_num:longint):longint;cdecl;
  136. PQcmdStatus : function (res:PPGresult):Pchar;cdecl;
  137. PQoidStatus : function (res:PPGresult):Pchar;cdecl;
  138. { old and ugly }
  139. PQoidValue : function (res:PPGresult):Oid;cdecl;
  140. { new and improved }
  141. PQcmdTuples : function (res:PPGresult):Pchar;cdecl;
  142. PQgetvalue : function (res:PPGresult; tup_num:longint; field_num:longint):Pchar;cdecl;
  143. PQgetlength : function (res:PPGresult; tup_num:longint; field_num:longint):longint;cdecl;
  144. PQgetisnull : function (res:PPGresult; tup_num:longint; field_num:longint):longint;cdecl;
  145. { Delete a PGresult }
  146. PQclear : procedure (res:PPGresult);cdecl;
  147. { For freeing other alloc'd results, such as PGnotify structs }
  148. PQfreemem : procedure (ptr:pointer);cdecl;
  149. { Exists for backward compatibility. bjm 2003-03-24 }
  150. { was #define dname(params) para_def_expr }
  151. { argument types are unknown }
  152. { return type might be wrong }
  153. // function PQfreeNotify(ptr : longint) : longint;
  154. {
  155. * Make an empty PGresult with given status (some apps find this
  156. * useful). If conn is not NULL and status indicates an error, the
  157. * conn's errorMessage is copied.
  158. }
  159. PQmakeEmptyPGresult : function (conn:PPGconn; status:TExecStatusType):PPGresult;cdecl;
  160. { Quoting strings before inclusion in queries. }
  161. PQescapeString : function (till:Pchar; from:Pchar; length:size_t):size_t;cdecl;
  162. PQescapeBytea : function (bintext:Pbyte; binlen:size_t; bytealen:Psize_t):Pbyte;cdecl;
  163. PQunescapeBytea : function (strtext:Pbyte; retbuflen:Psize_t):Pbyte;cdecl;
  164. { === in fe-print.c === }
  165. { output stream }
  166. PQprint : procedure (fout:PFILE; res:PPGresult; ps:PPQprintOpt);cdecl;
  167. { option structure }
  168. {
  169. * really old printing routines
  170. }
  171. { where to send the output }
  172. { pad the fields with spaces }
  173. { field separator }
  174. { display headers? }
  175. PQdisplayTuples : procedure (res:PPGresult; fp:PFILE; fillAlign:longint; fieldSep:Pchar; printHeader:longint;quiet:longint);cdecl;
  176. (* Const before type ignored *)
  177. { output stream }
  178. { print attribute names }
  179. { delimiter bars }
  180. PQprintTuples : procedure (res:PPGresult; fout:PFILE; printAttName:longint; terseOutput:longint; width:longint);cdecl;
  181. { width of column, if 0, use variable
  182. * width }
  183. { === in fe-lobj.c === }
  184. { Large-object access routines }
  185. lo_open : function (conn:PPGconn; lobjId:Oid; mode:longint):longint;cdecl;
  186. lo_close : function (conn:PPGconn; fd:longint):longint;cdecl;
  187. lo_read : function (conn:PPGconn; fd:longint; buf:Pchar; len:size_t):longint;cdecl;
  188. lo_write : function (conn:PPGconn; fd:longint; buf:Pchar; len:size_t):longint;cdecl;
  189. lo_lseek : function (conn:PPGconn; fd:longint; offset:longint; whence:longint):longint;cdecl;
  190. lo_creat : function (conn:PPGconn; mode:longint):Oid;cdecl;
  191. lo_tell : function (conn:PPGconn; fd:longint):longint;cdecl;
  192. lo_unlink : function (conn:PPGconn; lobjId:Oid):longint;cdecl;
  193. lo_import : function (conn:PPGconn; filename:Pchar):Oid;cdecl;
  194. lo_export : function (conn:PPGconn; lobjId:Oid; filename:Pchar):longint;cdecl;
  195. { === in fe-misc.c === }
  196. { Determine length of multibyte encoded char at *s }
  197. PQmblen : function (s:Pbyte; encoding:longint):longint;cdecl;
  198. { Get encoding id from environment variable PGCLIENTENCODING }
  199. PQenv2encoding: function :longint;cdecl;
  200. Procedure InitialisePostgres3;
  201. Procedure ReleasePostgres3;
  202. var Postgres3LibraryHandle : TLibHandle;
  203. implementation
  204. var RefCount : integer;
  205. Procedure InitialisePostgres3;
  206. begin
  207. inc(RefCount);
  208. if RefCount = 1 then
  209. begin
  210. Postgres3LibraryHandle := loadlibrary(pqlib);
  211. if Postgres3LibraryHandle = nilhandle then
  212. begin
  213. RefCount := 0;
  214. Raise EInOutError.Create('Can not load PosgreSQL client. Is it installed? ('+pqlib+')');
  215. end;
  216. pointer(PQconnectStart) := GetProcedureAddress(Postgres3LibraryHandle,'PQconnectStart');
  217. pointer(PQconnectPoll) := GetProcedureAddress(Postgres3LibraryHandle,'PQconnectPoll');
  218. pointer(PQconnectdb) := GetProcedureAddress(Postgres3LibraryHandle,'PQconnectdb');
  219. pointer(PQsetdbLogin) := GetProcedureAddress(Postgres3LibraryHandle,'PQsetdbLogin');
  220. pointer(PQfinish) := GetProcedureAddress(Postgres3LibraryHandle,'PQfinish');
  221. pointer(PQconndefaults) := GetProcedureAddress(Postgres3LibraryHandle,'PQconndefaults');
  222. pointer(PQconninfoFree) := GetProcedureAddress(Postgres3LibraryHandle,'PQconninfoFree');
  223. pointer(PQresetStart) := GetProcedureAddress(Postgres3LibraryHandle,'PQresetStart');
  224. pointer(PQresetPoll) := GetProcedureAddress(Postgres3LibraryHandle,'PQresetPoll');
  225. pointer(PQreset) := GetProcedureAddress(Postgres3LibraryHandle,'PQreset');
  226. pointer(PQrequestCancel) := GetProcedureAddress(Postgres3LibraryHandle,'PQrequestCancel');
  227. pointer(PQdb) := GetProcedureAddress(Postgres3LibraryHandle,'PQdb');
  228. pointer(PQuser) := GetProcedureAddress(Postgres3LibraryHandle,'PQuser');
  229. pointer(PQpass) := GetProcedureAddress(Postgres3LibraryHandle,'PQpass');
  230. pointer(PQhost) := GetProcedureAddress(Postgres3LibraryHandle,'PQhost');
  231. pointer(PQport) := GetProcedureAddress(Postgres3LibraryHandle,'PQport');
  232. pointer(PQtty) := GetProcedureAddress(Postgres3LibraryHandle,'PQtty');
  233. pointer(PQoptions) := GetProcedureAddress(Postgres3LibraryHandle,'PQoptions');
  234. pointer(PQstatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQstatus');
  235. pointer(PQtransactionStatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQtransactionStatus');
  236. pointer(PQparameterStatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQparameterStatus');
  237. pointer(PQprotocolVersion) := GetProcedureAddress(Postgres3LibraryHandle,'PQprotocolVersion');
  238. pointer(PQerrorMessage) := GetProcedureAddress(Postgres3LibraryHandle,'PQerrorMessage');
  239. pointer(PQsocket) := GetProcedureAddress(Postgres3LibraryHandle,'PQsocket');
  240. pointer(PQbackendPID) := GetProcedureAddress(Postgres3LibraryHandle,'PQbackendPID');
  241. pointer(PQclientEncoding) := GetProcedureAddress(Postgres3LibraryHandle,'PQclientEncoding');
  242. pointer(PQsetClientEncoding) := GetProcedureAddress(Postgres3LibraryHandle,'PQsetClientEncoding');
  243. {$ifdef USE_SSL}
  244. pointer(PQgetssl) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetssl');
  245. {$endif}
  246. pointer(PQsetErrorVerbosity) := GetProcedureAddress(Postgres3LibraryHandle,'PQsetErrorVerbosity');
  247. pointer(PQtrace) := GetProcedureAddress(Postgres3LibraryHandle,'PQtrace');
  248. pointer(PQuntrace) := GetProcedureAddress(Postgres3LibraryHandle,'PQuntrace');
  249. pointer(PQsetNoticeReceiver) := GetProcedureAddress(Postgres3LibraryHandle,'PQsetNoticeReceiver');
  250. pointer(PQsetNoticeProcessor) := GetProcedureAddress(Postgres3LibraryHandle,'PQsetNoticeProcessor');
  251. pointer(PQexec) := GetProcedureAddress(Postgres3LibraryHandle,'PQexec');
  252. pointer(PQexecParams) := GetProcedureAddress(Postgres3LibraryHandle,'PQexecParams');
  253. pointer(PQexecPrepared) := GetProcedureAddress(Postgres3LibraryHandle,'PQexecPrepared');
  254. pointer(PQsendQuery) := GetProcedureAddress(Postgres3LibraryHandle,'PQsendQuery');
  255. pointer(PQsendQueryParams) := GetProcedureAddress(Postgres3LibraryHandle,'PQsendQueryParams');
  256. pointer(PQsendQueryPrepared) := GetProcedureAddress(Postgres3LibraryHandle,'PQsendQueryPrepared');
  257. pointer(PQgetResult) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetResult');
  258. pointer(PQisBusy) := GetProcedureAddress(Postgres3LibraryHandle,'PQisBusy');
  259. pointer(PQconsumeInput) := GetProcedureAddress(Postgres3LibraryHandle,'PQconsumeInput');
  260. pointer(PQnotifies) := GetProcedureAddress(Postgres3LibraryHandle,'PQnotifies');
  261. pointer(PQputCopyData) := GetProcedureAddress(Postgres3LibraryHandle,'PQputCopyData');
  262. pointer(PQputCopyEnd) := GetProcedureAddress(Postgres3LibraryHandle,'PQputCopyEnd');
  263. pointer(PQgetCopyData) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetCopyData');
  264. pointer(PQgetline) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetline');
  265. pointer(PQputline) := GetProcedureAddress(Postgres3LibraryHandle,'PQputline');
  266. pointer(PQgetlineAsync) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetlineAsync');
  267. pointer(PQputnbytes) := GetProcedureAddress(Postgres3LibraryHandle,'PQputnbytes');
  268. pointer(PQendcopy) := GetProcedureAddress(Postgres3LibraryHandle,'PQendcopy');
  269. pointer(PQsetnonblocking) := GetProcedureAddress(Postgres3LibraryHandle,'PQsetnonblocking');
  270. pointer(PQisnonblocking) := GetProcedureAddress(Postgres3LibraryHandle,'PQisnonblocking');
  271. pointer(PQflush) := GetProcedureAddress(Postgres3LibraryHandle,'PQflush');
  272. pointer(PQfn) := GetProcedureAddress(Postgres3LibraryHandle,'PQfn');
  273. pointer(PQresultStatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQresultStatus');
  274. pointer(PQresStatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQresStatus');
  275. pointer(PQresultErrorMessage) := GetProcedureAddress(Postgres3LibraryHandle,'PQresultErrorMessage');
  276. pointer(PQresultErrorField) := GetProcedureAddress(Postgres3LibraryHandle,'PQresultErrorField');
  277. pointer(PQntuples) := GetProcedureAddress(Postgres3LibraryHandle,'PQntuples');
  278. pointer(PQnfields) := GetProcedureAddress(Postgres3LibraryHandle,'PQnfields');
  279. pointer(PQbinaryTuples) := GetProcedureAddress(Postgres3LibraryHandle,'PQbinaryTuples');
  280. pointer(PQfname) := GetProcedureAddress(Postgres3LibraryHandle,'PQfname');
  281. pointer(PQfnumber) := GetProcedureAddress(Postgres3LibraryHandle,'PQfnumber');
  282. pointer(PQftable) := GetProcedureAddress(Postgres3LibraryHandle,'PQftable');
  283. pointer(PQftablecol) := GetProcedureAddress(Postgres3LibraryHandle,'PQftablecol');
  284. pointer(PQfformat) := GetProcedureAddress(Postgres3LibraryHandle,'PQfformat');
  285. pointer(PQftype) := GetProcedureAddress(Postgres3LibraryHandle,'PQftype');
  286. pointer(PQfsize) := GetProcedureAddress(Postgres3LibraryHandle,'PQfsize');
  287. pointer(PQfmod) := GetProcedureAddress(Postgres3LibraryHandle,'PQfmod');
  288. pointer(PQcmdStatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQcmdStatus');
  289. pointer(PQoidStatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQoidStatus');
  290. pointer(PQoidValue) := GetProcedureAddress(Postgres3LibraryHandle,'PQoidValue');
  291. pointer(PQcmdTuples) := GetProcedureAddress(Postgres3LibraryHandle,'PQcmdTuples');
  292. pointer(PQgetvalue) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetvalue');
  293. pointer(PQgetlength) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetlength');
  294. pointer(PQgetisnull) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetisnull');
  295. pointer(PQclear) := GetProcedureAddress(Postgres3LibraryHandle,'PQclear');
  296. pointer(PQfreemem) := GetProcedureAddress(Postgres3LibraryHandle,'PQfreemem');
  297. pointer(PQmakeEmptyPGresult) := GetProcedureAddress(Postgres3LibraryHandle,'PQmakeEmptyPGresult');
  298. pointer(PQescapeString) := GetProcedureAddress(Postgres3LibraryHandle,'PQescapeString');
  299. pointer(PQescapeBytea) := GetProcedureAddress(Postgres3LibraryHandle,'PQescapeBytea');
  300. pointer(PQunescapeBytea) := GetProcedureAddress(Postgres3LibraryHandle,'PQunescapeBytea');
  301. pointer(PQprint) := GetProcedureAddress(Postgres3LibraryHandle,'PQprint');
  302. pointer(PQdisplayTuples) := GetProcedureAddress(Postgres3LibraryHandle,'PQdisplayTuples');
  303. pointer(PQprintTuples) := GetProcedureAddress(Postgres3LibraryHandle,'PQprintTuples');
  304. pointer(lo_open) := GetProcedureAddress(Postgres3LibraryHandle,'lo_open');
  305. pointer(lo_close) := GetProcedureAddress(Postgres3LibraryHandle,'lo_close');
  306. pointer(lo_read) := GetProcedureAddress(Postgres3LibraryHandle,'lo_read');
  307. pointer(lo_write) := GetProcedureAddress(Postgres3LibraryHandle,'lo_write');
  308. pointer(lo_lseek) := GetProcedureAddress(Postgres3LibraryHandle,'lo_lseek');
  309. pointer(lo_creat) := GetProcedureAddress(Postgres3LibraryHandle,'lo_creat');
  310. pointer(lo_tell) := GetProcedureAddress(Postgres3LibraryHandle,'lo_tell');
  311. pointer(lo_unlink) := GetProcedureAddress(Postgres3LibraryHandle,'lo_unlink');
  312. pointer(lo_import) := GetProcedureAddress(Postgres3LibraryHandle,'lo_import');
  313. pointer(lo_export) := GetProcedureAddress(Postgres3LibraryHandle,'lo_export');
  314. pointer(PQmblen) := GetProcedureAddress(Postgres3LibraryHandle,'PQmblen');
  315. pointer(PQenv2encoding) := GetProcedureAddress(Postgres3LibraryHandle,'PQenv2encoding');
  316. InitialiseDllist;
  317. end;
  318. end;
  319. Procedure ReleasePostgres3;
  320. begin
  321. if RefCount > 0 then dec(RefCount);
  322. if RefCount = 0 then
  323. begin
  324. if not UnloadLibrary(Postgres3LibraryHandle) then inc(RefCount);
  325. ReleaseDllist;
  326. end;
  327. end;
  328. // This function is also defined in postgres3!
  329. function PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME : pchar) : ppgconn;
  330. begin
  331. PQsetdb:=PQsetdbLogin(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME,'','');
  332. end;
  333. end.