Bug #3858 Bug in constructor of BlobFromLocator
Submitted: 22 May 2004 14:41 Modified: 11 Nov 2009 2:35
Reporter: Sean Radford Email Updates:
Status: Won't fix Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:3.1-nightly-20040522 OS:Any (All)
Assigned to: Mark Matthews CPU Architecture:Any

[22 May 2004 14:41] Sean Radford
Description:
The constructor of com.mysql.jdbc.BlobFromLocator (achieved for BLOB columns via setting the connection url parameter emulateLocators=true) there is a bug in setting the Blob's internal member fields tableName and blobColumnName.

Currrently the code is (lines 93 & 94): 

this.tableName = this.creatorResultSet.fields[0].getTableName();
this.blobColumnName = this.creatorResultSet.getString(blobColumnIndex);

This should have no real issue for tablName, but means that instead of getting the  blobs column name, blobColumnName is set to the value of the blob itself!

How to repeat:
set the connection url parameter emulateLocators=true
and get a Blob column

Suggested fix:
replace lines 93 & 94 with something akin to:

// blobColumnIndex is index 1 based, but java is index 0, so negate 1...
Field fld = this.creatorResultSet.fields[blobColumnIndex-1];
this.tableName = fld.getTableName();
this.blobColumnName = fld.getName();
[8 Jun 2004 17:15] Mark Matthews
This is as intended. To support MySQL servers that can not return the 'original' column name of an aliased column, the BlobFromLocator feature is desgined to be used by aliasing a string that refers to the real column name ('blobColumnName' AS FOO).

However, your approach does have merit, and we will consider supporting more than one 'mode' of locator emulation (original column name, aliased column name as string, aliased column) in the future.