Re: 'translate' libpq++ to libpqxx

From: jtv(at)xs4all(dot)nl
To: "Michiel Lange" <michiel(at)minas(dot)demon(dot)nl>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: 'translate' libpq++ to libpqxx
Date: 2003-04-20 16:49:08
Message-ID: 16246.24.132.41.217.1050857348.squirrel@webmail.xs4all.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces


> But the class 'PgConnection' seems to exist no more, and I hoped there
> would be an easy way to replace all occurrences of a function with another
> (it would have been even better if the syntaxes would be comparable, but
> that might have been not a good idea...)

Unfortunately for you, libpqxx and libpq++ are completely separate beasts
(http://gborg.postgresql.org/project/libpqxx/faq/faq.php?faq_id=91) and so
a one-to-one translation is not always possible. The real problem is
often that libpq++-based code often doesn't use exceptions (which in turn
typically means that the code is broken anyway).

Changing this can make your program much shorter, more maintainable, and
more reliable... But the update may involve your whole code, unless
you're willing to isolate the exceptions-enabled pieces of code in
try-catch blocks, which of course isn't quite as much fun.

The other major issue to take into account is how your program deals with
transactions. If it doesn't, fine. If it does, a poorly structured
program may need to be refactored to make the change possible.

These things aside, and the fact that a good deal of low-level error
handling code should become unnecessary (libpqxx does safe retries, for
instance, so you don't need to worry about them), there are no major
obstacles that I'm currently aware of.

I'll make a note to write a bit more about conversion of existing code in
the manual. And then (sigh) find a working way to translate it into HTML.

Jeroen

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message ljb 2003-04-21 00:20:26 FE/BE Protocol 3.0 Draft - Some Comments
Previous Message jtv 2003-04-20 16:32:44 Re: Getting to learn libpqxx