Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #526 #527

Merged
merged 2 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions vertica_python/tests/integration_tests/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,28 @@ def test_nextset_with_error(self):
with self.assertRaises(errors.MissingColumn):
cur.nextset()

# test for #526
def test_nextset_with_error_2(self):
with self._connect() as conn:
cur = conn.cursor()
cur.execute("CREATE TABLE {0} (a INT, b INT)".format(self._table))
# insert data
cur.execute("INSERT INTO {0} (a, b) VALUES (8, 2)".format(self._table))
cur.execute("INSERT INTO {0} (a, b) VALUES (2, 0)".format(self._table))
conn.commit()

cur.execute("SELECT 1; SELECT a/b FROM {}; SELECT 2".format(self._table))
# verify data from first query
res1 = cur.fetchall()
self.assertListOfListsEqual(res1, [[1]])
self.assertIsNone(cur.fetchone())

self.assertTrue(cur.nextset())
self.assertEqual(cur.fetchone()[0], Decimal('4'))
# Division by zero error at the second row, should be skipped by next nextset()
self.assertFalse(cur.nextset())
self.assertIsNone(cur.fetchone())

def test_qmark_paramstyle(self):
with self._connect() as conn:
cur = conn.cursor()
Expand Down
3 changes: 2 additions & 1 deletion vertica_python/vertica/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ def flush_to_end_of_result(self):

while True:
message = self.connection.read_message()
if isinstance(message, END_OF_RESULT_RESPONSES):
if (isinstance(message, messages.ReadyForQuery) or
isinstance(message, END_OF_RESULT_RESPONSES)):
self._message = message
break

Expand Down