[Libpqxx-general] connection closing early?
Jeroen Vermeulen
jtv at xs4all.nl
Sat Sep 26 11:05:30 UTC 2009
Caleb Cushing wrote:
> try {
> connection conn("user=xenoterracide dbname=xenoterracide");
> work tran(conn);
>
> tran.exec("SET client_min_messages=warning;");
> tran.commit();
> cout << "check" << endl; //connection dies about here
> tran.exec("DROP SCHEMA IF EXISTS korama CASCADE;"
> "CREATE SCHEMA korama;");
> tran.commit();
> cout << "check" << endl;
>
> ...
>
> I'm guess the connection is gone after the commit() is that right? it
> doesn't seem right...
No, the connection stays. The transaction finishes at that point, which
means that you can open a new one on the same connection.
Please don't stuff multiple statements into a single exec call; I can't
guarantee that it'll work. Also, please use set_variable on
transactions or connections if you want to set variables, not raw SQL.
Jeroen
More information about the Libpqxx-general
mailing list