results = yield from self._maybe_prepare_gen(
pgq, prepare=prepare, binary=binary
)
- self._set_results(results)
+ self._check_results(results)
+ self._results = results
self._set_result(0)
self._last_query = query
pgq.dump(params)
results = yield from self._maybe_prepare_gen(pgq, prepare=True)
- self._set_results(results)
+ self._check_results(results)
for res in results:
nrows += res.command_tuples or 0
ExecStatus.COPY_BOTH,
)
- def _set_results(self, results: List["PGresult"]) -> None:
+ def _check_results(self, results: List["PGresult"]) -> None:
"""
- Set the results from a query into the cursor state.
+ Verify that the results of a query are valid.
+
+ Verify that the query returned at least one result and that they all
+ represent a valid result from the database.
"""
if not results:
raise e.InternalError("got no result from the query")
if res.status not in self._status_ok:
self._raise_from_results(results)
- self._results = results
-
def _set_result(self, i: int, format: Optional[Format] = None) -> None:
"""
Select one of the results in the cursor as the active one.
conn = cur._conn
conn.pgconn.send_describe_portal(self.name.encode(cur._encoding))
results = yield from execute(conn.pgconn)
- cur._set_results(results)
+ cur._check_results(results)
+ cur._results = results
cur._set_result(0, format=self._format)
self.described = True