[jira] Created: (DERBY-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

View: New views
20 Messages — Rating Filter:   Alert me  

[jira] Created: (DERBY-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

NullPointerException with INSERT INTO ... from UNION and generated columns
--------------------------------------------------------------------------

                 Key: DERBY-4419
                 URL: https://issues.apache.org/jira/browse/DERBY-4419
             Project: Derby
          Issue Type: Bug
    Affects Versions: 10.5.3.0, 10.5.1.1, 10.4.1.3, 10.3.1.4, 10.6.0.0
            Reporter: Knut Anders Hatlen


The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:

ij> create table t1(x int);
0 rows inserted/updated/deleted
ij> insert into t1 values 1,2;
2 rows inserted/updated/deleted
ij> create table t2(x int);
0 rows inserted/updated/deleted
ij> insert into t2 values 2,3;
2 rows inserted/updated/deleted
ij> create table t3(x int, y int generated always as identity);
0 rows inserted/updated/deleted
ij> insert into t3(x) select * from t1 union select * from t2;
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-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12769106#action_12769106 ]

Knut Anders Hatlen commented on DERBY-4419:
-------------------------------------------

Stack trace:

java.lang.NullPointerException
        at org.apache.derby.impl.sql.compile.ResultColumn.columnTypeAndLengthMatch(ResultColumn.java:1003)
        at org.apache.derby.impl.sql.compile.ResultColumnList.columnTypesAndLengthsMatch(ResultColumnList.java:1686)
        at org.apache.derby.impl.sql.compile.ResultSetNode.columnTypesAndLengthsMatch(ResultSetNode.java:932)
        at org.apache.derby.impl.sql.compile.UnionNode.addNewNodes(UnionNode.java:411)
        at org.apache.derby.impl.sql.compile.UnionNode.modifyAccessPaths(UnionNode.java:361)
        at org.apache.derby.impl.sql.compile.SingleChildResultSetNode.modifyAccessPaths(SingleChildResultSetNode.java:439)
        at org.apache.derby.impl.sql.compile.DMLStatementNode.optimizeStatement(DMLStatementNode.java:323)
        at org.apache.derby.impl.sql.compile.DMLStatementNode.optimizeStatement(DMLStatementNode.java:302)
        at org.apache.derby.impl.sql.compile.DMLModStatementNode.optimizeStatement(DMLModStatementNode.java:1736)
        at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:381)
        at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:90)
        at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:828)
        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)

> NullPointerException with INSERT INTO ... from UNION and generated columns
> --------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-4419:
--------------------------------------

    Attachment: npe.sql

Attached script to reproduce the NPE.

> NullPointerException with INSERT INTO ... from UNION and generated columns
> --------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>         Attachments: npe.sql
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-4419:
--------------------------------------

    Component/s: SQL

> NullPointerException with INSERT INTO ... from UNION and generated columns
> --------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>         Attachments: npe.sql
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12769135#action_12769135 ]

Knut Anders Hatlen commented on DERBY-4419:
-------------------------------------------

It looks like the bug was introduced by this commit:

------------------------------------------------------------------------
r487414 | bpendleton | 2006-12-15 02:01:14 +0100 (Fri, 15 Dec 2006) | 55 lines

DERBY-1644: NPE when inserting values to tbl w/ identity col gen by default
(...)
------------------------------------------------------------------------

> NullPointerException with INSERT INTO ... from UNION and generated columns
> --------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>         Attachments: npe.sql
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12769411#action_12769411 ]

Bryan Pendleton commented on DERBY-4419:
----------------------------------------

Thanks for tracking this down, Knut. The test case is eerily similar to the DERBY-1644 case.

I'm afraid I don't have a good guess about what's going wrong, or why the DERBY-1644 patch caused this problem.

Are you intending to investigate this? I'll try to take a look, although not immediately.

> NullPointerException with INSERT INTO ... from UNION and generated columns
> --------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>         Attachments: npe.sql
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12769447#action_12769447 ]

Knut Anders Hatlen commented on DERBY-4419:
-------------------------------------------

Hi Bryan,
I don't have any immediate plans to look into it, but I may do so out of pure curiosity. :)
If I do so, I'll post whatever I find here.

> NullPointerException with INSERT INTO ... from UNION and generated columns
> --------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>         Attachments: npe.sql
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12769580#action_12769580 ]

Bryan Pendleton commented on DERBY-4419:
----------------------------------------

The following diff makes the repro script pass. I haven't done any other testing yet.
On the face of it, it seems reasonable to treat generated columns and autoincrement
generated columns the same way in this code, so I'll try running more tests to see
what I find.

Index: java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
===================================================================
--- java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java (revision 826583)
+++ java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java (working copy)
@@ -1678,7 +1678,7 @@
  ResultColumn resultColumn = (ResultColumn) elementAt(index);
 
  /* Skip over generated columns */
- if (resultColumn.isGenerated())
+ if (resultColumn.isGenerated() || resultColumn.isAutoincrementGenerated())
  {
  continue;
  }


> NullPointerException with INSERT INTO ... from UNION and generated columns
> --------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>         Attachments: npe.sql
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton reassigned DERBY-4419:
--------------------------------------

    Assignee: Bryan Pendleton

> NullPointerException with INSERT INTO ... from UNION and generated columns
> --------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Bryan Pendleton
>         Attachments: npe.sql
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton updated DERBY-4419:
-----------------------------------

    Attachment: addASimpleTest.diff

Regression tests of the above patch were clean.

Attached patch proposal adds a simple test, using the
script from the bug description.


> NullPointerException with INSERT INTO ... from UNION and generated columns
> --------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Bryan Pendleton
>         Attachments: addASimpleTest.diff, npe.sql
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12769961#action_12769961 ]

Knut Anders Hatlen commented on DERBY-4419:
-------------------------------------------

The fix looks reasonable to me. +1 to commit.

I noticed though that a NullPointerException is still thrown if the definition of T3.Y is changed to "GENERATED ALWAYS AS (X*2)". Probably a similar fix is needed for that case. Since this kind of generated columns wasn't introduced until 10.5, this is not a regression, so I'll file it as a separate bug.

> NullPointerException with INSERT INTO ... from UNION and generated columns
> --------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Bryan Pendleton
>         Attachments: addASimpleTest.diff, npe.sql
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12769964#action_12769964 ]

Knut Anders Hatlen commented on DERBY-4419:
-------------------------------------------

Logged the GENERATED ALWAYS AS (X*2) case as DERBY-4425.

> NullPointerException with INSERT INTO ... from UNION and generated columns
> --------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Bryan Pendleton
>         Attachments: addASimpleTest.diff, npe.sql
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770364#action_12770364 ]

Dag H. Wanvik commented on DERBY-4419:
--------------------------------------

This one threw me off at first:

/* Skip over generated columns */
- if (resultColumn.isGenerated())
+ if (resultColumn.isGenerated() || resultColumn.isAutoincrementGenerated())

In view of Knut's find, DERBY-4425, it seems that "generated column" in the code quoted means something else. Perhaps the term is overloaded in the code, which is unfortunate, and may lead to other issues later.
Cf this code fragment later in the same class:

    defaultInfo.isGeneratedColumn()

which is the test for *real* "generated column" in the SQL sense. From 4.14.8:

"A generated column is one whose values are determined by evaluation of a generation
expression.."

So, the ResultColumn method "isGenerated" means something else, i.e. column synthesized by Derby for various purposes (cf calls to markGenerated in UpdateNode/DeleteNode vs. GroupByNode/WindowResultSetNode).

> NullPointerException with INSERT INTO ... from UNION and generated columns
> --------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Bryan Pendleton
>         Attachments: addASimpleTest.diff, npe.sql
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770365#action_12770365 ]

Dag H. Wanvik commented on DERBY-4419:
--------------------------------------

Just to be clear, +1, though, if we want to clean up terminology that would be another issue..

> NullPointerException with INSERT INTO ... from UNION and generated columns
> --------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Bryan Pendleton
>         Attachments: addASimpleTest.diff, npe.sql
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and generated columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770370#action_12770370 ]

