wiki:WikiStart

Version 113 (modified by jtv, 9 years ago) (diff)

--

Welcome!

libpqxx is the official C++ client API for PostgreSQL, the enterprise-strength open-source database software. (If "PostgreSQL" is too verbose, call it by its shorter name, postgres).

If you are writing software in C++ that needs to access databases managed by postgres—on just about any platform—then libpqxx is the library you use. The source code is available from here, although in most cases you'd normally work with pre-built binary packages provided by a package maintainer for your specific platform, and distributed through your normal package management infrastructure.

News

2010-10-26: Performance Tips page

I presented some basic query optimization tips at Barcamp this weekend. To my horror, most of my audience had never heard of "EXPLAIN ANALYZE" and other basics. So much for my plan to get past all that and straight to the hard queries.

But since there seems to be an interest, we now have a PerformanceTips page to help users learn how to solve their database performance problems.

2010-10-26: New ticket classification

I just updated the bug tracker to replace the standard but unhelpful "severity" classifications (Critical, Blocker, Severe, and so on) with a different classification developed by Kirit Sælensminde: Fails to communicate failure, breaks, incomplete, unusable, ugly. We're running this as an experiment to help validate his ideas about reporting bug severity.

2010-10-12: another site fix

After fixing the worst of our site problems, we hit a rarer one. It looks solved now: it turns out Trac needs to write to its config file occasionally. Not something we expected, so obviously we had things set up without this privilege.

According to the Trac website, failure to allow writing to the configuration file will frustrate Trac's internal caching. We haven't seen this problem come back since we changed this, so fingers crossed…

2010-09-26: site outages resolved

For the past few months we've had regular site outages and load problems. We finally found the problem: the Subversion server svnserve, which we use for anonymous access, took a long time to start up through inetd and apparently locked up CPU time and networking. This led to Trac processes busy-waiting and the server dropping off the network.

Thanks go to Kirit Sælensminde for continuing to draw attention to the svn problems in particular. Nothing else clearly pointed in the right direction!

2010-09-21: binary-escaping problems renewed

After a long, hard fight with changes in the escaping of binary strings in postgres 9.0, we're now hitting more problems with the 9.1 alpha. See #205. Daily snapshot builds are held up until we can resolve these problems.

Finding Everything

Where What
Sales Pitch Why this library should interest you
Using This Site The various services offered by this development site
Download Page Source archives (no binaries; those depend on your individual platform)
FAQ Frequently Asked Questions, and their answers
Online Documentation Wiki and copies of packaged documentation
Packagers Page Information for maintainers of libpqxx packages
Consulting? Where can I get professional development help?
Bug Tracker Known bugs and requests (as in View Tickets option in top button bar)
Bugs by Milestone Bugs and feature requests, but ordered by milestone
Reporting Bugs How to report a problem or request a new feature
Mailing Lists Hosted on pgFoundry site
Performance Tips Figure out and solve performance problems
Other Projects Other open-source development projects hosted here
libpqxx Elsewhere Sites where libpqxx is registered as a project
Author and Contributors Who made all this?

For issues not suitable for the mailing list or bug tickets, contact the author as jtv at xs4all.nl.

Also, you may want to have a look at the other open source projects hosted on this site.

Technical Overview

This library works on top of the C-level API library, libpq. You will need libpq in order to use libpqxx.

The first thing you're likely to notice in programming with libpqxx is that unlike other libraries, it revolves entirely around transactions. Transactions are a central concept in database management systems, but they are widely underappreciated among application developers. Another well-known open source database system, MySQL, never even got around to implementing them at all in their own engine, relying on a third-party replacement engine (now owned by Oracle) to provide this functionality instead.

It may sometimes be possible to build limited applications reliably without serious use of transactions. More usually, however, applications are designed without transactions simply because the developers aren't aware of the risks they are taking, and any data loss is rare or small enough not to be noticed. That kind of design was not considered acceptable for libpqxx.

With conventional database APIs, you issue commands and queries to a database session or connection, and optionally create the occasional transaction. In libpqxx you start a transaction inside the connection first, do your SQL work using that transaction, then commit the transaction when it's complete. There are several types of transactions with various "quality of service" properties; if you don't really want to use transactions at all, one of the available transaction types is called nontransaction. This transaction type provides classic, nontransactional behaviour.

Every command or query issues a result object, which is really a smart pointer so it can be copied around without incurring much cost in terms of performance. No need to write special code to check these for success; error conditions are converted to regular C++ exceptions. Result objects can be kept around for as long as they are needed, completely separate from the connections and transactions that originated them.


Ohloh Metrics GTF Contributor