|
[
Permlink
| « Hide
]
Mamta A. Satoor added a comment - 11/Jun/08 05:57 AM
I am looking at this jira entry to see if something rings a bell in the code which might cause this npe.
Mamta A. Satoor made changes - 18/Jun/08 05:47 AM
I think this got broken in 10.4 codeline after the checkin r619995 -
DERBY-2917 Changed the runtime type DataTypeDescriptor to no longer be a TypeDescriptor (catalog type) but instead only have a catalog type (TypeDescriptor). Added code to handle upgrade issue of DataTypeDescriptor's being written as catalog types in RoutineAliasInfo. iapi.types.DataTypeDescriptor.writeExternal used to write the TypeId and the TypeDescriptor in 10.3 codeline. So, the code for writeExternal for DataTypeDescriptor was as follows in 10.3 public void writeExternal( ObjectOutput out ) throws IOException { out.writeObject( typeId ); out.writeObject( typeDescriptor ); } This code was changed in 10.4 codeline to look as follows public void writeExternal( ObjectOutput out ) throws IOException { out.writeObject(typeDescriptor); out.writeInt(getCollationDerivation()); } Starting 10.4, we now rely on loading the TypeId on the fly rather than storing it on the disk as shown below in the readExternal code public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { typeDescriptor = (TypeDescriptorImpl) in.readObject(); typeId = TypeId.getBuiltInTypeId(this.getJDBCTypeId()); collationDerivation = in.readInt(); } The problem is for some reason, we are not able to read the TypeId for the REF datatype(ie in the code above, TypeId.getBuiltInTypeId(this.getJDBCTypeId()); returns null when dealing with REF datatype). I am going to see if we just need a simple case clause for REF in the switch statement in TypeId.getBuiltInTypeId or something else to fix the problem. I will also spend some time figuring out how we are able to get a good TypeId object for REF object in other places when it appears that it is definitely not available to iapi.types.DataTypeDescriptor.readExternal Dan, if this rings a bell to you, will you let me know if my analysis is correct and why we are not able to load TypeId for REF datatype. I added a case clause for Types.REF as shown below in TypeId.getBuiltInTypeId(int)
case Types.REF: return REF_ID; I thought adding this code will get us the correct TypeId for REF datatypes when DataTypeDescriptor.readExternal does following typeId = TypeId.getBuiltInTypeId(this.getJDBCTypeId()); But even with the addition of case statement for Types.REF, I get null pointer exception. The reason is that for some reason, for REF datatypes, Derby does not use Types.REF. Instead it uses Types.OTHER (see BaseTypeIdImpl.setTypeIdSpecificInstanceVariables():line 300 case StoredFormatIds.REF_TYPE_ID_IMPL: SQLTypeName = TypeId.REF_NAME; JDBCTypeId = Types.OTHER; break; My question is why did we decide to use Types.OTHER rather than Types.REF for REF datatype? Also, I do not think it would be correct for me to check for Types.OTHER in TypeId.getBuiltInTypeId(int) and then always return TypeId for REF. Would appreciate any feedback on this. Derby does not support the REF datatype, so using Types.REF would be incorrect for an internal type.
Since we are dealing with the internal type which will be assigned a Types.OTHER type then we can't rely on Types.xxx to get us the correct data type. I am attaching a patch which relies on using the name of the data type rather than it's Type.xxx to construct the correct TypeId. I am accomplising that by changing DataTypeDescriptor.readExternal to use this.getTypeName rather than this.getJDBCTypeId to construct the TypeId. In addition to this change, I had to change DataTypeDescriptor.getTypeName() to use TypeDescriptor to get the type name rather than TypeId. This is because TypeId is not available when DataTypeDescriptor.readExternal calls DataTypeDescriptor.getTypeName. This will match how we already implement DataTypeDescriptor.getJDBCTypeId(). With my patch, I have run Junit and old harness suite with no new regressions. Please let me know if anyone has any comments on the patch. I will plan on committing it early next week if there are no comments. I will also work on writing a test case for this Jira entry.
Mamta A. Satoor made changes - 20/Jun/08 06:24 PM
Mamta A. Satoor made changes - 20/Jun/08 07:09 PM
Committed fix for this jira entry with revision 670778. I will work on migrating this to 10.4 codeline.
Mamta A. Satoor made changes - 23/Jun/08 09:43 PM
Backported the changes to 10.4 codeline with revision 671619
Mamta A. Satoor made changes - 25/Jun/08 06:22 PM
Rick Hillegas made changes - 04/Aug/08 08:24 PM
Myrna van Lunteren made changes - 04/May/09 06:22 PM
Dag H. Wanvik made changes - 30/Jun/09 03:55 PM
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||