Deallocate one, or all, prepared statement in the session. ``name == None`` stands for DEALLOCATE ALL. If possible, use protocol-level commands; otherwise use SQL statements. Note that PgBouncer doesn't support DEALLOCATE name, but it supports protocol-lev
(self, name: bytes | None)
| 489 | return result |
| 490 | |
| 491 | def _deallocate(self, name: bytes | None) -> PQGen[None]: |
| 492 | """ |
| 493 | Deallocate one, or all, prepared statement in the session. |
| 494 | |
| 495 | ``name == None`` stands for DEALLOCATE ALL. |
| 496 | |
| 497 | If possible, use protocol-level commands; otherwise use SQL statements. |
| 498 | |
| 499 | Note that PgBouncer doesn't support DEALLOCATE name, but it supports |
| 500 | protocol-level Close from 1.21 and DEALLOCATE ALL from 1.22. |
| 501 | """ |
| 502 | if name is None or not _HAS_SEND_CLOSE: |
| 503 | stmt = b"DEALLOCATE " + name if name is not None else b"DEALLOCATE ALL" |
| 504 | yield from self._exec_command(stmt) |
| 505 | return |
| 506 | |
| 507 | self._check_connection_ok() |
| 508 | |
| 509 | if self._pipeline: |
| 510 | cmd = partial(self.pgconn.send_close_prepared, name) |
| 511 | self._pipeline.command_queue.append(cmd) |
| 512 | self._pipeline.result_queue.append(None) |
| 513 | return |
| 514 | |
| 515 | self.pgconn.send_close_prepared(name) |
| 516 | |
| 517 | result = (yield from generators.execute(self.pgconn))[-1] |
| 518 | if result.status != COMMAND_OK: |
| 519 | if result.status == FATAL_ERROR: |
| 520 | raise e.error_from_result(result, encoding=self.pgconn._encoding) |
| 521 | else: |
| 522 | raise e.InterfaceError( |
| 523 | f"unexpected result {pq.ExecStatus(result.status).name}" |
| 524 | " from sending closing prepared statement message" |
| 525 | ) |
| 526 | |
| 527 | def _check_connection_ok(self) -> None: |
| 528 | if self.pgconn.status == OK: |
no test coverage detected