Bug #73370 NULL values not working with prepared statements in CPY
| Submitted: | 24 Jul 2014 7:34 | Modified: | 27 Aug 2014 18:12 |
|---|---|---|---|
| Reporter: | Peeyush Gupta | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / Python | Severity: | S3 (Non-critical) |
| Version: | 1.2.2 | OS: | Any |
| Assigned to: | Peeyush Gupta | CPU Architecture: | Any |
| Tags: | prepared statement, python | ||
[27 Aug 2014 18:12]
Paul DuBois
Noted in 2.0.1 changelog. Binding None (NULL) to a parameter marker in a prepared statement did not work.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.049 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: While trying to insert NULL values through prepared statements raises an error 1210 (HY000): Incorrect arguments to mysqld_stmt_execute How to repeat: conn = mysql.connector.connect(**config) cur = conn.cursor() cur.execute("DROP TABLE IF EXISTS test") cur.execute("CREATE TABLE test(col1 INT NOT NULL, col2 INT NULL, PRIMARY KEY(col1))") cur = conn.cursor(Prepared=True) sql = "INSERT INTO test(col1,col2) VALUES (?, ?)" cur.execute(sql, (31, None)) Ref: http://stackoverflow.com/questions/24208962/unable-to-use-none-null-values-in-python-mysql... Suggested fix: @@ -620,6 +620,8 @@ class MySQLProtocol(object): flags = 0 if value is None: null_bitmap[(pos // 8)] |= 1 << (pos % 8) + types.append(utils.int1store(FieldType.NULL) + + utils.int1store(flags)) continue elif pos in long_data_used: if long_data_used[pos][0]: