Check return code of db_generate_bulk_request

When inserting data via parameter callback function, an error
will be raised.
This commit is contained in:
Georg Richter
2024-09-14 15:31:57 +02:00
parent e705d637ea
commit afb3ccd778
2 changed files with 17 additions and 0 deletions

View File

@ -1225,7 +1225,10 @@ MrdbCursor_execute_bulk(MrdbCursor *self)
mysql_stmt_bind_param(self->stmt, self->params);
if (!(buf= self->connection->mysql->methods->db_execute_generate_request(self->stmt, &buflen, 1)))
{
mariadb_throw_exception(self->stmt, NULL, 1, NULL);
goto error;
}
if ((rc= Mrdb_execute_direct(self, self->parseinfo.statement, self->parseinfo.statement_len)))
{

View File

@ -1614,6 +1614,20 @@ class TestCursor(unittest.TestCase):
cursor.close()
connection.close()
def test_conpy291(self):
connection = create_connection()
cursor = connection.cursor()
cursor.execute("DROP TABLE IF EXISTS t1")
cursor.execute("CREATE TABLE t1 (a int, b int, c varchar(100), d int)")
data= [(1, INDICATOR.NULL, "foo", INDICATOR.NULL),
(2, 3, "foo", 5)]
cursor.executemany("INSERT INTO t1 VALUES (?,?,?,?)", data)
self.assertEqual(cursor.rowcount, 2)
cursor.execute("DROP TABLE IF EXISTS t1")
def test_conpy276(self):
connection = create_connection()
cursor = connection.cursor()