* PQreset: resets the connection to the backend by closing the * existing connection and creating a new one. */
| 4407 | * existing connection and creating a new one. |
| 4408 | */ |
| 4409 | void |
| 4410 | PQreset(PGconn *conn) |
| 4411 | { |
| 4412 | if (conn) |
| 4413 | { |
| 4414 | closePGconn(conn); |
| 4415 | |
| 4416 | if (connectDBStart(conn) && connectDBComplete(conn)) |
| 4417 | { |
| 4418 | /* |
| 4419 | * Notify event procs of successful reset. We treat an event proc |
| 4420 | * failure as disabling the connection ... good idea? |
| 4421 | */ |
| 4422 | int i; |
| 4423 | |
| 4424 | for (i = 0; i < conn->nEvents; i++) |
| 4425 | { |
| 4426 | PGEventConnReset evt; |
| 4427 | |
| 4428 | evt.conn = conn; |
| 4429 | if (!conn->events[i].proc(PGEVT_CONNRESET, &evt, |
| 4430 | conn->events[i].passThrough)) |
| 4431 | { |
| 4432 | conn->status = CONNECTION_BAD; |
| 4433 | appendPQExpBuffer(&conn->errorMessage, |
| 4434 | libpq_gettext("PGEventProc \"%s\" failed during PGEVT_CONNRESET event\n"), |
| 4435 | conn->events[i].name); |
| 4436 | break; |
| 4437 | } |
| 4438 | } |
| 4439 | } |
| 4440 | } |
| 4441 | } |
| 4442 | |
| 4443 | |
| 4444 | /* |
no test coverage detected