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 "Knut Anders Hatlen (JIRA)" <ji...@apache.org> on 2009/09/25 15:08:15 UTC
[jira] Created: (DERBY-4388) NullPointerException in RIGHT JOIN
with NOT BETWEEN
NullPointerException in RIGHT JOIN with NOT BETWEEN
---------------------------------------------------
Key: DERBY-4388
URL: https://issues.apache.org/jira/browse/DERBY-4388
Project: Derby
Issue Type: Bug
Components: SQL
Affects Versions: 10.5.3.0, 10.4.2.0, 10.3.3.0, 10.2.2.0, 10.1.3.1, 10.0.2.1, 10.6.0.0
Reporter: Knut Anders Hatlen
ij> create table t1(x int);
0 rows inserted/updated/deleted
ij> create table t2(x int);
0 rows inserted/updated/deleted
ij> insert into t2 values (1);
1 row inserted/updated/deleted
ij> select * from t1 right join t2 on t1.x = t2.x where t1.x not between 0 and 4;
X |X
-----------------------
ERROR 38000: The exception 'java.lang.NullPointerException' was thrown while evaluating an expression.
ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DERBY-4388) NullPointerException in RIGHT JOIN
with NOT BETWEEN
Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-4388?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Knut Anders Hatlen updated DERBY-4388:
--------------------------------------
Attachment: d4388-1b.diff
Thanks for looking at the patch, Dag. I think you're right about the first clone not being necessary. I've prepared a new patch (1b) which only clones the left operand in the second comparison. I'm rerunning the regression tests and will commit if they pass.
> NullPointerException in RIGHT JOIN with NOT BETWEEN
> ---------------------------------------------------
>
> Key: DERBY-4388
> URL: https://issues.apache.org/jira/browse/DERBY-4388
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.0.2.1, 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.3.0, 10.6.0.0
> Reporter: Knut Anders Hatlen
> Assignee: Knut Anders Hatlen
> Attachments: d4388-1a.diff, d4388-1a.stat, d4388-1b.diff
>
>
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values (1);
> 1 row inserted/updated/deleted
> ij> select * from t1 right join t2 on t1.x = t2.x where t1.x not between 0 and 4;
> X |X
> -----------------------
> ERROR 38000: The exception 'java.lang.NullPointerException' was thrown while evaluating an expression.
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (DERBY-4388) NullPointerException in RIGHT JOIN
with NOT BETWEEN
Posted by "Dag H. Wanvik (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-4388?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12762441#action_12762441 ]
Dag H. Wanvik commented on DERBY-4388:
--------------------------------------
Thanks for this patch, Knut. I read the logic of InListOperatorNode.eliminateNots and that lead me to believe that only the
*second* clone is necessary (the point being that the two "new" comparison operations not share the same column reference. I tried this
by substituting leftOperand for leftClone in the first comparison (leftO < rightOList.elementAt(0)), the test ran ok.
but it may be safer to clone both. Just thought I should mention it.
Without the patch, the test fails, withit it works, so an good improvement, I think.
+1
> NullPointerException in RIGHT JOIN with NOT BETWEEN
> ---------------------------------------------------
>
> Key: DERBY-4388
> URL: https://issues.apache.org/jira/browse/DERBY-4388
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.0.2.1, 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.3.0, 10.6.0.0
> Reporter: Knut Anders Hatlen
> Assignee: Knut Anders Hatlen
> Attachments: d4388-1a.diff, d4388-1a.stat
>
>
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values (1);
> 1 row inserted/updated/deleted
> ij> select * from t1 right join t2 on t1.x = t2.x where t1.x not between 0 and 4;
> X |X
> -----------------------
> ERROR 38000: The exception 'java.lang.NullPointerException' was thrown while evaluating an expression.
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (DERBY-4388) NullPointerException in RIGHT JOIN
with NOT BETWEEN
Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-4388?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12762155#action_12762155 ]
Knut Anders Hatlen commented on DERBY-4388:
-------------------------------------------
The query also fails if a left join is used:
ij> select * from t2 left join t1 on t1.x=t2.x where t1.x not between 0 and 4;
X |X
-----------------------
ERROR 38000: The exception 'java.lang.NullPointerException' was thrown while evaluating an expression.
ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
> NullPointerException in RIGHT JOIN with NOT BETWEEN
> ---------------------------------------------------
>
> Key: DERBY-4388
> URL: https://issues.apache.org/jira/browse/DERBY-4388
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.0.2.1, 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.3.0, 10.6.0.0
> Reporter: Knut Anders Hatlen
>
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values (1);
> 1 row inserted/updated/deleted
> ij> select * from t1 right join t2 on t1.x = t2.x where t1.x not between 0 and 4;
> X |X
> -----------------------
> ERROR 38000: The exception 'java.lang.NullPointerException' was thrown while evaluating an expression.
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DERBY-4388) NullPointerException in RIGHT JOIN
with NOT BETWEEN
Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-4388?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Knut Anders Hatlen updated DERBY-4388:
--------------------------------------
Issue & fix info: [Patch Available, Repro attached] (was: [Repro attached])
All the regression tests ran cleanly.
> NullPointerException in RIGHT JOIN with NOT BETWEEN
> ---------------------------------------------------
>
> Key: DERBY-4388
> URL: https://issues.apache.org/jira/browse/DERBY-4388
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.0.2.1, 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.3.0, 10.6.0.0
> Reporter: Knut Anders Hatlen
> Assignee: Knut Anders Hatlen
> Attachments: d4388-1a.diff, d4388-1a.stat
>
>
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values (1);
> 1 row inserted/updated/deleted
> ij> select * from t1 right join t2 on t1.x = t2.x where t1.x not between 0 and 4;
> X |X
> -----------------------
> ERROR 38000: The exception 'java.lang.NullPointerException' was thrown while evaluating an expression.
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DERBY-4388) NullPointerException in RIGHT JOIN
with NOT BETWEEN
Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-4388?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Knut Anders Hatlen updated DERBY-4388:
--------------------------------------
Attachment: derby-4388-10.5.diff
The regression test could not be merged to 10.5 because InbetweenTest does not exist on the 10.5 branch. derby-4388-10.5.diff contains the fix and adds a regression test case in the lang/inbetween.sql test, which is present in 10.5. The test case raises NPE without the fix.
> NullPointerException in RIGHT JOIN with NOT BETWEEN
> ---------------------------------------------------
>
> Key: DERBY-4388
> URL: https://issues.apache.org/jira/browse/DERBY-4388
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.0.2.1, 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.3.0, 10.6.0.0
> Reporter: Knut Anders Hatlen
> Assignee: Knut Anders Hatlen
> Fix For: 10.6.0.0
>
> Attachments: d4388-1a.diff, d4388-1a.stat, d4388-1b.diff, derby-4388-10.5.diff
>
>
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values (1);
> 1 row inserted/updated/deleted
> ij> select * from t1 right join t2 on t1.x = t2.x where t1.x not between 0 and 4;
> X |X
> -----------------------
> ERROR 38000: The exception 'java.lang.NullPointerException' was thrown while evaluating an expression.
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (DERBY-4388) NullPointerException in RIGHT JOIN
with NOT BETWEEN
Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-4388?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Knut Anders Hatlen updated DERBY-4388:
--------------------------------------
Attachment: d4388-1a.stat
d4388-1a.diff
Attaching a patch which changes BetweenOperatorNode.eliminateNots() to follow the same pattern as InListOperatorNode.eliminateNots() and adds a test case to InbetweenTest. No tests except InbetweenTest have been run yet, but I will start a full regression test run and report back.
> NullPointerException in RIGHT JOIN with NOT BETWEEN
> ---------------------------------------------------
>
> Key: DERBY-4388
> URL: https://issues.apache.org/jira/browse/DERBY-4388
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.0.2.1, 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.3.0, 10.6.0.0
> Reporter: Knut Anders Hatlen
> Assignee: Knut Anders Hatlen
> Attachments: d4388-1a.diff, d4388-1a.stat
>
>
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values (1);
> 1 row inserted/updated/deleted
> ij> select * from t1 right join t2 on t1.x = t2.x where t1.x not between 0 and 4;
> X |X
> -----------------------
> ERROR 38000: The exception 'java.lang.NullPointerException' was thrown while evaluating an expression.
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (DERBY-4388) NullPointerException in RIGHT JOIN
with NOT BETWEEN
Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-4388?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12762184#action_12762184 ]
Knut Anders Hatlen commented on DERBY-4388:
-------------------------------------------
BetweenOperatorNode.eliminateNots() rewrites T1.X NOT BETWEEN 0 AND 4 to T1.X < 0 OR T1.X > 4. I compared the optimized tree for a NOT BETWEEN query with a query manually rewritten to the equivalent less-than/greater-than form and saw that the structure of the column references was different.
Looking at how other nodes implement eliminateNots(), I found that InListOperatorNode is similar to BetweenOperatorNode, except that it always clones the left operand if it is a ColumnReference. A comment told that the cloning was necessary because the reference could be remapped during optimization, and then the different nodes would need a separate instance. Changing BetweenOperatorNode to clone ColumnReferences appears to fix the NPE.
> NullPointerException in RIGHT JOIN with NOT BETWEEN
> ---------------------------------------------------
>
> Key: DERBY-4388
> URL: https://issues.apache.org/jira/browse/DERBY-4388
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.0.2.1, 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.3.0, 10.6.0.0
> Reporter: Knut Anders Hatlen
> Assignee: Knut Anders Hatlen
>
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values (1);
> 1 row inserted/updated/deleted
> ij> select * from t1 right join t2 on t1.x = t2.x where t1.x not between 0 and 4;
> X |X
> -----------------------
> ERROR 38000: The exception 'java.lang.NullPointerException' was thrown while evaluating an expression.
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Assigned: (DERBY-4388) NullPointerException in RIGHT JOIN
with NOT BETWEEN
Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-4388?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Knut Anders Hatlen reassigned DERBY-4388:
-----------------------------------------
Assignee: Knut Anders Hatlen
> NullPointerException in RIGHT JOIN with NOT BETWEEN
> ---------------------------------------------------
>
> Key: DERBY-4388
> URL: https://issues.apache.org/jira/browse/DERBY-4388
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.0.2.1, 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.3.0, 10.6.0.0
> Reporter: Knut Anders Hatlen
> Assignee: Knut Anders Hatlen
>
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values (1);
> 1 row inserted/updated/deleted
> ij> select * from t1 right join t2 on t1.x = t2.x where t1.x not between 0 and 4;
> X |X
> -----------------------
> ERROR 38000: The exception 'java.lang.NullPointerException' was thrown while evaluating an expression.
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (DERBY-4388) NullPointerException in RIGHT JOIN with
NOT BETWEEN
Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-4388?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Knut Anders Hatlen closed DERBY-4388.
-------------------------------------
Resolution: Fixed
Fix Version/s: 10.5.3.1
Committed to 10.5 with revision 825450.
> NullPointerException in RIGHT JOIN with NOT BETWEEN
> ---------------------------------------------------
>
> Key: DERBY-4388
> URL: https://issues.apache.org/jira/browse/DERBY-4388
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.0.2.1, 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.3.0, 10.6.0.0
> Reporter: Knut Anders Hatlen
> Assignee: Knut Anders Hatlen
> Fix For: 10.5.3.1, 10.6.0.0
>
> Attachments: d4388-1a.diff, d4388-1a.stat, d4388-1b.diff, derby-4388-10.5.diff
>
>
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values (1);
> 1 row inserted/updated/deleted
> ij> select * from t1 right join t2 on t1.x = t2.x where t1.x not between 0 and 4;
> X |X
> -----------------------
> ERROR 38000: The exception 'java.lang.NullPointerException' was thrown while evaluating an expression.
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (DERBY-4388) NullPointerException in RIGHT JOIN
with NOT BETWEEN
Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DERBY-4388?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12759520#action_12759520 ]
Knut Anders Hatlen commented on DERBY-4388:
-------------------------------------------
The stack trace is similar to DERBY-4342, but I'm logging it as a separate issue since this query doesn't use VALUE or COALESCE. Also, DERBY-4342 throws NPE during Statement.execute(), whereas the NPE in this issue is thrown during ResultSet.next().
Here's the relevant part of the stack trace:
java.lang.NullPointerException
at org.apache.derby.impl.sql.execute.BaseActivation.getColumnFromRow(BaseActivation.java:1451)
at org.apache.derby.exe.ac0b5b0099x0123xf14ex9cd1x000003c495d81.e4(Unknown Source)
at org.apache.derby.impl.services.reflect.DirectCall.invoke(ReflectGeneratedClass.java:147)
at org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.getNextRowCore(ProjectRestrictResultSet.java:268)
at org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.getNextRow(BasicNoPutResultSetImpl.java:471)
at org.apache.derby.impl.jdbc.EmbedResultSet.movePosition(EmbedResultSet.java:427)
at org.apache.derby.impl.jdbc.EmbedResultSet.next(EmbedResultSet.java:371)
> NullPointerException in RIGHT JOIN with NOT BETWEEN
> ---------------------------------------------------
>
> Key: DERBY-4388
> URL: https://issues.apache.org/jira/browse/DERBY-4388
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.0.2.1, 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.3.0, 10.6.0.0
> Reporter: Knut Anders Hatlen
>
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values (1);
> 1 row inserted/updated/deleted
> ij> select * from t1 right join t2 on t1.x = t2.x where t1.x not between 0 and 4;
> X |X
> -----------------------
> ERROR 38000: The exception 'java.lang.NullPointerException' was thrown while evaluating an expression.
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.