Rupert Kittinger-Sereinig | 20 Oct 10:03 2007

Re: [old-libpqxx-general] Any decision on implicit conversion to std::string or at least operator== ?

Hi everybody,

I would also like to see some enhancement in this issue. I think it is 
mainly a question of style, but my codebase is full of calls to c_str() 
for this reason.

I do not like the idea of configuring at compile time, this will just 
add some preprocessor acrobatics to the headers.

I would prefer to have all the comparison operators that are provided 
for std::strings, and I would implement them as free functions that live 
in a different header file. Those who do not want them need not #include 


> So, to summarize my new proposal: in case you don't have a
> decision, or that you're inclined not to include it, may I propose
> that you include these features as *optional* features that could
> be enabled at configure-time?   I'm talking about:
> ./configure --enable-implicit-string
> or
> ./configure --enable-operator==string
(Continue reading)

Geeky Jim | 14 Sep 17:06 2007

How to compile libpqxx as 32bit library on 64bit x86_64 systems?

Dear list members,

I am having difficulties creating libpqxx 2.6.9 as a 32bit library on 64bit x86_64 systems. 

I am running FC7 using  gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20070502 (Red Hat 4.1.2-12)

uname -m

I am still new to GNU's buildtools.  I tried to insert these flags in but it did not help.

CFLAGS += -m32

Any pointers?


Libpqxx-general mailing list
Shannon Allen | 5 Sep 00:03 2007

lostream to a file

I am trying to get comfortable using the lostream class for large 
objects.  I have a large binary file that I am storing in a BLOB that I 
can get back out using largeobjectaccess and then use the to_file(file) 
method to write it back out and that works fine.  However, I want to 
give users streaming functionality, but I need to know how to do it 
first :-) .

What I would like to do first is stream this back out to a file, similar 
to what I've already done with largeobjectaccess::to_file(file), but 
instead I want to use lostream.

Given this code, what do I need to do next?

   pqxx::work w(*atr->getConn(),me);
   pqxx::ilostream s(w, id5);

   ofstream file("test.seqb", ios::out | ios::binary | ios::trunc);
   cout << "Streaming blob into a file " << endl;

   //This isn't right
      file << s;
   cout << "Done Streaming blob into a file " << endl;
Shannon Allen | 30 Aug 19:38 2007

Re: using tablewriter with binary data

Was this issue resolved?  I am trying to load a .png image file into a 
BYTEA column and before my upgrade (was using 2.6.9) I was getting a 
server error stating there was a data exception error on the COPY 
command.  Now, after the upgrade, I am no longer getting an "error" but 
I looks like only the 1st 8 bytes are being written to the bytea column.

If I use a standard INSERT command it goes in just fine.

Just looking at my table and my bytea column using PGADMIN

Using INSERT this is what's in the bytea column

Using tablewriter this is all that is written

Any insights??



is there a way to successfully use tablewriter to insert
binary data?

The problem I am seeing is that applying escape_binary() to
the tuple
value yields an extra level of escaping (which breaks), and
either not
escaping at all or using sqlesc() breaks as expected as soon
as a null
byte is encountered.

I looked at the source and the tablewriter seems to do it's
escaping of a select few characters (tabs, whitespace,
backslash, a
few more), but I see no way to make this either generic
anything) or optional.

Any input would be appreciated.

Jeroen T. Vermeulen | 14 Aug 21:10 2007

Re: PQCancel

On Mon, August 13, 2007 15:55, rclemley@... wrote:

>>One problem is, all this asynchronous stuff requires locking.  We don't
>> do
>>that right now, and it's a pretty big step to take.
> I think that the cancellation methods could be added to pqxx without
> implementing locking.  One of my biggest concerns in implementing
> request cancellation in pqxx was how to implement the tests.

I can imagine, yes.  It's not perfect, but perhaps the pg_sleep() function
could help here.  One thread can do a "select pg_sleep(60)" while another
can wait 5 seconds (or whatever you feel is long enough that it won't fail
just because the test system happens to be busy) and then cancel the

> I am preparing to replace all of our home-brew database objects'
> implementations with libpqxx.  The program is multi-threaded so we
> already handle locking issues in other ways at higher-levels.

That's the general policy for libpqxx at the moment anyway, so whoever
follows that should be okay.

> Statement cancellation is the only thing we need that's missing in pqxx.

Thanks for working on this!

Jeroen T. Vermeulen | 13 Aug 09:22 2007

Moving mailing lists

Hello all,

This mailing list is moving!

The site that has been hosting this mailing list, GBorg, is being
decommissioned.  The libpqxx-general and libpqxx-announce mailing lists
are moving to its replacement, pgFoundry:

The main project page, however, remains at

