Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Not a Bug
-
None
-
None
-
None
Description
If to bind , for example, bit(16) field as MYSQL_TYPE_LONG, Connector/C will copy only 2 bytes to the buffer when fetches the row. Thus application can get basically wrong value.
mysql_query(ma, "DROP TABLE IF EXISTS `copying_bug`");
mysql_query(ma, "CREATE TABLE `copying_bug` (`a` bit(16) NOT NULL)");
mysql_query(ma, "INSERT INTO `copying_bug` (`a`) VALUES(0)");
st= mysql_stmt_init(ma);
val= 0xffffffff;
bind.buffer_length= 4;
bind.buffer= &val;
bind.buffer_type= MYSQL_TYPE_LONG;
bind.length= &bind.length_value;
bind.is_null= NULL;
bind.error= NULL;
mysql_stmt_prepare(st, "SELECT a FROM copying_bug", strlen("SELECT a FROM copying_bug");
mysql_stmt_execute(st);
mysql_stmt_bind_result(st, &bind);
mysql_stmt_fetch(st);
printf("Value is: %d, (copied)size is %d\n", val, bind.length_value);
mysql_stmt_close(st);
mysql_query(ma, "DROP TABLE IF EXISTS `copying_bug`");