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 "Christopher Schick (JIRA)" <de...@db.apache.org> on 2006/08/25 11:33:22 UTC

[jira] Created: (DERBY-1763) Using RTRIM(LTRIM(col)) and group by col gives NPE

Using RTRIM(LTRIM(col)) and group by col gives NPE
--------------------------------------------------

                 Key: DERBY-1763
                 URL: http://issues.apache.org/jira/browse/DERBY-1763
             Project: Derby
          Issue Type: Bug
          Components: SQL
    Affects Versions: 10.1.3.1
         Environment: Windows 2000, Sun JDK 1.4.2_10
            Reporter: Christopher Schick


When trying to execute a simple SQL Statement that includes both the RTRIM() and LTRIM() functions on a column in the SELECT clause and contains a GROUP BY clause on that column, the following Nullpointer Exception is thrown:
ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
This does NOT happen, if only RTRIM() OR LTRIM() is used, or if no GROUP BY clause is specified.

This issue is quite urgent for us, as we don't see a workaround to achieve the desired results.

Attached an example table schema and the affected SELECT Statement.
--------------------------------------------
CREATE TABLE t1 (
c1 VARCHAR(10),
c2 VARCHAR(10)
);

INSERT INTO t1 VALUES('a', 'b');
INSERT INTO t1 VALUES('c', 'd');

SELECT RTRIM(LTRIM(c1)), 
                 COUNT(*)
FROM t1
GROUP BY c1;



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Re: [jira] Created: (DERBY-1763) Using RTRIM(LTRIM(col)) and group by col gives NPE

Posted by Saurabh Vyas <Sa...@Sun.COM>.
I tried to reproduce the error and I got the following stack trace :


2006-08-25 09:46:24.654 GMT Thread[main,5,main] (XID = 140), (SESSIONID 
= 0), (D ATABASE = test), (DRDAID = null), Failed Statement is: select 
rtrim(ltrim(c1)) , count(*) from tbl1 group by c1
java.lang.NullPointerException
        at 
org.apache.derby.impl.sql.execute.BasicSortObserver.getClone(BasicSor 
tObserver.java:172)
        at 
org.apache.derby.impl.sql.execute.BasicSortObserver.insertNonDuplicat 
eKey(BasicSortObserver.java:92)
        at 
org.apache.derby.impl.sql.execute.AggregateSortObserver.insertNonDupl 
icateKey(AggregateSortObserver.java:124)
        at 
org.apache.derby.impl.store.access.sort.SortBuffer.insert(SortBuffer. 
java:216)
        at 
org.apache.derby.impl.store.access.sort.MergeInserter.insert(MergeIns 
erter.java:111)
        at 
org.apache.derby.impl.sql.execute.GroupedAggregateResultSet.loadSorte 
r(GroupedAggregateResultSet.java:330)
        at 
org.apache.derby.impl.sql.execute.GroupedAggregateResultSet.openCore( 
GroupedAggregateResultSet.java:202)
        at 
org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.openCore(P 
rojectRestrictResultSet.java:172)
        at 
org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.openCore(P 
rojectRestrictResultSet.java:172)
        at 
org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.open(BasicN 
oPutResultSetImpl.java:260)
        at 
org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPre 
paredStatement.java:358)
        at 
org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedState 
ment.java:1182)
        at 
org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java :585)
        at 
org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java :517)
        at org.apache.derby.impl.tools.ij.ij.executeImmediate(ij.java:313)
        at 
org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:488)
        at 
org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:3 48)
        at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:249)
        at org.apache.derby.impl.tools.ij.Main.go(Main.java:204)
        at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:170)
        at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:56)
        at org.apache.derby.tools.ij.main(ij.java:70)
Cleanup action completed

I am intrested in working on this issue. Can any one give some inputs in 
this ?

thanks,
saurabh


Christopher Schick (JIRA) wrote:

>Using RTRIM(LTRIM(col)) and group by col gives NPE
>--------------------------------------------------
>
>                 Key: DERBY-1763
>                 URL: http://issues.apache.org/jira/browse/DERBY-1763
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1
>         Environment: Windows 2000, Sun JDK 1.4.2_10
>            Reporter: Christopher Schick
>
>
>When trying to execute a simple SQL Statement that includes both the RTRIM() and LTRIM() functions on a column in the SELECT clause and contains a GROUP BY clause on that column, the following Nullpointer Exception is thrown:
>ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
>This does NOT happen, if only RTRIM() OR LTRIM() is used, or if no GROUP BY clause is specified.
>
>This issue is quite urgent for us, as we don't see a workaround to achieve the desired results.
>
>Attached an example table schema and the affected SELECT Statement.
>--------------------------------------------
>CREATE TABLE t1 (
>c1 VARCHAR(10),
>c2 VARCHAR(10)
>);
>
>INSERT INTO t1 VALUES('a', 'b');
>INSERT INTO t1 VALUES('c', 'd');
>
>SELECT RTRIM(LTRIM(c1)), 
>                 COUNT(*)
>FROM t1
>GROUP BY c1;
>
>
>
>  
>


[jira] Commented: (DERBY-1763) Using RTRIM(LTRIM(col)) and group by col gives NPE

Posted by "Christopher Schick (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1763?page=comments#action_12430525 ] 
            
Christopher Schick commented on DERBY-1763:
-------------------------------------------

true. 
However, it's not limited to count(*) actually. count(1) and count(c1) show the same behavior.
Haven't checked on a sane build though, if the error message changes in that case.

> Using RTRIM(LTRIM(col)) and group by col gives NPE
> --------------------------------------------------
>
>                 Key: DERBY-1763
>                 URL: http://issues.apache.org/jira/browse/DERBY-1763
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1
>         Environment: Windows 2000, Sun JDK 1.4.2_10
>            Reporter: Christopher Schick
>
> When trying to execute a simple SQL Statement that includes both the RTRIM() and LTRIM() functions on a column in the SELECT clause and contains a GROUP BY clause on that column, the following Nullpointer Exception is thrown:
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
> This does NOT happen, if only RTRIM() OR LTRIM() is used, or if no GROUP BY clause is specified.
> This issue is quite urgent for us, as we don't see a workaround to achieve the desired results.
> Attached an example table schema and the affected SELECT Statement.
> --------------------------------------------
> CREATE TABLE t1 (
> c1 VARCHAR(10),
> c2 VARCHAR(10)
> );
> INSERT INTO t1 VALUES('a', 'b');
> INSERT INTO t1 VALUES('c', 'd');
> SELECT RTRIM(LTRIM(c1)), 
>                  COUNT(*)
> FROM t1
> GROUP BY c1;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (DERBY-1763) Using RTRIM(LTRIM(col)) and group by col gives NPE

Posted by "Christopher Schick (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1763?page=comments#action_12437562 ] 
            
Christopher Schick commented on DERBY-1763:
-------------------------------------------

Tested and found working w/ 10.2.1.5 (10.2 RC).
This issue can be closed from my side.
Thanks to everyone who has been working on this.

> Using RTRIM(LTRIM(col)) and group by col gives NPE
> --------------------------------------------------
>
>                 Key: DERBY-1763
>                 URL: http://issues.apache.org/jira/browse/DERBY-1763
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1
>         Environment: Windows 2000, Sun JDK 1.4.2_10
>            Reporter: Christopher Schick
>
> When trying to execute a simple SQL Statement that includes both the RTRIM() and LTRIM() functions on a column in the SELECT clause and contains a GROUP BY clause on that column, the following Nullpointer Exception is thrown:
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
> This does NOT happen, if only RTRIM() OR LTRIM() is used, or if no GROUP BY clause is specified.
> This issue is quite urgent for us, as we don't see a workaround to achieve the desired results.
> Attached an example table schema and the affected SELECT Statement.
> --------------------------------------------
> CREATE TABLE t1 (
> c1 VARCHAR(10),
> c2 VARCHAR(10)
> );
> INSERT INTO t1 VALUES('a', 'b');
> INSERT INTO t1 VALUES('c', 'd');
> SELECT RTRIM(LTRIM(c1)), 
>                  COUNT(*)
> FROM t1
> GROUP BY c1;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (DERBY-1763) Using RTRIM(LTRIM(col)) and group by col gives NPE

Posted by "Andrew McIntyre (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1763?page=comments#action_12438038 ] 
            
Andrew McIntyre commented on DERBY-1763:
----------------------------------------

I suspect that this has probably been fixed by the changes to DERBY-883, which supports expressions in GROUP BY.

Since the original reporter of this issue has reported it fixed in 10.2, I will close this issue as fixed in 10.2 in a few days if there are no other comments.

> Using RTRIM(LTRIM(col)) and group by col gives NPE
> --------------------------------------------------
>
>                 Key: DERBY-1763
>                 URL: http://issues.apache.org/jira/browse/DERBY-1763
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1
>         Environment: Windows 2000, Sun JDK 1.4.2_10
>            Reporter: Christopher Schick
>
> When trying to execute a simple SQL Statement that includes both the RTRIM() and LTRIM() functions on a column in the SELECT clause and contains a GROUP BY clause on that column, the following Nullpointer Exception is thrown:
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
> This does NOT happen, if only RTRIM() OR LTRIM() is used, or if no GROUP BY clause is specified.
> This issue is quite urgent for us, as we don't see a workaround to achieve the desired results.
> Attached an example table schema and the affected SELECT Statement.
> --------------------------------------------
> CREATE TABLE t1 (
> c1 VARCHAR(10),
> c2 VARCHAR(10)
> );
> INSERT INTO t1 VALUES('a', 'b');
> INSERT INTO t1 VALUES('c', 'd');
> SELECT RTRIM(LTRIM(c1)), 
>                  COUNT(*)
> FROM t1
> GROUP BY c1;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (DERBY-1763) Using RTRIM(LTRIM(col)) and group by col gives NPE

Posted by "Kathey Marsden (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1763?page=all ]

Kathey Marsden updated DERBY-1763:
----------------------------------

    Derby Info:   (was: [Existing Application Impact])

Unchecking "Existing Application Impact" as it is an indicator that it is used for behavior changes  which may newly affect applications that are already running successfully on Derby .  From what I understand of this issue it is not a change in behavior or regression from a previous Derby release which might affect an Existing Derby Application on upgrade.

Chris, I hope you will get involved and take a shot at fixing this bug.  There are lots of SQL experts  on the list who I am sure would be happy to help. See: http://wiki.apache.org/db-derby/FrontPage#head-586d3e6d6e98537c1aff50dc1aec0d62412cb526
for information on getting started.

> Using RTRIM(LTRIM(col)) and group by col gives NPE
> --------------------------------------------------
>
>                 Key: DERBY-1763
>                 URL: http://issues.apache.org/jira/browse/DERBY-1763
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1
>         Environment: Windows 2000, Sun JDK 1.4.2_10
>            Reporter: Christopher Schick
>
> When trying to execute a simple SQL Statement that includes both the RTRIM() and LTRIM() functions on a column in the SELECT clause and contains a GROUP BY clause on that column, the following Nullpointer Exception is thrown:
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
> This does NOT happen, if only RTRIM() OR LTRIM() is used, or if no GROUP BY clause is specified.
> This issue is quite urgent for us, as we don't see a workaround to achieve the desired results.
> Attached an example table schema and the affected SELECT Statement.
> --------------------------------------------
> CREATE TABLE t1 (
> c1 VARCHAR(10),
> c2 VARCHAR(10)
> );
> INSERT INTO t1 VALUES('a', 'b');
> INSERT INTO t1 VALUES('c', 'd');
> SELECT RTRIM(LTRIM(c1)), 
>                  COUNT(*)
> FROM t1
> GROUP BY c1;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (DERBY-1763) Using RTRIM(LTRIM(col)) and group by col gives NPE

Posted by "Bryan Pendleton (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1763?page=comments#action_12430514 ] 
            
Bryan Pendleton commented on DERBY-1763:
----------------------------------------

I think the bug also involves the "count(*)"; if you remove that from the select
statement (SELECT RTRIM(LTRIM(c1)) FROM t1 GROUP BY c1), the
null pointer exception does not occur.

Also, when you run with a sane=true build, the message is slightly different
and also points more directly at the count(*) part of the query. The message
in a sane=true build is:

ij> select rtrim(ltrim(c1)), count(*), c1 from t1 group by c1;
ERROR XJ001: Java exception: 'ASSERT FAILED col[2]  is null: org.apache.derby.shared.common.sanity.AssertFailure'.

> Using RTRIM(LTRIM(col)) and group by col gives NPE
> --------------------------------------------------
>
>                 Key: DERBY-1763
>                 URL: http://issues.apache.org/jira/browse/DERBY-1763
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1
>         Environment: Windows 2000, Sun JDK 1.4.2_10
>            Reporter: Christopher Schick
>
> When trying to execute a simple SQL Statement that includes both the RTRIM() and LTRIM() functions on a column in the SELECT clause and contains a GROUP BY clause on that column, the following Nullpointer Exception is thrown:
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
> This does NOT happen, if only RTRIM() OR LTRIM() is used, or if no GROUP BY clause is specified.
> This issue is quite urgent for us, as we don't see a workaround to achieve the desired results.
> Attached an example table schema and the affected SELECT Statement.
> --------------------------------------------
> CREATE TABLE t1 (
> c1 VARCHAR(10),
> c2 VARCHAR(10)
> );
> INSERT INTO t1 VALUES('a', 'b');
> INSERT INTO t1 VALUES('c', 'd');
> SELECT RTRIM(LTRIM(c1)), 
>                  COUNT(*)
> FROM t1
> GROUP BY c1;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Resolved: (DERBY-1763) Using RTRIM(LTRIM(col)) and group by col gives NPE

