From cd82f2f1340f20515c7501401ae6224e40481634 Mon Sep 17 00:00:00 2001 From: sitingren Date: Mon, 7 Aug 2023 09:27:33 +0000 Subject: [PATCH 1/2] fix #526 --- vertica_python/vertica/cursor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vertica_python/vertica/cursor.py b/vertica_python/vertica/cursor.py index 06e33057..25dc7c7d 100644 --- a/vertica_python/vertica/cursor.py +++ b/vertica_python/vertica/cursor.py @@ -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 From f604e41973e7af30612264d07a771408e7dc095b Mon Sep 17 00:00:00 2001 From: sitingren Date: Mon, 7 Aug 2023 10:27:03 +0000 Subject: [PATCH 2/2] add test --- .../tests/integration_tests/test_cursor.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/vertica_python/tests/integration_tests/test_cursor.py b/vertica_python/tests/integration_tests/test_cursor.py index 122052b2..41b4d5f1 100644 --- a/vertica_python/tests/integration_tests/test_cursor.py +++ b/vertica_python/tests/integration_tests/test_cursor.py @@ -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()