| 330 | } |
| 331 | |
| 332 | void dut_libpq::connect(std::string &conninfo) |
| 333 | { |
| 334 | if (conn) { |
| 335 | PQfinish(conn); |
| 336 | } |
| 337 | conn = PQconnectdb(conninfo.c_str()); |
| 338 | if (PQstatus(conn) != CONNECTION_OK) |
| 339 | { |
| 340 | char *errmsg = PQerrorMessage(conn); |
| 341 | if (strlen(errmsg)) |
| 342 | throw dut::broken(errmsg, "08001"); |
| 343 | } |
| 344 | |
| 345 | command("set statement_timeout to '1s'"); |
| 346 | command("set client_min_messages to 'ERROR';"); |
| 347 | command("set application_name to '" PACKAGE "::dut';"); |
| 348 | |
| 349 | PQsetNoticeReceiver(conn, dut_libpq_notice_rx, (void *) 0); |
| 350 | } |
| 351 | |
| 352 | dut_libpq::dut_libpq(std::string conninfo) |
| 353 | : conninfo_(conninfo) |