db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mamta Satoor" <msat...@gmail.com>
Subject DERBY-1478 subtask DERBY-2583 - need help in debugging stack trace thrown during code generation
Date Mon, 14 May 2007 19:57:56 GMT
Hi,

I checked in code on April 24th revision 532082 for DERBY-2583 "At code
generation time, look at collation type to determine what kind of DVD should
get generated for character types."

The intention of the commit was to generate following
StringDataValueObject.getValue(DataValueFactory.getCharacterCollator(collationType));


This code generation change went in
BaseTypeCompiler.generateCollationSensitiveDataValue and it looked as
follows
 protected void generateCollationSensitiveDataValue(MethodBuilder mb,
   int collationType, String className){
  if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC)
   return;
  //In case of character DVDs, for territory based collation, we need to
  //generate DVDs with territory based RuleBasedCollator and hence we
  //need to generate CollatorSQLChar/CollatorSQLVarchar/
  //CollatorSQLLongvarchar/CollatorSQLClob
  pushDataValueFactory(mb, className);
  mb.push(collationType);
  mb.callMethod(VMOpcode.INVOKEINTERFACE, null, "getCharacterCollator",
    "java.text.RuleBasedCollator", 1);
  mb.callMethod(VMOpcode.INVOKEINTERFACE, null, "getValue", interfaceName(),
1);
 }
This new api gets called by CharTypeCompiler and CLOBTypeCompiler as shown
below
 generateDataValue(MethodBuilder, int, String, LocalField) -
org.apache.derby.impl.sql.compile.CharTypeCompiler
 generateNull(MethodBuilder, int, String) -
org.apache.derby.impl.sql.compile.CharTypeCompiler
 generateNull(MethodBuilder, int, String) -
org.apache.derby.impl.sql.compile.CLOBTypeCompiler
 generateDataValue(MethodBuilder, int, String, LocalField) -
org.apache.derby.impl.sql.compile.CLOBTypeCompiler


When this new api is called, StringDataValue is already on the stack for
code generation. And the new code just uses that StringDataValue to generate
the additional code of StringDataValueObject.getValue(
DataValueFactory.getCharacterCollator(collationType)); and this new code
generation leaves a StringDataValue on the stack. So this new api used up
the StringDataValue on the stack and left another StringDataValue in it's
place.

Now that we have the background information, let me talk about the problem
at hand. When following piece of sql is executed inside a collated db, it
causes a stack trace
connect
'jdbc:derby:c:/dellater/db1_52_data;create=true;territory=no_no;collation=TERRITORY_BASED';
create table localize1(nc10 char(10));
insert into localize1 values ('a');
select nc10 from localize1;

The stack trace looks as follows
ERROR XJ001: Java exception: ': java.lang.ClassCastException'.
java.sql.SQLException: Java exception: ': java.lang.ClassCastException'.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(
SQLExceptionFactory.java:45)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java
:88)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java
:99)
        at org.apache.derby.impl.jdbc.Util.javaException(Util.java:234)
        at
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(
TransactionResourceImpl.java:386)
        at
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(
TransactionResourceImpl.java:345)
        at org.apache.derby.impl.jdbc.EmbedConnection.handleException(
EmbedConnection.java:1533)
        at org.apache.derby.impl.jdbc.ConnectionChild.handleException(
ConnectionChild.java:81)
        at org.apache.derby.impl.jdbc.EmbedStatement.execute(
EmbedStatement.java:573)
        at org.apache.derby.impl.jdbc.EmbedStatement.execute(
EmbedStatement.java:516)
        at org.apache.derby.impl.tools.ij.ij.executeImmediate(ij.java:330)
        at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java
:531)
        at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(
utilMain.java:373)
        at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:271)
        at org.apache.derby.impl.tools.ij.Main.go(Main.java:215)
        at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:181)
        at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:56)
        at org.apache.derby.tools.ij.main(ij.java:71)
Caused by: java.lang.ClassCastException
        at
org.apache.derby.impl.services.bytecode.CodeChunk.getTypeDescriptor(
CodeChunk.java:1007)
        at
org.apache.derby.impl.services.bytecode.CodeChunk.getVariableStackDelta(
CodeChunk.java:1059)
        at org.apache.derby.impl.services.bytecode.CodeChunk.stackWordDelta(
CodeChunk.java:992)
        at org.apache.derby.impl.services.bytecode.CodeChunk.findMaxStack(
CodeChunk.java:954)
        at org.apache.derby.impl.services.bytecode.CodeChunk.complete(
CodeChunk.java:810)
        at org.apache.derby.impl.services.bytecode.BCMethod.complete(
BCMethod.java:241)
        at
org.apache.derby.impl.sql.compile.ResultColumnList.generateHolderMethod(
ResultColumnList.java:1477)
        at org.apache.derby.impl.sql.compile.FromBaseTable.getScanArguments(
FromBaseTable.java:3399)
        at org.apache.derby.impl.sql.compile.FromBaseTable.generateResultSet
(FromBaseTable.java:3135)
        at org.apache.derby.impl.sql.compile.FromBaseTable.generate(
FromBaseTable.java:3062)
        at
org.apache.derby.impl.sql.compile.ProjectRestrictNode.generateMinion(
ProjectRestrictNode.java:1351)
        at org.apache.derby.impl.sql.compile.ProjectRestrictNode.generate(
ProjectRestrictNode.java:1302)
        at
org.apache.derby.impl.sql.compile.ProjectRestrictNode.generateMinion(
ProjectRestrictNode.java:1351)
        at org.apache.derby.impl.sql.compile.ProjectRestrictNode.generate(
ProjectRestrictNode.java:1302)
        at
org.apache.derby.impl.sql.compile.ScrollInsensitiveResultSetNode.generate(
ScrollInsensitiveResultSetNode.java:109)
        at org.apache.derby.impl.sql.compile.CursorNode.generate(
CursorNode.java:564)
        at org.apache.derby.impl.sql.compile.StatementNode.generate(
StatementNode.java:347)
        at org.apache.derby.impl.sql.GenericStatement.prepMinion(
GenericStatement.java:447)
        at org.apache.derby.impl.sql.GenericStatement.prepare(
GenericStatement.java:88)
        at
org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement
(GenericLanguageConnectionContext.java:742)
        at org.apache.derby.impl.jdbc.EmbedStatement.execute(
EmbedStatement.java:567)
        ... 9 more


Looking at stack trace, it looks like something is wrong in maybe my code
generation changes and wondered if someone familiar with code generation can
tell me what I am doing wrong. I will keep debugging but any help will be
greatly appreciated.

thanks,
Mamta

Mime
View raw message