mirror of
https://github.com/mariadb-corporation/mariadb-connector-python.git
synced 2025-08-02 13:56:54 +00:00
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:
@ -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)))
|
||||
{
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user