mirror of
https://github.com/mariadb-corporation/mariadb-connector-python.git
synced 2025-08-14 08:56:00 +00:00
CONPY-289: BIGINT out of range on bulk insert
If a bigint value is > LONGLONG_MAX it must be indicated that it is an unsigned value (param->is_unsigned= 1).
This commit is contained in:
@ -1100,10 +1100,18 @@ mariadb_get_parameter_info(MrdbCursor *self,
|
|||||||
|
|
||||||
if (pinfo.type == MYSQL_TYPE_LONGLONG)
|
if (pinfo.type == MYSQL_TYPE_LONGLONG)
|
||||||
{
|
{
|
||||||
|
uint64_t tmp= PyLong_AsLongLong(paramvalue.value);
|
||||||
|
|
||||||
|
if (tmp == (uint64_t)-1 && PyErr_Occurred)
|
||||||
|
{
|
||||||
|
param->is_unsigned= 1;
|
||||||
|
PyErr_Clear();
|
||||||
|
}
|
||||||
if (pinfo.bits > bits)
|
if (pinfo.bits > bits)
|
||||||
{
|
{
|
||||||
bits= (uint32_t)pinfo.bits;
|
bits= (uint32_t)pinfo.bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!param->buffer_type ||
|
if (!param->buffer_type ||
|
||||||
|
@ -1645,6 +1645,23 @@ class TestCursor(unittest.TestCase):
|
|||||||
self.assertEqual(cursor.rowcount, 4)
|
self.assertEqual(cursor.rowcount, 4)
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
|
def test_conpy289(self):
|
||||||
|
with create_connection() as conn:
|
||||||
|
cursor= conn.cursor()
|
||||||
|
cursor.execute("CREATE OR REPLACE TABLE t289 (a bigint unsigned,"\
|
||||||
|
"b bigint unsigned, c bigint unsigned,"\
|
||||||
|
"d bigint unsigned)")
|
||||||
|
|
||||||
|
data= [(0, 9232974212090577672, 11529232914765115761, 58),
|
||||||
|
(0, 13837380911034793984, 11529233872889843812, 0),
|
||||||
|
(0, 0, 2351636844950589488, 9999)]
|
||||||
|
|
||||||
|
cursor.executemany("insert into t289 values (?,?,?,?)", data)
|
||||||
|
|
||||||
|
cursor.execute("SELECT * FROM t289")
|
||||||
|
rows= cursor.fetchall()
|
||||||
|
self.assertEqual(rows, data)
|
||||||
|
|
||||||
def test_conpy91(self):
|
def test_conpy91(self):
|
||||||
with create_connection() as connection:
|
with create_connection() as connection:
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
|
Reference in New Issue
Block a user