postgres3dyn.pp 22 KB

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