[CONPY-254] executemany insert final value NULL gives SystemError Created: 2023-03-28  Updated: 2023-12-08

Status: Needs Feedback
Project: MariaDB Connector/Python
Component/s: Generic
Affects Version/s: 1.1.6
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Michael Currie Assignee: Georg Richter
Resolution: Unresolved Votes: 0
Labels: None

Python Version: 3.10

 Description   

Cannot insert a NULL into the final position, but inserting NULL in any other position is okay.

This makes no sense!

Steps to reproduce the error:

import sys
import mariadb
NULL = mariadb.constants.INDICATOR.NULL
 
conn = mariadb.connect(**db_credentials)
cursor = conn.cursor()
 
cursor.execute("DROP TABLE IF EXISTS ind1;")
cursor.execute("CREATE TABLE ind1 (id1 int, id2 int);")
 
# This command works:
cursor.executemany(
    "INSERT INTO ind1 (id1, id2) VALUES (?,?)", [(NULL, 2)])
 
# This command returns:
# SystemError: <method '_execute_bulk' of 'mariadb.cursor' objects>
#  returned NULL without setting an exception
cursor.executemany(
    "INSERT INTO ind1 (id1, id2) VALUES (?,?)", [(2, NULL)])
 
print(mariadb.__version__)
# 1.1.6
print(sys.version)
# '3.10.9 | packaged by Anaconda, Inc. |
# (main, Mar  8 2023, 10:42:25)
# [MSC v.1916 64 bit (AMD64)]'
print(mariadb.mariadbapi_version)
# 3.3.4
print(conn.server_info)
# 10.7.7-MariaDB-1:10.7.7+maria~ubu2004-log



 Comments   
Comment by Georg Richter [ 2023-03-29 ]

Hi,

could you please also provide information about database server and Connector/C?

print(mariadb.mariadbapi_version)
print(conn.server_info)

Are you sure that the value of mariadb._version_ is 1.1.16 and not 1.1.6 ?

Comment by Michael Currie [ 2023-03-29 ]

Georg thanks for the quick response - yes indeed it is 1.1.6, my typo

Other information is here above

Comment by Georg Richter [ 2023-03-30 ]

Ok, I was able to repeat this problem - however it only fails on Windows.

Comment by Georg Richter [ 2023-04-05 ]

I cannot reproduce it whenever I build v1.1.6 tagged Connector/Python version with tagged v3.1.4 Connector/C version on both builder and my own machine.
Testing with the pypi version always fail.

We had to exchange the windows builder machine in January, the v1.1.6 final release was build on this builder, so I think that Connector/C was not automatically updated and was built with a pre-release.

I will do some more investigations, the plan is to push a post-release of 1.1.6 next week if I can't find another reason.

Thanks for your patience!

Comment by Kelvin Cheung [ 2023-12-03 ]

Has there been an update to this? I have a similar issue that started appearing in the last few months.

mariadb.mariadbapi_version = 3.3.8
conn.server_info = 10.3.32-MariaDB

It was working fine previously. I checked that executing individual rows also works. Issue appears to be inserting NULLs (Python Nones) into Int columns that accept NULL values. I also tested creating a temporary table with this structure and that also worked (both execute and executemany). Very strange.

Comment by Kelvin Cheung [ 2023-12-08 ]

I think it was something to do with the Python version. I must have upgraded to 3.11/3.12 recently. The issue seems to disappear if I downgrade back to 3.8.

Generated at Thu Feb 08 03:31:24 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.