Bryan Pendleton commented on DERBY-4419:
----------------------------------------

I agree, Dag, the terminology is worrisome here.

There is also ResultColumn.isGeneratedForUnmatchedColumnInInsert()

I think there is more to learn here; I shall study it some more.

> NullPointerException with INSERT INTO ... from UNION and generated columns
> --------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Bryan Pendleton
>         Attachments: addASimpleTest.diff, npe.sql
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and identity columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-4419:
--------------------------------------

    Summary: NullPointerException with INSERT INTO ... from UNION and identity columns  (was: NullPointerException with INSERT INTO ... from UNION and generated columns)

Changed "generated columns" to "identity columns" in the bug summary so that we at least get the terminology right here. :)

> NullPointerException with INSERT INTO ... from UNION and identity columns
> -------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Bryan Pendleton
>         Attachments: addASimpleTest.diff, npe.sql
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and identity columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton updated DERBY-4419:
-----------------------------------

    Attachment: use4425CodePatch.diff

It looks like, indeed, the same code patch from DERBY-4425 will work here,
of course with a different regression test.

The full regression suite was clean.

I'm intending to commit the fixes for DERBY-4419 and DERBY-4425, since
they seem small, self-contained, and safe.

I don't have a great resolution for the terminology confusion of the word "generated",
which has come to have a variety of meanings inside the Derby SQL engine. Hopefully
over time we can tease these details apart.

In the meantime, I don't think that the proposed patch makes matters much worse.


> NullPointerException with INSERT INTO ... from UNION and identity columns
> -------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Bryan Pendleton
>         Attachments: addASimpleTest.diff, npe.sql, use4425CodePatch.diff
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and identity columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12771884#action_12771884 ]

Knut Anders Hatlen commented on DERBY-4419:
-------------------------------------------

+1. Looks like a simple and safe fix.

> NullPointerException with INSERT INTO ... from UNION and identity columns
> -------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Bryan Pendleton
>         Attachments: addASimpleTest.diff, npe.sql, use4425CodePatch.diff
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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] Resolved: (DERBY-4419) NullPointerException with INSERT INTO ... from UNION and identity columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton resolved DERBY-4419.
------------------------------------

       Resolution: Fixed
    Fix Version/s: 10.6.0.0

Committed to the trunk as revision 831304.

I'm not planning to merge this back to prior branches, although I think it
would be a straightforward merge if it interests anyone.

> NullPointerException with INSERT INTO ... from UNION and identity columns
> -------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Bryan Pendleton
>             Fix For: 10.6.0.0
>
>         Attachments: addASimpleTest.diff, npe.sql, use4425CodePatch.diff
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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-4419) NullPointerException with INSERT INTO ... from UNION and identity columns

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/DERBY-4419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12787396#action_12787396 ]

Knut Anders Hatlen commented on DERBY-4419:
-------------------------------------------

DERBY-4442 fixed a family of INSERT bugs, including this one, making the original fix for this issue unnecessary. The fix was therefore backed out in revision 888311, but the tests are still part of the regression test suite.

> NullPointerException with INSERT INTO ... from UNION and identity columns
> -------------------------------------------------------------------------
>
>                 Key: DERBY-4419
>                 URL: https://issues.apache.org/jira/browse/DERBY-4419
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.3.1.4, 10.4.1.3, 10.5.1.1, 10.5.3.0, 10.6.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Bryan Pendleton
>             Fix For: 10.6.0.0
>
>         Attachments: addASimpleTest.diff, npe.sql, use4425CodePatch.diff
>
>
> The following sequence of statements works on 10.2.2.0 and earlier, and raises a NullPointerException with 10.3.1.4 and later:
> ij> create table t1(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values 1,2;
> 2 rows inserted/updated/deleted
> ij> create table t2(x int);
> 0 rows inserted/updated/deleted
> ij> insert into t2 values 2,3;
> 2 rows inserted/updated/deleted
> ij> create table t3(x int, y int generated always as identity);
> 0 rows inserted/updated/deleted
> ij> insert into t3(x) select * from t1 union select * from t2;
> 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.