[
https://issues.apache.org/jira/browse/DERBY-4439?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12775081#action_12775081
]
Mamta A. Satoor commented on DERBY-4439:
----------------------------------------
I looked through the code and experimented with some changes. Basically, during
the bind phase, CursorNode does binding in following order
super.bind(dataDictionary);
// bind the query expression
resultSet.bindResultColumns(fromList);
// this rejects any untyped nulls in the select list
// pass in null to indicate that we don't have any
// types for this node
resultSet.bindUntypedNullsToResultColumns(null);
In other words, untyped nulls are bound at the end.
In case of our query, where we are using a binary operator node, while we are
going through the resultSet.bindResultColumns(fromList) code in CursorNode, we
call BinaryOperatorNode.bindExpression() and towards the end of this method,
there is following call
return genSQLJavaSQLTree();
This piece of code assumes that everything is bound by now but since call to
untyped nulls has not been made, we run into NPE.
I tried putting in call to binding untyped nulls in FromSubquery.bindExpression
and that fixed the query in question but that is not the right thing to do
exactly. For following query, with my changes, we end up throwing exception
that Null is only allowed in a VALUES clause within an INSERT statement.
create table u (c1 integer);
insert into u select * from (values null) as X;
We need to be able to differentiate the fact that we are dealing with a
CursorNode at the top and hence only for that case, we should try to bind
untyped nulls. I will work on this more. If anyone has any suggestions on a
fix, please share them here
> NullPointerException at bind time when selecting from VALUES NULL
> -----------------------------------------------------------------
>
> Key: DERBY-4439
> URL: https://issues.apache.org/jira/browse/DERBY-4439
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.5.3.0, 10.6.0.0
> Reporter: Knut Anders Hatlen
> Priority: Minor
>
> I see a NullPointerException when I try the following query:
> ij> select x*2 from (values null) v(x);
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
> It should fail gracefully instead, like this similar query:
> ij> select x from (values null) v(x);
> ERROR 42X07: Null is only allowed in a VALUES clause within an INSERT
> statement.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.