MCPcopy
hub / github.com/psycopg/psycopg / _rollback_gen

Method _rollback_gen

psycopg/psycopg/_connection_base.py:590–615  ·  view source on GitHub ↗

Generator implementing `Connection.rollback()`.

(self)

Source from the content-addressed store, hash-verified

588 yield from self._pipeline._sync_gen()
589
590 def _rollback_gen(self) -> PQGen[None]:
591 """Generator implementing `Connection.rollback()`."""
592 if self._num_transactions:
593 raise e.ProgrammingError(
594 "Explicit rollback() forbidden within a Transaction "
595 "context. (Either raise Rollback() or allow "
596 "an exception to propagate out of the context.)"
597 )
598 if self._tpc:
599 raise e.ProgrammingError(
600 "rollback() cannot be used during a two-phase transaction"
601 )
602
603 # Get out of a "pipeline aborted" state
604 if self._pipeline:
605 yield from self._pipeline._sync_gen()
606
607 if self.pgconn.transaction_status == IDLE:
608 return
609
610 yield from self._exec_command(b"ROLLBACK")
611 self._prepared.clear()
612 yield from self._prepared.maintain_gen(self)
613
614 if self._pipeline:
615 yield from self._pipeline._sync_gen()
616
617 def xid(self, format_id: int, gtrid: str, bqual: str) -> Xid:
618 """

Callers

nothing calls this directly

Calls 4

_exec_commandMethod · 0.95
_sync_genMethod · 0.80
maintain_genMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected