Search Postgresql Archives

Re: Libpq question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/21/2012 7:56 AM, Merlin Moncure wrote:
On Sun, May 20, 2012 at 2:52 PM, John Townsend
<jtownsend@xxxxxxxxxxxxxxxxxxxx> wrote:
By by-passing the "dll" (or "so" on Linux) library I mean you write function
or procedure calls to the server that is running as a service on Windows.
You don't use the library with its 160 exported functions. You connect
directly to the server thus saving one layer of protocols.  To do this, you
have to translate all the c functions you need (not just the headers or ".h"
files) into pascal. Not a trivial task!
It is possible to write functions and procedures on the server but
they must still be invoked from the client side.  Currently the only
way to use any server side features is through the frontend/backend
protocol.  libpq is a library that handles the frontend side of the
processing -- that's why the header is named libpq-fe.h: it's for the
front end.  You can bypass libpq but that would mean you'd have to
write your own client side handler for the protocol -- definitely a
non-trivial project and you'd probably end up with something worse
than libpq unless you are an expert programmer.
Therein lies the problem, - I am not an expert. I know quite a bit about Delphi & SQL, but that's it.

But to be a good you need to know both languages very well, that is C++ and pascal. Translating the header files is easy,  that's why most developers use libpq.dll or .so. One uses only about 20 or so functions - that is - for most projects. Translating the C++ function body (some are pretty long and complex) takes more knowledge, not only about C but about PostGreSQL.

Also, you must then translate all the internal functions that libpq uses. There are currently 160 functions exported.

This kind of a project was done all the time by Borland programmers in the past.


In other words, you can bypass libpq itself but not the protocol.  To
bypass the protocol, start moving your code into server functions.
Using pascal (Delphi or FPC). How would this be done? This is the ultimate goal.

Would it be worth it? Depends, but for most situations would not give you
more speed. With FPC comes a nice utility called h2pas.exe that does a
decent job and can save you a lot of time. You still have to clean some
translations.
I believe Zeos has an already converted .pas file for libpq.

Yes, they have translated the most used functions, the c header files, that is. My count shows ~ 70 out of 160.

Thanks for your reply.

John


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux