You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Mamta Satoor <ms...@gmail.com> on 2007/04/23 18:56:15 UTC

Code generation for DERBY-1478 ie generating DVDs of type CollatorSQLxxx vs SQLxxx

Hi,

Currently, the DVD code generation is done by ExpressionClassBuilder using
the method
void generateDataValue(MethodBuilder mb, TypeCompiler tc, LocalField field)
{
  pushDataValueFactory(mb);
  mb.swap(); // need the dvf as the instance
  tc.generateDataValue(mb, field);
 }

When dealing with character types, we want to generate either CollatorSQLxxx
or SQLxxx (where xxx is Char, Longvarch, Varchar or Clob) depending on the
collation type, ie we want to generate code like following for character
types
DVD = new SQLxxx();
DVD = DVD.getValue(DVF.getCharacterCollator(collationType));
return DVD;

But currently, the collation type does not get passed to
ExpressionClassBuilder.generateDataValue and it is not available to
TypeCompiler. So, what I am proposing is change
ExpressionClassBuilder.generateDataValue to take collation type as parameter
as shown below and pass the collation type to TypeCompiler.generateDataValue
 void generateDataValue(MethodBuilder mb, TypeCompiler tc, int
collationType, LocalField field) {
  pushDataValueFactory(mb);
  mb.swap(); // need the dvf as the instance
  tc.generateDataValue(mb, collationType, field);
 }

CharTypeCompiler will be the only one which will utilize the collation type.
Currently, generateDataValue is implemented by BaseTypeCompiler only. Now,
CharTypeCompiler will overwrite generateDataValue and it will generate the
additional code for DVD.getValue(DVF.getCharacterCollator(collationType));

Please let me know if anyone has any thoughts on this approach. I will start
investigating further into this.

Thanks,
Mamta