Posted by "Andrew McIntyre (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-1763?page=all ]

Andrew McIntyre resolved DERBY-1763.
------------------------------------

    Fix Version/s: 10.2.1.5
       Resolution: Fixed

Original reporter verified this as fixed in 10.2.x, probably a side-effect of the work for DERBY-883. Marking this issue resolved. Please reopen if you feel this is in error.

> Using RTRIM(LTRIM(col)) and group by col gives NPE
> --------------------------------------------------
>
>                 Key: DERBY-1763
>                 URL: http://issues.apache.org/jira/browse/DERBY-1763
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1
>         Environment: Windows 2000, Sun JDK 1.4.2_10
>            Reporter: Christopher Schick
>             Fix For: 10.2.1.5
>
>
> When trying to execute a simple SQL Statement that includes both the RTRIM() and LTRIM() functions on a column in the SELECT clause and contains a GROUP BY clause on that column, the following Nullpointer Exception is thrown:
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
> This does NOT happen, if only RTRIM() OR LTRIM() is used, or if no GROUP BY clause is specified.
> This issue is quite urgent for us, as we don't see a workaround to achieve the desired results.
> Attached an example table schema and the affected SELECT Statement.
> --------------------------------------------
> CREATE TABLE t1 (
> c1 VARCHAR(10),
> c2 VARCHAR(10)
> );
> INSERT INTO t1 VALUES('a', 'b');
> INSERT INTO t1 VALUES('c', 'd');
> SELECT RTRIM(LTRIM(c1)), 
>                  COUNT(*)
> FROM t1
> GROUP BY c1;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (DERBY-1763) Using RTRIM(LTRIM(col)) and group by col gives NPE

Posted by "Saurabh Vyas (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-1763?page=comments#action_12434080 ] 
            
Saurabh Vyas commented on DERBY-1763:
-------------------------------------

I tried to simulate the same  scenario on Derby-10.2  and it works fine here with no excption/assert.

ij version 10.2
ij> connect 'jdbc:derby:mydb;create=true';
ij> CREATE TABLE t1 (
c1 VARCHAR(10),
c2 VARCHAR(10)
);
0 rows inserted/updated/deleted
ij> INSERT INTO t1 VALUES('a', 'b');
1 row inserted/updated/deleted
ij> INSERT INTO t1 VALUES('c', 'd');
1 row inserted/updated/deleted
ij> SELECT RTRIM(LTRIM(c1)),
                 COUNT(*)
FROM t1
GROUP BY c1;
1         |2
----------------------
a         |1
c         |1

2 rows selected

Is the issue already fixed and a patch is available?
Any inputs on this ?
Well I am workin upon root causing it in 10.1.3 release.

> Using RTRIM(LTRIM(col)) and group by col gives NPE
> --------------------------------------------------
>
>                 Key: DERBY-1763
>                 URL: http://issues.apache.org/jira/browse/DERBY-1763
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.1.3.1
>         Environment: Windows 2000, Sun JDK 1.4.2_10
>            Reporter: Christopher Schick
>
> When trying to execute a simple SQL Statement that includes both the RTRIM() and LTRIM() functions on a column in the SELECT clause and contains a GROUP BY clause on that column, the following Nullpointer Exception is thrown:
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
> This does NOT happen, if only RTRIM() OR LTRIM() is used, or if no GROUP BY clause is specified.
> This issue is quite urgent for us, as we don't see a workaround to achieve the desired results.
> Attached an example table schema and the affected SELECT Statement.
> --------------------------------------------
> CREATE TABLE t1 (
> c1 VARCHAR(10),
> c2 VARCHAR(10)
> );
> INSERT INTO t1 VALUES('a', 'b');
> INSERT INTO t1 VALUES('c', 'd');
> SELECT RTRIM(LTRIM(c1)), 
>                  COUNT(*)
> FROM t1
> GROUP BY c1;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira