in mysql-connector-python/lib/mysql/connector/cursor_cext.py [0:0]
def nextset(self) -> Optional[bool]:
if self._connection.next_result():
# prepare cursor to load the next result set, and ultimately, load it.
self._reset_result(free=False, preserve_last_executed_stmt=True)
if not self._connection.result_set_available:
self._handle_result(self._connection.fetch_eof_status())
else:
self._handle_result(self._connection.fetch_eof_columns())
# if mapping is enabled, run the if-block, otherwise simply return `True`.
if self._stmt_partitions is not None and self._stmt_map_results:
if not self._stmt_partition["single_stmts"]:
# It means there are still results to be consumed, but no more
# statements to relate these results to.
# In this case, we raise a no fatal error and don't clear
# `_executed` so its current value is reported when users
# access the property `statement`.
# If this case ever happens, a bug report should be filed,
# assuming it is happening on supported use cases.
warnings.warn(
"MappingWarning: Number of result sets greater than number "
"of single statements."
)
else:
self._executed = self._stmt_partition["single_stmts"].popleft()
return True
if self._stmt_partitions is not None:
# Let's see if there are more mappable statements (partitions)
# to be executed.
# If there are no more partitions, we simply return `None`, otherwise
# we execute the correponding mappable multi statement and repeat the
# process all over again.
try:
self._stmt_partition = next(self._stmt_partitions)
except StopIteration:
pass
else:
# This block only happens when mapping is enabled because when it
# is disabled, only one partition is generated, and at this point,
# such partiton has already been processed.
self._executed = self._stmt_partition["single_stmts"].popleft()
try:
self._handle_result(
self._connection.cmd_query(
self._stmt_partition["mappable_stmt"],
raw=self._raw,
buffered=self._buffered,
raw_as_string=self._raw_as_string,
)
)
except MySQLInterfaceError as err:
if hasattr(err, "errno"):
raise get_mysql_exception(
err.errno, msg=err.msg, sqlstate=err.sqlstate
) from err
raise InterfaceError(str(err)) from err
return True
self._reset_result(free=True)
return None