Skip to content

Commit dc138a9

Browse files
committed
BUG22476689: Importing world.sql fails with cext enabled
This patch fixes the importing of world.sql with the C extension enabled. A test was added for regression.
1 parent b92eab2 commit dc138a9

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

lib/mysql/connector/cursor_cext.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ def _execute_iter(self):
205205
if exc.errno != CR_NO_RESULT_SET:
206206
raise
207207
i += 1
208-
self._executed = executed_list[i].strip()
208+
try:
209+
self._executed = executed_list[i].strip()
210+
except IndexError:
211+
self._executed = executed_list[0]
209212
yield self
210213
return
211214

tests/cext/test_cext_cursor.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
# MySQL Connector/Python - MySQL driver written in Python.
3-
# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
3+
# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
44

55
# MySQL Connector/Python is licensed under the terms of the GPLv2
66
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -29,6 +29,7 @@
2929
import unittest
3030

3131
from mysql.connector import errors, errorcode
32+
from .. import PY2
3233

3334
import tests
3435

@@ -516,6 +517,28 @@ def tests_execute_multi(self):
516517
cur.close()
517518
self.cnx.rollback()
518519

520+
cur = self._get_cursor(self.cnx)
521+
cur.execute("DROP PROCEDURE IF EXISTS multi_results")
522+
procedure = (
523+
"CREATE PROCEDURE multi_results () "
524+
"BEGIN SELECT 1; SELECT 'ham'; END"
525+
)
526+
cur.execute(procedure)
527+
stmt = "CALL multi_results()"
528+
if not PY2:
529+
stmt = b"CALL multi_results()"
530+
exp_result = [[(1,)], [(u'ham',)]]
531+
results = []
532+
for result in cur.execute(stmt, multi=True):
533+
if result.with_rows:
534+
self.assertEqual(stmt, result._executed)
535+
results.append(result.fetchall())
536+
537+
self.assertEqual(exp_result, results)
538+
cur.execute("DROP PROCEDURE multi_results")
539+
540+
cur.close()
541+
519542

520543
class CExtMySQLCursorBufferedTests(tests.CMySQLCursorTests):
521544

0 commit comments

Comments
 (0)