|
Thanks Army, I just found the problem and running my patch against derbyall currently. Some explanation of the problem:
In the bind phase of ConditionalNode (NULLIF), the CAST node is generated on top of the untyped NULL and it gets the data type descriptor(DTD) of the left operand. However, the CAST node should have DTD where its value can be nullable. BinaryComparisonOperatorNode bcon = (BinaryComparisonOperatorNode)testCondition; QueryTreeNode cast = getNodeFactory().getNode( C_NodeTypes.CAST_NODE, thenElseList.elementAt(0), bcon.getLeftOperand().getTypeServices(), <=== not nullable! getContextManager()); The second query: select nullif('x','x') as f0, f1 from a union all select nullif('x','x') as f0, nullif(1,1) as f1 from b; works because it didn't generate a NormalizedResultSet on top of the PRN on the right hand side of the union since the datatype and length matches. So it didn't hit the path where it does additional checking at execution time. For the first query: select nullif('x','x') as f0, f1 from a union all select nullif('x','x') as f0, nullif('x','x') as f1 from b; The union result column's length does not match with the right hand side result column, so it generated a NormalizedResultSet on top of the RHS of the union. When the system retrieves the row from NormalizedResultSet at execution time, the normalize method is called on the DTD and checks if the source is NULL and whether its DTD is not nullable. In this case, the SQLSTATE 23502 is thrown. Thanks for the quick turn-around on this, Yip.
Your description of the problem sounds correct to me and the changes themselves match what you say. They also line up with I confirmed that the patch applies cleanly to trunk and that the new test case fails without your changes and passes with it. The code comments also indicate why the change was necessary, which is great. It's a pretty small change, it makes sense to me, and derbayll passed. So I vote +1 to commit... Thanks Yip for the patch and thanks Army for the review. The patch looks good to me, too, and
my build and tests were successful, so I committed it to the trunk as subversion revision 465122. Should this patch be merged back to previous branch(es)? I cleared patch available since the patch is now committed to the trunk, but didn't resolve the issue in case we want to merge it to a release branch first. Thanks Yip! I committed the merged fix to the 10.2 branch as revision 465256.
This issue has been resolved for over a year with no further movement. Closing.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DERBY-7. Before those changes were committed the query ran without error; after that commit this query now fails. For what that's worth...