Feature Questions
What happened to (some libpq++ class)? Why isn't it there anymore?
See "I want to use libpq++ and I have a question''" in the General section.
Is libpqxx Managed Code / Managed C++?
No: libpqxx is C++. Microsoft's .NET "Managed C++" is effectively a different language that is to some extent compatible with C++.
So far as we've heard, you can't link lipqxx into a Managed Code program. At least not directly; there may be some indirect way of doing it.
Data is transferred in text form. Can I make it work directly in binary?
Many people ask for this feature because they are looking for increased performance. The underlying libpq library can transfer all data in binary form, but this is not likely to be supported in libpqxx any time soon. There are good reasons for this. In a nutshell, in most cases it wouldn't help much (if at all) yet it wouldn't come for free even for those who didn't use it.
Nevertheless, there are special cases where binary transfers do make sense, and these are fully supported by libpqxx:
- Large objects or blobs. These are stored separately from regular data, and can be accessed using a file-like API. It's possible to retrieve or even rewrite just a small part of a very large object, for example, without having to transfer the whole thing to the client and back to the server.
- Prepared statements can take binary parameters. Some applications wrap INSERT statements in prepared statements to save the server from having to parse the entire statement, so for inserting data this may be close to what you're doing already. But for efficient bulk insertion of data, the tablewriter class is probably a better choice.
Apart from large objects, unfortunately, there is no way to retrieve regular data in binary form. If you want to work with relatively large binary objects but do not wish to use the large-object API, the best alternative is to keep them in regular columns of BYTEA type. Insert them using a prepared statement to avoid text conversion on the way to the server, and retrieve them into binarystring objects.
Can I let libpqxx write data from the database directly into my objects so I can access SQL fields as if they were C++ struct/class members?
No. This may be added at some point in the future, as a separate layer of abstraction.
Roger Leigh is working on a library that offers something along the lines of object persistence. It's called libpqxx-object and builds on top of libpqxx. At the time of this FAQ's writing, however, it's still experimental.
For my program I need to access some C-level libpq structure that libpqxx hides from me. Can you add a member function that lets me do this?
Generally, no. If you require support for specific high-level functionality, the better solution is usually to build it into the abstraction layer rather than to break the abstraction layer open like this.
Also, the isolation that the abstraction layer provides allows libpqxx to do things like automatic connection recovery. Such things can be impossible if the library does not have full and unique control over the underlying C-level structures, or in other cases they might lead to subtle and complex bugs in your program.
Feel free, however, to prototype enhancements that meet your own needs, see what works best for you, and then submit a feature request.
Can I have two or more simultaneous transactions?
Not within the same connection. Even if you use nested transactions (see the subtransaction class), a connection is always dealing with just one transaction at a time. Of course you can create a new transaction on the same connection once the previous one has completed.
If you want to have multiple concurrent transactions, let them work on different connections. An easy way to do this is to set up a connection pool: create a bunch of lazyconnection objects, all initialized with the same connection string. Connections of this type will set themselves up only when they are actually used, so there is no big cost to creating more than you're going to use.
