| 604 | ) |
| 605 | |
| 606 | def _check_result_for_fetch(self) -> PGresult: |
| 607 | if self.closed: |
| 608 | raise e.InterfaceError("the cursor is closed") |
| 609 | |
| 610 | if not (res := self.pgresult): |
| 611 | raise e.ProgrammingError("no result available") |
| 612 | |
| 613 | if (status := res.status) == TUPLES_OK: |
| 614 | return res |
| 615 | elif status == FATAL_ERROR: |
| 616 | raise e.error_from_result(res, encoding=self._encoding) |
| 617 | elif status == PIPELINE_ABORTED: |
| 618 | raise e.PipelineAborted("pipeline aborted") |
| 619 | else: |
| 620 | if res.command_status: |
| 621 | detail = f" (command status: {res.command_status.decode()})" |
| 622 | else: |
| 623 | try: |
| 624 | status_name = pq.ExecStatus(status).name |
| 625 | except ValueError: |
| 626 | status_name = f"{status} - unknown" |
| 627 | detail = f" (result status: {status_name})" |
| 628 | raise e.ProgrammingError( |
| 629 | f"the last operation didn't produce records{detail}" |
| 630 | ) |
| 631 | |
| 632 | def _check_copy_result(self, result: PGresult) -> None: |
| 633 | """ |