I don't know exactly when the list you are getting this from will
disappear, but I expect it to be soon.  So please, if you wish to continue
reading either or both of these lists, please go over there now and

Starting now, all new threads on libpqxx-general will be directed to the
new list.  I hope you will accept my apologies for this inconvenience, and
join us on the other side.

Rob Lemley | 10 Aug 18:50 2007


I am interested in adding PQCancel (and friends) support to libpqxx.

I've found one mention of it in the TODO
but it seems to have been removed from the current TODO.

Currently we use PQrequestCancel() to stop long running queries
when our application server (ie postgresql client) must shutdown.

Before I go further, I was wondering anyone has insights
about using PQCancel (PQrequestCancel is deprecated),
and/or implementing a cancel function in libpqxx (presumably
as a member of the connection_base class).


Denis Dzyubenko | 10 Aug 14:38 2007

problem with writing large floating point values to postgres


I have a problem with writing values of type double in pqxx. I've
already created a ticket (#116), but received no feedback. Maybe the
ticket was unclear, so I'll try to explain my problem.

The problem is that when writing large double values to iostream, it
is displayed in exponential form, omitting last digits. So, when this
number in exponental form converted back to double, it gets rounded
and significant digits is lost.

For example, if I do this:

std::cout << 12345678;

I'll get '1.23457e+007' on screen, and as you see - last two digits
were omitted and in fact, the number is rounded to '12345700'.
This can be fixed by specifying the precision to iostream library:

std::cout << 12345678;

And this time, I'll get on screen the number I expected '12345678'.

Since pqxx::to_string/from_string uses std::stringstream for
converting double values, we face the problem that when I try to write
large 'double' to postgres, the number that is actually written is the
rounded one.

Here is the test application that uses pqxx::to_string/from_string

#include <iostream>
#include <string>
#include <pqxx/pqxx>

int main(int, char**)
  std::stringstream ss;

  const double orig_value = 12345678;
  double value;

  // converting double to string and vice versa
  std::string str_value = pqxx::to_string(orig_value);
  pqxx::from_string(str_value, value);

  // using C-function
  printf("printf:\n \torig = %f \n\tnew  = %f\n", orig_value, value);

  // using iostream with default params
  std::cout << std::endl << "cout: " << std::endl
            << "\torig = " << orig_value << std::endl
            << "\tnew  = " << value << std::endl;

  // using iostream and manually specifying the floating value precision
  std::cout << std::endl << "cout with precision: " << std::endl
            << "\torig = " << orig_value << std::endl
            << "\tnew  = " << value << std::endl;
  return 0;

And its output:

        orig = 12345678.000000
        new  = 12345700.000000

        orig = 1.23457e+007
        new  = 1.23457e+007

cout with precision:
        orig = 12345678
        new  = 12345700

As you can see, after using to_string/from_string the number becomes incorrect.

This problem can be fixed by adding the following line to function
'to_string_fallback' in util.cxx

template<typename T> inline string to_string_fallback(T Obj)
  stringstream S;
  S.precision(41); // ADD THIS LINE
  S << Obj;
  string R;
  S >> R;
  return R;


Rilson Nascimento | 10 Aug 05:24 2007

connection in TIME_WAIT with pqxx

Hi there,

I am using pqxx in a multi-threaded server that connects to a PostgreSQL database. I'm experiencing a problem in which my server leaves a bunch of TIME_WAIT socket connection with the PostgreSQL server when it is running.

When I run 'netstat -tcp' I see literally hundreds of connections from my server to PgSQL in TIME_WAIT state (see below), even after a short period of server activity:
tcp     0     0  localhost:38727       localhost:5432         TIME_WAIT

I'm using pqxx's lazyconnection. Actually there is only ONE client running in a loop sending transactions to the server (via tcp socket), which in turn connects to the PgSQL database via a lazyconnection (I tried with the usual connection object too).

I guess this is an effect of poor networking programming (socket programming) and/or poor pqxx programming.
Whatever, What should I do to realize this is not a problem related with misusing of pqxx? I mean, I want to be sure I am using pqxx in the right fashion to ensure this problem is not caused by pqxx.

Thanks for your help,


Libpqxx-general mailing list
Jacob Rief | 9 Aug 09:57 2007

Solution for "array in a result query"

in February there was a request about retrieving binary data from table rows containing array-data.
Jeroen T. Vermeulen replyed that array support will be integrated. I now worked on that same matter and I
found a solution, which is a bit tricky, but it works. I even wrote a template class to implement this feature.
If there is any interrest, I would like to publish this workarround on the wiki. Where shall I post this?

GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung:
DALE PEDERSEN | 26 Jul 23:00 2007

m.pedersen@...: Re: pqxx-config script

is this you?
Libpqxx-general mailing list