[GENERAL] libpq - prevent automatic reconnect

2012-12-05 Thread icholy
libpq will automatically reconnect if the connection is dropped. auto con = PQconnectdb("info");while (true) {PQclear(PQexec(con, "SELECT * FROM foo LIMIT 1")); std::this_thread::sleep_for(std::chrono::seconds(1));std::cout << "here " << i++ << std::endl; } $ sudo ifconfig eth0 do

Re: [GENERAL] libpq error message deallocation

2012-12-04 Thread icholy
thanks for the quick reply! -- View this message in context: http://postgresql.1045698.n5.nabble.com/libpq-error-message-deallocation-tp5735032p5735046.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@postgresql

[GENERAL] libpq error message deallocation

2012-12-04 Thread icholy
PQerrorMessage function return char const* char const* msg = PQerrorMessage(conn); Now since it's const, I don't think I should be deallocating it and I've never seen that done in any examples. But then, when and how does it get freed? At first I thought it gets deallocated once another error m

Re: [GENERAL] libpq - PQsendQuery wait for complete result

2012-11-30 Thread icholy
Albe Laurenz *EXTERN* wrote > If you have a single SQL statement, you will get only one > PQresult. You get more than one if you send a query string > with more than one statement, e.g. > > PQsendQuery(conn, "SELECT 42; SELECT 'Hello'"); > > would result in two PQresults. > > You can get multip

[GENERAL] libpq - PQsendQuery wait for complete result

2012-11-29 Thread icholy
I'm having problem with libpq's *PQexec* function hanging on intermittent connections. After searching around, the solution seems to be to use the asynchronous functions *PQsendQuery*/*PQgetResult* and implement your own timeout. Now the issue I'm facing is that *PQgetResult* needs to be called m