Bug #45413 Field_blob::unpack ignores "to" parameter
Submitted: 9 Jun 2009 20:05 Modified: 7 Oct 2010 19:33
Reporter: Zardosht Kasheff (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1.30, 5.1 bzr OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution, field, field_blob, unpack

[9 Jun 2009 20:05] Zardosht Kasheff
Description:
Field_blob::unpack does not unpack to the parameter "to". Instead, it unpacks to whatever is pointed to in the member variable "ptr". 

Just as Field_blob::pack temporarily saves ptr to pack from the "from" variable, Field_blob::unpack should temporarily save ptr to unpack to the "to" variable.

How to repeat:
written above

Suggested fix:
Pattern-matching off of Field_blob::pack, temporarily save ptr and make sure to unpack to "to" (I hope this formats correctly):

--- field.cc
+++ field.cc
@@ -8194,6 +8194,8 @@
  DBUG_PRINT("enter", ("to: 0x%lx; from: 0x%lx;"
                       " param_data: %u; low_byte_first: %d",
                       (ulong) to, (ulong) from, param_data, low_byte_first));
+  uchar *save= ptr;
+  ptr= (uchar*) to;
  uint const master_packlength=
    param_data > 0 ? param_data & 0xFF : packlength;
  uint32 const length= get_length(from, master_packlength, low_byte_first);
@@ -8201,6 +8203,7 @@
  bitmap_set_bit(table->write_set, field_index);
  store(reinterpret_cast<const char*>(from) + master_packlength,
        length, field_charset);
+  ptr=save;                    // Restore org row pointer
  DBUG_DUMP("record", to, table->s->reclength);
  DBUG_RETURN(from + master_packlength + length);
}
[11 Jun 2009 16:55] Zardosht Kasheff
Apparently the patch I did above is not sufficient. Field_blob::store still will not pack the data to the right location
[16 Jun 2009 7:33] Sveta Smirnova
Thank you for the report.

Verified as described.
[18 Jun 2009 23:21] Omer Barnir
This is a minor internal code doc issue that has no affect on actual server operations
[7 Oct 2010 19:32] Sveta Smirnova
See also bug #51343
[8 Oct 2010 7:54] Georgi Kodinov
Bug #51343 made a duplicate of this one.
[17 Mar 2023 11:39] srinivas kota
parameter is not valid 
bug is there mysqlworkbench is not working