|
The bug occurs when a generation clause includes a forward reference to a generated column which is declared later on in the table's signature. The bug occurs because we look for the referenced columns after we bind the generation clauses. When we bind the earlier generated columns, we trip across references to columns which haven't been bound yet. This raises an npe. The fix is to bind the generation clauses after we look for illegal references.
Attaching derby-4145-01-aa-forwardReference.diff. This changes the way that we find generation clauses which reference other generated columns.
Previously, we bound the generation clauses before looking for illegal references. This failed if a generation clause had a forward reference to another generated column declared later in the table's signature. Now we look for illegal references before binding the generation clauses. Touches the following files: M java/engine/org/apache/derby/impl/sql/compile/GenerationClauseNode.java Add a new method so that a generation clause can find the columns it references. M java/engine/org/apache/derby/impl/sql/compile/AlterTableNode.java M java/engine/org/apache/derby/impl/sql/compile/CreateTableNode.java M java/engine/org/apache/derby/impl/sql/compile/TableElementList.java Relocate the search for illegal references so that it happens just before we bind the generation clauses. M java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java Add a test case for this bug. Committed derby-4145-01-aa-forwardReference.diff at subversion revision 762520.
Ported 762520 from trunk to 10.5 branch at subversion revision 762521.
Thanks, Rick! I've verified that it now works on trunk and on the 10.5 branch. Closing the issue.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
java.lang.NullPointerException
at org.apache.derby.impl.sql.compile.BinaryOperatorNode.genSQLJavaSQLTree(BinaryOperatorNode.java:416)
at org.apache.derby.impl.sql.compile.BinaryOperatorNode.bindExpression(BinaryOperatorNode.java:329)
at org.apache.derby.impl.sql.compile.BinaryArithmeticOperatorNode.bindExpression(BinaryArithmeticOperatorNode.java:129)
at org.apache.derby.impl.sql.compile.GenerationClauseNode.bindExpression(GenerationClauseNode.java:117)
at org.apache.derby.impl.sql.compile.TableElementList.bindAndValidateGenerationClauses(TableElementList.java:803)
at org.apache.derby.impl.sql.compile.CreateTableNode.bindStatement(CreateTableNode.java:441)
at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:316)
at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:88)
at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:802)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:606)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:555)
at org.apache.derby.impl.tools.ij.ij.executeImmediate(ij.java:329)
at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:505)
at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:347)
at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:245)
at org.apache.derby.impl.tools.ij.Main.go(Main.java:210)
at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:177)
at org.apache.derby.impl.tools.ij.Main.main(Main.java:73)
at org.apache.derby.tools.ij.main(ij.java:59)