[CONC-172] Wrong result if bound numeric buffer is bigger than field size Created: 2016-04-12 Updated: 2016-04-24 Resolved: 2016-04-24 |
|
| Status: | Closed |
| Project: | MariaDB Connector/C |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Minor |
| Reporter: | Lawrin Novitsky | Assignee: | Georg Richter |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | 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`"); st= mysql_stmt_init(ma); val= 0xffffffff; bind.buffer_length= 4; mysql_stmt_prepare(st, "SELECT a FROM copying_bug", strlen("SELECT a FROM copying_bug"); 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`"); |
| Comments |
| Comment by Lawrin Novitsky [ 2016-04-12 ] |
|
It may be more like a documentation issue |
| Comment by Georg Richter [ 2016-04-24 ] |
|
Bit values are returned as strings and require interpretation on client side. For converting a bit column into numeric value use column + 0 or CAST in your select statement. |