Bug #29548 NULL value for string field not handled correctly
Submitted: 4 Jul 2007 12:40 Modified: 9 Jul 2007 11:24
Reporter: Mats Kindahl Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Proxy: Core Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[4 Jul 2007 12:40] Mats Kindahl
Description:
When trying to retrieve a value of a string field that is NULL, an exception is thrown.

How to repeat:
The following script will trigger an assertion if row[0] hold a NULL string field.

  function read_query_result(result)
     for row in result.resultset.rows do
        print("type: " .. type(row[0]))
        print("value: " .. row[0])
     end
  end

Suggested fix:
On line 1220 in network-mysqld-proxy.c the following code is found::

	field_len = network_mysqld_proto_decode_lenenc(packet, &off);

	if (field_len == MYSQLD_PACKET_NULL) {

Since field_len is 251 for a NULL field, but MYSQLD_PACKET_NULL is -5, the comparison will be false, causing a trigger for the else branch to trigger.

Either casting the MYSQLD_PACKET_NULL to ``unsigned char`` or comparing with 251 directly will fix the problem.
[9 Jul 2007 11:24] Sveta Smirnova
Thank you for the report.

Current sources contain string "if (field_len == 251)" instead of "if (field_len == MYSQLD_PACKET_NULL)". So I close this report as "Can't repeat"