Bug #1644 Insertion of more than 3 NULL columns with parameter binding fails
Submitted: 24 Oct 2003 7:12 Modified: 27 Oct 2003 1:52
Reporter: David Ritter Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.1 OS:Linux (Linux)
Assigned to: Bugs System CPU Architecture:Any

[24 Oct 2003 7:12] David Ritter
Description:
Using prepared statements, insertion of more than three columns with NULL values fails to insert additional NULLS.  After the third column NULLS will be 
inserted into the database as zeros.

How to repeat:
create table foo_dfr(col1 int, col2 int, col3 int, col4 int);
insert into foo_dfr values( ?,?,?,? );

First insert four columns of a value (i.e. 22) to verify binding is working
correctly.  Then Bind to each columns bind parameter an is_null value of 1.
Then insert four more columns of integers, just for sanity.
A subsequent select on the server will result in this:

mysql> select * from foo_dfr;
+------+------+------+------+
| col1 | col2 | col3 | col4 |
+------+------+------+------+
|   22 |   22 |   22 |   22 |
| NULL | NULL | NULL |    0 |
|   88 |   88 |   88 |   88 |
+------+------+------+------+
3 rows in set (0.00 sec)
[24 Oct 2003 7:13] David Ritter
C API Test Case

Attachment: nullTest.cpp (text/plain), 9.16 KiB.

[24 Oct 2003 7:57] Dean Ellis
Verified in the latest BitKeeper sources.
[25 Oct 2003 22:22] Johan Backlund
Problem is at line 75 in sql_prepare.cc. The definition of IS_PARAM_NULL needs an extra set of paranthesises, like this

#define IS_PARAM_NULL(pos, param_no) pos[param_no/8] & (1 << (param_no & 7))
[27 Oct 2003 1:52] Per-Erik Martin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html